Received: from eggs.gnu.org ([2001:4830:134:3::10]:39337) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clCPy-0007sv-Dy for qemu-devel@nongnu.org; Tue, 07 Mar 2017 05:32:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1clCPv-0005Bf-94 for qemu-devel@nongnu.org; Tue, 07 Mar 2017 05:32:34 -0500 Received: from smtp3.mundo-r.com ([212.51.32.191]:39724 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clCPu-0005Bb-TP for qemu-devel@nongnu.org; Tue, 07 Mar 2017 05:32:31 -0500 From: Alberto Garcia In-Reply-To: <20170303135150.12145-3-stefanha@redhat.com> References: <20170303135150.12145-1-stefanha@redhat.com> <20170303135150.12145-3-stefanha@redhat.com> Date: Tue, 07 Mar 2017 11:32:29 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [RFC 2/4] raw-format: add bdrv_max_size() support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi , qemu-devel@nongnu.org Cc: Eric Blake , Kevin Wolf , Maor Lipchuk , "Daniel P. Berrange" , Nir Soffer , John Snow On Fri 03 Mar 2017 02:51:48 PM CET, Stefan Hajnoczi wrote: > +static uint64_t raw_max_size(QemuOpts *opts, BlockDriverState *in_bs, > + Error **errp) > +{ > + if (in_bs) { > + int64_t size = bdrv_nb_sectors(in_bs); > + if (size < 0) { > + error_setg_errno(errp, -size, "Unable to get image size"); > + return 0; > + } > + return (uint64_t)size * BDRV_SECTOR_SIZE; > + } Why not use bdrv_getlength() directly? It gives you the size in bytes. Berto