iotests: 055: Don't attach the target image already for drive-backup

Double attach is not a valid usage of the target image, drive-backup
will open the blockdev itself so skip the add_drive call in this case.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Fam Zheng 2017-05-03 00:35:44 +08:00 committed by Kevin Wolf
parent 55e5a3b65e
commit 4797aeabdc
1 changed files with 18 additions and 14 deletions

View File

@ -458,17 +458,18 @@ class TestDriveCompression(iotests.QMPTestCase):
except OSError:
pass
def do_prepare_drives(self, fmt, args):
def do_prepare_drives(self, fmt, args, attach_target):
self.vm = iotests.VM().add_drive(test_img)
qemu_img('create', '-f', fmt, blockdev_target_img,
str(TestDriveCompression.image_len), *args)
self.vm.add_drive(blockdev_target_img, format=fmt, interface="none")
if attach_target:
self.vm.add_drive(blockdev_target_img, format=fmt, interface="none")
self.vm.launch()
def do_test_compress_complete(self, cmd, format, **args):
self.do_prepare_drives(format['type'], format['args'])
def do_test_compress_complete(self, cmd, format, attach_target, **args):
self.do_prepare_drives(format['type'], format['args'], attach_target)
self.assert_no_active_block_jobs()
@ -484,15 +485,16 @@ class TestDriveCompression(iotests.QMPTestCase):
def test_complete_compress_drive_backup(self):
for format in TestDriveCompression.fmt_supports_compression:
self.do_test_compress_complete('drive-backup', format,
self.do_test_compress_complete('drive-backup', format, False,
target=blockdev_target_img, mode='existing')
def test_complete_compress_blockdev_backup(self):
for format in TestDriveCompression.fmt_supports_compression:
self.do_test_compress_complete('blockdev-backup', format, target='drive1')
self.do_test_compress_complete('blockdev-backup', format, True,
target='drive1')
def do_test_compress_cancel(self, cmd, format, **args):
self.do_prepare_drives(format['type'], format['args'])
def do_test_compress_cancel(self, cmd, format, attach_target, **args):
self.do_prepare_drives(format['type'], format['args'], attach_target)
self.assert_no_active_block_jobs()
@ -506,15 +508,16 @@ class TestDriveCompression(iotests.QMPTestCase):
def test_compress_cancel_drive_backup(self):
for format in TestDriveCompression.fmt_supports_compression:
self.do_test_compress_cancel('drive-backup', format,
self.do_test_compress_cancel('drive-backup', format, False,
target=blockdev_target_img, mode='existing')
def test_compress_cancel_blockdev_backup(self):
for format in TestDriveCompression.fmt_supports_compression:
self.do_test_compress_cancel('blockdev-backup', format, target='drive1')
self.do_test_compress_cancel('blockdev-backup', format, True,
target='drive1')
def do_test_compress_pause(self, cmd, format, **args):
self.do_prepare_drives(format['type'], format['args'])
def do_test_compress_pause(self, cmd, format, attach_target, **args):
self.do_prepare_drives(format['type'], format['args'], attach_target)
self.assert_no_active_block_jobs()
@ -546,12 +549,13 @@ class TestDriveCompression(iotests.QMPTestCase):
def test_compress_pause_drive_backup(self):
for format in TestDriveCompression.fmt_supports_compression:
self.do_test_compress_pause('drive-backup', format,
self.do_test_compress_pause('drive-backup', format, False,
target=blockdev_target_img, mode='existing')
def test_compress_pause_blockdev_backup(self):
for format in TestDriveCompression.fmt_supports_compression:
self.do_test_compress_pause('blockdev-backup', format, target='drive1')
self.do_test_compress_pause('blockdev-backup', format, True,
target='drive1')
if __name__ == '__main__':
iotests.main(supported_fmts=['raw', 'qcow2'])