From patchwork Thu Jun 26 11:23:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 364496 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B6FD714001A for ; Thu, 26 Jun 2014 21:29:41 +1000 (EST) Received: from localhost ([::1]:43713 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X07s3-0003hT-Mn for incoming@patchwork.ozlabs.org; Thu, 26 Jun 2014 07:29:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59115) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X07mL-0002Zs-Mt for qemu-devel@nongnu.org; Thu, 26 Jun 2014 07:23:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X07m9-0000t0-6O for qemu-devel@nongnu.org; Thu, 26 Jun 2014 07:23:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51730) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X07m8-0000sR-Ub for qemu-devel@nongnu.org; Thu, 26 Jun 2014 07:23:33 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s5QBNV4V026742 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 26 Jun 2014 07:23:31 -0400 Received: from blackfin.pond.sub.org (ovpn-116-62.ams2.redhat.com [10.36.116.62]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s5QBNSij010101 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 26 Jun 2014 07:23:30 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 1E4143040880; Thu, 26 Jun 2014 13:23:26 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 26 Jun 2014 13:23:21 +0200 Message-Id: <1403781805-17171-7-git-send-email-armbru@redhat.com> In-Reply-To: <1403781805-17171-1-git-send-email-armbru@redhat.com> References: <1403781805-17171-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, benoit@irqsave.net, stefanha@redhat.com, mreitz@redhat.com Subject: [Qemu-devel] [PATCH v5 06/10] block: Use bdrv_nb_sectors() in img_convert() 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 Instead of bdrv_getlength(). Replace variable output_length by output_sectors. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Benoit Canet --- qemu-img.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index c98896b..c16037b 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -1470,13 +1470,13 @@ static int img_convert(int argc, char **argv) buf = qemu_blockalign(out_bs, bufsectors * BDRV_SECTOR_SIZE); if (skip_create) { - int64_t output_length = bdrv_getlength(out_bs); - if (output_length < 0) { + int64_t output_sectors = bdrv_nb_sectors(out_bs); + if (output_sectors < 0) { error_report("unable to get output image length: %s\n", - strerror(-output_length)); + strerror(-output_sectors)); ret = -1; goto out; - } else if (output_length < total_sectors << BDRV_SECTOR_BITS) { + } else if (output_sectors < total_sectors) { error_report("output file is smaller than input file"); ret = -1; goto out;