ruby-libvirt 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/tests/test_domain.rb CHANGED
@@ -11,9 +11,6 @@ $: << File.dirname(__FILE__)
11
11
  require 'libvirt'
12
12
  require 'test_utils.rb'
13
13
 
14
- GUEST_DISK = '/var/lib/libvirt/images/ruby-libvirt-tester.qcow2'
15
- UUID = "93a5c045-6457-2c09-e56f-927cdf34e17a"
16
-
17
14
  conn = Libvirt::open("qemu:///system")
18
15
 
19
16
  # initial cleanup for previous runs
@@ -25,59 +22,8 @@ rescue
25
22
  # in case we didn't find it, don't do anything
26
23
  end
27
24
 
28
- # XML data for later tests
29
- new_dom_xml = <<EOF
30
- <domain type='kvm'>
31
- <name>ruby-libvirt-tester</name>
32
- <uuid>#{UUID}</uuid>
33
- <memory>1048576</memory>
34
- <currentMemory>1048576</currentMemory>
35
- <vcpu>2</vcpu>
36
- <os>
37
- <type arch='x86_64'>hvm</type>
38
- <boot dev='hd'/>
39
- </os>
40
- <features>
41
- <acpi/>
42
- <apic/>
43
- <pae/>
44
- </features>
45
- <clock offset='utc'/>
46
- <on_poweroff>destroy</on_poweroff>
47
- <on_reboot>restart</on_reboot>
48
- <on_crash>restart</on_crash>
49
- <devices>
50
- <disk type='file' device='disk'>
51
- <driver name='qemu' type='qcow2'/>
52
- <source file='#{GUEST_DISK}'/>
53
- <target dev='vda' bus='virtio'/>
54
- </disk>
55
- <interface type='bridge'>
56
- <mac address='52:54:00:60:3c:95'/>
57
- <source bridge='virbr0'/>
58
- <model type='virtio'/>
59
- <target dev='rl556'/>
60
- </interface>
61
- <serial type='pty'>
62
- <target port='0'/>
63
- </serial>
64
- <console type='pty'>
65
- <target port='0'/>
66
- </console>
67
- <input type='mouse' bus='ps2'/>
68
- <graphics type='vnc' port='-1' autoport='yes' keymap='en-us'/>
69
- <video>
70
- <model type='cirrus' vram='9216' heads='1'/>
71
- </video>
72
- </devices>
73
- </domain>
74
- EOF
75
-
76
- # qemu command-line that roughly corresponds to the above XML
77
- qemu_cmd_line = "/usr/bin/qemu-kvm -S -M pc-0.13 -enable-kvm -m 1024 -smp 1,sockets=1,cores=1,threads=1 -name ruby-libvirt-tester -uuid #{UUID} -nodefconfig -nodefaults -chardev socket,id=monitor,path=/var/lib/libvirt/qemu/ruby-libvirt-tester.monitor,server,nowait -mon chardev=monitor,mode=readline -rtc base=utc -boot c -chardev pty,id=serial0 -device isa-serial,chardev=serial0 -usb -vnc 127.0.0.1:0 -k en-us -vga cirrus -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5"
78
-
79
25
  # setup for later tests
80
- `rm -f #{GUEST_DISK} ; qemu-img create -f qcow2 #{GUEST_DISK} 5G`
26
+ `rm -f #{$GUEST_DISK} ; qemu-img create -f qcow2 #{$GUEST_DISK} 5G`
81
27
  `rm -f /var/lib/libvirt/images/ruby-libvirt-test.save`
82
28
 
83
29
  new_hostdev_xml = <<EOF
@@ -90,132 +36,8 @@ EOF
90
36
 
91
37
  # start tests
92
38
 
93
- # TESTGROUP: conn.num_of_domains
94
- expect_too_many_args(conn, "num_of_domains", 1)
95
- expect_success(conn, "no args", "num_of_domains")
96
-
97
- # TESTGROUP: conn.list_domains
98
- expect_too_many_args(conn, "list_domains", 1)
99
- expect_success(conn, "no args", "list_domains")
100
-
101
- # TESTGROUP: conn.num_of_defined_domains
102
- expect_too_many_args(conn, "num_of_defined_domains", 1)
103
- expect_success(conn, "no args", "num_of_defined_domains")
104
-
105
- # TESTGROUP: conn.list_domains
106
- expect_too_many_args(conn, "list_defined_domains", 1)
107
- expect_success(conn, "no args", "list_defined_domains")
108
-
109
- # TESTGROUP: conn.create_domain_linux
110
- expect_too_many_args(conn, "create_domain_linux", new_dom_xml, 0, 1)
111
- expect_too_few_args(conn, "create_domain_linux")
112
- expect_invalid_arg_type(conn, "create_domain_linux", nil)
113
- expect_invalid_arg_type(conn, "create_domain_linux", 1)
114
- expect_invalid_arg_type(conn, "create_domain_linux", new_dom_xml, "foo")
115
- expect_fail(conn, Libvirt::Error, "invalid xml", "create_domain_linux", "hello")
116
- newdom = expect_success(conn, "domain xml", "create_domain_linux", new_dom_xml) {|x| x.class == Libvirt::Domain}
117
- sleep 1
118
-
119
- expect_fail(conn, Libvirt::Error, "already existing domain", "create_domain_linux", new_dom_xml)
120
-
121
- newdom.destroy
122
-
123
- # TESTGROUP: conn.create_domain_xml
124
- expect_too_many_args(conn, "create_domain_xml", new_dom_xml, 0, 1)
125
- expect_too_few_args(conn, "create_domain_xml")
126
- expect_invalid_arg_type(conn, "create_domain_xml", nil)
127
- expect_invalid_arg_type(conn, "create_domain_xml", 1)
128
- expect_invalid_arg_type(conn, "create_domain_xml", new_dom_xml, "foo")
129
- expect_fail(conn, Libvirt::Error, "invalid xml", "create_domain_xml", "hello")
130
- newdom = expect_success(conn, "domain xml", "create_domain_xml", new_dom_xml) {|x| x.class == Libvirt::Domain}
131
- sleep 1
132
-
133
- expect_fail(conn, Libvirt::Error, "already existing domain", "create_domain_xml", new_dom_xml)
134
-
135
- newdom.destroy
136
-
137
- # TESTGROUP: conn.lookup_domain_by_name
138
- newdom = conn.create_domain_xml(new_dom_xml)
139
- sleep 1
140
-
141
- expect_too_many_args(conn, "lookup_domain_by_name", 1, 2)
142
- expect_too_few_args(conn, "lookup_domain_by_name")
143
- expect_invalid_arg_type(conn, "lookup_domain_by_name", 1)
144
- expect_fail(conn, Libvirt::RetrieveError, "non-existent name arg", "lookup_domain_by_name", "foobarbazsucker")
145
-
146
- expect_success(conn, "name arg for running domain", "lookup_domain_by_name", "ruby-libvirt-tester") {|x| x.name == "ruby-libvirt-tester"}
147
- newdom.destroy
148
-
149
- newdom = conn.define_domain_xml(new_dom_xml)
150
- expect_success(conn, "name arg for defined domain", "lookup_domain_by_name", "ruby-libvirt-tester") {|x| x.name == "ruby-libvirt-tester"}
151
- newdom.undefine
152
-
153
- # TESTGROUP: conn.lookup_domain_by_id
154
- newdom = conn.create_domain_xml(new_dom_xml)
155
- sleep 1
156
-
157
- expect_too_many_args(conn, "lookup_domain_by_id", 1, 2)
158
- expect_too_few_args(conn, "lookup_domain_by_id")
159
- expect_invalid_arg_type(conn, "lookup_domain_by_id", "foo")
160
- expect_fail(conn, Libvirt::Error, "with negative value", "lookup_domain_by_id", -1)
161
-
162
- expect_success(conn, "id arg for running domain", "lookup_domain_by_id", newdom.id)
163
- newdom.destroy
164
-
165
- # TESTGROUP: conn.lookup_domain_by_uuid
166
- newdom = conn.create_domain_xml(new_dom_xml)
167
- sleep 1
168
-
169
- expect_too_many_args(conn, "lookup_domain_by_uuid", 1, 2)
170
- expect_too_few_args(conn, "lookup_domain_by_uuid")
171
- expect_invalid_arg_type(conn, "lookup_domain_by_uuid", 1)
172
- expect_fail(conn, Libvirt::RetrieveError, "invalid UUID", "lookup_domain_by_uuid", "abcd")
173
-
174
- expect_success(conn, "UUID arg for running domain", "lookup_domain_by_uuid", newdom.uuid) {|x| x.uuid == UUID}
175
- newdom.destroy
176
-
177
- newdom = conn.define_domain_xml(new_dom_xml)
178
- expect_success(conn, "UUID arg for defined domain", "lookup_domain_by_uuid", newdom.uuid) {|x| x.uuid == UUID}
179
- newdom.undefine
180
-
181
- # TESTGROUP: conn.define_domain_xml
182
- expect_too_many_args(conn, "define_domain_xml", 1, 2)
183
- expect_too_few_args(conn, "define_domain_xml")
184
- expect_invalid_arg_type(conn, "define_domain_xml", 1)
185
- expect_invalid_arg_type(conn, "define_domain_xml", nil)
186
- expect_fail(conn, Libvirt::DefinitionError, "invalid XML", "define_domain_xml", "hello")
187
-
188
- newdom = expect_success(conn, "domain xml arg", "define_domain_xml", new_dom_xml)
189
- newdom.undefine
190
-
191
- # TESTGROUP: conn.domain_xml_from_native
192
- expect_too_many_args(conn, "domain_xml_from_native", 1, 2, 3, 4)
193
- expect_too_few_args(conn, "domain_xml_from_native")
194
- expect_too_few_args(conn, "domain_xml_from_native", 1)
195
- expect_invalid_arg_type(conn, "domain_xml_from_native", 1, 2)
196
- expect_invalid_arg_type(conn, "domain_xml_from_native", nil, 2)
197
- expect_invalid_arg_type(conn, "domain_xml_from_native", "qemu-argv", 2)
198
- expect_invalid_arg_type(conn, "domain_xml_from_native", "qemu-argv", nil)
199
- expect_invalid_arg_type(conn, "domain_xml_from_native", "qemu-argv", "foo", "bar")
200
- expect_fail(conn, Libvirt::Error, "unsupported first arg", "domain_xml_from_native", "foo", "bar")
201
-
202
- expect_success(conn, "qemu-argv and qemu_cmd_line", "domain_xml_from_native", "qemu-argv", qemu_cmd_line)
203
-
204
- # TESTGROUP: conn.domain_xml_to_native
205
- expect_too_many_args(conn, "domain_xml_to_native", 1, 2, 3, 4)
206
- expect_too_few_args(conn, "domain_xml_to_native")
207
- expect_too_few_args(conn, "domain_xml_to_native", 1)
208
- expect_invalid_arg_type(conn, "domain_xml_to_native", 1, 2)
209
- expect_invalid_arg_type(conn, "domain_xml_to_native", nil, 2)
210
- expect_invalid_arg_type(conn, "domain_xml_to_native", "qemu-argv", 2)
211
- expect_invalid_arg_type(conn, "domain_xml_to_native", "qemu-argv", nil)
212
- expect_invalid_arg_type(conn, "domain_xml_to_native", "qemu-argv", "foo", "bar")
213
- expect_fail(conn, Libvirt::Error, "unsupported first arg", "domain_xml_to_native", "foo", "bar")
214
-
215
- expect_success(conn, "qemu-argv and domain XML", "domain_xml_to_native", "qemu-argv", new_dom_xml)
216
-
217
39
  # TESTGROUP: dom.migrate
218
- newdom = conn.create_domain_xml(new_dom_xml)
40
+ newdom = conn.create_domain_xml($new_dom_xml)
219
41
  sleep 1
220
42
 
221
43
  dconn = Libvirt::open("qemu:///system")
@@ -236,7 +58,7 @@ dconn.close
236
58
  newdom.destroy
237
59
 
238
60
  # TESTGROUP: dom.migrate_to_uri
239
- newdom = conn.create_domain_xml(new_dom_xml)
61
+ newdom = conn.create_domain_xml($new_dom_xml)
240
62
  sleep 1
241
63
 
242
64
  expect_too_many_args(newdom, "migrate_to_uri", 1, 2, 3, 4, 5)
@@ -253,7 +75,7 @@ dconn.close
253
75
  newdom.destroy
254
76
 
255
77
  # TESTGROUP: dom.migrate_set_max_downtime
256
- newdom = conn.define_domain_xml(new_dom_xml)
78
+ newdom = conn.define_domain_xml($new_dom_xml)
257
79
 
258
80
  expect_too_many_args(newdom, "migrate_set_max_downtime", 1, 2, 3)
259
81
  expect_too_few_args(newdom, "migrate_set_max_downtime")
@@ -263,7 +85,7 @@ expect_fail(newdom, Libvirt::Error, "on off domain", "migrate_set_max_downtime",
263
85
 
264
86
  newdom.undefine
265
87
 
266
- newdom = conn.create_domain_xml(new_dom_xml)
88
+ newdom = conn.create_domain_xml($new_dom_xml)
267
89
  sleep 1
268
90
  expect_fail(newdom, Libvirt::Error, "while no migration in progress", "migrate_set_max_downtime", 10)
269
91
 
@@ -273,7 +95,7 @@ expect_fail(newdom, Libvirt::Error, "while no migration in progress", "migrate_s
273
95
  newdom.destroy
274
96
 
275
97
  # TESTGROUP: dom.shutdown
276
- newdom = conn.create_domain_xml(new_dom_xml)
98
+ newdom = conn.create_domain_xml($new_dom_xml)
277
99
  sleep 1
278
100
 
279
101
  expect_too_many_args(newdom, "shutdown", 1)
@@ -282,7 +104,7 @@ sleep 1
282
104
  newdom.destroy
283
105
 
284
106
  # TESTGROUP: dom.reboot
285
- newdom = conn.create_domain_xml(new_dom_xml)
107
+ newdom = conn.create_domain_xml($new_dom_xml)
286
108
  sleep 1
287
109
  expect_too_many_args(newdom, "reboot", 1, 2)
288
110
  expect_invalid_arg_type(newdom, "reboot", "hello")
@@ -299,14 +121,14 @@ sleep 1
299
121
  newdom.destroy
300
122
 
301
123
  # TESTGROUP: dom.destroy
302
- newdom = conn.create_domain_xml(new_dom_xml)
124
+ newdom = conn.create_domain_xml($new_dom_xml)
303
125
  sleep 1
304
126
 
305
127
  expect_too_many_args(newdom, "destroy", 1)
306
128
  expect_success(newdom, "no args", "destroy")
307
129
 
308
130
  # TESTGROUP: dom.suspend
309
- newdom = conn.create_domain_xml(new_dom_xml)
131
+ newdom = conn.create_domain_xml($new_dom_xml)
310
132
  sleep 1
311
133
 
312
134
  expect_too_many_args(newdom, "suspend", 1)
@@ -314,7 +136,7 @@ expect_success(newdom, "no args", "suspend")
314
136
  newdom.destroy
315
137
 
316
138
  # TESTGROUP: dom.resume
317
- newdom = conn.create_domain_xml(new_dom_xml)
139
+ newdom = conn.create_domain_xml($new_dom_xml)
318
140
  sleep 1
319
141
 
320
142
  expect_success(newdom, "no args running domain", "resume")
@@ -325,7 +147,7 @@ expect_success(newdom, "no args suspended domain", "resume")
325
147
  newdom.destroy
326
148
 
327
149
  # TESTGROUP: dom.save
328
- newdom = conn.define_domain_xml(new_dom_xml)
150
+ newdom = conn.define_domain_xml($new_dom_xml)
329
151
  newdom.create
330
152
  sleep 1
331
153
 
@@ -341,7 +163,7 @@ expect_success(newdom, "path arg", "save", "/var/lib/libvirt/images/ruby-libvirt
341
163
  newdom.undefine
342
164
 
343
165
  # TESTGROUP: dom.managed_save
344
- newdom = conn.define_domain_xml(new_dom_xml)
166
+ newdom = conn.define_domain_xml($new_dom_xml)
345
167
  newdom.create
346
168
  sleep 1
347
169
 
@@ -351,7 +173,7 @@ expect_success(newdom, "no args", "managed_save")
351
173
  newdom.undefine
352
174
 
353
175
  # TESTGROUP: dom.has_managed_save?
354
- newdom = conn.define_domain_xml(new_dom_xml)
176
+ newdom = conn.define_domain_xml($new_dom_xml)
355
177
  newdom.create
356
178
  sleep 1
357
179
 
@@ -375,7 +197,7 @@ end
375
197
  newdom.undefine
376
198
 
377
199
  # TESTGROUP: dom.managed_save_remove
378
- newdom = conn.define_domain_xml(new_dom_xml)
200
+ newdom = conn.define_domain_xml($new_dom_xml)
379
201
  newdom.create
380
202
  sleep 1
381
203
  newdom.managed_save
@@ -396,7 +218,7 @@ end
396
218
  newdom.undefine
397
219
 
398
220
  # TESTGROUP: dom.core_dump
399
- newdom = conn.define_domain_xml(new_dom_xml)
221
+ newdom = conn.define_domain_xml($new_dom_xml)
400
222
  newdom.create
401
223
  sleep 1
402
224
 
@@ -419,7 +241,7 @@ expect_fail(newdom, Libvirt::Error, "of shut-off domain", "core_dump", "/var/lib
419
241
  newdom.undefine
420
242
 
421
243
  # TESTGROUP: Libvirt::Domain::restore
422
- newdom = conn.define_domain_xml(new_dom_xml)
244
+ newdom = conn.define_domain_xml($new_dom_xml)
423
245
  newdom.create
424
246
  sleep 1
425
247
  newdom.save("/var/lib/libvirt/images/ruby-libvirt-test.save")
@@ -441,7 +263,7 @@ newdom.destroy
441
263
  newdom.undefine
442
264
 
443
265
  # TESTGROUP: dom.info
444
- newdom = conn.create_domain_xml(new_dom_xml)
266
+ newdom = conn.create_domain_xml($new_dom_xml)
445
267
  sleep 1
446
268
 
447
269
  expect_too_many_args(newdom, "info", 1)
@@ -451,7 +273,7 @@ expect_success(newdom, "no args", "info") {|x| x.state == Libvirt::Domain::RUNNI
451
273
  newdom.destroy
452
274
 
453
275
  # TESTGROUP: dom.security_label
454
- newdom = conn.create_domain_xml(new_dom_xml)
276
+ newdom = conn.create_domain_xml($new_dom_xml)
455
277
  sleep 1
456
278
 
457
279
  expect_too_many_args(newdom, "security_label", 1)
@@ -461,7 +283,7 @@ expect_success(newdom, "no args", "security_label")
461
283
  newdom.destroy
462
284
 
463
285
  # TESTGROUP: dom.block_stats
464
- newdom = conn.create_domain_xml(new_dom_xml)
286
+ newdom = conn.create_domain_xml($new_dom_xml)
465
287
  sleep 1
466
288
 
467
289
  expect_too_many_args(newdom, "block_stats", 1, 2)
@@ -474,7 +296,7 @@ expect_success(newdom, "block device arg", "block_stats", "vda")
474
296
  newdom.destroy
475
297
 
476
298
  # TESTGROUP: dom.memory_stats
477
- newdom = conn.create_domain_xml(new_dom_xml)
299
+ newdom = conn.create_domain_xml($new_dom_xml)
478
300
  sleep 1
479
301
 
480
302
  expect_too_many_args(newdom, "memory_stats", 1, 2)
@@ -485,7 +307,7 @@ expect_success(newdom, "no args", "memory_stats")
485
307
  newdom.destroy
486
308
 
487
309
  # TESTGROUP: dom.blockinfo
488
- newdom = conn.create_domain_xml(new_dom_xml)
310
+ newdom = conn.create_domain_xml($new_dom_xml)
489
311
  sleep 1
490
312
 
491
313
  expect_too_many_args(newdom, "blockinfo", 1, 2, 3)
@@ -494,12 +316,12 @@ expect_invalid_arg_type(newdom, "blockinfo", 1)
494
316
  expect_invalid_arg_type(newdom, "blockinfo", "foo", "bar")
495
317
  expect_fail(newdom, Libvirt::RetrieveError, "invalid path", "blockinfo", "foo")
496
318
 
497
- expect_success(newdom, "path arg", "blockinfo", GUEST_DISK)
319
+ expect_success(newdom, "path arg", "blockinfo", $GUEST_DISK)
498
320
 
499
321
  newdom.destroy
500
322
 
501
323
  # TESTGROUP: dom.block_peek
502
- newdom = conn.create_domain_xml(new_dom_xml)
324
+ newdom = conn.create_domain_xml($new_dom_xml)
503
325
  sleep 1
504
326
 
505
327
  expect_too_many_args(newdom, "block_peek", 1, 2, 3, 4, 5)
@@ -512,7 +334,7 @@ expect_invalid_arg_type(newdom, "block_peek", "foo", 0, "bar")
512
334
  expect_invalid_arg_type(newdom, "block_peek", "foo", 0, 512, "baz")
513
335
  expect_fail(newdom, Libvirt::RetrieveError, "invalid path", "block_peek", "foo", 0, 512)
514
336
 
515
- blockpeek = newdom.block_peek(GUEST_DISK, 0, 512)
337
+ blockpeek = newdom.block_peek($GUEST_DISK, 0, 512)
516
338
 
517
339
  # 51 46 49 fb are the first 4 bytes of a qcow2 image
518
340
  if blockpeek[0] != 0x51 or blockpeek[1] != 0x46 or blockpeek[2] != 0x49 or
@@ -525,7 +347,7 @@ end
525
347
  newdom.destroy
526
348
 
527
349
  # TESTGROUP: dom.memory_peek
528
- newdom = conn.create_domain_xml(new_dom_xml)
350
+ newdom = conn.create_domain_xml($new_dom_xml)
529
351
  sleep 1
530
352
 
531
353
  expect_too_many_args(newdom, "memory_peek", 1, 2, 3, 4)
@@ -536,12 +358,11 @@ expect_invalid_arg_type(newdom, "memory_peek", 0, "bar")
536
358
  expect_invalid_arg_type(newdom, "memory_peek", 0, 512, "baz")
537
359
 
538
360
  expect_success(newdom, "offset and size args", "memory_peek", 0, 512)
539
- puts_ok "dom.memory_peek succeeded"
540
361
 
541
362
  newdom.destroy
542
363
 
543
364
  # TESTGROUP: dom.get_vcpus
544
- newdom = conn.create_domain_xml(new_dom_xml)
365
+ newdom = conn.create_domain_xml($new_dom_xml)
545
366
  sleep 1
546
367
 
547
368
  expect_too_many_args(newdom, "get_vcpus", 1)
@@ -551,7 +372,7 @@ expect_success(newdom, "no args", "get_vcpus") {|x| x.length == 2}
551
372
  newdom.destroy
552
373
 
553
374
  # TESTGROUP: dom.active?
554
- newdom = conn.create_domain_xml(new_dom_xml)
375
+ newdom = conn.create_domain_xml($new_dom_xml)
555
376
  sleep 1
556
377
 
557
378
  expect_too_many_args(newdom, "active?", 1)
@@ -560,7 +381,7 @@ expect_success(newdom, "no args", "active?") {|x| x == true}
560
381
 
561
382
  newdom.destroy
562
383
 
563
- newdom = conn.define_domain_xml(new_dom_xml)
384
+ newdom = conn.define_domain_xml($new_dom_xml)
564
385
 
565
386
  expect_success(newdom, "no args", "active?") {|x| x == false}
566
387
 
@@ -573,7 +394,7 @@ newdom.destroy
573
394
  newdom.undefine
574
395
 
575
396
  # TESTGROUP: dom.persistent?
576
- newdom = conn.create_domain_xml(new_dom_xml)
397
+ newdom = conn.create_domain_xml($new_dom_xml)
577
398
  sleep 1
578
399
 
579
400
  expect_too_many_args(newdom, "persistent?", 1)
@@ -582,14 +403,14 @@ expect_success(newdom, "no args", "persistent?") {|x| x == false}
582
403
 
583
404
  newdom.destroy
584
405
 
585
- newdom = conn.define_domain_xml(new_dom_xml)
406
+ newdom = conn.define_domain_xml($new_dom_xml)
586
407
 
587
408
  expect_success(newdom, "no args", "persistent?") {|x| x == true}
588
409
 
589
410
  newdom.undefine
590
411
 
591
412
  # TESTGROUP: dom.ifinfo
592
- newdom = conn.create_domain_xml(new_dom_xml)
413
+ newdom = conn.create_domain_xml($new_dom_xml)
593
414
  sleep 1
594
415
 
595
416
  expect_too_many_args(newdom, "ifinfo", 1, 2)
@@ -602,7 +423,7 @@ expect_success(newdom, "interface arg", "ifinfo", "rl556")
602
423
  newdom.destroy
603
424
 
604
425
  # TESTGROUP: dom.name
605
- newdom = conn.create_domain_xml(new_dom_xml)
426
+ newdom = conn.create_domain_xml($new_dom_xml)
606
427
  sleep 1
607
428
 
608
429
  expect_too_many_args(newdom, "name", 1)
@@ -612,7 +433,7 @@ expect_success(newdom, "no args", "name") {|x| x == "ruby-libvirt-tester"}
612
433
  newdom.destroy
613
434
 
614
435
  # TESTGROUP: dom.id
615
- newdom = conn.create_domain_xml(new_dom_xml)
436
+ newdom = conn.create_domain_xml($new_dom_xml)
616
437
  sleep 1
617
438
 
618
439
  expect_too_many_args(newdom, "id", 1)
@@ -622,17 +443,17 @@ expect_success(newdom, "no args", "id")
622
443
  newdom.destroy
623
444
 
624
445
  # TESTGROUP: dom.uuid
625
- newdom = conn.create_domain_xml(new_dom_xml)
446
+ newdom = conn.create_domain_xml($new_dom_xml)
626
447
  sleep 1
627
448
 
628
449
  expect_too_many_args(newdom, "uuid", 1)
629
450
 
630
- expect_success(newdom, "no args", "uuid") {|x| x == UUID}
451
+ expect_success(newdom, "no args", "uuid") {|x| x == $GUEST_UUID}
631
452
 
632
453
  newdom.destroy
633
454
 
634
455
  # TESTGROUP: dom.os_type
635
- newdom = conn.create_domain_xml(new_dom_xml)
456
+ newdom = conn.create_domain_xml($new_dom_xml)
636
457
  sleep 1
637
458
 
638
459
  expect_too_many_args(newdom, "os_type", 1)
@@ -642,7 +463,7 @@ expect_success(newdom, "no args", "os_type") {|x| x == "hvm"}
642
463
  newdom.destroy
643
464
 
644
465
  # TESTGROUP: dom.max_memory
645
- newdom = conn.create_domain_xml(new_dom_xml)
466
+ newdom = conn.create_domain_xml($new_dom_xml)
646
467
  sleep 1
647
468
 
648
469
  expect_too_many_args(newdom, "max_memory", 1)
@@ -652,7 +473,7 @@ expect_success(newdom, "no args", "max_memory") {|x| x == 1048576}
652
473
  newdom.destroy
653
474
 
654
475
  # TESTGROUP: dom.max_memory=
655
- newdom = conn.define_domain_xml(new_dom_xml)
476
+ newdom = conn.define_domain_xml($new_dom_xml)
656
477
 
657
478
  expect_too_many_args(newdom, "max_memory=", 1, 2)
658
479
  expect_too_few_args(newdom, "max_memory=")
@@ -671,7 +492,7 @@ end
671
492
  newdom.undefine
672
493
 
673
494
  # TESTGROUP: dom.memory=
674
- newdom = conn.define_domain_xml(new_dom_xml)
495
+ newdom = conn.define_domain_xml($new_dom_xml)
675
496
 
676
497
  expect_too_many_args(newdom, "memory=", 1, 2)
677
498
  expect_too_few_args(newdom, "memory=")
@@ -681,7 +502,7 @@ expect_fail(newdom, Libvirt::Error, "shutoff domain", "memory=", 2)
681
502
 
682
503
  newdom.undefine
683
504
 
684
- newdom = conn.create_domain_xml(new_dom_xml)
505
+ newdom = conn.create_domain_xml($new_dom_xml)
685
506
  sleep 1
686
507
 
687
508
  expect_success(newdom, "number arg", "memory=", 200000)
@@ -689,7 +510,7 @@ expect_success(newdom, "number arg", "memory=", 200000)
689
510
  newdom.destroy
690
511
 
691
512
  # TESTGROUP: dom.max_vcpus
692
- newdom = conn.create_domain_xml(new_dom_xml)
513
+ newdom = conn.create_domain_xml($new_dom_xml)
693
514
  sleep 1
694
515
 
695
516
  expect_too_many_args(newdom, "max_vcpus", 1)
@@ -699,7 +520,7 @@ expect_success(newdom, "no args", "max_vcpus")
699
520
  newdom.destroy
700
521
 
701
522
  # TESTGROUP: dom.vcpus=
702
- newdom = conn.define_domain_xml(new_dom_xml)
523
+ newdom = conn.define_domain_xml($new_dom_xml)
703
524
 
704
525
  expect_too_many_args(newdom, "vcpus=", 1, 2)
705
526
  expect_too_few_args(newdom, "vcpus=")
@@ -709,7 +530,7 @@ expect_fail(newdom, Libvirt::Error, "shutoff domain", "vcpus=", 2)
709
530
 
710
531
  newdom.undefine
711
532
 
712
- newdom = conn.create_domain_xml(new_dom_xml)
533
+ newdom = conn.create_domain_xml($new_dom_xml)
713
534
  sleep 1
714
535
 
715
536
  # FIXME: this kills the domain for some reason
@@ -718,7 +539,7 @@ sleep 1
718
539
  newdom.destroy
719
540
 
720
541
  # TESTGROUP: dom.pin_vcpu
721
- newdom = conn.create_domain_xml(new_dom_xml)
542
+ newdom = conn.create_domain_xml($new_dom_xml)
722
543
  sleep 1
723
544
 
724
545
  expect_too_many_args(newdom, "pin_vcpu", 1, 2, 3)
@@ -731,7 +552,7 @@ expect_success(newdom, "cpu args", "pin_vcpu", 0, [0])
731
552
  newdom.destroy
732
553
 
733
554
  # TESTGROUP: dom.xml_desc
734
- newdom = conn.create_domain_xml(new_dom_xml)
555
+ newdom = conn.create_domain_xml($new_dom_xml)
735
556
  sleep 1
736
557
 
737
558
  expect_too_many_args(newdom, "xml_desc", 1, 2)
@@ -742,14 +563,14 @@ expect_success(newdom, "no args", "xml_desc")
742
563
  newdom.destroy
743
564
 
744
565
  # TESTGROUP: dom.undefine
745
- newdom = conn.define_domain_xml(new_dom_xml)
566
+ newdom = conn.define_domain_xml($new_dom_xml)
746
567
 
747
568
  expect_too_many_args(newdom, "undefine", 1)
748
569
 
749
570
  expect_success(newdom, "no args", "undefine")
750
571
 
751
572
  # TESTGROUP: dom.create
752
- newdom = conn.define_domain_xml(new_dom_xml)
573
+ newdom = conn.define_domain_xml($new_dom_xml)
753
574
 
754
575
  expect_too_many_args(newdom, "create", 1, 2)
755
576
  expect_invalid_arg_type(newdom, "create", "foo")
@@ -762,7 +583,7 @@ newdom.destroy
762
583
  newdom.undefine
763
584
 
764
585
  # TESTGROUP: dom.autostart?
765
- newdom = conn.define_domain_xml(new_dom_xml)
586
+ newdom = conn.define_domain_xml($new_dom_xml)
766
587
 
767
588
  expect_too_many_args(newdom, "autostart?", 1)
768
589
 
@@ -775,7 +596,7 @@ expect_success(newdom, "no args", "autostart?") {|x| x == true}
775
596
  newdom.undefine
776
597
 
777
598
  # TESTGROUP: dom.autostart=
778
- newdom = conn.define_domain_xml(new_dom_xml)
599
+ newdom = conn.define_domain_xml($new_dom_xml)
779
600
 
780
601
  expect_too_many_args(newdom, "autostart=", 1, 2)
781
602
  expect_invalid_arg_type(newdom, "autostart=", 'foo')
@@ -799,7 +620,7 @@ end
799
620
  newdom.undefine
800
621
 
801
622
  # TESTGROUP: dom.attach_device
802
- newdom = conn.define_domain_xml(new_dom_xml)
623
+ newdom = conn.define_domain_xml($new_dom_xml)
803
624
 
804
625
  expect_too_many_args(newdom, "attach_device", 1, 2, 3)
805
626
  expect_too_few_args(newdom, "attach_device")
@@ -810,7 +631,7 @@ expect_fail(newdom, Libvirt::Error, "shut off domain", "attach_device", new_host
810
631
 
811
632
  newdom.undefine
812
633
 
813
- newdom = conn.create_domain_xml(new_dom_xml)
634
+ newdom = conn.create_domain_xml($new_dom_xml)
814
635
  sleep 1
815
636
 
816
637
  #expect_success(newdom, "hostdev XML", "attach_device", new_hostdev_xml)
@@ -818,7 +639,7 @@ sleep 1
818
639
  newdom.destroy
819
640
 
820
641
  # TESTGROUP: dom.detach_device
821
- newdom = conn.define_domain_xml(new_dom_xml)
642
+ newdom = conn.define_domain_xml($new_dom_xml)
822
643
 
823
644
  expect_too_many_args(newdom, "detach_device", 1, 2, 3)
824
645
  expect_too_few_args(newdom, "detach_device")
@@ -829,7 +650,7 @@ expect_fail(newdom, Libvirt::Error, "shut off domain", "detach_device", new_host
829
650
 
830
651
  newdom.undefine
831
652
 
832
- newdom = conn.create_domain_xml(new_dom_xml)
653
+ newdom = conn.create_domain_xml($new_dom_xml)
833
654
  sleep 1
834
655
 
835
656
  #expect_success(newdom, "hostdev XML", "detach_device", new_hostdev_xml)
@@ -837,7 +658,7 @@ sleep 1
837
658
  newdom.destroy
838
659
 
839
660
  # TESTGROUP: dom.update_device
840
- newdom = conn.define_domain_xml(new_dom_xml)
661
+ newdom = conn.define_domain_xml($new_dom_xml)
841
662
 
842
663
  expect_too_many_args(newdom, "update_device", 1, 2, 3)
843
664
  expect_too_few_args(newdom, "update_device")
@@ -848,7 +669,7 @@ expect_fail(newdom, Libvirt::Error, "shut off domain", "update_device", new_host
848
669
 
849
670
  newdom.undefine
850
671
 
851
- newdom = conn.create_domain_xml(new_dom_xml)
672
+ newdom = conn.create_domain_xml($new_dom_xml)
852
673
  sleep 1
853
674
 
854
675
  #expect_success(newdom, "hostdev XML", "update_device", new_hostdev_xml)
@@ -856,7 +677,7 @@ sleep 1
856
677
  newdom.destroy
857
678
 
858
679
  # TESTGROUP: dom.free
859
- newdom = conn.define_domain_xml(new_dom_xml)
680
+ newdom = conn.define_domain_xml($new_dom_xml)
860
681
  newdom.undefine
861
682
  expect_too_many_args(newdom, "free", 1)
862
683
 
@@ -864,7 +685,7 @@ newdom.free
864
685
  puts_ok "dom.free succeeded"
865
686
 
866
687
  # TESTGROUP: dom.snapshot_create_xml
867
- newdom = conn.define_domain_xml(new_dom_xml)
688
+ newdom = conn.define_domain_xml($new_dom_xml)
868
689
 
869
690
  expect_too_many_args(newdom, "snapshot_create_xml", 1, 2, 3)
870
691
  expect_too_few_args(newdom, "snapshot_create_xml")
@@ -884,7 +705,7 @@ end
884
705
  newdom.undefine
885
706
 
886
707
  # TESTGROUP: dom.num_of_snapshots
887
- newdom = conn.define_domain_xml(new_dom_xml)
708
+ newdom = conn.define_domain_xml($new_dom_xml)
888
709
 
889
710
  expect_too_many_args(newdom, "num_of_snapshots", 1, 2)
890
711
  expect_invalid_arg_type(newdom, "num_of_snapshots", 'foo')
@@ -898,7 +719,7 @@ expect_success(newdom, "no args", "num_of_snapshots") {|x| x == 1}
898
719
  newdom.undefine
899
720
 
900
721
  # TESTGROUP: dom.list_snapshots
901
- newdom = conn.define_domain_xml(new_dom_xml)
722
+ newdom = conn.define_domain_xml($new_dom_xml)
902
723
 
903
724
  expect_too_many_args(newdom, "list_snapshots", 1, 2)
904
725
  expect_invalid_arg_type(newdom, "list_snapshots", 'foo')
@@ -912,7 +733,7 @@ expect_success(newdom, "no args", "list_snapshots") {|x| x.length == 1}
912
733
  newdom.undefine
913
734
 
914
735
  # TESTGROUP: dom.lookup_snapshot_by_name
915
- newdom = conn.define_domain_xml(new_dom_xml)
736
+ newdom = conn.define_domain_xml($new_dom_xml)
916
737
  newdom.snapshot_create_xml("<domainsnapshot><name>foo</name></domainsnapshot>")
917
738
 
918
739
  expect_too_many_args(newdom, "lookup_snapshot_by_name", 1, 2, 3)
@@ -925,7 +746,7 @@ expect_success(newdom, "name arg", "lookup_snapshot_by_name", "foo")
925
746
  newdom.undefine
926
747
 
927
748
  # TESTGROUP: dom.has_current_snapshot?
928
- newdom = conn.define_domain_xml(new_dom_xml)
749
+ newdom = conn.define_domain_xml($new_dom_xml)
929
750
 
930
751
  expect_too_many_args(newdom, "has_current_snapshot?", 1, 2)
931
752
  expect_invalid_arg_type(newdom, "has_current_snapshot?", 'foo')
@@ -939,7 +760,7 @@ expect_success(newdom, "no args", "has_current_snapshot?") {|x| x == true}
939
760
  newdom.undefine
940
761
 
941
762
  # TESTGROUP: dom.revert_to_snapshot
942
- newdom = conn.define_domain_xml(new_dom_xml)
763
+ newdom = conn.define_domain_xml($new_dom_xml)
943
764
 
944
765
  expect_too_many_args(newdom, "revert_to_snapshot", 1, 2, 3)
945
766
  expect_too_few_args(newdom, "revert_to_snapshot")
@@ -957,7 +778,7 @@ expect_success(newdom, "snapshot arg", "revert_to_snapshot", snap)
957
778
  newdom.undefine
958
779
 
959
780
  # TESTGROUP: dom.current_snapshot
960
- newdom = conn.define_domain_xml(new_dom_xml)
781
+ newdom = conn.define_domain_xml($new_dom_xml)
961
782
 
962
783
  expect_too_many_args(newdom, "current_snapshot", 1, 2)
963
784
  expect_invalid_arg_type(newdom, "current_snapshot", 'foo')
@@ -970,7 +791,7 @@ expect_success(newdom, "no args", "current_snapshot")
970
791
  newdom.undefine
971
792
 
972
793
  # TESTGROUP: snapshot.xml_desc
973
- newdom = conn.define_domain_xml(new_dom_xml)
794
+ newdom = conn.define_domain_xml($new_dom_xml)
974
795
  snap = newdom.snapshot_create_xml("<domainsnapshot/>")
975
796
 
976
797
  expect_too_many_args(snap, "xml_desc", 1, 2)
@@ -981,7 +802,7 @@ expect_success(newdom, "no args", "xml_desc")
981
802
  newdom.undefine
982
803
 
983
804
  # TESTGROUP: snapshot.delete
984
- newdom = conn.define_domain_xml(new_dom_xml)
805
+ newdom = conn.define_domain_xml($new_dom_xml)
985
806
  snap = newdom.snapshot_create_xml("<domainsnapshot/>")
986
807
 
987
808
  expect_too_many_args(snap, "delete", 1, 2)
@@ -992,14 +813,14 @@ expect_success(snap, "no args", "delete")
992
813
  newdom.undefine
993
814
 
994
815
  # TESTGROUP: snapshot.free
995
- newdom = conn.define_domain_xml(new_dom_xml)
816
+ newdom = conn.define_domain_xml($new_dom_xml)
996
817
  newdom.undefine
997
818
  expect_too_many_args(newdom, "free", 1)
998
819
 
999
820
  expect_success(newdom, "no args", "free")
1000
821
 
1001
822
  # TESTGROUP: dom.job_info
1002
- newdom = conn.define_domain_xml(new_dom_xml)
823
+ newdom = conn.define_domain_xml($new_dom_xml)
1003
824
 
1004
825
  expect_too_many_args(newdom, "job_info", 1)
1005
826
 
@@ -1007,7 +828,7 @@ expect_fail(newdom, Libvirt::RetrieveError, "shutoff domain", "job_info")
1007
828
 
1008
829
  newdom.undefine
1009
830
 
1010
- newdom = conn.create_domain_xml(new_dom_xml)
831
+ newdom = conn.create_domain_xml($new_dom_xml)
1011
832
  sleep 1
1012
833
 
1013
834
  expect_success(newdom, "no args", "job_info")
@@ -1015,7 +836,7 @@ expect_success(newdom, "no args", "job_info")
1015
836
  newdom.destroy
1016
837
 
1017
838
  # TESTGROUP: dom.abort_job
1018
- newdom = conn.define_domain_xml(new_dom_xml)
839
+ newdom = conn.define_domain_xml($new_dom_xml)
1019
840
 
1020
841
  expect_too_many_args(newdom, "abort_job", 1)
1021
842
 
@@ -1023,7 +844,7 @@ expect_fail(newdom, Libvirt::Error, "not running domain", "abort_job")
1023
844
 
1024
845
  newdom.undefine
1025
846
 
1026
- newdom = conn.create_domain_xml(new_dom_xml)
847
+ newdom = conn.create_domain_xml($new_dom_xml)
1027
848
  sleep 1
1028
849
 
1029
850
  expect_fail(newdom, Libvirt::Error, "no active job", "abort_job")
@@ -1034,7 +855,7 @@ expect_fail(newdom, Libvirt::Error, "no active job", "abort_job")
1034
855
  newdom.destroy
1035
856
 
1036
857
  # TESTGROUP: dom.scheduler_type
1037
- newdom = conn.define_domain_xml(new_dom_xml)
858
+ newdom = conn.define_domain_xml($new_dom_xml)
1038
859
 
1039
860
  expect_too_many_args(newdom, "scheduler_type", 1)
1040
861
 
@@ -1051,7 +872,7 @@ end
1051
872
  newdom.undefine
1052
873
 
1053
874
  # TESTGROUP: dom.scheduler_parameters
1054
- newdom = conn.define_domain_xml(new_dom_xml)
875
+ newdom = conn.define_domain_xml($new_dom_xml)
1055
876
 
1056
877
  expect_too_many_args(newdom, "scheduler_parameters", 1)
1057
878
 
@@ -1068,18 +889,72 @@ end
1068
889
  newdom.undefine
1069
890
 
1070
891
  # TESTGROUP: dom.scheduler_parameters=
1071
- newdom = conn.define_domain_xml(new_dom_xml)
892
+ newdom = conn.define_domain_xml($new_dom_xml)
1072
893
 
1073
894
  expect_too_many_args(newdom, "scheduler_parameters=", 1, 2)
1074
895
  expect_too_few_args(newdom, "scheduler_parameters=")
1075
896
  expect_invalid_arg_type(newdom, "scheduler_parameters=", 0)
1076
897
 
1077
- # FIXME: set scheduler_parameters here
898
+ begin
899
+ newdom.scheduler_parameters={"cpu_shares"=>512}
900
+ rescue NoMethodError
901
+ puts_skipped "dom.scheduler_parameters= does not exist"
902
+ rescue Libvirt::RetrieveError
903
+ # this may not be supported (if cgroups aren't configured), so skip it
904
+ puts_ok "dom.scheduler_parameters= not supported"
905
+ end
1078
906
 
1079
907
  newdom.undefine
1080
908
 
909
+ # TESTGROUP: dom.qemu_monitor_command
910
+ new_test_xml = <<EOF
911
+ <domain type='test'>
912
+ <name>fc4</name>
913
+ <uuid>EF86180145B911CB88E3AFBFE5370493</uuid>
914
+ <os>
915
+ <type>xen</type>
916
+ <kernel>/boot/vmlinuz-2.6.15-1.43_FC5guest</kernel>
917
+ <initrd>/boot/initrd-2.6.15-1.43_FC5guest.img</initrd>
918
+ <root>/dev/sda1</root>
919
+ <cmdline> ro selinux=0 3</cmdline>
920
+ </os>
921
+ <memory>261072</memory>
922
+ <currentMemory>131072</currentMemory>
923
+ <vcpu>1</vcpu>
924
+ <devices>
925
+ <disk type='file'>
926
+ <source file='/u/fc4.img'/>
927
+ <target dev='sda1'/>
928
+ </disk>
929
+ <interface type='bridge'>
930
+ <source bridge='xenbr0'/>
931
+ <mac address='aa:00:00:00:00:11'/>
932
+ <script path='/etc/xen/scripts/vif-bridge'/>
933
+ </interface>
934
+ <console tty='/dev/pts/5'/>
935
+ </devices>
936
+ </domain>
937
+ EOF
938
+
939
+ newdom = conn.create_domain_xml($new_dom_xml)
940
+
941
+ expect_too_many_args(newdom, "qemu_monitor_command", 1, 2, 3)
942
+ expect_too_few_args(newdom, "qemu_monitor_command")
943
+ expect_invalid_arg_type(newdom, "qemu_monitor_command", 1)
944
+ expect_invalid_arg_type(newdom, "qemu_monitor_command", "foo", "bar")
945
+ testconn = Libvirt::open("test:///default")
946
+ fakedom = testconn.create_domain_xml(new_test_xml)
947
+ expect_invalid_arg_type(fakedom, "qemu_monitor_command", "foo")
948
+ fakedom.destroy
949
+ testconn.close
950
+ expect_fail(newdom, Libvirt::RetrieveError, "invalid command", "qemu_monitor_command", "foo")
951
+
952
+ expect_success(newdom, "monitor command", "qemu_monitor_command", '{"execute":"query-cpus"}')
953
+
954
+ newdom.destroy
955
+
1081
956
  # TESTGROUP: dom.num_vcpus
1082
- newdom = conn.define_domain_xml(new_dom_xml)
957
+ newdom = conn.define_domain_xml($new_dom_xml)
1083
958
 
1084
959
  expect_too_many_args(newdom, "num_vcpus", 1, 2)
1085
960
  expect_too_few_args(newdom, "num_vcpus")
@@ -1091,7 +966,7 @@ expect_success(newdom, "config flag", "num_vcpus", Libvirt::Domain::VCPU_CONFIG)
1091
966
 
1092
967
  newdom.undefine
1093
968
 
1094
- newdom = conn.create_domain_xml(new_dom_xml)
969
+ newdom = conn.create_domain_xml($new_dom_xml)
1095
970
  sleep 1
1096
971
 
1097
972
  expect_success(newdom, "config flag on transient domain", "num_vcpus", Libvirt::Domain::VCPU_CONFIG)
@@ -1100,7 +975,7 @@ expect_success(newdom, "live flag on transient domain", "num_vcpus", Libvirt::Do
1100
975
  newdom.destroy
1101
976
 
1102
977
  # TESTGROUP: dom.vcpus_flags=
1103
- newdom = conn.define_domain_xml(new_dom_xml)
978
+ newdom = conn.define_domain_xml($new_dom_xml)
1104
979
 
1105
980
  expect_too_many_args(newdom, "vcpus_flags=", 1, 2, 3)
1106
981
  expect_too_few_args(newdom, "vcpus_flags=")
@@ -1114,14 +989,105 @@ expect_success(newdom, "2 vcpu config", "vcpus_flags=", [2, Libvirt::Domain::VCP
1114
989
 
1115
990
  newdom.undefine
1116
991
 
1117
- newdom = conn.create_domain_xml(new_dom_xml)
992
+ newdom = conn.create_domain_xml($new_dom_xml)
1118
993
  sleep 1
1119
994
 
1120
995
  expect_fail(newdom, Libvirt::Error, "vcpu config on transient domain", "vcpus_flags=", [2, Libvirt::Domain::VCPU_CONFIG])
1121
996
  expect_fail(newdom, Libvirt::Error, "too many vcpus", "vcpus_flags=", [4, Libvirt::Domain::VCPU_LIVE])
1122
997
 
1123
998
  # FIXME: this doesn't work for some reason
1124
- #expect_success(newdom, "vcpus to 1", "vcpus_flags", [1,Libvirt::Domain::VCPU_LIVE])
999
+ #expect_success(newdom, "vcpus to 1", "vcpus_flags=", [1, Libvirt::Domain::VCPU_LIVE])
1000
+
1001
+ newdom.destroy
1002
+
1003
+ # TESTGROUP: dom.memory_parameters=
1004
+ newdom = conn.define_domain_xml($new_dom_xml)
1005
+
1006
+ expect_too_many_args(newdom, "memory_parameters=", 1, 2, 3)
1007
+ expect_too_few_args(newdom, "memory_parameters=")
1008
+ expect_invalid_arg_type(newdom, "memory_parameters=", 0)
1009
+ expect_fail(newdom, ArgumentError, "empty array", "memory_parameters=", [])
1010
+ expect_invalid_arg_type(newdom, "memory_parameters=", [1, 0])
1011
+ expect_invalid_arg_type(newdom, "memory_parameters=", [{}, "foo"])
1012
+
1013
+ begin
1014
+ newdom.memory_parameters={"soft_limit" => 9007199254740999, "swap_hard_limit" => 9007199254740999}
1015
+ rescue NoMethodError
1016
+ puts_skipped "dom.memory_parameters= does not exist"
1017
+ rescue Libvirt::RetrieveError
1018
+ # this may not be supported (if cgroups aren't configured), so skip it
1019
+ puts_skipped "memory_parameters= not supported"
1020
+ end
1021
+
1022
+ newdom.undefine
1023
+
1024
+ # TESTGROUP: dom.memory_parameters
1025
+ newdom = conn.define_domain_xml($new_dom_xml)
1026
+
1027
+ expect_too_many_args(newdom, "memory_parameters", 1, 2)
1028
+
1029
+ begin
1030
+ newdom.memory_parameters
1031
+ puts_ok "dom.memory_parameters succeeded"
1032
+ rescue NoMethodError
1033
+ puts_skipped "memory_parameters does not exist"
1034
+ rescue Libvirt::RetrieveError
1035
+ # this may not be supported (if cgroups aren't configured), so skip it
1036
+ puts_skipped "memory_parameters not supported"
1037
+ end
1038
+
1039
+ newdom.undefine
1040
+
1041
+ # TESTGROUP: dom.blkio_parameters=
1042
+ newdom = conn.define_domain_xml($new_dom_xml)
1043
+
1044
+ expect_too_many_args(newdom, "blkio_parameters=", 1, 2, 3)
1045
+ expect_too_few_args(newdom, "blkio_parameters=")
1046
+ expect_invalid_arg_type(newdom, "blkio_parameters=", 0)
1047
+ expect_fail(newdom, ArgumentError, "empty array", "blkio_parameters=", [])
1048
+ expect_invalid_arg_type(newdom, "blkio_parameters=", [1, 0])
1049
+ expect_invalid_arg_type(newdom, "blkio_parameters=", [{}, "foo"])
1050
+
1051
+ begin
1052
+ newdom.blkio_parameters={"weight" => 1}
1053
+ rescue NoMethodError
1054
+ puts_skipped "blkio_parameters= does not exist"
1055
+ rescue Libvirt::RetrieveError
1056
+ # this may not be supported (if cgroups aren't configured), so skip it
1057
+ puts_skipped "blkio_parameters= not supported"
1058
+ end
1059
+
1060
+ newdom.undefine
1061
+
1062
+ # TESTGROUP: dom.blkio_parameters
1063
+ newdom = conn.define_domain_xml($new_dom_xml)
1064
+
1065
+ expect_too_many_args(newdom, "blkio_parameters", 1, 2)
1066
+
1067
+ begin
1068
+ newdom.blkio_parameters
1069
+ puts_ok "dom.blkio_parameters succeeded"
1070
+ rescue NoMethodError
1071
+ puts_skipped "blkio_parameters does not exist"
1072
+ rescue Libvirt::RetrieveError
1073
+ # this may not be supported (if cgroups aren't configured), so skip it
1074
+ puts_skipped "blkio_parameters not supported"
1075
+ end
1076
+
1077
+ newdom.undefine
1078
+
1079
+ # TESTGROUP: dom.open_console
1080
+ newdom = conn.create_domain_xml(new_dom_xml)
1081
+ stream = conn.stream
1082
+
1083
+ expect_too_many_args(newdom, "open_console", 1, 2, 3, 4)
1084
+ expect_too_few_args(newdom, "open_console")
1085
+ expect_too_few_args(newdom, "open_console", 1)
1086
+ expect_invalid_arg_type(newdom, "open_console", 1, stream)
1087
+ expect_invalid_arg_type(newdom, "open_console", "pty", 1)
1088
+ expect_invalid_arg_type(newdom, "open_console", "pty", stream, "wow")
1089
+
1090
+ expect_success(newdom, "device and stream args", "open_console", "pty", stream)
1125
1091
 
1126
1092
  newdom.destroy
1127
1093