From ac3c5d831aa0ff796659300e186be1a35862dbd3 Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Mon, 24 Jun 2013 17:13:13 +0200 Subject: [PATCH] blockdev: use bdrv_getlength() in qmp_drive_mirror() Use bdrv_getlength() for its byte units and error return instead of bdrv_get_geometry(). Reported-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Kevin Wolf Signed-off-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf --- blockdev.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/blockdev.c b/blockdev.c index c17b525154..445f6e1d84 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1371,7 +1371,7 @@ void qmp_drive_mirror(const char *device, const char *target, BlockDriver *drv = NULL; Error *local_err = NULL; int flags; - uint64_t size; + int64_t size; int ret; if (!has_speed) { @@ -1435,8 +1435,12 @@ void qmp_drive_mirror(const char *device, const char *target, sync = MIRROR_SYNC_MODE_FULL; } - bdrv_get_geometry(bs, &size); - size *= 512; + size = bdrv_getlength(bs); + if (size < 0) { + error_setg_errno(errp, -size, "bdrv_getlength failed"); + return; + } + if (sync == MIRROR_SYNC_MODE_FULL && mode != NEW_IMAGE_MODE_EXISTING) { /* create new image w/o backing file */ assert(format && drv);