block/drive-mirror: Reuse backing HD for sync=none
cover block/drive-mirror: Reuse backing HD for sync=none
This series fixes the drive-mirror blockjob in case of "none" sync mode to always use the old (current) image file as the backing file of the newly created mirrored file (in case of "absolute-paths" mode).
It is rather important to get this into 1.7, as we will introduce an at least pretty strange API in case the original file is unbacked otherwise.
Max Reitz (2):
block/drive-mirror: Reuse backing HD for sync=none
qemu-iotests: Fix test 041
blockdev.c | 3 +++ tests/qemu-iotests/041 | 32 ++++++++++++++++++++++++-------- tests/qemu-iotests/041.out | 4 ++-- 3 files changed, 29 insertions(+), 10 deletions(-)
Signature · 1 line
1.8.4.2
PATCH 1/2 block/drive-mirror: Reuse backing HD for sync=none
For "none" sync mode in "absolute-paths" mode, the current image should be used as the backing file for the newly created image.
The current behavior is:
a) If the image to be mirrored has a backing file, use that (which is wrong, since the operations recorded by "none" are applied to the image itself, not to its backing file).
b) If the image to be mirrored lacks a backing file, the target doesn't have one either (which is not really wrong, but not really right, either; "none" records a set of operations executed on the image file, therefore having no backing file to apply these operations on seems rather pointless).
For a, this is clearly a bugfix. For b, it is still a bugfix, although it might break existing API - but since that case crashed qemu just three weeks ago (before 1452686495922b81d6cf43edf025c1aef15965c0), we can safely assume there is no such API relying on that case yet.
--- blockdev.c | 3 +++ 1 file changed, 3 insertions(+)
blockdev.c +3 -0
@@ -2021,6 +2021,9 @@ void qmp_drive_mirror(const char *device, const char *target,if (!source && sync ==MIRROR_SYNC_MODE_TOP ) { sync =MIRROR_SYNC_MODE_FULL ; } +if (sync ==MIRROR_SYNC_MODE_NONE ) { + source = bs; + } size =bdrv_getlength (bs);if (size <0 ) {
Signature · 1 line
1.8.4.2
Quoted 18 lines · Max Reitz
For "none" sync mode in "absolute-paths" mode, the current image should be used as the backing file for the newly created image.
The current behavior is:
a) If the image to be mirrored has a backing file, use that (which is wrong, since the operations recorded by "none" are applied to the image itself, not to its backing file).
b) If the image to be mirrored lacks a backing file, the target doesn't have one either (which is not really wrong, but not really right, either; "none" records a set of operations executed on the image file, therefore having no backing file to apply these operations on seems rather pointless).For a, this is clearly a bugfix. For b, it is still a bugfix, although it might break existing API - but since that case crashed qemu just three weeks ago (before
1452686495922b81d6cf43edf025c1aef15965c0), we can safely assume there is no such API relying on that case yet.
Quoted 5 lines
Suggested-by Paolo Bonzini <[email protected]>Signed-off-by Max Reitz <[email protected]>--- blockdev.c | 3 +++ 1 file changed, 3 insertions(+)
And definitely agree that this is a bug fix worth having in 1.7, before we bake in borked semantics that libvirt would have to work around depending on qemu version.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH for-1.7 2/2] qemu-iotests: Fix test 041
In reply to Max ReitzQuoted 11 lines · Max Reitz
Performing multiple drive-mirror blockjobs on the same qemu instance results in the image file used for the block device being replaced by the newly mirrored file, which is not what we want.
Fix this by performing one dedicated test per sync mode.
Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/041 | 32 ++++++++++++++++++++++++-------- tests/qemu-iotests/041.out | 4 ++-- 2 files changed, 26 insertions(+), 10 deletions(-)
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH 2/2 qemu-iotests: Fix test 041
In reply to Max ReitzPerforming multiple drive-mirror blockjobs on the same qemu instance results in the image file used for the block device being replaced by the newly mirrored file, which is not what we want.
Fix this by performing one dedicated test per sync mode.
--- tests/qemu-iotests/041 | 32 ++++++++++++++++++++++++-------- tests/qemu-iotests/041.out | 4 ++-- 2 files changed, 26 insertions(+), 10 deletions(-)
tests/qemu-iotests/041 +24 -8
@@ -691,16 +691,32 @@ class TestUnbackedSource(ImageMirroringTestCase): os.remove(test_img) os.remove(target_img) - def test_absolute_paths(self): + def test_absolute_paths_full(self): + self.assert_no_active_block_jobs() + result = self.vm.qmp('drive-mirror', device='drive0', + sync='full', target=target_img, + mode='absolute-paths') + self.assert_qmp(result, 'return', {}) + self.complete_and_wait() + self.assert_no_active_block_jobs() + + def test_absolute_paths_top(self): + self.assert_no_active_block_jobs() + result = self.vm.qmp('drive-mirror', device='drive0', + sync='top', target=target_img, + mode='absolute-paths') + self.assert_qmp(result, 'return', {}) + self.complete_and_wait() self.assert_no_active_block_jobs() - for sync_mode in ['full', 'top', 'none']: - result = self.vm.qmp('drive-mirror', device='drive0', - sync=sync_mode, target=target_img, - mode='absolute-paths') - self.assert_qmp(result, 'return', {}) - self.complete_and_wait() - self.assert_no_active_block_jobs() + def test_absolute_paths_none(self): + self.assert_no_active_block_jobs() + result = self.vm.qmp('drive-mirror', device='drive0', + sync='none', target=target_img, + mode='absolute-paths') + self.assert_qmp(result, 'return', {}) + self.complete_and_wait() + self.assert_no_active_block_jobs() if __name__ == '__main__': iotests.main(supported_fmts=['qcow2', 'qed'])
tests/qemu-iotests/041.out +2 -2
@@ -1,5 +1,5 @@ -......................... +........................... ---------------------------------------------------------------------- -Ran 25 tests +Ran 27 tests OK
Signature · 1 line
1.8.4.2
Il 25/11/2013 20:28, Max Reitz ha scritto:
Quoted 4 lines
This series fixes the drive-mirror blockjob in case of "none" sync mode to always use the old (current) image file as the backing file of the newly created mirrored file (in case of "absolute-paths" mode).
Quoted 8 lines
It is rather important to get this into 1.7, as we will introduce an at least pretty strange API in case the original file is unbacked otherwise.
Max Reitz (2):
block/drive-mirror: Reuse backing HD for sync=none
qemu-iotests: Fix test 041
Quoted 7 lines · Max Reitz
This series fixes the drive-mirror blockjob in case of "none" sync mode to always use the old (current) image file as the backing file of the newly created mirrored file (in case of "absolute-paths" mode).
It is rather important to get this into 1.7, as we will introduce an at least pretty strange API in case the original file is unbacked otherwise.
Kevin/Stefan? Do we need this for 1.7?
Regards,
Anthony Liguori
Quoted 13 lines
Max Reitz (2):
block/drive-mirror: Reuse backing HD for sync=none
qemu-iotests: Fix test 041blockdev.c | 3 +++ tests/qemu-iotests/041 | 32 ++++++++++++++++++++++++-------- tests/qemu-iotests/041.out | 4 ++-- 3 files changed, 29 insertions(+), 10 deletions(-)Signature · 1 line
1.8.4.2
Kevin Wolf
Reviewed-byAm 26.11.2013 um 19:02 hat Anthony Liguori geschrieben:
Quoted 11 lines
Quoted 7 lines · Max Reitz
This series fixes the drive-mirror blockjob in case of "none" sync mode to always use the old (current) image file as the backing file of the newly created mirrored file (in case of "absolute-paths" mode).
It is rather important to get this into 1.7, as we will introduce an at least pretty strange API in case the original file is unbacked otherwise.
Kevin/Stefan? Do we need this for 1.7?
Yes, it would be good to pick it up in order to avoid changing the API in 1.8 (I guess we would do it anyway because the current behaviour doesn't make any sense and we'd call it bug fix, but libvirt would have to deal with it and better to do it right in the first release.)
Do you want to pick it up yourself or should I send a pull request?
Kevin
Quoted 11 lines · Kevin Wolf
Am 26.11.2013 um 19:02 hat Anthony Liguori geschrieben:
Quoted 10 lines
Quoted 7 lines · Max Reitz
This series fixes the drive-mirror blockjob in case of "none" sync mode to always use the old (current) image file as the backing file of the newly created mirrored file (in case of "absolute-paths" mode).
It is rather important to get this into 1.7, as we will introduce an at least pretty strange API in case the original file is unbacked otherwise.
Quoted 8 lines
Quoted 1 line
Kevin/Stefan? Do we need this for 1.7?
Yes, it would be good to pick it up in order to avoid changing the API in 1.8 (I guess we would do it anyway because the current behaviour doesn't make any sense and we'd call it bug fix, but libvirt would have to deal with it and better to do it right in the first release.)
Do you want to pick it up yourself or should I send a pull request?
I'll pick it up.
Regards,
Anthony Liguori
Quoted 4 lines
Reviewed-by Kevin Wolf <[email protected]>Kevin