qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] block: Create proper size file for disk mirror


From: Vishvananda Ishaya
Subject: [Qemu-devel] [PATCH] block: Create proper size file for disk mirror
Date: Thu, 24 Jan 2013 10:00:40 -0800

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 <address@hidden>
---
Fixes https://bugs.launchpad.net/qemu/+bug/1103903

 blockdev.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/blockdev.c b/blockdev.c
index 9126587..bb63162 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -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();
-- 
1.7.9.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]