[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 03/11] block/drive-mirror: Check for NULL backing_hd
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 03/11] block/drive-mirror: Check for NULL backing_hd |
Date: |
Fri, 15 Nov 2013 18:53:11 +0100 |
From: Max Reitz <address@hidden>
It should be possible to execute the QMP "drive-mirror" command in
"none" sync mode and "absolute-paths" mode even for block devices
lacking a backing file.
"absolute-paths" does in fact not require a backing file to be present,
as can be seen from the "top" sync mode code path. "top" basically
states that the device should indeed have a backing file - however, the
current code catches the case if it doesn't and then simply treats it as
"full" sync mode, creating a target image without a backing file (in
"absolute-paths" mode). Thus, "absolute-paths" does not imply the target
file must indeed have a backing file.
Therefore, the target file may be left unbacked in case of "none" sync
mode as well, if the specified device is not backed either. Currently,
qemu will crash trying to dereference the backing file pointer since it
assumes that it will always be non-NULL in that case ("none" with
"absolute-paths").
Signed-off-by: Max Reitz <address@hidden>
Reviewed-by: Wenchao Xia <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
blockdev.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/blockdev.c b/blockdev.c
index 86e6bff..d955694 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2029,7 +2029,9 @@ void qmp_drive_mirror(const char *device, const char
*target,
return;
}
- if (sync == MIRROR_SYNC_MODE_FULL && mode != NEW_IMAGE_MODE_EXISTING) {
+ if ((sync == MIRROR_SYNC_MODE_FULL || !source)
+ && mode != NEW_IMAGE_MODE_EXISTING)
+ {
/* create new image w/o backing file */
assert(format && drv);
bdrv_img_create(target, format,
--
1.8.1.4
- [Qemu-devel] [PULL 00/11] Block fixes for 1.7.0, Kevin Wolf, 2013/11/15
- [Qemu-devel] [PULL 02/11] qapi-schema: Update description for NewImageMode, Kevin Wolf, 2013/11/15
- [Qemu-devel] [PULL 01/11] block: Print its file name if backing file opening failed, Kevin Wolf, 2013/11/15
- [Qemu-devel] [PULL 03/11] block/drive-mirror: Check for NULL backing_hd,
Kevin Wolf <=
- [Qemu-devel] [PULL 05/11] MAINTAINERS: add block tree repo URLs, Kevin Wolf, 2013/11/15
- [Qemu-devel] [PULL 04/11] qemu-iotests: Extend 041 for unbacked mirroring, Kevin Wolf, 2013/11/15
- [Qemu-devel] [PULL 07/11] qcow2: fix possible corruption when reading multiple clusters, Kevin Wolf, 2013/11/15
- [Qemu-devel] [PULL 06/11] qmp: access the local QemuOptsLists for drive option, Kevin Wolf, 2013/11/15
- [Qemu-devel] [PULL 08/11] qemu-iotests: Test qcow2 count_contiguous_clusters(), Kevin Wolf, 2013/11/15
- [Qemu-devel] [PULL 10/11] MAINTAINERS: add block driver sub-maintainers, Kevin Wolf, 2013/11/15
- [Qemu-devel] [PULL 09/11] qemu-img: Fix overwriting 'ret' before using, Kevin Wolf, 2013/11/15
- [Qemu-devel] [PULL 11/11] block: Fail if requested driver is not available, Kevin Wolf, 2013/11/15