yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-blockdev-use-bdrv_getlength-in-qmp_drive_mirror.patch

0a122b
From 38d5e0867780e352a3890792f684594deb7afd7e Mon Sep 17 00:00:00 2001
0a122b
From: Max Reitz <mreitz@redhat.com>
0a122b
Date: Sun, 19 Jan 2014 18:07:55 +0100
0a122b
Subject: [PATCH 21/34] blockdev: use bdrv_getlength() in qmp_drive_mirror()
0a122b
0a122b
RH-Author: Max Reitz <mreitz@redhat.com>
0a122b
Message-id: <1390154881-17140-2-git-send-email-mreitz@redhat.com>
0a122b
Patchwork-id: 56814
0a122b
O-Subject: [RHEL-7.0 qemu-kvm PATCH v2 1/7] blockdev: use bdrv_getlength() in qmp_drive_mirror()
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
From: Stefan Hajnoczi <stefanha@redhat.com>
0a122b
0a122b
BZ: 921890
0a122b
0a122b
Use bdrv_getlength() for its byte units and error return instead of
0a122b
bdrv_get_geometry().
0a122b
0a122b
Reported-by: Kevin Wolf <kwolf@redhat.com>
0a122b
Reviewed-by: Eric Blake <eblake@redhat.com>
0a122b
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
0a122b
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
0a122b
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
0a122b
(cherry picked from commit ac3c5d831aa0ff796659300e186be1a35862dbd3)
0a122b
0a122b
Signed-off-by: Max Reitz <mreitz@redhat.com>
0a122b
---
0a122b
 blockdev.c | 10 +++++++---
0a122b
 1 file changed, 7 insertions(+), 3 deletions(-)
0a122b
0a122b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
0a122b
---
0a122b
 blockdev.c |   10 +++++++---
0a122b
 1 files changed, 7 insertions(+), 3 deletions(-)
0a122b
0a122b
diff --git a/blockdev.c b/blockdev.c
0a122b
index 33a5f5f..0ba2504 100644
0a122b
--- a/blockdev.c
0a122b
+++ b/blockdev.c
0a122b
@@ -1541,7 +1541,7 @@ void qmp_drive_mirror(const char *device, const char *target,
0a122b
     BlockDriver *drv = NULL;
0a122b
     Error *local_err = NULL;
0a122b
     int flags;
0a122b
-    uint64_t size;
0a122b
+    int64_t size;
0a122b
     int ret;
0a122b
 
0a122b
     if (!has_speed) {
0a122b
@@ -1605,8 +1605,12 @@ void qmp_drive_mirror(const char *device, const char *target,
0a122b
         sync = MIRROR_SYNC_MODE_FULL;
0a122b
     }
0a122b
 
0a122b
-    bdrv_get_geometry(bs, &size);
0a122b
-    size *= 512;
0a122b
+    size = bdrv_getlength(bs);
0a122b
+    if (size < 0) {
0a122b
+        error_setg_errno(errp, -size, "bdrv_getlength failed");
0a122b
+        return;
0a122b
+    }
0a122b
+
0a122b
     if (sync == MIRROR_SYNC_MODE_FULL && mode != NEW_IMAGE_MODE_EXISTING) {
0a122b
         /* create new image w/o backing file */
0a122b
         assert(format && drv);
0a122b
-- 
0a122b
1.7.1
0a122b