From patchwork Mon Jun 24 15:13:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 253880 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7E53E2C0091 for ; Tue, 25 Jun 2013 01:17:16 +1000 (EST) Received: from localhost ([::1]:45127 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ur8W2-0000pR-77 for incoming@patchwork.ozlabs.org; Mon, 24 Jun 2013 11:17:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38007) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ur8Tr-0006hG-TT for qemu-devel@nongnu.org; Mon, 24 Jun 2013 11:15:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ur8Tm-0004hG-R1 for qemu-devel@nongnu.org; Mon, 24 Jun 2013 11:14:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:1536) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ur8Tm-0004h3-IL for qemu-devel@nongnu.org; Mon, 24 Jun 2013 11:14:54 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r5OFDa4l017945 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 24 Jun 2013 11:13:37 -0400 Received: from localhost (ovpn-112-34.ams2.redhat.com [10.36.112.34]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r5OFDZk5012674; Mon, 24 Jun 2013 11:13:36 -0400 From: Stefan Hajnoczi To: Date: Mon, 24 Jun 2013 17:13:13 +0200 Message-Id: <1372086800-4720-6-git-send-email-stefanha@redhat.com> In-Reply-To: <1372086800-4720-1-git-send-email-stefanha@redhat.com> References: <1372086800-4720-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Fam Zheng , dietmar@proxmox.com, imain@redhat.com, Stefan Hajnoczi , Paolo Bonzini , xiawenc@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH v6 05/12] blockdev: use bdrv_getlength() in qmp_drive_mirror() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- blockdev.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/blockdev.c b/blockdev.c index f6938d3..911aeb8 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);