ruby-libvirt-catphish 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/COPYING +510 -0
- data/NEWS +141 -0
- data/README +219 -0
- data/README.rdoc +28 -0
- data/Rakefile +166 -0
- data/ext/libvirt/_libvirt.c +1033 -0
- data/ext/libvirt/common.c +490 -0
- data/ext/libvirt/common.h +285 -0
- data/ext/libvirt/connect.c +3501 -0
- data/ext/libvirt/connect.h +12 -0
- data/ext/libvirt/domain.c +5907 -0
- data/ext/libvirt/domain.h +11 -0
- data/ext/libvirt/extconf.h +392 -0
- data/ext/libvirt/extconf.rb +506 -0
- data/ext/libvirt/interface.c +200 -0
- data/ext/libvirt/interface.h +8 -0
- data/ext/libvirt/network.c +555 -0
- data/ext/libvirt/network.h +8 -0
- data/ext/libvirt/nodedevice.c +299 -0
- data/ext/libvirt/nodedevice.h +8 -0
- data/ext/libvirt/nwfilter.c +138 -0
- data/ext/libvirt/nwfilter.h +8 -0
- data/ext/libvirt/secret.c +268 -0
- data/ext/libvirt/secret.h +8 -0
- data/ext/libvirt/storage.c +1022 -0
- data/ext/libvirt/storage.h +6 -0
- data/ext/libvirt/stream.c +392 -0
- data/ext/libvirt/stream.h +9 -0
- data/lib/libvirt.rb +40 -0
- data/tests/test_conn.rb +818 -0
- data/tests/test_domain.rb +1443 -0
- data/tests/test_interface.rb +100 -0
- data/tests/test_network.rb +175 -0
- data/tests/test_nodedevice.rb +90 -0
- data/tests/test_nwfilter.rb +60 -0
- data/tests/test_open.rb +250 -0
- data/tests/test_secret.rb +114 -0
- data/tests/test_storage.rb +527 -0
- data/tests/test_stream.rb +171 -0
- data/tests/test_utils.rb +254 -0
- metadata +84 -0
@@ -0,0 +1,1443 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
# Test the domain methods the bindings support. Note that this tester requires
|
4
|
+
# the qemu driver to be enabled and available for use.
|
5
|
+
|
6
|
+
# Note that the order of the TESTGROUPs below match the order that the
|
7
|
+
# functions are defined in the ext/libvirt/domain.c file
|
8
|
+
|
9
|
+
$: << File.dirname(__FILE__)
|
10
|
+
|
11
|
+
require 'libvirt'
|
12
|
+
require 'test_utils.rb'
|
13
|
+
|
14
|
+
set_test_object("domain")
|
15
|
+
|
16
|
+
conn = Libvirt::open("qemu:///system")
|
17
|
+
|
18
|
+
cleanup_test_domain(conn)
|
19
|
+
|
20
|
+
# setup for later tests
|
21
|
+
`qemu-img create -f qcow2 #{$GUEST_DISK} 5G`
|
22
|
+
`qemu-img create -f raw #{$GUEST_RAW_DISK} 5G`
|
23
|
+
|
24
|
+
|
25
|
+
new_hostdev_xml = <<EOF
|
26
|
+
<hostdev mode='subsystem' type='pci' managed='yes'>
|
27
|
+
<source>
|
28
|
+
<address bus='0x45' slot='0x55' function='0x33'/>
|
29
|
+
</source>
|
30
|
+
</hostdev>
|
31
|
+
EOF
|
32
|
+
|
33
|
+
# start tests
|
34
|
+
|
35
|
+
# TESTGROUP: dom.migrate_max_speed
|
36
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
37
|
+
sleep 1
|
38
|
+
|
39
|
+
expect_too_many_args(newdom, "migrate_max_speed", 1, 2)
|
40
|
+
expect_invalid_arg_type(newdom, "migrate_max_speed", 'foo')
|
41
|
+
expect_invalid_arg_type(newdom, "migrate_max_speed", [])
|
42
|
+
expect_invalid_arg_type(newdom, "migrate_max_speed", {})
|
43
|
+
|
44
|
+
expect_success(newdom, "no args", "migrate_max_speed")
|
45
|
+
|
46
|
+
newdom.destroy
|
47
|
+
|
48
|
+
# TESTGROUP: dom.reset
|
49
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
50
|
+
sleep 1
|
51
|
+
|
52
|
+
expect_too_many_args(newdom, "reset", 1, 2)
|
53
|
+
expect_invalid_arg_type(newdom, "reset", 'foo')
|
54
|
+
expect_invalid_arg_type(newdom, "reset", [])
|
55
|
+
expect_invalid_arg_type(newdom, "reset", {})
|
56
|
+
|
57
|
+
expect_success(newdom, "no args", "reset")
|
58
|
+
|
59
|
+
newdom.destroy
|
60
|
+
|
61
|
+
# TESTGROUP: dom.hostname
|
62
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
63
|
+
sleep 1
|
64
|
+
|
65
|
+
expect_too_many_args(newdom, "hostname", 1, 2)
|
66
|
+
expect_invalid_arg_type(newdom, "hostname", 'foo')
|
67
|
+
expect_invalid_arg_type(newdom, "hostname", [])
|
68
|
+
expect_invalid_arg_type(newdom, "hostname", {})
|
69
|
+
|
70
|
+
# FIXME: spits an error "this function is not supported by the connection driver"
|
71
|
+
#expect_success(newdom, "no args", "hostname")
|
72
|
+
|
73
|
+
newdom.destroy
|
74
|
+
|
75
|
+
# TESTGROUP: dom.metadata
|
76
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
77
|
+
sleep 1
|
78
|
+
|
79
|
+
expect_too_many_args(newdom, "metadata", 1, 2, 3, 4)
|
80
|
+
expect_too_few_args(newdom, "metadata")
|
81
|
+
expect_invalid_arg_type(newdom, "metadata", 'foo')
|
82
|
+
expect_invalid_arg_type(newdom, "metadata", nil)
|
83
|
+
expect_invalid_arg_type(newdom, "metadata", [])
|
84
|
+
expect_invalid_arg_type(newdom, "metadata", {})
|
85
|
+
expect_invalid_arg_type(newdom, "metadata", 1, 1)
|
86
|
+
expect_invalid_arg_type(newdom, "metadata", 1, 'foo', 'bar')
|
87
|
+
|
88
|
+
expect_success(newdom, "no args", "metadata", Libvirt::Domain::METADATA_DESCRIPTION) {|x| x == "Ruby Libvirt Tester"}
|
89
|
+
|
90
|
+
newdom.destroy
|
91
|
+
|
92
|
+
# TESTGROUP: dom.metadata=
|
93
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
94
|
+
sleep 1
|
95
|
+
|
96
|
+
expect_too_many_args(newdom, "metadata=", 1, 2, 3, 4, 5, 6)
|
97
|
+
expect_too_few_args(newdom, "metadata=")
|
98
|
+
expect_too_few_args(newdom, "metadata=", [1])
|
99
|
+
expect_invalid_arg_type(newdom, "metadata=", 1)
|
100
|
+
expect_invalid_arg_type(newdom, "metadata=", 'foo')
|
101
|
+
expect_invalid_arg_type(newdom, "metadata=", nil)
|
102
|
+
expect_invalid_arg_type(newdom, "metadata=", {})
|
103
|
+
expect_invalid_arg_type(newdom, "metadata=", ['foo', nil])
|
104
|
+
expect_invalid_arg_type(newdom, "metadata=", [nil, nil])
|
105
|
+
expect_invalid_arg_type(newdom, "metadata=", [[], nil])
|
106
|
+
expect_invalid_arg_type(newdom, "metadata=", [{}, nil])
|
107
|
+
expect_invalid_arg_type(newdom, "metadata=", [1, 1])
|
108
|
+
expect_invalid_arg_type(newdom, "metadata=", [1, []])
|
109
|
+
expect_invalid_arg_type(newdom, "metadata=", [1, {}])
|
110
|
+
|
111
|
+
expect_success(newdom, "no args", "metadata=", [Libvirt::Domain::METADATA_DESCRIPTION, 'foo'])
|
112
|
+
expect_success(newdom, "no args", "metadata=", [Libvirt::Domain::METADATA_DESCRIPTION, 'foo', nil, nil, 0])
|
113
|
+
|
114
|
+
expect_success(newdom, "no args", "metadata", Libvirt::Domain::METADATA_DESCRIPTION) {|x| x == "foo"}
|
115
|
+
|
116
|
+
newdom.destroy
|
117
|
+
|
118
|
+
# TESTGROUP: dom.updated?
|
119
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
120
|
+
sleep 1
|
121
|
+
|
122
|
+
expect_too_many_args(newdom, "updated?", 1)
|
123
|
+
|
124
|
+
expect_success(newdom, "no args", "updated?")
|
125
|
+
|
126
|
+
newdom.destroy
|
127
|
+
|
128
|
+
# TESTGROUP: dom.inject_nmi
|
129
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
130
|
+
sleep 1
|
131
|
+
|
132
|
+
expect_too_many_args(newdom, "inject_nmi", 1, 2)
|
133
|
+
expect_invalid_arg_type(newdom, "inject_nmi", 'foo')
|
134
|
+
|
135
|
+
expect_success(newdom, "no args", "inject_nmi")
|
136
|
+
|
137
|
+
newdom.destroy
|
138
|
+
|
139
|
+
# TESTGROUP: dom.control_info
|
140
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
141
|
+
sleep 1
|
142
|
+
|
143
|
+
expect_too_many_args(newdom, "control_info", 1, 2)
|
144
|
+
expect_invalid_arg_type(newdom, "control_info", 'foo')
|
145
|
+
|
146
|
+
expect_success(newdom, "no args", "control_info")
|
147
|
+
|
148
|
+
newdom.destroy
|
149
|
+
|
150
|
+
# TESTGROUP: dom.send_key
|
151
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
152
|
+
sleep 1
|
153
|
+
|
154
|
+
expect_too_many_args(newdom, "send_key", 1, 2, 3, 4)
|
155
|
+
expect_too_few_args(newdom, "send_key")
|
156
|
+
expect_too_few_args(newdom, "send_key", 1)
|
157
|
+
expect_too_few_args(newdom, "send_key", 1, 2)
|
158
|
+
expect_invalid_arg_type(newdom, "send_key", nil, 0, [])
|
159
|
+
expect_invalid_arg_type(newdom, "send_key", nil, 0, [1])
|
160
|
+
expect_invalid_arg_type(newdom, "send_key", 'foo', 0, [])
|
161
|
+
expect_invalid_arg_type(newdom, "send_key", 0, nil, [])
|
162
|
+
expect_invalid_arg_type(newdom, "send_key", 0, 'foo', [])
|
163
|
+
expect_invalid_arg_type(newdom, "send_key", 0, 1, nil)
|
164
|
+
expect_invalid_arg_type(newdom, "send_key", 0, 1, 'foo')
|
165
|
+
expect_invalid_arg_type(newdom, "send_key", 0, 1, 2)
|
166
|
+
expect_invalid_arg_type(newdom, "send_key", nil, 0, [nil])
|
167
|
+
expect_invalid_arg_type(newdom, "send_key", nil, 0, ['foo'])
|
168
|
+
|
169
|
+
# FIXME: this fails for reasons that are unclear to me
|
170
|
+
#expect_success(newdom, "codeset, holdtime, keycodes args", "send_key", 0, 1, [])
|
171
|
+
|
172
|
+
newdom.destroy
|
173
|
+
|
174
|
+
# TESTGROUP: dom.migrate
|
175
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
176
|
+
sleep 1
|
177
|
+
|
178
|
+
dconn = Libvirt::open("qemu:///system")
|
179
|
+
|
180
|
+
expect_too_many_args(newdom, "migrate", 1, 2, 3, 4, 5, 6)
|
181
|
+
expect_too_few_args(newdom, "migrate")
|
182
|
+
expect_fail(newdom, ArgumentError, "invalid connection object", "migrate", "foo")
|
183
|
+
expect_invalid_arg_type(newdom, "migrate", dconn, 'foo')
|
184
|
+
expect_invalid_arg_type(newdom, "migrate", dconn, 0, 1)
|
185
|
+
expect_invalid_arg_type(newdom, "migrate", dconn, 0, 'foo', 1)
|
186
|
+
expect_invalid_arg_type(newdom, "migrate", dconn, 0, 'foo', 'bar', 'baz')
|
187
|
+
|
188
|
+
# FIXME: how can we make this work?
|
189
|
+
#expect_success(newdom, "conn arg", "migrate", dconn)
|
190
|
+
|
191
|
+
dconn.close
|
192
|
+
|
193
|
+
newdom.destroy
|
194
|
+
|
195
|
+
# TESTGROUP: dom.migrate_to_uri
|
196
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
197
|
+
sleep 1
|
198
|
+
|
199
|
+
expect_too_many_args(newdom, "migrate_to_uri", 1, 2, 3, 4, 5)
|
200
|
+
expect_too_few_args(newdom, "migrate_to_uri")
|
201
|
+
expect_invalid_arg_type(newdom, "migrate_to_uri", 1)
|
202
|
+
expect_invalid_arg_type(newdom, "migrate_to_uri", "qemu:///system", 'foo')
|
203
|
+
expect_invalid_arg_type(newdom, "migrate_to_uri", "qemu:///system", 0, 1)
|
204
|
+
expect_invalid_arg_type(newdom, "migrate_to_uri", "qemu:///system", 0, 'foo', 'bar')
|
205
|
+
|
206
|
+
#expect_success(newdom, "URI arg", "migrate_to_uri", "qemu://remote/system")
|
207
|
+
|
208
|
+
dconn.close
|
209
|
+
|
210
|
+
newdom.destroy
|
211
|
+
|
212
|
+
# TESTGROUP: dom.migrate_set_max_downtime
|
213
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
214
|
+
|
215
|
+
expect_too_many_args(newdom, "migrate_set_max_downtime", 1, 2, 3)
|
216
|
+
expect_too_few_args(newdom, "migrate_set_max_downtime")
|
217
|
+
expect_invalid_arg_type(newdom, "migrate_set_max_downtime", 'foo')
|
218
|
+
expect_invalid_arg_type(newdom, "migrate_set_max_downtime", 10, 'foo')
|
219
|
+
expect_fail(newdom, Libvirt::Error, "on off domain", "migrate_set_max_downtime", 10)
|
220
|
+
|
221
|
+
newdom.undefine
|
222
|
+
|
223
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
224
|
+
sleep 1
|
225
|
+
#expect_fail(newdom, Libvirt::Error, "while no migration in progress", "migrate_set_max_downtime", 10)
|
226
|
+
|
227
|
+
#newdom.migrate_to_uri("qemu://remote/system")
|
228
|
+
#expect_success(newdom, "10 second downtime", "migrate_set_max_downtime", 10)
|
229
|
+
|
230
|
+
newdom.destroy
|
231
|
+
|
232
|
+
# TESTGROUP: dom.migrate2
|
233
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
234
|
+
sleep 1
|
235
|
+
|
236
|
+
dconn = Libvirt::open("qemu:///system")
|
237
|
+
|
238
|
+
expect_too_many_args(newdom, "migrate2", 1, 2, 3, 4, 5, 6, 7)
|
239
|
+
expect_too_few_args(newdom, "migrate2")
|
240
|
+
expect_fail(newdom, ArgumentError, "invalid connection object", "migrate2", "foo")
|
241
|
+
expect_invalid_arg_type(newdom, "migrate2", dconn, 0)
|
242
|
+
|
243
|
+
# FIXME: how can we make this work?
|
244
|
+
#expect_success(newdom, "conn arg", "migrate2", dconn)
|
245
|
+
|
246
|
+
dconn.close
|
247
|
+
|
248
|
+
newdom.destroy
|
249
|
+
|
250
|
+
# TESTGROUP: dom.migrate_to_uri2
|
251
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
252
|
+
sleep 1
|
253
|
+
|
254
|
+
expect_too_many_args(newdom, "migrate_to_uri2", 1, 2, 3, 4, 5, 6, 7)
|
255
|
+
expect_invalid_arg_type(newdom, "migrate_to_uri2", 1)
|
256
|
+
expect_invalid_arg_type(newdom, "migrate_to_uri2", "qemu:///system", 1)
|
257
|
+
expect_invalid_arg_type(newdom, "migrate_to_uri2", "qemu:///system", 'foo', 1)
|
258
|
+
expect_invalid_arg_type(newdom, "migrate_to_uri2", "qemu:///system", 'foo', 'bar', 'baz')
|
259
|
+
expect_invalid_arg_type(newdom, "migrate_to_uri2", "qemu:///system", 'foo', 'bar', 0, 1)
|
260
|
+
expect_invalid_arg_type(newdom, "migrate_to_uri2", "qemu:///system", 'foo', 'bar', 0, 'foo', 'baz')
|
261
|
+
|
262
|
+
#expect_success(newdom, "URI arg", "migrate_to_uri2", "qemu://remote/system")
|
263
|
+
|
264
|
+
dconn.close
|
265
|
+
|
266
|
+
newdom.destroy
|
267
|
+
|
268
|
+
# TESTGROUP: dom.migrate_set_max_speed
|
269
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
270
|
+
sleep 1
|
271
|
+
|
272
|
+
expect_too_many_args(newdom, "migrate_set_max_speed", 1, 2, 3)
|
273
|
+
expect_too_few_args(newdom, "migrate_set_max_speed")
|
274
|
+
expect_invalid_arg_type(newdom, "migrate_set_max_speed", 'foo')
|
275
|
+
expect_invalid_arg_type(newdom, "migrate_set_max_speed", 5, 'foo')
|
276
|
+
|
277
|
+
#expect_success(newdom, "Bandwidth arg", "migrate_set_max_speed", 5)
|
278
|
+
|
279
|
+
newdom.destroy
|
280
|
+
|
281
|
+
# TESTGROUP: dom.shutdown
|
282
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
283
|
+
sleep 1
|
284
|
+
|
285
|
+
expect_too_many_args(newdom, "shutdown", 1, 2)
|
286
|
+
expect_success(newdom, "no args", "shutdown")
|
287
|
+
sleep 1
|
288
|
+
newdom.destroy
|
289
|
+
|
290
|
+
# TESTGROUP: dom.reboot
|
291
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
292
|
+
sleep 1
|
293
|
+
expect_too_many_args(newdom, "reboot", 1, 2)
|
294
|
+
expect_invalid_arg_type(newdom, "reboot", "hello")
|
295
|
+
|
296
|
+
expect_success(newdom, "no args", "reboot")
|
297
|
+
sleep 1
|
298
|
+
|
299
|
+
expect_success(newdom, "flags arg", "reboot", 0)
|
300
|
+
sleep 1
|
301
|
+
|
302
|
+
newdom.destroy
|
303
|
+
|
304
|
+
# TESTGROUP: dom.destroy
|
305
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
306
|
+
sleep 1
|
307
|
+
|
308
|
+
expect_too_many_args(newdom, "destroy", 1, 2)
|
309
|
+
expect_success(newdom, "no args", "destroy")
|
310
|
+
|
311
|
+
# TESTGROUP: dom.suspend
|
312
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
313
|
+
sleep 1
|
314
|
+
|
315
|
+
expect_too_many_args(newdom, "suspend", 1)
|
316
|
+
expect_success(newdom, "no args", "suspend")
|
317
|
+
newdom.destroy
|
318
|
+
|
319
|
+
# TESTGROUP: dom.resume
|
320
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
321
|
+
sleep 1
|
322
|
+
|
323
|
+
expect_fail(newdom, Libvirt::Error, "already running", "resume")
|
324
|
+
|
325
|
+
newdom.suspend
|
326
|
+
expect_too_many_args(newdom, "resume", 1)
|
327
|
+
expect_success(newdom, "no args suspended domain", "resume")
|
328
|
+
newdom.destroy
|
329
|
+
|
330
|
+
# TESTGROUP: dom.save
|
331
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
332
|
+
sleep 1
|
333
|
+
|
334
|
+
expect_too_many_args(newdom, "save", 1, 2, 3, 4)
|
335
|
+
expect_too_few_args(newdom, "save")
|
336
|
+
expect_invalid_arg_type(newdom, "save", 1)
|
337
|
+
expect_invalid_arg_type(newdom, "save", nil)
|
338
|
+
expect_fail(newdom, Libvirt::Error, "non-existent path", "save", "/this/path/does/not/exist")
|
339
|
+
|
340
|
+
expect_success(newdom, "path arg", "save", $GUEST_SAVE)
|
341
|
+
|
342
|
+
`rm -f #{$GUEST_SAVE}`
|
343
|
+
|
344
|
+
# TESTGROUP: dom.managed_save
|
345
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
346
|
+
newdom.create
|
347
|
+
sleep 1
|
348
|
+
|
349
|
+
expect_too_many_args(newdom, "managed_save", 1, 2)
|
350
|
+
expect_invalid_arg_type(newdom, "managed_save", "hello")
|
351
|
+
expect_success(newdom, "no args", "managed_save")
|
352
|
+
newdom.undefine(Libvirt::Domain::UNDEFINE_MANAGED_SAVE)
|
353
|
+
|
354
|
+
# TESTGROUP: dom.has_managed_save?
|
355
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
356
|
+
newdom.create
|
357
|
+
sleep 1
|
358
|
+
|
359
|
+
expect_too_many_args(newdom, "has_managed_save?", 1, 2)
|
360
|
+
expect_invalid_arg_type(newdom, "has_managed_save?", "hello")
|
361
|
+
|
362
|
+
if newdom.has_managed_save?
|
363
|
+
puts_fail "domain.has_managed_save? reports true on a new domain"
|
364
|
+
else
|
365
|
+
puts_ok "domain.has_managed_save? not true on new domain"
|
366
|
+
end
|
367
|
+
|
368
|
+
newdom.managed_save
|
369
|
+
|
370
|
+
if not newdom.has_managed_save?
|
371
|
+
puts_fail "domain.has_managed_save? reports false after a managed save"
|
372
|
+
else
|
373
|
+
puts_ok "domain.has_managed_save? reports true after a managed save"
|
374
|
+
end
|
375
|
+
|
376
|
+
newdom.undefine(Libvirt::Domain::UNDEFINE_MANAGED_SAVE)
|
377
|
+
|
378
|
+
# TESTGROUP: dom.managed_save_remove
|
379
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
380
|
+
newdom.create
|
381
|
+
sleep 1
|
382
|
+
newdom.managed_save
|
383
|
+
|
384
|
+
expect_too_many_args(newdom, "managed_save_remove", 1, 2)
|
385
|
+
expect_invalid_arg_type(newdom, "managed_save_remove", "hello")
|
386
|
+
|
387
|
+
if not newdom.has_managed_save?
|
388
|
+
puts_fail "prior to domain.managed_save_remove, no managed save file"
|
389
|
+
end
|
390
|
+
expect_success(newdom, "no args", "managed_save_remove")
|
391
|
+
if newdom.has_managed_save?
|
392
|
+
puts_fail "after domain.managed_save_remove, managed save file still exists"
|
393
|
+
else
|
394
|
+
puts_ok "after domain.managed_save_remove, managed save file no longer exists"
|
395
|
+
end
|
396
|
+
|
397
|
+
newdom.undefine
|
398
|
+
|
399
|
+
# TESTGROUP: dom.core_dump
|
400
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
401
|
+
newdom.create
|
402
|
+
sleep 1
|
403
|
+
|
404
|
+
expect_too_many_args(newdom, "core_dump", 1, 2, 3)
|
405
|
+
expect_too_few_args(newdom, "core_dump")
|
406
|
+
expect_invalid_arg_type(newdom, "core_dump", 1, 2)
|
407
|
+
expect_invalid_arg_type(newdom, "core_dump", "/path", "foo")
|
408
|
+
expect_fail(newdom, Libvirt::Error, "invalid path", "core_dump", "/this/path/does/not/exist")
|
409
|
+
|
410
|
+
expect_success(newdom, "live with path arg", "core_dump", "/var/lib/libvirt/images/ruby-libvirt-test.core")
|
411
|
+
|
412
|
+
`rm -f /var/lib/libvirt/images/ruby-libvirt-test.core`
|
413
|
+
|
414
|
+
expect_success(newdom, "crash with path arg", "core_dump", "/var/lib/libvirt/images/ruby-libvirt-test.core", Libvirt::Domain::DUMP_CRASH)
|
415
|
+
|
416
|
+
expect_fail(newdom, Libvirt::Error, "of shut-off domain", "core_dump", "/var/lib/libvirt/images/ruby-libvirt-test.core", Libvirt::Domain::DUMP_CRASH)
|
417
|
+
|
418
|
+
`rm -f /var/lib/libvirt/images/ruby-libvirt-test.core`
|
419
|
+
|
420
|
+
newdom.undefine
|
421
|
+
|
422
|
+
# TESTGROUP: Libvirt::Domain::restore
|
423
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
424
|
+
newdom.create
|
425
|
+
sleep 1
|
426
|
+
newdom.save($GUEST_SAVE)
|
427
|
+
|
428
|
+
expect_too_many_args(Libvirt::Domain, "restore", 1, 2, 3)
|
429
|
+
expect_too_few_args(Libvirt::Domain, "restore")
|
430
|
+
expect_invalid_arg_type(Libvirt::Domain, "restore", 1, 2)
|
431
|
+
expect_invalid_arg_type(Libvirt::Domain, "restore", conn, 2)
|
432
|
+
expect_fail(Libvirt::Domain, Libvirt::Error, "invalid path", "restore", conn, "/this/path/does/not/exist")
|
433
|
+
`touch /tmp/foo`
|
434
|
+
expect_fail(Libvirt::Domain, Libvirt::Error, "invalid save file", "restore", conn, "/tmp/foo")
|
435
|
+
`rm -f /tmp/foo`
|
436
|
+
|
437
|
+
expect_success(Libvirt::Domain, "2 args", "restore", conn, $GUEST_SAVE)
|
438
|
+
|
439
|
+
`rm -f #{$GUEST_SAVE}`
|
440
|
+
|
441
|
+
newdom.destroy
|
442
|
+
newdom.undefine
|
443
|
+
|
444
|
+
# TESTGROUP: dom.info
|
445
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
446
|
+
sleep 1
|
447
|
+
|
448
|
+
expect_too_many_args(newdom, "info", 1)
|
449
|
+
|
450
|
+
expect_success(newdom, "no args", "info") {|x| x.state == Libvirt::Domain::RUNNING and x.max_mem == 1048576 and x.memory == 1048576 and x.nr_virt_cpu == 2}
|
451
|
+
|
452
|
+
newdom.destroy
|
453
|
+
|
454
|
+
# TESTGROUP: dom.security_label
|
455
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
456
|
+
sleep 1
|
457
|
+
|
458
|
+
expect_too_many_args(newdom, "security_label", 1)
|
459
|
+
|
460
|
+
expect_success(newdom, "no args", "security_label")
|
461
|
+
|
462
|
+
newdom.destroy
|
463
|
+
|
464
|
+
# TESTGROUP: dom.block_stats
|
465
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
466
|
+
sleep 1
|
467
|
+
|
468
|
+
expect_too_many_args(newdom, "block_stats", 1, 2)
|
469
|
+
expect_too_few_args(newdom, "block_stats")
|
470
|
+
expect_invalid_arg_type(newdom, "block_stats", 1)
|
471
|
+
expect_fail(newdom, Libvirt::RetrieveError, "invalid path", "block_stats", "foo")
|
472
|
+
|
473
|
+
expect_success(newdom, "block device arg", "block_stats", "vda")
|
474
|
+
|
475
|
+
newdom.destroy
|
476
|
+
|
477
|
+
# TESTGROUP: dom.memory_stats
|
478
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
479
|
+
sleep 1
|
480
|
+
|
481
|
+
expect_too_many_args(newdom, "memory_stats", 1, 2)
|
482
|
+
expect_invalid_arg_type(newdom, "memory_stats", "foo")
|
483
|
+
|
484
|
+
expect_success(newdom, "no args", "memory_stats")
|
485
|
+
|
486
|
+
newdom.destroy
|
487
|
+
|
488
|
+
# TESTGROUP: dom.blockinfo
|
489
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
490
|
+
sleep 1
|
491
|
+
|
492
|
+
expect_too_many_args(newdom, "blockinfo", 1, 2, 3)
|
493
|
+
expect_too_few_args(newdom, "blockinfo")
|
494
|
+
expect_invalid_arg_type(newdom, "blockinfo", 1)
|
495
|
+
expect_invalid_arg_type(newdom, "blockinfo", "foo", "bar")
|
496
|
+
expect_fail(newdom, Libvirt::RetrieveError, "invalid path", "blockinfo", "foo")
|
497
|
+
|
498
|
+
expect_success(newdom, "path arg", "blockinfo", $GUEST_DISK)
|
499
|
+
|
500
|
+
newdom.destroy
|
501
|
+
|
502
|
+
# TESTGROUP: dom.block_peek
|
503
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
504
|
+
sleep 1
|
505
|
+
|
506
|
+
expect_too_many_args(newdom, "block_peek", 1, 2, 3, 4, 5)
|
507
|
+
expect_too_few_args(newdom, "block_peek")
|
508
|
+
expect_too_few_args(newdom, "block_peek", 1)
|
509
|
+
expect_too_few_args(newdom, "block_peek", 1, 2)
|
510
|
+
expect_invalid_arg_type(newdom, "block_peek", 1, 2, 3)
|
511
|
+
expect_invalid_arg_type(newdom, "block_peek", "foo", "bar", 3)
|
512
|
+
expect_invalid_arg_type(newdom, "block_peek", "foo", 0, "bar")
|
513
|
+
expect_invalid_arg_type(newdom, "block_peek", "foo", 0, 512, "baz")
|
514
|
+
expect_fail(newdom, Libvirt::RetrieveError, "invalid path", "block_peek", "foo", 0, 512)
|
515
|
+
|
516
|
+
# blockpeek = newdom.block_peek($GUEST_RAW_DISK, 0, 512)
|
517
|
+
|
518
|
+
# # 0x51 0x46 0x49 0xfb are the first 4 bytes of a qcow2 image
|
519
|
+
# if blockpeek[0].unpack('C')[0] != 0x51 or blockpeek[1].unpack('C')[0] != 0x46 or
|
520
|
+
# blockpeek[2].unpack('C')[0] != 0x49 or blockpeek[3].unpack('C')[0] != 0xfb
|
521
|
+
# puts_fail "domain.block_peek read did not return valid data"
|
522
|
+
# else
|
523
|
+
# puts_ok "domain.block_peek read valid data"
|
524
|
+
# end
|
525
|
+
|
526
|
+
newdom.destroy
|
527
|
+
|
528
|
+
# TESTGROUP: dom.memory_peek
|
529
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
530
|
+
sleep 1
|
531
|
+
|
532
|
+
expect_too_many_args(newdom, "memory_peek", 1, 2, 3, 4)
|
533
|
+
expect_too_few_args(newdom, "memory_peek")
|
534
|
+
expect_too_few_args(newdom, "memory_peek", 1)
|
535
|
+
expect_invalid_arg_type(newdom, "memory_peek", "foo", 2)
|
536
|
+
expect_invalid_arg_type(newdom, "memory_peek", 0, "bar")
|
537
|
+
expect_invalid_arg_type(newdom, "memory_peek", 0, 512, "baz")
|
538
|
+
|
539
|
+
expect_success(newdom, "offset and size args", "memory_peek", 0, 512)
|
540
|
+
|
541
|
+
newdom.destroy
|
542
|
+
|
543
|
+
# TESTGROUP: dom.get_vcpus
|
544
|
+
expect_too_many_args(newdom, "get_vcpus", 1)
|
545
|
+
|
546
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
547
|
+
|
548
|
+
expect_success(newdom, "get_vcpus on shutoff domain", "get_vcpus") {|x| x.length == 2}
|
549
|
+
|
550
|
+
newdom.create
|
551
|
+
sleep 1
|
552
|
+
|
553
|
+
expect_success(newdom, "no args", "get_vcpus") {|x| x.length == 2}
|
554
|
+
|
555
|
+
newdom.destroy
|
556
|
+
newdom.undefine
|
557
|
+
|
558
|
+
# TESTGROUP: dom.active?
|
559
|
+
expect_too_many_args(newdom, "active?", 1)
|
560
|
+
|
561
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
562
|
+
|
563
|
+
expect_success(newdom, "no args", "active?") {|x| x == false}
|
564
|
+
|
565
|
+
newdom.create
|
566
|
+
sleep 1
|
567
|
+
|
568
|
+
expect_success(newdom, "no args", "active?") {|x| x == true}
|
569
|
+
|
570
|
+
newdom.destroy
|
571
|
+
newdom.undefine
|
572
|
+
|
573
|
+
# TESTGROUP: dom.persistent?
|
574
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
575
|
+
sleep 1
|
576
|
+
|
577
|
+
expect_too_many_args(newdom, "persistent?", 1)
|
578
|
+
|
579
|
+
expect_success(newdom, "no args", "persistent?") {|x| x == false}
|
580
|
+
|
581
|
+
newdom.destroy
|
582
|
+
|
583
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
584
|
+
|
585
|
+
expect_success(newdom, "no args", "persistent?") {|x| x == true}
|
586
|
+
|
587
|
+
newdom.undefine
|
588
|
+
|
589
|
+
# TESTGROUP: dom.ifinfo
|
590
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
591
|
+
sleep 1
|
592
|
+
|
593
|
+
expect_too_many_args(newdom, "ifinfo", 1, 2)
|
594
|
+
expect_too_few_args(newdom, "ifinfo")
|
595
|
+
expect_invalid_arg_type(newdom, "ifinfo", 1)
|
596
|
+
expect_fail(newdom, Libvirt::RetrieveError, "invalid arg", "ifinfo", "foo")
|
597
|
+
|
598
|
+
expect_success(newdom, "interface arg", "ifinfo", "rl556")
|
599
|
+
|
600
|
+
newdom.destroy
|
601
|
+
|
602
|
+
# TESTGROUP: dom.name
|
603
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
604
|
+
sleep 1
|
605
|
+
|
606
|
+
expect_too_many_args(newdom, "name", 1)
|
607
|
+
|
608
|
+
expect_success(newdom, "no args", "name") {|x| x == "rb-libvirt-test"}
|
609
|
+
|
610
|
+
newdom.destroy
|
611
|
+
|
612
|
+
# TESTGROUP: dom.id
|
613
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
614
|
+
sleep 1
|
615
|
+
|
616
|
+
expect_too_many_args(newdom, "id", 1)
|
617
|
+
|
618
|
+
expect_success(newdom, "no args", "id")
|
619
|
+
|
620
|
+
newdom.destroy
|
621
|
+
|
622
|
+
# TESTGROUP: dom.uuid
|
623
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
624
|
+
sleep 1
|
625
|
+
|
626
|
+
expect_too_many_args(newdom, "uuid", 1)
|
627
|
+
|
628
|
+
expect_success(newdom, "no args", "uuid") {|x| x == $GUEST_UUID}
|
629
|
+
|
630
|
+
newdom.destroy
|
631
|
+
|
632
|
+
# TESTGROUP: dom.os_type
|
633
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
634
|
+
sleep 1
|
635
|
+
|
636
|
+
expect_too_many_args(newdom, "os_type", 1)
|
637
|
+
|
638
|
+
expect_success(newdom, "no args", "os_type") {|x| x == "hvm"}
|
639
|
+
|
640
|
+
newdom.destroy
|
641
|
+
|
642
|
+
# TESTGROUP: dom.max_memory
|
643
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
644
|
+
sleep 1
|
645
|
+
|
646
|
+
expect_too_many_args(newdom, "max_memory", 1)
|
647
|
+
|
648
|
+
expect_success(newdom, "no args", "max_memory") {|x| x == 1048576}
|
649
|
+
|
650
|
+
newdom.destroy
|
651
|
+
|
652
|
+
# TESTGROUP: dom.max_memory=
|
653
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
654
|
+
|
655
|
+
expect_too_many_args(newdom, "max_memory=", 1, 2)
|
656
|
+
expect_too_few_args(newdom, "max_memory=")
|
657
|
+
expect_invalid_arg_type(newdom, "max_memory=", 'foo')
|
658
|
+
|
659
|
+
expect_success(newdom, "memory arg", "max_memory=", 200000)
|
660
|
+
|
661
|
+
newdom.undefine
|
662
|
+
|
663
|
+
# TESTGROUP: dom.memory=
|
664
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
665
|
+
|
666
|
+
expect_too_many_args(newdom, "memory=", 1, 2)
|
667
|
+
expect_too_many_args(newdom, "memory=", [1, 2, 3])
|
668
|
+
expect_too_few_args(newdom, "memory=")
|
669
|
+
expect_too_few_args(newdom, "memory=", [])
|
670
|
+
expect_invalid_arg_type(newdom, "memory=", 'foo')
|
671
|
+
expect_fail(newdom, Libvirt::Error, "shutoff domain", "memory=", [2, Libvirt::Domain::AFFECT_LIVE])
|
672
|
+
|
673
|
+
newdom.undefine
|
674
|
+
|
675
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
676
|
+
sleep 1
|
677
|
+
|
678
|
+
expect_success(newdom, "number arg", "memory=", 200000)
|
679
|
+
|
680
|
+
newdom.destroy
|
681
|
+
|
682
|
+
# TESTGROUP: dom.max_vcpus
|
683
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
684
|
+
sleep 1
|
685
|
+
|
686
|
+
expect_too_many_args(newdom, "max_vcpus", 1)
|
687
|
+
|
688
|
+
expect_success(newdom, "no args", "max_vcpus")
|
689
|
+
|
690
|
+
newdom.destroy
|
691
|
+
|
692
|
+
# TESTGROUP: dom.vcpus=
|
693
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
694
|
+
|
695
|
+
expect_too_many_args(newdom, "vcpus=", 1, 2)
|
696
|
+
expect_too_many_args(newdom, "vcpus=", [0, 1, 2])
|
697
|
+
expect_too_few_args(newdom, "vcpus=")
|
698
|
+
expect_too_few_args(newdom, "vcpus=", [])
|
699
|
+
expect_invalid_arg_type(newdom, "vcpus=", 'foo')
|
700
|
+
expect_fail(newdom, Libvirt::Error, "shutoff domain", "vcpus=", [2, Libvirt::Domain::AFFECT_LIVE])
|
701
|
+
|
702
|
+
newdom.undefine
|
703
|
+
|
704
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
705
|
+
sleep 1
|
706
|
+
|
707
|
+
expect_success(newdom, "number arg", "vcpus=", 2)
|
708
|
+
|
709
|
+
newdom.destroy
|
710
|
+
|
711
|
+
# TESTGROUP: dom.pin_vcpu
|
712
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
713
|
+
sleep 1
|
714
|
+
|
715
|
+
expect_too_many_args(newdom, "pin_vcpu", 1, 2, 3, 4)
|
716
|
+
expect_too_few_args(newdom, "pin_vcpu")
|
717
|
+
expect_invalid_arg_type(newdom, "pin_vcpu", 'foo', [0])
|
718
|
+
expect_invalid_arg_type(newdom, "pin_vcpu", 0, 1)
|
719
|
+
|
720
|
+
expect_success(newdom, "cpu args", "pin_vcpu", 0, [0])
|
721
|
+
|
722
|
+
newdom.destroy
|
723
|
+
|
724
|
+
# TESTGROUP: dom.xml_desc
|
725
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
726
|
+
sleep 1
|
727
|
+
|
728
|
+
expect_too_many_args(newdom, "xml_desc", 1, 2)
|
729
|
+
expect_invalid_arg_type(newdom, "xml_desc", "foo")
|
730
|
+
|
731
|
+
expect_success(newdom, "no args", "xml_desc")
|
732
|
+
|
733
|
+
newdom.destroy
|
734
|
+
|
735
|
+
# TESTGROUP: dom.undefine
|
736
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
737
|
+
|
738
|
+
expect_too_many_args(newdom, "undefine", 1, 2)
|
739
|
+
|
740
|
+
expect_success(newdom, "no args", "undefine")
|
741
|
+
|
742
|
+
# TESTGROUP: dom.create
|
743
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
744
|
+
|
745
|
+
expect_too_many_args(newdom, "create", 1, 2)
|
746
|
+
expect_invalid_arg_type(newdom, "create", "foo")
|
747
|
+
|
748
|
+
expect_success(newdom, "no args", "create")
|
749
|
+
|
750
|
+
expect_fail(newdom, Libvirt::Error, "on already running domain", "create")
|
751
|
+
|
752
|
+
newdom.destroy
|
753
|
+
newdom.undefine
|
754
|
+
|
755
|
+
# TESTGROUP: dom.autostart?
|
756
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
757
|
+
|
758
|
+
expect_too_many_args(newdom, "autostart?", 1)
|
759
|
+
|
760
|
+
expect_success(newdom, "no args", "autostart?") {|x| x == false}
|
761
|
+
|
762
|
+
newdom.autostart = true
|
763
|
+
|
764
|
+
expect_success(newdom, "no args", "autostart?") {|x| x == true}
|
765
|
+
|
766
|
+
newdom.undefine
|
767
|
+
|
768
|
+
# TESTGROUP: dom.autostart=
|
769
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
770
|
+
|
771
|
+
expect_too_many_args(newdom, "autostart=", 1, 2)
|
772
|
+
expect_invalid_arg_type(newdom, "autostart=", 'foo')
|
773
|
+
expect_invalid_arg_type(newdom, "autostart=", nil)
|
774
|
+
expect_invalid_arg_type(newdom, "autostart=", 1234)
|
775
|
+
|
776
|
+
expect_success(newdom, "true arg", "autostart=", true)
|
777
|
+
if not newdom.autostart?
|
778
|
+
puts_fail "domain.autostart= did not set autostart to true"
|
779
|
+
else
|
780
|
+
puts_ok "domain.autostart= set autostart to true"
|
781
|
+
end
|
782
|
+
|
783
|
+
expect_success(newdom, "false arg", "autostart=", false)
|
784
|
+
if newdom.autostart?
|
785
|
+
puts_fail "domain.autostart= did not set autostart to false"
|
786
|
+
else
|
787
|
+
puts_ok "domain.autostart= set autostart to false"
|
788
|
+
end
|
789
|
+
|
790
|
+
newdom.undefine
|
791
|
+
|
792
|
+
# TESTGROUP: dom.attach_device
|
793
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
794
|
+
|
795
|
+
expect_too_many_args(newdom, "attach_device", 1, 2, 3)
|
796
|
+
expect_too_few_args(newdom, "attach_device")
|
797
|
+
expect_invalid_arg_type(newdom, "attach_device", 1)
|
798
|
+
expect_invalid_arg_type(newdom, "attach_device", 'foo', 'bar')
|
799
|
+
expect_fail(newdom, Libvirt::Error, "invalid XML", "attach_device", "hello")
|
800
|
+
expect_fail(newdom, Libvirt::Error, "shut off domain", "attach_device", new_hostdev_xml)
|
801
|
+
|
802
|
+
newdom.undefine
|
803
|
+
|
804
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
805
|
+
sleep 1
|
806
|
+
|
807
|
+
#expect_success(newdom, "hostdev XML", "attach_device", new_hostdev_xml)
|
808
|
+
|
809
|
+
newdom.destroy
|
810
|
+
|
811
|
+
# TESTGROUP: dom.detach_device
|
812
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
813
|
+
|
814
|
+
expect_too_many_args(newdom, "detach_device", 1, 2, 3)
|
815
|
+
expect_too_few_args(newdom, "detach_device")
|
816
|
+
expect_invalid_arg_type(newdom, "detach_device", 1)
|
817
|
+
expect_invalid_arg_type(newdom, "detach_device", 'foo', 'bar')
|
818
|
+
expect_fail(newdom, Libvirt::Error, "invalid XML", "detach_device", "hello")
|
819
|
+
expect_fail(newdom, Libvirt::Error, "shut off domain", "detach_device", new_hostdev_xml)
|
820
|
+
|
821
|
+
newdom.undefine
|
822
|
+
|
823
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
824
|
+
sleep 1
|
825
|
+
|
826
|
+
#expect_success(newdom, "hostdev XML", "detach_device", new_hostdev_xml)
|
827
|
+
|
828
|
+
newdom.destroy
|
829
|
+
|
830
|
+
# TESTGROUP: dom.update_device
|
831
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
832
|
+
|
833
|
+
expect_too_many_args(newdom, "update_device", 1, 2, 3)
|
834
|
+
expect_too_few_args(newdom, "update_device")
|
835
|
+
expect_invalid_arg_type(newdom, "update_device", 1)
|
836
|
+
expect_invalid_arg_type(newdom, "update_device", 'foo', 'bar')
|
837
|
+
expect_fail(newdom, Libvirt::Error, "invalid XML", "update_device", "hello")
|
838
|
+
expect_fail(newdom, Libvirt::Error, "shut off domain", "update_device", new_hostdev_xml)
|
839
|
+
|
840
|
+
newdom.undefine
|
841
|
+
|
842
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
843
|
+
sleep 1
|
844
|
+
|
845
|
+
#expect_success(newdom, "hostdev XML", "update_device", new_hostdev_xml)
|
846
|
+
|
847
|
+
newdom.destroy
|
848
|
+
|
849
|
+
# TESTGROUP: dom.free
|
850
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
851
|
+
newdom.undefine
|
852
|
+
expect_too_many_args(newdom, "free", 1)
|
853
|
+
|
854
|
+
expect_success(newdom, "free", "free")
|
855
|
+
|
856
|
+
# TESTGROUP: dom.snapshot_create_xml
|
857
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
858
|
+
|
859
|
+
expect_too_many_args(newdom, "snapshot_create_xml", 1, 2, 3)
|
860
|
+
expect_too_few_args(newdom, "snapshot_create_xml")
|
861
|
+
expect_invalid_arg_type(newdom, "snapshot_create_xml", 1)
|
862
|
+
expect_invalid_arg_type(newdom, "snapshot_create_xml", nil)
|
863
|
+
expect_invalid_arg_type(newdom, "snapshot_create_xml", 'foo', 'bar')
|
864
|
+
|
865
|
+
expect_success(newdom, "simple XML arg", "snapshot_create_xml", "<domainsnapshot/>")
|
866
|
+
|
867
|
+
snaps = newdom.num_of_snapshots
|
868
|
+
if snaps != 1
|
869
|
+
puts_fail "domain.snapshot_create_xml after one snapshot has #{snaps} snapshots"
|
870
|
+
else
|
871
|
+
puts_ok "domain.snapshot_create_xml after one snapshot has 1 snapshot"
|
872
|
+
end
|
873
|
+
|
874
|
+
newdom.undefine(Libvirt::Domain::UNDEFINE_SNAPSHOTS_METADATA)
|
875
|
+
|
876
|
+
# TESTGROUP: dom.num_of_snapshots
|
877
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
878
|
+
|
879
|
+
expect_too_many_args(newdom, "num_of_snapshots", 1, 2)
|
880
|
+
expect_invalid_arg_type(newdom, "num_of_snapshots", 'foo')
|
881
|
+
|
882
|
+
expect_success(newdom, "no args", "num_of_snapshots") {|x| x == 0}
|
883
|
+
|
884
|
+
newdom.snapshot_create_xml("<domainsnapshot/>")
|
885
|
+
|
886
|
+
expect_success(newdom, "no args", "num_of_snapshots") {|x| x == 1}
|
887
|
+
|
888
|
+
newdom.undefine(Libvirt::Domain::UNDEFINE_SNAPSHOTS_METADATA)
|
889
|
+
|
890
|
+
# TESTGROUP: dom.list_snapshots
|
891
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
892
|
+
|
893
|
+
expect_too_many_args(newdom, "list_snapshots", 1, 2)
|
894
|
+
expect_invalid_arg_type(newdom, "list_snapshots", 'foo')
|
895
|
+
|
896
|
+
expect_success(newdom, "no args", "list_snapshots") {|x| x.length == 0}
|
897
|
+
|
898
|
+
newdom.snapshot_create_xml("<domainsnapshot/>")
|
899
|
+
|
900
|
+
expect_success(newdom, "no args", "list_snapshots") {|x| x.length == 1}
|
901
|
+
|
902
|
+
newdom.undefine(Libvirt::Domain::UNDEFINE_SNAPSHOTS_METADATA)
|
903
|
+
|
904
|
+
# TESTGROUP: dom.lookup_snapshot_by_name
|
905
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
906
|
+
newdom.snapshot_create_xml("<domainsnapshot><name>foo</name></domainsnapshot>")
|
907
|
+
|
908
|
+
expect_too_many_args(newdom, "lookup_snapshot_by_name", 1, 2, 3)
|
909
|
+
expect_too_few_args(newdom, "lookup_snapshot_by_name")
|
910
|
+
expect_invalid_arg_type(newdom, "lookup_snapshot_by_name", 1)
|
911
|
+
expect_invalid_arg_type(newdom, "lookup_snapshot_by_name", 'foo', 'bar')
|
912
|
+
|
913
|
+
expect_success(newdom, "name arg", "lookup_snapshot_by_name", "foo")
|
914
|
+
|
915
|
+
newdom.undefine(Libvirt::Domain::UNDEFINE_SNAPSHOTS_METADATA)
|
916
|
+
|
917
|
+
# TESTGROUP: dom.has_current_snapshot?
|
918
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
919
|
+
|
920
|
+
expect_too_many_args(newdom, "has_current_snapshot?", 1, 2)
|
921
|
+
expect_invalid_arg_type(newdom, "has_current_snapshot?", 'foo')
|
922
|
+
|
923
|
+
expect_success(newdom, "no args", "has_current_snapshot?") {|x| x == false}
|
924
|
+
|
925
|
+
newdom.snapshot_create_xml("<domainsnapshot><name>foo</name></domainsnapshot>")
|
926
|
+
|
927
|
+
expect_success(newdom, "no args", "has_current_snapshot?") {|x| x == true}
|
928
|
+
|
929
|
+
newdom.undefine(Libvirt::Domain::UNDEFINE_SNAPSHOTS_METADATA)
|
930
|
+
|
931
|
+
# TESTGROUP: dom.revert_to_snapshot
|
932
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
933
|
+
|
934
|
+
expect_too_many_args(newdom, "revert_to_snapshot", 1, 2, 3)
|
935
|
+
expect_too_few_args(newdom, "revert_to_snapshot")
|
936
|
+
expect_invalid_arg_type(newdom, "revert_to_snapshot", 1)
|
937
|
+
expect_invalid_arg_type(newdom, "revert_to_snapshot", nil)
|
938
|
+
expect_invalid_arg_type(newdom, "revert_to_snapshot", 'foo')
|
939
|
+
|
940
|
+
snap = newdom.snapshot_create_xml("<domainsnapshot><name>foo</name></domainsnapshot>")
|
941
|
+
sleep 1
|
942
|
+
|
943
|
+
expect_invalid_arg_type(newdom, "revert_to_snapshot", snap, 'foo')
|
944
|
+
|
945
|
+
expect_success(newdom, "snapshot arg", "revert_to_snapshot", snap)
|
946
|
+
|
947
|
+
newdom.undefine(Libvirt::Domain::UNDEFINE_SNAPSHOTS_METADATA)
|
948
|
+
|
949
|
+
# TESTGROUP: dom.current_snapshot
|
950
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
951
|
+
|
952
|
+
expect_too_many_args(newdom, "current_snapshot", 1, 2)
|
953
|
+
expect_invalid_arg_type(newdom, "current_snapshot", 'foo')
|
954
|
+
expect_fail(newdom, Libvirt::RetrieveError, "with no snapshots", "current_snapshot")
|
955
|
+
|
956
|
+
newdom.snapshot_create_xml("<domainsnapshot><name>foo</name></domainsnapshot>")
|
957
|
+
|
958
|
+
expect_success(newdom, "no args", "current_snapshot")
|
959
|
+
|
960
|
+
newdom.undefine(Libvirt::Domain::UNDEFINE_SNAPSHOTS_METADATA)
|
961
|
+
|
962
|
+
# TESTGROUP: dom.job_info
|
963
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
964
|
+
|
965
|
+
expect_too_many_args(newdom, "job_info", 1)
|
966
|
+
|
967
|
+
expect_fail(newdom, Libvirt::RetrieveError, "shutoff domain", "job_info")
|
968
|
+
|
969
|
+
newdom.undefine
|
970
|
+
|
971
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
972
|
+
sleep 1
|
973
|
+
|
974
|
+
expect_success(newdom, "no args", "job_info")
|
975
|
+
|
976
|
+
newdom.destroy
|
977
|
+
|
978
|
+
# TESTGROUP: dom.abort_job
|
979
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
980
|
+
|
981
|
+
expect_too_many_args(newdom, "abort_job", 1)
|
982
|
+
|
983
|
+
expect_fail(newdom, Libvirt::Error, "not running domain", "abort_job")
|
984
|
+
|
985
|
+
newdom.undefine
|
986
|
+
|
987
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
988
|
+
sleep 1
|
989
|
+
|
990
|
+
expect_fail(newdom, Libvirt::Error, "no active job", "abort_job")
|
991
|
+
|
992
|
+
# FIXME: need to start long running job here
|
993
|
+
#expect_success(newdom, "no args", "abort_job")
|
994
|
+
|
995
|
+
newdom.destroy
|
996
|
+
|
997
|
+
# TESTGROUP: dom.scheduler_type
|
998
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
999
|
+
|
1000
|
+
expect_too_many_args(newdom, "scheduler_type", 1)
|
1001
|
+
|
1002
|
+
expect_success(newdom, "no args", "scheduler_type")
|
1003
|
+
|
1004
|
+
newdom.undefine
|
1005
|
+
|
1006
|
+
# TESTGROUP: dom.scheduler_parameters
|
1007
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
1008
|
+
|
1009
|
+
expect_too_many_args(newdom, "scheduler_parameters", 1, 1)
|
1010
|
+
|
1011
|
+
expect_success(newdom, "no args", "scheduler_parameters")
|
1012
|
+
|
1013
|
+
newdom.undefine
|
1014
|
+
|
1015
|
+
# TESTGROUP: dom.scheduler_parameters=
|
1016
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
1017
|
+
|
1018
|
+
expect_too_many_args(newdom, "scheduler_parameters=", 1, 2)
|
1019
|
+
expect_too_few_args(newdom, "scheduler_parameters=")
|
1020
|
+
expect_invalid_arg_type(newdom, "scheduler_parameters=", 0)
|
1021
|
+
|
1022
|
+
expect_success(newdom, "cpu shares arg", "scheduler_parameters=", {"cpu_shares" => 512})
|
1023
|
+
|
1024
|
+
newdom.undefine
|
1025
|
+
|
1026
|
+
# TESTGROUP: dom.qemu_monitor_command
|
1027
|
+
new_test_xml = <<EOF
|
1028
|
+
<domain type='test'>
|
1029
|
+
<name>fc4</name>
|
1030
|
+
<uuid>EF86180145B911CB88E3AFBFE5370493</uuid>
|
1031
|
+
<os>
|
1032
|
+
<type>xen</type>
|
1033
|
+
<kernel>/boot/vmlinuz-2.6.15-1.43_FC5guest</kernel>
|
1034
|
+
<initrd>/boot/initrd-2.6.15-1.43_FC5guest.img</initrd>
|
1035
|
+
<root>/dev/sda1</root>
|
1036
|
+
<cmdline> ro selinux=0 3</cmdline>
|
1037
|
+
</os>
|
1038
|
+
<memory>261072</memory>
|
1039
|
+
<currentMemory>131072</currentMemory>
|
1040
|
+
<vcpu>1</vcpu>
|
1041
|
+
<devices>
|
1042
|
+
<disk type='file'>
|
1043
|
+
<source file='/u/fc4.img'/>
|
1044
|
+
<target dev='sda1'/>
|
1045
|
+
</disk>
|
1046
|
+
<interface type='bridge'>
|
1047
|
+
<source bridge='xenbr0'/>
|
1048
|
+
<mac address='aa:00:00:00:00:11'/>
|
1049
|
+
<script path='/etc/xen/scripts/vif-bridge'/>
|
1050
|
+
</interface>
|
1051
|
+
<console tty='/dev/pts/5'/>
|
1052
|
+
</devices>
|
1053
|
+
</domain>
|
1054
|
+
EOF
|
1055
|
+
|
1056
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
1057
|
+
|
1058
|
+
expect_too_many_args(newdom, "qemu_monitor_command", 1, 2, 3)
|
1059
|
+
expect_too_few_args(newdom, "qemu_monitor_command")
|
1060
|
+
expect_invalid_arg_type(newdom, "qemu_monitor_command", 1)
|
1061
|
+
expect_invalid_arg_type(newdom, "qemu_monitor_command", "foo", "bar")
|
1062
|
+
# FIXME: the test driver doesn't support virDomainDestroyFlags() presently
|
1063
|
+
#testconn = Libvirt::open("test:///default")
|
1064
|
+
#fakedom = testconn.create_domain_xml(new_test_xml)
|
1065
|
+
#expect_invalid_arg_type(fakedom, "qemu_monitor_command", "foo")
|
1066
|
+
#fakedom.destroy
|
1067
|
+
#testconn.close
|
1068
|
+
expect_fail(newdom, Libvirt::RetrieveError, "invalid command", "qemu_monitor_command", "foo")
|
1069
|
+
|
1070
|
+
expect_success(newdom, "monitor command", "qemu_monitor_command", '{"execute":"query-cpus"}')
|
1071
|
+
|
1072
|
+
newdom.destroy
|
1073
|
+
|
1074
|
+
# TESTGROUP: dom.num_vcpus
|
1075
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
1076
|
+
|
1077
|
+
expect_too_many_args(newdom, "num_vcpus", 1, 2)
|
1078
|
+
expect_too_few_args(newdom, "num_vcpus")
|
1079
|
+
expect_invalid_arg_type(newdom, "num_vcpus", 'foo')
|
1080
|
+
expect_fail(newdom, Libvirt::Error, "active flag on shutoff domain", "num_vcpus", Libvirt::Domain::VCPU_LIVE)
|
1081
|
+
expect_fail(newdom, Libvirt::Error, "live and config flags", "num_vcpus", Libvirt::Domain::VCPU_LIVE | Libvirt::Domain::VCPU_CONFIG)
|
1082
|
+
expect_success(newdom, "config flag", "num_vcpus", Libvirt::Domain::VCPU_CONFIG) {|x| x == 2}
|
1083
|
+
|
1084
|
+
newdom.undefine
|
1085
|
+
|
1086
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
1087
|
+
sleep 1
|
1088
|
+
|
1089
|
+
expect_fail(newdom, Libvirt::RetrieveError, "config flag on transient domain", "num_vcpus", Libvirt::Domain::VCPU_CONFIG)
|
1090
|
+
expect_success(newdom, "live flag on transient domain", "num_vcpus", Libvirt::Domain::VCPU_LIVE)
|
1091
|
+
|
1092
|
+
newdom.destroy
|
1093
|
+
|
1094
|
+
# TESTGROUP: dom.vcpus_flags=
|
1095
|
+
# dom.vcpus_flags= is deprecated in favor of dom.vcpus=, so we don't do any
|
1096
|
+
# tests here for it
|
1097
|
+
|
1098
|
+
# TESTGROUP: dom.memory_parameters=
|
1099
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
1100
|
+
|
1101
|
+
expect_too_many_args(newdom, "memory_parameters=", 1, 2, 3)
|
1102
|
+
expect_too_many_args(newdom, "memory_parameters=", [1, 2, 3])
|
1103
|
+
expect_too_few_args(newdom, "memory_parameters=")
|
1104
|
+
expect_too_few_args(newdom, "memory_parameters=", [])
|
1105
|
+
expect_invalid_arg_type(newdom, "memory_parameters=", 0)
|
1106
|
+
expect_invalid_arg_type(newdom, "memory_parameters=", [1, 0])
|
1107
|
+
expect_invalid_arg_type(newdom, "memory_parameters=", [{}, "foo"])
|
1108
|
+
|
1109
|
+
expect_success(newdom, "soft and hard limit", "memory_parameters=", {"soft_limit" => 9007199254740999, "swap_hard_limit" => 9007199254740999})
|
1110
|
+
|
1111
|
+
newdom.undefine
|
1112
|
+
|
1113
|
+
# TESTGROUP: dom.memory_parameters
|
1114
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
1115
|
+
|
1116
|
+
expect_too_many_args(newdom, "memory_parameters", 1, 2)
|
1117
|
+
|
1118
|
+
expect_success(newdom, "no args", "memory_parameters")
|
1119
|
+
|
1120
|
+
newdom.undefine
|
1121
|
+
|
1122
|
+
# TESTGROUP: dom.blkio_parameters=
|
1123
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
1124
|
+
|
1125
|
+
expect_too_many_args(newdom, "blkio_parameters=", 1, 2, 3)
|
1126
|
+
expect_too_many_args(newdom, "blkio_parameters=", [1, 2, 3])
|
1127
|
+
expect_too_few_args(newdom, "blkio_parameters=")
|
1128
|
+
expect_too_few_args(newdom, "blkio_parameters=", [])
|
1129
|
+
expect_invalid_arg_type(newdom, "blkio_parameters=", 0)
|
1130
|
+
expect_invalid_arg_type(newdom, "blkio_parameters=", [1, 0])
|
1131
|
+
expect_invalid_arg_type(newdom, "blkio_parameters=", [{}, "foo"])
|
1132
|
+
|
1133
|
+
expect_success(newdom, "hash", "blkio_parameters=", {"weight" => 100})
|
1134
|
+
|
1135
|
+
newdom.undefine
|
1136
|
+
|
1137
|
+
# TESTGROUP: dom.blkio_parameters
|
1138
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
1139
|
+
|
1140
|
+
expect_too_many_args(newdom, "blkio_parameters", 1, 2)
|
1141
|
+
|
1142
|
+
expect_success(newdom, "no args", "blkio_parameters")
|
1143
|
+
|
1144
|
+
newdom.undefine
|
1145
|
+
|
1146
|
+
# TESTGROUP: dom.open_console
|
1147
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
1148
|
+
stream = conn.stream
|
1149
|
+
|
1150
|
+
expect_too_many_args(newdom, "open_console", 1, 2, 3, 4)
|
1151
|
+
expect_too_few_args(newdom, "open_console")
|
1152
|
+
expect_too_few_args(newdom, "open_console", 1)
|
1153
|
+
expect_invalid_arg_type(newdom, "open_console", 1, stream)
|
1154
|
+
expect_invalid_arg_type(newdom, "open_console", "pty", 1)
|
1155
|
+
expect_invalid_arg_type(newdom, "open_console", "pty", stream, "wow")
|
1156
|
+
|
1157
|
+
#expect_success(newdom, "device and stream args", "open_console", "pty", stream)
|
1158
|
+
|
1159
|
+
newdom.destroy
|
1160
|
+
|
1161
|
+
# TESTGROUP: dom.block_rebase
|
1162
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
1163
|
+
|
1164
|
+
expect_too_many_args(newdom, "block_rebase", 1, 2, 3, 4, 5)
|
1165
|
+
expect_too_few_args(newdom, "block_rebase")
|
1166
|
+
expect_invalid_arg_type(newdom, "block_rebase", 1)
|
1167
|
+
expect_invalid_arg_type(newdom, "block_rebase", "foo", 1)
|
1168
|
+
expect_invalid_arg_type(newdom, "block_rebase", "foo", "bar", "baz")
|
1169
|
+
expect_invalid_arg_type(newdom, "block_rebase", "foo", "bar", 1, "boom")
|
1170
|
+
|
1171
|
+
# FIXME: I don't know how to make block_rebase work
|
1172
|
+
#expect_success(newdom, "disk", "block_rebase", diskname)
|
1173
|
+
|
1174
|
+
newdom.destroy
|
1175
|
+
|
1176
|
+
# TESTGROUP: dom.migrate_max_downtime=
|
1177
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
1178
|
+
|
1179
|
+
expect_too_many_args(newdom, "migrate_max_downtime=", 1, 2)
|
1180
|
+
expect_too_many_args(newdom, "migrate_max_downtime=", [1, 2, 3])
|
1181
|
+
expect_too_few_args(newdom, "migrate_max_downtime=")
|
1182
|
+
expect_too_few_args(newdom, "migrate_max_downtime=", [])
|
1183
|
+
expect_invalid_arg_type(newdom, "migrate_max_downtime=", 'foo')
|
1184
|
+
expect_invalid_arg_type(newdom, "migrate_max_downtime=", nil)
|
1185
|
+
expect_fail(newdom, Libvirt::Error, "on off domain", "migrate_max_downtime=", 10)
|
1186
|
+
expect_fail(newdom, Libvirt::Error, "on off domain, two args", "migrate_max_downtime=", [10, 10])
|
1187
|
+
|
1188
|
+
newdom.undefine
|
1189
|
+
|
1190
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
1191
|
+
sleep 1
|
1192
|
+
#expect_fail(newdom, Libvirt::Error, "while no migration in progress", "migrate_max_downtime=", 10)
|
1193
|
+
|
1194
|
+
# FIXME: get this working
|
1195
|
+
#newdom.migrate_to_uri("qemu://remote/system")
|
1196
|
+
#expect_success(newdom, "10 second downtime", "migrate_max_downtime=", 10)
|
1197
|
+
|
1198
|
+
newdom.destroy
|
1199
|
+
|
1200
|
+
# TESTGROUP: dom.migrate_max_speed=
|
1201
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
1202
|
+
sleep 1
|
1203
|
+
|
1204
|
+
expect_too_many_args(newdom, "migrate_max_speed=", 1, 2)
|
1205
|
+
expect_too_many_args(newdom, "migrate_max_speed=", [1, 2, 3])
|
1206
|
+
expect_too_few_args(newdom, "migrate_max_speed=")
|
1207
|
+
expect_too_few_args(newdom, "migrate_max_speed=", [])
|
1208
|
+
expect_invalid_arg_type(newdom, "migrate_max_speed=", 'foo')
|
1209
|
+
expect_invalid_arg_type(newdom, "migrate_max_speed=", nil)
|
1210
|
+
expect_invalid_arg_type(newdom, "migrate_max_speed=", ['foo', 1])
|
1211
|
+
expect_invalid_arg_type(newdom, "migrate_max_speed=", [1, 'foo'])
|
1212
|
+
|
1213
|
+
#expect_success(newdom, "Bandwidth arg", "migrate_max_speed=", 5)
|
1214
|
+
|
1215
|
+
newdom.destroy
|
1216
|
+
|
1217
|
+
# TESTGROUP: dom.state
|
1218
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
1219
|
+
sleep 1
|
1220
|
+
|
1221
|
+
expect_too_many_args(newdom, "state", 1, 2)
|
1222
|
+
expect_invalid_arg_type(newdom, "state", 'foo')
|
1223
|
+
|
1224
|
+
expect_success(newdom, "no arg", "state")
|
1225
|
+
|
1226
|
+
newdom.destroy
|
1227
|
+
|
1228
|
+
# TESTGROUP: dom.screenshot
|
1229
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
1230
|
+
sleep 1
|
1231
|
+
|
1232
|
+
stream = conn.stream
|
1233
|
+
|
1234
|
+
expect_too_many_args(newdom, "screenshot", 1, 2, 3, 4)
|
1235
|
+
expect_too_few_args(newdom, "screenshot")
|
1236
|
+
expect_too_few_args(newdom, "screenshot", stream)
|
1237
|
+
expect_invalid_arg_type(newdom, "screenshot", 1, 0)
|
1238
|
+
expect_invalid_arg_type(newdom, "screenshot", nil, 0)
|
1239
|
+
expect_invalid_arg_type(newdom, "screenshot", stream, nil)
|
1240
|
+
expect_invalid_arg_type(newdom, "screenshot", stream, 'foo')
|
1241
|
+
expect_invalid_arg_type(newdom, "screenshot", stream, 0, 'foo')
|
1242
|
+
|
1243
|
+
expect_success(newdom, "stream and screen arg", "screenshot", stream, 0)
|
1244
|
+
|
1245
|
+
newdom.destroy
|
1246
|
+
|
1247
|
+
# TESTGROUP: dom.vcpus_flags=
|
1248
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
1249
|
+
|
1250
|
+
expect_too_many_args(newdom, "vcpus_flags=", 1, 2)
|
1251
|
+
expect_too_many_args(newdom, "vcpus_flags=", [0, 1, 2])
|
1252
|
+
expect_too_few_args(newdom, "vcpus_flags=")
|
1253
|
+
expect_too_few_args(newdom, "vcpus_flags=", [])
|
1254
|
+
expect_invalid_arg_type(newdom, "vcpus_flags=", 'foo')
|
1255
|
+
expect_fail(newdom, Libvirt::Error, "shutoff domain", "vcpus_flags=", [2, Libvirt::Domain::AFFECT_LIVE])
|
1256
|
+
|
1257
|
+
newdom.undefine
|
1258
|
+
|
1259
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
1260
|
+
sleep 1
|
1261
|
+
|
1262
|
+
expect_success(newdom, "number arg", "vcpus_flags=", 2)
|
1263
|
+
|
1264
|
+
newdom.destroy
|
1265
|
+
|
1266
|
+
# TESTGROUP: domain.list_all_snapshots
|
1267
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
1268
|
+
snap = newdom.snapshot_create_xml("<domainsnapshot/>")
|
1269
|
+
|
1270
|
+
expect_too_many_args(newdom, "list_all_snapshots", 1, 2)
|
1271
|
+
expect_invalid_arg_type(newdom, "list_all_snapshots", 'foo')
|
1272
|
+
|
1273
|
+
expect_success(newdom, "no args", "list_all_snapshots")
|
1274
|
+
|
1275
|
+
newdom.undefine(Libvirt::Domain::UNDEFINE_SNAPSHOTS_METADATA)
|
1276
|
+
sleep 1
|
1277
|
+
|
1278
|
+
# TESTGROUP: domain.open_graphics
|
1279
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
1280
|
+
sleep 1
|
1281
|
+
|
1282
|
+
expect_too_many_args(newdom, "open_graphics", 1, 2, 3, 4)
|
1283
|
+
expect_too_few_args(newdom, "open_graphics")
|
1284
|
+
expect_invalid_arg_type(newdom, "open_graphics", nil)
|
1285
|
+
expect_invalid_arg_type(newdom, "open_graphics", 'foo')
|
1286
|
+
expect_invalid_arg_type(newdom, "open_graphics", [])
|
1287
|
+
expect_invalid_arg_type(newdom, "open_graphics", {})
|
1288
|
+
expect_invalid_arg_type(newdom, "open_graphics", 4, 'foo')
|
1289
|
+
expect_invalid_arg_type(newdom, "open_graphics", 4, [])
|
1290
|
+
expect_invalid_arg_type(newdom, "open_graphics", 4, {})
|
1291
|
+
expect_invalid_arg_type(newdom, "open_graphics", 4, 0, 'foo')
|
1292
|
+
expect_invalid_arg_type(newdom, "open_graphics", 4, 0, [])
|
1293
|
+
expect_invalid_arg_type(newdom, "open_graphics", 4, 0, {})
|
1294
|
+
|
1295
|
+
#expect_success(newdom, "fd arg", "open_graphics", fd)
|
1296
|
+
|
1297
|
+
set_test_object("snapshot")
|
1298
|
+
|
1299
|
+
# TESTGROUP: snapshot.xml_desc
|
1300
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
1301
|
+
snap = newdom.snapshot_create_xml("<domainsnapshot/>")
|
1302
|
+
|
1303
|
+
expect_too_many_args(snap, "xml_desc", 1, 2)
|
1304
|
+
expect_invalid_arg_type(snap, "xml_desc", 'foo')
|
1305
|
+
|
1306
|
+
expect_success(newdom, "no args", "xml_desc")
|
1307
|
+
|
1308
|
+
newdom.undefine(Libvirt::Domain::UNDEFINE_SNAPSHOTS_METADATA)
|
1309
|
+
sleep 1
|
1310
|
+
|
1311
|
+
# TESTGROUP: snapshot.delete
|
1312
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
1313
|
+
snap = newdom.snapshot_create_xml("<domainsnapshot/>")
|
1314
|
+
|
1315
|
+
expect_too_many_args(snap, "delete", 1, 2)
|
1316
|
+
expect_invalid_arg_type(snap, "delete", 'foo')
|
1317
|
+
|
1318
|
+
expect_success(snap, "no args", "delete")
|
1319
|
+
|
1320
|
+
newdom.undefine(Libvirt::Domain::UNDEFINE_SNAPSHOTS_METADATA)
|
1321
|
+
sleep 1
|
1322
|
+
|
1323
|
+
# TESTGROUP: snapshot.name
|
1324
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
1325
|
+
snap = newdom.snapshot_create_xml("<domainsnapshot/>")
|
1326
|
+
|
1327
|
+
expect_too_many_args(snap, "name", 1)
|
1328
|
+
|
1329
|
+
expect_success(snap, "no args", "name")
|
1330
|
+
|
1331
|
+
newdom.undefine(Libvirt::Domain::UNDEFINE_SNAPSHOTS_METADATA)
|
1332
|
+
sleep 1
|
1333
|
+
|
1334
|
+
# TESTGROUP: snapshot.num_children
|
1335
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
1336
|
+
snap = newdom.snapshot_create_xml("<domainsnapshot/>")
|
1337
|
+
|
1338
|
+
expect_too_many_args(snap, "num_children", 1, 2)
|
1339
|
+
|
1340
|
+
expect_success(snap, "no args, no children", "num_children") {|x| x == 0}
|
1341
|
+
|
1342
|
+
newdom.undefine(Libvirt::Domain::UNDEFINE_SNAPSHOTS_METADATA)
|
1343
|
+
sleep 1
|
1344
|
+
|
1345
|
+
# TESTGROUP: snapshot.list_children_names
|
1346
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
1347
|
+
snap = newdom.snapshot_create_xml("<domainsnapshot/>")
|
1348
|
+
|
1349
|
+
expect_too_many_args(snap, "list_children_names", 1, 2)
|
1350
|
+
|
1351
|
+
expect_success(snap, "no args, no children", "num_children") {|x| x == 0}
|
1352
|
+
|
1353
|
+
newdom.undefine(Libvirt::Domain::UNDEFINE_SNAPSHOTS_METADATA)
|
1354
|
+
sleep 1
|
1355
|
+
|
1356
|
+
# TESTGROUP: snapshot.free
|
1357
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
1358
|
+
snap = newdom.snapshot_create_xml("<domainsnapshot/>")
|
1359
|
+
|
1360
|
+
expect_too_many_args(snap, "free", 1)
|
1361
|
+
|
1362
|
+
expect_success(snap, "no args", "free")
|
1363
|
+
|
1364
|
+
newdom.undefine(Libvirt::Domain::UNDEFINE_SNAPSHOTS_METADATA)
|
1365
|
+
sleep 1
|
1366
|
+
|
1367
|
+
# TESTGROUP: snapshot.has_metadata?
|
1368
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
1369
|
+
snap = newdom.snapshot_create_xml("<domainsnapshot/>")
|
1370
|
+
|
1371
|
+
expect_too_many_args(snap, "has_metadata?", 1, 2)
|
1372
|
+
expect_invalid_arg_type(snap, "has_metadata?", "foo")
|
1373
|
+
|
1374
|
+
expect_success(snap, "no args", "has_metadata?") {|x| x == true}
|
1375
|
+
|
1376
|
+
newdom.undefine(Libvirt::Domain::UNDEFINE_SNAPSHOTS_METADATA)
|
1377
|
+
sleep 1
|
1378
|
+
|
1379
|
+
# TESTGROUP: snapshot.list_children_names
|
1380
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
1381
|
+
snap = newdom.snapshot_create_xml("<domainsnapshot><name>snap</name></domainsnapshot>")
|
1382
|
+
snap2 = newdom.snapshot_create_xml("<domainsnapshot><name>snap2</name></domainsnapshot>")
|
1383
|
+
|
1384
|
+
expect_too_many_args(snap, "list_children_names", 1, 2)
|
1385
|
+
expect_invalid_arg_type(snap, "list_children_names", "foo")
|
1386
|
+
expect_invalid_arg_type(snap, "list_children_names", [])
|
1387
|
+
expect_invalid_arg_type(snap, "list_children_names", {})
|
1388
|
+
|
1389
|
+
expect_success(snap, "no args", "list_children_names")
|
1390
|
+
|
1391
|
+
newdom.undefine(Libvirt::Domain::UNDEFINE_SNAPSHOTS_METADATA)
|
1392
|
+
sleep 1
|
1393
|
+
|
1394
|
+
# TESTGROUP: snapshot.list_all_children
|
1395
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
1396
|
+
snap = newdom.snapshot_create_xml("<domainsnapshot/>")
|
1397
|
+
|
1398
|
+
expect_too_many_args(snap, "list_all_children", 1, 2)
|
1399
|
+
expect_invalid_arg_type(snap, "list_all_children", "foo")
|
1400
|
+
expect_invalid_arg_type(snap, "list_all_children", [])
|
1401
|
+
expect_invalid_arg_type(snap, "list_all_children", {})
|
1402
|
+
|
1403
|
+
expect_success(snap, "no args", "list_all_children")
|
1404
|
+
|
1405
|
+
newdom.undefine(Libvirt::Domain::UNDEFINE_SNAPSHOTS_METADATA)
|
1406
|
+
sleep 1
|
1407
|
+
|
1408
|
+
# TESTGROUP: snapshot.parent
|
1409
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
1410
|
+
snap = newdom.snapshot_create_xml("<domainsnapshot/>")
|
1411
|
+
sleep 1
|
1412
|
+
snap2 = newdom.snapshot_create_xml("<domainsnapshot/>")
|
1413
|
+
|
1414
|
+
expect_too_many_args(snap2, "parent", 1, 2)
|
1415
|
+
expect_invalid_arg_type(snap2, "parent", "foo")
|
1416
|
+
expect_invalid_arg_type(snap2, "parent", [])
|
1417
|
+
expect_invalid_arg_type(snap2, "parent", {})
|
1418
|
+
|
1419
|
+
expect_success(snap2, "no args", "parent")
|
1420
|
+
expect_success(snap, "no args", "parent")
|
1421
|
+
|
1422
|
+
newdom.undefine(Libvirt::Domain::UNDEFINE_SNAPSHOTS_METADATA)
|
1423
|
+
sleep 1
|
1424
|
+
|
1425
|
+
# TESTGROUP: snapshot.current?
|
1426
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
1427
|
+
snap = newdom.snapshot_create_xml("<domainsnapshot/>")
|
1428
|
+
|
1429
|
+
expect_too_many_args(snap, "current?", 1, 2)
|
1430
|
+
expect_invalid_arg_type(snap, "current?", "foo")
|
1431
|
+
expect_invalid_arg_type(snap, "current?", [])
|
1432
|
+
expect_invalid_arg_type(snap, "current?", {})
|
1433
|
+
|
1434
|
+
expect_success(snap, "no args", "current?")
|
1435
|
+
|
1436
|
+
newdom.undefine(Libvirt::Domain::UNDEFINE_SNAPSHOTS_METADATA)
|
1437
|
+
sleep 1
|
1438
|
+
|
1439
|
+
# END TESTS
|
1440
|
+
|
1441
|
+
conn.close
|
1442
|
+
|
1443
|
+
finish_tests
|