diff options
author | Stefan Hajnoczi <stefanha@redhat.com> | 2013-06-24 17:13:13 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2013-06-28 09:20:26 +0200 |
commit | ac3c5d831aa0ff796659300e186be1a35862dbd3 (patch) | |
tree | 8ce199a08d701e447e97f91174ee049b48358965 /blockdev.c | |
parent | cb78466ef60ccf707a6f38a1294c435b65a828e0 (diff) |
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 <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'blockdev.c')
-rw-r--r-- | blockdev.c | 10 |
1 files 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); |