Received: from eggs.gnu.org ([2001:4830:134:3::10]:49395) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XuGsY-0004WU-3s for qemu-devel@nongnu.org; Fri, 28 Nov 2014 03:26:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XuGsR-0002qJ-U9 for qemu-devel@nongnu.org; Fri, 28 Nov 2014 03:26:14 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54809) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XuGsR-0002qD-ME for qemu-devel@nongnu.org; Fri, 28 Nov 2014 03:26:07 -0500 From: Markus Armbruster References: <1416392276-10408-1-git-send-email-tumanova@linux.vnet.ibm.com> <1416392276-10408-2-git-send-email-tumanova@linux.vnet.ibm.com> <87d288g0ap.fsf@blackfin.pond.sub.org> <54774BBD.8020506@linux.vnet.ibm.com> Date: Fri, 28 Nov 2014 09:25:58 +0100 In-Reply-To: <54774BBD.8020506@linux.vnet.ibm.com> (Ekaterina Tumanova's message of "Thu, 27 Nov 2014 19:05:17 +0300") Message-ID: <87wq6f7muh.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v2 1/6] geometry: add bdrv functions for geometry and blocksize List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Ekaterina Tumanova Cc: kwolf@redhat.com, borntraeger@de.ibm.com, Public KVM Mailing List , mihajlov@linux.vnet.ibm.com, dahi@linux.vnet.ibm.com, stefanha@redhat.com, cornelia.huck@de.ibm.com, pbonzini@redhat.com Ekaterina Tumanova writes: > On 11/27/2014 05:55 PM, Markus Armbruster wrote: >> I'm sorry for the delay. I got the flu and have difficulties thinking >> straight for longer than a few minutes. >> >> Ekaterina Tumanova writes: >> >>> Add driver functions for geometry and blocksize detection >>> >>> Signed-off-by: Ekaterina Tumanova >>> --- >>> block.c | 26 ++++++++++++++++++++++++++ >>> include/block/block.h | 20 ++++++++++++++++++++ >>> include/block/block_int.h | 3 +++ >>> 3 files changed, 49 insertions(+) >>> >>> diff --git a/block.c b/block.c >>> index a612594..5df35cf 100644 >>> --- a/block.c >>> +++ b/block.c >>> @@ -548,6 +548,32 @@ void bdrv_refresh_limits(BlockDriverState *bs, Error **errp) >>> } >>> } >>> >>> +struct ProbeBlockSize bdrv_probe_blocksizes(BlockDriverState *bs) >>> +{ >>> + BlockDriver *drv = bs->drv; >>> + struct ProbeBlockSize err_geo = { .rc = -1 }; >>> + >>> + assert(drv != NULL); >>> + if (drv->bdrv_probe_blocksizes) { >>> + return drv->bdrv_probe_blocksizes(bs); >>> + } >>> + >>> + return err_geo; >>> +} >> >> I'm not sure about "probe". Naming is hard. "get"? >> > There was already "bdrv_get_geometry", and I wanted the _geometry and > _blocksize functions to use the same naming convention. Fair enough. bdrv_get_geometry() is a silly wrapper around bdrv_nb_sectors() that maps failure to zero sectors. I hope to kill it some time. Doesn't help you now. > I thought probe might be more suitable, since we do not "get" the value > for sure. maybe "detect"? Feel free to stick to "probe". >> Squashing status and actual payload into a single struct to use as >> return type isn't wrong, but unusual. When the payload can't represent >> failure conveniently, we usually return status, and write the payload to >> a buffer provided by the caller, like this: >> >> int bdrv_get_blocksizes(BlockDriverState *bs, >> uint16_t *physical_blk_sz, >> uint16_t *logical_blk_sz) >> >> Or, with a struct to hold both sizes: >> >> int bdrv_get_blocksizes(BlockDriverState *bs, BlockSizes *bsz) >> > Do you insist on changing that? Returning a struct via stack seemed > useful to me, since there was less probability of caller allocating > a buffer of incorrect size or smth like that. You'd have to do crazy stuff to defeat the static type checker. Please stick to the common technique. [...]