Received: from eggs.gnu.org ([2001:4830:134:3::10]:47669) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y0Xt9-0002Rv-Rj for qemu-devel@nongnu.org; Mon, 15 Dec 2014 10:48:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y0Xt3-00079Z-Ij for qemu-devel@nongnu.org; Mon, 15 Dec 2014 10:48:47 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59674) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y0Xt3-00079N-Bt for qemu-devel@nongnu.org; Mon, 15 Dec 2014 10:48:41 -0500 From: Markus Armbruster References: <1417802181-20834-1-git-send-email-tumanova@linux.vnet.ibm.com> <1417802181-20834-6-git-send-email-tumanova@linux.vnet.ibm.com> <87bnn5ggy5.fsf@blackfin.pond.sub.org> <548EF2EA.6030406@linux.vnet.ibm.com> Date: Mon, 15 Dec 2014 16:48:32 +0100 In-Reply-To: <548EF2EA.6030406@linux.vnet.ibm.com> (Ekaterina Tumanova's message of "Mon, 15 Dec 2014 17:40:42 +0300") Message-ID: <87r3w0dicv.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v3 5/5] BlockConf: Call backend functions to detect geometry and blocksizes 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 12/15/2014 04:50 PM, Markus Armbruster wrote: >> Ekaterina Tumanova writes: >> >>> geometry: hd_geometry_guess function autodetects the drive geometry. >>> This patch adds a block backend call, that probes the backing device >>> geometry. If the inner driver method is implemented and succeeds >>> (currently only for DASDs), the blkconf_geometry will pass-through >>> the backing device geometry. Otherwise will fallback to old logic. >>> >>> blocksize: This patch initializes blocksize properties to 0. >>> In order to set the properly a blkconf_blocksizes was introduced. >>> If user didn't set physical or logical blocksize, it will >>> retrieve it's value from a driver (which will return a default 512 for >>> any backend but DASD). >>> >>> The blkconf_blocksizes call was added to all users of BlkConf. >>> >>> Signed-off-by: Ekaterina Tumanova >>> --- >>> hw/block/block.c | 18 ++++++++++++++++++ >>> hw/block/hd-geometry.c | 12 ++++++++++++ >>> hw/block/nvme.c | 1 + >>> hw/block/virtio-blk.c | 1 + >>> hw/core/qdev-properties.c | 3 ++- >>> hw/ide/qdev.c | 1 + >>> hw/scsi/scsi-disk.c | 1 + >>> hw/usb/dev-storage.c | 1 + >>> include/hw/block/block.h | 5 +++-- >>> 9 files changed, 40 insertions(+), 3 deletions(-) >>> >>> diff --git a/hw/block/block.c b/hw/block/block.c >>> index a625773..9c07516 100644 >>> --- a/hw/block/block.c >>> +++ b/hw/block/block.c >>> @@ -25,6 +25,24 @@ void blkconf_serial(BlockConf *conf, char **serial) >>> } >>> } >>> >>> +void blkconf_blocksizes(BlockConf *conf) >>> +{ >>> + BlockBackend *blk = conf->blk; >>> + BlockSizes blocksizes; >>> + >>> + if (conf->physical_block_size && conf->logical_block_size) { >>> + return; >>> + } >> >> This conditional isn't necessary for correctness. Feel free to drop it. >> > > But this allows to avoid the ioctl call when user has specified both > values. Remove anyway? It's device model setup, i.e. not a fast path. I'd favor simplicity and compactness over speed there. >>> + blk_probe_blocksizes(blk, &blocksizes); >>> + >>> + if (!conf->physical_block_size) { >>> + conf->physical_block_size = blocksizes.phys; >>> + } >>> + if (!conf->logical_block_size) { >>> + conf->logical_block_size = blocksizes.log; >>> + } >> > > I'll add a comment to make it apparent. > >> This works because you change the default block size to 0 (second to >> last hunk). >> >>> +} >>> + >>> void blkconf_geometry(BlockConf *conf, int *ptrans, >>> unsigned cyls_max, unsigned heads_max, unsigned secs_max, >>> Error **errp) [...]