Lines Matching full:self

48     def process_events(self):  argument
49 for event in self.vm.get_qmp_events(wait=False):
52 event['data']['id'] == self.device_name)):
54 self.has_closed = True
56 self.has_opened = True
58 def wait_for_open(self): argument
59 if not self.has_real_tray:
63 while not self.has_opened:
64 self.process_events()
66 def wait_for_close(self): argument
67 if not self.has_real_tray:
71 while not self.has_closed:
72 self.process_events()
76 def test_blockdev_change_medium(self): argument
77 self.vm.cmd('blockdev-change-medium',
78 id=self.device_name, filename=new_img,
81 self.wait_for_open()
82 self.wait_for_close()
84 result = self.vm.qmp('query-block')
85 if self.has_real_tray:
86 self.assert_qmp(result, 'return[0]/tray_open', False)
87 self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
89 def test_eject(self): argument
90 self.vm.cmd('eject', id=self.device_name, force=True)
92 self.wait_for_open()
94 result = self.vm.qmp('query-block')
95 if self.has_real_tray:
96 self.assert_qmp(result, 'return[0]/tray_open', True)
97 self.assert_qmp_absent(result, 'return[0]/inserted')
99 def test_tray_eject_change(self): argument
100 self.vm.cmd('eject', id=self.device_name, force=True)
102 self.wait_for_open()
104 result = self.vm.qmp('query-block')
105 if self.has_real_tray:
106 self.assert_qmp(result, 'return[0]/tray_open', True)
107 self.assert_qmp_absent(result, 'return[0]/inserted')
109 self.vm.cmd('blockdev-change-medium', id=self.device_name,
112 self.wait_for_close()
114 result = self.vm.qmp('query-block')
115 if self.has_real_tray:
116 self.assert_qmp(result, 'return[0]/tray_open', False)
117 self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
119 def test_tray_open_close(self): argument
120 self.vm.cmd('blockdev-open-tray',
121 id=self.device_name, force=True)
123 self.wait_for_open()
125 result = self.vm.qmp('query-block')
126 if self.has_real_tray:
127 self.assert_qmp(result, 'return[0]/tray_open', True)
128 if self.was_empty == True:
129 self.assert_qmp_absent(result, 'return[0]/inserted')
131 self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img)
133 self.vm.cmd('blockdev-close-tray', id=self.device_name)
135 if self.has_real_tray or not self.was_empty:
136 self.wait_for_close()
138 result = self.vm.qmp('query-block')
139 if self.has_real_tray:
140 self.assert_qmp(result, 'return[0]/tray_open', False)
141 if self.was_empty == True:
142 self.assert_qmp_absent(result, 'return[0]/inserted')
144 self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img)
146 def test_tray_eject_close(self): argument
147 self.vm.cmd('eject', id=self.device_name, force=True)
149 self.wait_for_open()
151 result = self.vm.qmp('query-block')
152 if self.has_real_tray:
153 self.assert_qmp(result, 'return[0]/tray_open', True)
154 self.assert_qmp_absent(result, 'return[0]/inserted')
156 self.vm.cmd('blockdev-close-tray', id=self.device_name)
158 self.wait_for_close()
160 result = self.vm.qmp('query-block')
161 if self.has_real_tray:
162 self.assert_qmp(result, 'return[0]/tray_open', False)
163 self.assert_qmp_absent(result, 'return[0]/inserted')
165 def test_tray_open_change(self): argument
166 self.vm.cmd('blockdev-open-tray', id=self.device_name,
169 self.wait_for_open()
171 result = self.vm.qmp('query-block')
172 if self.has_real_tray:
173 self.assert_qmp(result, 'return[0]/tray_open', True)
174 if self.was_empty == True:
175 self.assert_qmp_absent(result, 'return[0]/inserted')
177 self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img)
179 self.vm.cmd('blockdev-change-medium', id=self.device_name,
183 self.wait_for_close()
185 result = self.vm.qmp('query-block')
186 if self.has_real_tray:
187 self.assert_qmp(result, 'return[0]/tray_open', False)
188 self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
190 def test_cycle(self, read_only_node=False): argument
191 self.vm.cmd('blockdev-add',
198 self.vm.cmd('blockdev-open-tray',
199 id=self.device_name, force=True)
201 self.wait_for_open()
203 result = self.vm.qmp('query-block')
204 if self.has_real_tray:
205 self.assert_qmp(result, 'return[0]/tray_open', True)
206 if self.was_empty == True:
207 self.assert_qmp_absent(result, 'return[0]/inserted')
209 self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img)
211 self.vm.cmd('blockdev-remove-medium',
212 id=self.device_name)
214 result = self.vm.qmp('query-block')
215 if self.has_real_tray:
216 self.assert_qmp(result, 'return[0]/tray_open', True)
217 self.assert_qmp_absent(result, 'return[0]/inserted')
219 self.vm.cmd('blockdev-insert-medium',
220 id=self.device_name, node_name='new')
222 result = self.vm.qmp('query-block')
223 if self.has_real_tray:
224 self.assert_qmp(result, 'return[0]/tray_open', True)
225 self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
227 self.vm.cmd('blockdev-close-tray', id=self.device_name)
229 self.wait_for_close()
231 result = self.vm.qmp('query-block')
232 if self.has_real_tray:
233 self.assert_qmp(result, 'return[0]/tray_open', False)
234 self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
236 def test_cycle_read_only_media(self): argument
237 self.test_cycle(True)
239 def test_close_on_closed(self): argument
241 self.vm.cmd('blockdev-close-tray', id=self.device_name)
242 self.assertEqual(self.vm.get_qmp_events(wait=False), [])
244 def test_remove_on_closed(self): argument
245 if not self.has_real_tray:
248 result = self.vm.qmp('blockdev-remove-medium', id=self.device_name)
249 self.assert_qmp(result, 'error/class', 'GenericError')
251 def test_insert_on_closed(self): argument
252 if not self.has_real_tray:
255 self.vm.cmd('blockdev-add',
261 result = self.vm.qmp('blockdev-insert-medium', id=self.device_name,
263 self.assert_qmp(result, 'error/class', 'GenericError')
268 def setUp(self): argument
271 self.vm = iotests.VM()
272 if self.use_drive:
273 self.vm.add_drive(old_img, 'media=%s' % self.media, 'none')
275 self.vm.add_blockdev([ 'node-name=drive0',
279 if self.interface == 'scsi':
280 self.vm.add_object('iothread,id=iothread0')
281 self.vm.add_device('virtio-scsi-pci,iothread=iothread0')
282 self.vm.add_device('%s,drive=drive0,id=%s' %
283 (interface_to_device_name(self.interface),
284 self.device_name))
285 self.vm.launch()
287 def tearDown(self): argument
288 self.vm.shutdown()
292 def test_insert_on_filled(self): argument
293 self.vm.cmd('blockdev-add',
299 self.vm.cmd('blockdev-open-tray', id=self.device_name)
301 self.wait_for_open()
303 result = self.vm.qmp('blockdev-insert-medium', id=self.device_name,
305 self.assert_qmp(result, 'error/class', 'GenericError')
310 def setUp(self): argument
312 self.vm = iotests.VM()
313 if self.use_drive:
314 self.vm.add_drive(None, 'media=%s' % self.media, 'none')
315 if self.interface == 'scsi':
316 self.vm.add_object('iothread,id=iothread0')
317 self.vm.add_device('virtio-scsi-pci,iothread=iothread0')
318 self.vm.add_device('%s,%sid=%s' %
319 (interface_to_device_name(self.interface),
320 'drive=drive0,' if self.use_drive else '',
321 self.device_name))
322 self.vm.launch()
324 def tearDown(self): argument
325 self.vm.shutdown()
328 def test_remove_on_empty(self): argument
329 self.vm.cmd('blockdev-open-tray', id=self.device_name)
331 self.wait_for_open()
334 self.vm.cmd('blockdev-remove-medium', id=self.device_name)
359 def setUp(self): argument
362 self.vm = iotests.VM()
364 def tearDown(self): argument
365 self.vm.shutdown()
371 def test_ro_ro_retain(self): argument
374 self.vm.add_drive(old_img, 'media=disk,read-only=on', 'none')
375 self.vm.add_device('floppy,drive=drive0,id=%s' % self.device_name)
376 self.vm.launch()
378 result = self.vm.qmp('query-block')
379 self.assert_qmp(result, 'return[0]/inserted/ro', True)
380 self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img)
382 self.vm.cmd('blockdev-change-medium', id=self.device_name,
387 result = self.vm.qmp('query-block')
388 self.assert_qmp(result, 'return[0]/inserted/ro', True)
389 self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
391 def test_ro_rw_retain(self): argument
393 self.vm.add_drive(old_img, 'media=disk,read-only=on', 'none')
394 self.vm.add_device('floppy,drive=drive0,id=%s' % self.device_name)
395 self.vm.launch()
397 result = self.vm.qmp('query-block')
398 self.assert_qmp(result, 'return[0]/inserted/ro', True)
399 self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img)
401 self.vm.cmd('blockdev-change-medium', id=self.device_name,
406 result = self.vm.qmp('query-block')
407 self.assert_qmp(result, 'return[0]/inserted/ro', True)
408 self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
411 def test_rw_ro_retain(self): argument
413 self.vm.add_drive(old_img, 'media=disk', 'none')
414 self.vm.add_device('floppy,drive=drive0,id=%s' % self.device_name)
415 self.vm.launch()
417 result = self.vm.qmp('query-block')
418 self.assert_qmp(result, 'return[0]/inserted/ro', False)
419 self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img)
421 result = self.vm.qmp('blockdev-change-medium', id=self.device_name,
425 self.assert_qmp(result, 'error/class', 'GenericError')
427 self.assertEqual(self.vm.get_qmp_events(wait=False), [])
429 result = self.vm.qmp('query-block')
430 self.assert_qmp(result, 'return[0]/inserted/ro', False)
431 self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img)
433 def test_ro_rw(self): argument
435 self.vm.add_drive(old_img, 'media=disk,read-only=on', 'none')
436 self.vm.add_device('floppy,drive=drive0,id=%s' % self.device_name)
437 self.vm.launch()
439 result = self.vm.qmp('query-block')
440 self.assert_qmp(result, 'return[0]/inserted/ro', True)
441 self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img)
443 self.vm.cmd('blockdev-change-medium',
444 id=self.device_name,
449 result = self.vm.qmp('query-block')
450 self.assert_qmp(result, 'return[0]/inserted/ro', False)
451 self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
453 def test_rw_ro(self): argument
455 self.vm.add_drive(old_img, 'media=disk', 'none')
456 self.vm.add_device('floppy,drive=drive0,id=%s' % self.device_name)
457 self.vm.launch()
459 result = self.vm.qmp('query-block')
460 self.assert_qmp(result, 'return[0]/inserted/ro', False)
461 self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img)
463 self.vm.cmd('blockdev-change-medium',
464 id=self.device_name,
469 result = self.vm.qmp('query-block')
470 self.assert_qmp(result, 'return[0]/inserted/ro', True)
471 self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
473 def test_make_rw_ro(self): argument
474 self.vm.add_drive(old_img, 'media=disk', 'none')
475 self.vm.add_device('floppy,drive=drive0,id=%s' % self.device_name)
476 self.vm.launch()
478 result = self.vm.qmp('query-block')
479 self.assert_qmp(result, 'return[0]/inserted/ro', False)
480 self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img)
482 self.vm.cmd('blockdev-change-medium',
483 id=self.device_name,
488 result = self.vm.qmp('query-block')
489 self.assert_qmp(result, 'return[0]/inserted/ro', True)
490 self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
493 def test_make_ro_rw(self): argument
495 self.vm.add_drive(old_img, 'media=disk', 'none')
496 self.vm.add_device('floppy,drive=drive0,id=%s' % self.device_name)
497 self.vm.launch()
499 result = self.vm.qmp('query-block')
500 self.assert_qmp(result, 'return[0]/inserted/ro', False)
501 self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img)
503 result = self.vm.qmp('blockdev-change-medium',
504 id=self.device_name,
508 self.assert_qmp(result, 'error/class', 'GenericError')
510 result = self.vm.qmp('query-block')
511 self.assert_qmp(result, 'return[0]/inserted/ro', False)
512 self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img)
514 def test_make_rw_ro_by_retain(self): argument
516 self.vm.add_drive(old_img, 'media=disk,read-only=on', 'none')
517 self.vm.add_device('floppy,drive=drive0,id=%s' % self.device_name)
518 self.vm.launch()
520 result = self.vm.qmp('query-block')
521 self.assert_qmp(result, 'return[0]/inserted/ro', True)
522 self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img)
524 self.vm.cmd('blockdev-change-medium', id=self.device_name,
529 result = self.vm.qmp('query-block')
530 self.assert_qmp(result, 'return[0]/inserted/ro', True)
531 self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
534 def test_make_ro_rw_by_retain(self): argument
536 self.vm.add_drive(old_img, 'media=disk', 'none')
537 self.vm.add_device('floppy,drive=drive0,id=%s' % self.device_name)
538 self.vm.launch()
540 result = self.vm.qmp('query-block')
541 self.assert_qmp(result, 'return[0]/inserted/ro', False)
542 self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img)
544 result = self.vm.qmp('blockdev-change-medium', id=self.device_name,
548 self.assert_qmp(result, 'error/class', 'GenericError')
550 result = self.vm.qmp('query-block')
551 self.assert_qmp(result, 'return[0]/inserted/ro', False)
552 self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img)
554 def test_rw_ro_cycle(self): argument
556 self.vm.add_drive(old_img, 'media=disk', 'none')
557 self.vm.add_device('floppy,drive=drive0,id=%s' % self.device_name)
558 self.vm.launch()
560 result = self.vm.qmp('query-block')
561 self.assert_qmp(result, 'return[0]/inserted/ro', False)
562 self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img)
564 self.vm.cmd('blockdev-add',
571 result = self.vm.qmp('query-block')
572 self.assert_qmp(result, 'return[0]/inserted/ro', False)
573 self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img)
575 self.vm.cmd('blockdev-remove-medium', id=self.device_name)
577 result = self.vm.qmp('query-block')
578 self.assert_qmp_absent(result, 'return[0]/inserted')
580 self.vm.cmd('blockdev-insert-medium', id=self.device_name,
583 result = self.vm.qmp('query-block')
584 self.assert_qmp(result, 'return[0]/inserted/ro', True)
585 self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
587 result = self.vm.qmp('query-block')
588 self.assert_qmp(result, 'return[0]/inserted/ro', True)
589 self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
599 def setUp(self): argument
602 self.vm = iotests.VM()
603 self.vm.add_drive_raw("id=drive0,driver=null-co,if=none")
604 self.vm.add_device('floppy,drive=drive0,id=%s' % self.device_name)
605 self.vm.launch()
607 result = self.vm.qmp('query-block')
608 self.assert_qmp(result, 'return[0]/inserted/image/format', 'null-co')
612 self.vm.cmd('blockdev-remove-medium', id=self.device_name)
614 result = self.vm.qmp('query-block')
615 self.assert_qmp_absent(result, 'return[0]/inserted')
617 self.vm.cmd('blockdev-add',
623 self.vm.cmd('blockdev-insert-medium', id=self.device_name,
626 result = self.vm.qmp('query-block')
627 self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img)
629 def tearDown(self): argument
630 self.vm.shutdown()
640 def test_snapshot_and_commit(self): argument
641 self.vm.cmd('blockdev-snapshot-sync', device='drive0',
645 result = self.vm.qmp('query-block')
646 self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
647 self.assert_qmp(result,
651 self.vm.cmd('block-commit', device='drive0')
653 self.vm.event_wait(name='BLOCK_JOB_READY')
655 result = self.vm.qmp('query-block-jobs')
656 self.assert_qmp(result, 'return[0]/device', 'drive0')
658 self.vm.cmd('block-job-complete', device='drive0')
660 self.vm.event_wait(name='BLOCK_JOB_COMPLETED')