yeahuh / rpms / qemu-kvm

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