thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
9ae3a8
From bcc312ef8d0c8ff3c8743e01bd24fd26c4cc96f6 Mon Sep 17 00:00:00 2001
9ae3a8
From: Max Reitz <mreitz@redhat.com>
9ae3a8
Date: Sun, 19 Jan 2014 18:07:57 +0100
9ae3a8
Subject: [PATCH 23/34] block/drive-mirror: Check for NULL backing_hd
9ae3a8
9ae3a8
RH-Author: Max Reitz <mreitz@redhat.com>
9ae3a8
Message-id: <1390154881-17140-4-git-send-email-mreitz@redhat.com>
9ae3a8
Patchwork-id: 56816
9ae3a8
O-Subject: [RHEL-7.0 qemu-kvm PATCH v2 3/7] block/drive-mirror: Check for NULL backing_hd
9ae3a8
Bugzilla: 921890
9ae3a8
RH-Acked-by: Fam Zheng <famz@redhat.com>
9ae3a8
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
9ae3a8
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
9ae3a8
9ae3a8
BZ: 921890
9ae3a8
9ae3a8
It should be possible to execute the QMP "drive-mirror" command in
9ae3a8
"none" sync mode and "absolute-paths" mode even for block devices
9ae3a8
lacking a backing file.
9ae3a8
9ae3a8
"absolute-paths" does in fact not require a backing file to be present,
9ae3a8
as can be seen from the "top" sync mode code path. "top" basically
9ae3a8
states that the device should indeed have a backing file - however, the
9ae3a8
current code catches the case if it doesn't and then simply treats it as
9ae3a8
"full" sync mode, creating a target image without a backing file (in
9ae3a8
"absolute-paths" mode). Thus, "absolute-paths" does not imply the target
9ae3a8
file must indeed have a backing file.
9ae3a8
9ae3a8
Therefore, the target file may be left unbacked in case of "none" sync
9ae3a8
mode as well, if the specified device is not backed either. Currently,
9ae3a8
qemu will crash trying to dereference the backing file pointer since it
9ae3a8
assumes that it will always be non-NULL in that case ("none" with
9ae3a8
"absolute-paths").
9ae3a8
9ae3a8
Signed-off-by: Max Reitz <mreitz@redhat.com>
9ae3a8
Reviewed-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
9ae3a8
Reviewed-by: Eric Blake <eblake@redhat.com>
9ae3a8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9ae3a8
(cherry picked from commit 1452686495922b81d6cf43edf025c1aef15965c0)
9ae3a8
9ae3a8
Signed-off-by: Max Reitz <mreitz@redhat.com>
9ae3a8
---
9ae3a8
 blockdev.c | 4 +++-
9ae3a8
 1 file changed, 3 insertions(+), 1 deletion(-)
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 blockdev.c |    4 +++-
9ae3a8
 1 files changed, 3 insertions(+), 1 deletions(-)
9ae3a8
9ae3a8
diff --git a/blockdev.c b/blockdev.c
9ae3a8
index 0ba2504..06bbf30 100644
9ae3a8
--- a/blockdev.c
9ae3a8
+++ b/blockdev.c
9ae3a8
@@ -1611,7 +1611,9 @@ void qmp_drive_mirror(const char *device, const char *target,
9ae3a8
         return;
9ae3a8
     }
9ae3a8
 
9ae3a8
-    if (sync == MIRROR_SYNC_MODE_FULL && mode != NEW_IMAGE_MODE_EXISTING) {
9ae3a8
+    if ((sync == MIRROR_SYNC_MODE_FULL || !source)
9ae3a8
+        && mode != NEW_IMAGE_MODE_EXISTING)
9ae3a8
+    {
9ae3a8
         /* create new image w/o backing file */
9ae3a8
         assert(format && drv);
9ae3a8
         bdrv_img_create(target, format,
9ae3a8
-- 
9ae3a8
1.7.1
9ae3a8