block: Create proper size file for disk mirror
PATCH 1/1 block: Create proper size file for disk mirror
The qmp monitor command to mirror a disk was passing -1 for size along with the disk's backing file. This size of the resulting disk is the size of the backing file, which is incorrect if the disk has been resized. Therefore we should always pass in the size of the current disk.
---
Fixes https://bugs.launchpad.net/qemu/+bug/1103903
blockdev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
blockdev.c +3 -3
@@ -1259,11 +1259,11 @@ void qmp_drive_mirror(const char *device, const char *target,return ; } +bdrv_get_geometry (bs, &size); + size *=512 ;if (sync ==MIRROR_SYNC_MODE_FULL && mode !=NEW_IMAGE_MODE_EXISTING ) {/* create new image w/o backing file */ assert (format && drv); -bdrv_get_geometry (bs, &size); - size *=512 ;bdrv_img_create (target, format,NULL ,NULL ,NULL , size, flags, &local_err); }else {
@@ -1276,7 +1276,7 @@ void qmp_drive_mirror(const char *device, const char *target,bdrv_img_create (target, format, source->filename, source->drv->format_name, -NULL ,-1 , flags, &local_err); +NULL , size, flags, &local_err);break ;default :abort ();
Signature · 1 line
1.7.9.5
Kevin Wolf
AppliedAm 24.01.2013 19:00, schrieb Vishvananda Ishaya:
Quoted 7 lines
The qmp monitor command to mirror a disk was passing -1 for size along with the disk's backing file. This size of the resulting disk is the size of the backing file, which is incorrect if the disk has been resized. Therefore we should always pass in the size of the current disk.
Signed-off-by Vishvananda Ishaya <[email protected]>
Thanks, applied to the block branch.
Can you send a qemu-iotests test case that tests this condition? (Probably best as an extension to case 041)
Kevin
Quoted 7 lines · Kevin Wolf
Am 24.01.2013 19:00, schrieb Vishvananda Ishaya:
Quoted 6 lines
The qmp monitor command to mirror a disk was passing -1 for size along with the disk's backing file. This size of the resulting disk is the size of the backing file, which is incorrect if the disk has been resized. Therefore we should always pass in the size of the current disk.
Quoted 6 lines
Quoted 1 line
Signed-off-by Vishvananda Ishaya <[email protected]>Thanks, applied to the block branch.
Can you send a qemu-iotests test case that tests this condition? (Probably best as an extension to case 041)
I have a test for this. Would you like it as a separate patch or should i respin the original?
Vish
Quoted 12 lines · Vishvananda Ishaya
Quoted 9 lines · Kevin Wolf
Am 24.01.2013 19:00, schrieb Vishvananda Ishaya:
Quoted 7 lines
The qmp monitor command to mirror a disk was passing -1 for size along with the disk's backing file. This size of the resulting disk is the size of the backing file, which is incorrect if the disk has been resized. Therefore we should always pass in the size of the current disk.
Signed-off-by Vishvananda Ishaya <[email protected]>
Quoted 7 lines
Quoted 4 lines
Thanks, applied to the block branch.
Can you send a qemu-iotests test case that tests this condition? (Probably best as an extension to case 041)
I have a test for this. Would you like it as a separate patch or should i respin the original?
Since the original has already been applied to the block branch, you are best off sending a separate patch for the test addition.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Am 25.01.2013 19:13, schrieb Eric Blake:
Quoted 15 lines · Vishvananda Ishaya
Quoted 14 lines · Kevin Wolf
Quoted 12 lines
Am 24.01.2013 19:00, schrieb Vishvananda Ishaya:
Quoted 7 lines
The qmp monitor command to mirror a disk was passing -1 for size along with the disk's backing file. This size of the resulting disk is the size of the backing file, which is incorrect if the disk has been resized. Therefore we should always pass in the size of the current disk.
Signed-off-by Vishvananda Ishaya <[email protected]>Thanks, applied to the block branch.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Can you send a qemu-iotests test case that tests this condition? (Probably best as an extension to case 041)
I have a test for this. Would you like it as a separate patch or should i respin the original?
Since the original has already been applied to the block branch, you are best off sending a separate patch for the test addition.
Yes, please.
Kevin
PATCH 1/1 block: Adds mirroring tests for resized images
In reply to Kevin WolfThis test verifies two mirroring issues are fixed with resized images:
* sync='top' creates an image that is the proper size
* sync='full' doesn't cause an assertion failure and crash qemu
---
These are tests for my patches for the following bugs:
https://bugs.launchpad.net/qemu/+bug/1103868
https://bugs.launchpad.net/qemu/+bug/1103903
tests/qemu-iotests/041 | 48 ++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/041.out | 4 ++-- 2 files changed, 50 insertions(+), 2 deletions(-)
tests/qemu-iotests/041 +48 -0
@@ -292,6 +292,54 @@ class TestMirrorNoBacking(ImageMirroringTestCase): self.assertTrue(self.compare_images(test_img, target_img), 'target image does not match source after mirroring') +class TestMirrorResized(ImageMirroringTestCase): + backing_len = 1 * 1024 * 1024 # MB + image_len = 2 * 1024 * 1024 # MB + + def setUp(self): + self.create_image(backing_img, TestMirrorResized.backing_len) + qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, test_img) + qemu_img('resize', test_img, '2M') + self.vm = iotests.VM().add_drive(test_img) + self.vm.launch() + + def tearDown(self): + self.vm.shutdown() + os.remove(test_img) + os.remove(backing_img) + try: + os.remove(target_img) + except OSError: + pass + + def test_complete_top(self): + self.assert_no_active_mirrors() + + result = self.vm.qmp('drive-mirror', device='drive0', sync='top', + target=target_img) + self.assert_qmp(result, 'return', {}) + + self.complete_and_wait() + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/inserted/file', target_img) + self.vm.shutdown() + self.assertTrue(self.compare_images(test_img, target_img), + 'target image does not match source after mirroring') + + def test_complete_full(self): + self.assert_no_active_mirrors() + + result = self.vm.qmp('drive-mirror', device='drive0', sync='full', + target=target_img) + self.assert_qmp(result, 'return', {}) + + self.complete_and_wait() + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/inserted/file', target_img) + self.vm.shutdown() + self.assertTrue(self.compare_images(test_img, target_img), + 'target image does not match source after mirroring') + class TestReadErrors(ImageMirroringTestCase): image_len = 2 * 1024 * 1024 # MB
tests/qemu-iotests/041.out +2 -2
@@ -1,5 +1,5 @@ -.................. +.................... ---------------------------------------------------------------------- -Ran 18 tests +Ran 20 tests OK
Signature · 1 line
1.7.9.5
Re: [Qemu-trivial] [PATCH] block: Adds mirroring tests for resized images
Il 25/01/2013 19:57, Vishvananda Ishaya ha scritto:
Quoted 79 lines
This test verifies two mirroring issues are fixed with resized images:
* sync='top' creates an image that is the proper size
* sync='full' doesn't cause an assertion failure and crash qemu
---
These are tests for my patches for the following bugs:https://bugs.launchpad.net/qemu/+bug/1103868
https://bugs.launchpad.net/qemu/+bug/1103903tests/qemu-iotests/041 | 48 ++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/041.out | 4 ++-- 2 files changed, 50 insertions(+), 2 deletions(-)tests/qemu-iotests/041 +48
-0@@ -292,6 +292,54 @@ class TestMirrorNoBacking(ImageMirroringTestCase): self.assertTrue(self.compare_images(test_img, target_img), 'target image does not match source after mirroring') +class TestMirrorResized(ImageMirroringTestCase): + backing_len = 1 * 1024 * 1024 # MB + image_len = 2 * 1024 * 1024 # MB + + def setUp(self): + self.create_image(backing_img, TestMirrorResized.backing_len) + qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, test_img) + qemu_img('resize', test_img, '2M') + self.vm = iotests.VM().add_drive(test_img) + self.vm.launch() + + def tearDown(self): + self.vm.shutdown() + os.remove(test_img) + os.remove(backing_img) + try: + os.remove(target_img) + except OSError: + pass + + def test_complete_top(self): + self.assert_no_active_mirrors() + + result = self.vm.qmp('drive-mirror', device='drive0', sync='top', + target=target_img) + self.assert_qmp(result, 'return', {}) + + self.complete_and_wait() + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/inserted/file', target_img) + self.vm.shutdown() + self.assertTrue(self.compare_images(test_img, target_img), + 'target image does not match source after mirroring') + + def test_complete_full(self): + self.assert_no_active_mirrors() + + result = self.vm.qmp('drive-mirror', device='drive0', sync='full', + target=target_img) + self.assert_qmp(result, 'return', {}) + + self.complete_and_wait() + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/inserted/file', target_img) + self.vm.shutdown() + self.assertTrue(self.compare_images(test_img, target_img), + 'target image does not match source after mirroring') + class TestReadErrors(ImageMirroringTestCase): image_len = 2 * 1024 * 1024 # MBtests/qemu-iotests/041.out +0
-0
tests/qemu-iotests/041.out line 5
Quoted 7 lines
tests/qemu-iotests/041.out +2
-2@@ -1,5 +1,5 @@ -.................. +.................... ---------------------------------------------------------------------- -Ran 18 tests +Ran 20 tests OK
The patch doesn't apply to the block branch, but the conflicts should be trivial.
Paolo
Stefan Hajnoczi
AppliedRe: [Qemu-trivial] [PATCH] block: Adds mirroring tests for resized images
In reply to Vishvananda IshayaQuoted 7 lines · Vishvananda Ishaya
This test verifies two mirroring issues are fixed with resized images:
* sync='top' creates an image that is the proper size
* sync='full' doesn't cause an assertion failure and crash qemu
---
These are tests for my patches for the following bugs:
Quoted 6 lines
https://bugs.launchpad.net/qemu/+bug/1103868
https://bugs.launchpad.net/qemu/+bug/1103903tests/qemu-iotests/041 | 48 ++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/041.out | 4 ++-- 2 files changed, 50 insertions(+), 2 deletions(-)
Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block
Stefan
Quoted 6 lines · Vishvananda Ishaya
The qmp monitor command to mirror a disk was passing -1 for size along with the disk's backing file. This size of the resulting disk is the size of the backing file, which is incorrect if the disk has been resized. Therefore we should always pass in the size of the current disk.
Quoted 6 lines
Signed-off-by Vishvananda Ishaya <[email protected]>---
Fixes https://bugs.launchpad.net/qemu/+bug/1103903blockdev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Also CCed Paolo Bonzini who wrote the code.