From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55072) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YMFHz-0000lz-KM for qemu-devel@nongnu.org; Fri, 13 Feb 2015 07:24:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YMFHu-000804-GH for qemu-devel@nongnu.org; Fri, 13 Feb 2015 07:24:07 -0500 Received: from e06smtp12.uk.ibm.com ([195.75.94.108]:44716) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YMFHu-0007yN-84 for qemu-devel@nongnu.org; Fri, 13 Feb 2015 07:24:02 -0500 Received: from /spool/local by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 13 Feb 2015 12:23:59 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 8E502219004D for ; Fri, 13 Feb 2015 12:23:52 +0000 (GMT) Received: from d06av03.portsmouth.uk.ibm.com (d06av03.portsmouth.uk.ibm.com [9.149.37.213]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t1DCNvA55046636 for ; Fri, 13 Feb 2015 12:23:57 GMT Received: from d06av03.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av03.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t1DCNulc006519 for ; Fri, 13 Feb 2015 05:23:57 -0700 Message-ID: <54DDECDB.5000507@de.ibm.com> Date: Fri, 13 Feb 2015 13:23:55 +0100 From: Christian Borntraeger MIME-Version: 1.0 References: <1421678101-44779-1-git-send-email-tumanova@linux.vnet.ibm.com> <1421678101-44779-6-git-send-email-tumanova@linux.vnet.ibm.com> In-Reply-To: <1421678101-44779-6-git-send-email-tumanova@linux.vnet.ibm.com> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v6 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 , Public KVM Mailing List Cc: kwolf@redhat.com, thuth@linux.vnet.ibm.com, armbru@redhat.com, mihajlov@linux.vnet.ibm.com, dahi@linux.vnet.ibm.com, stefanha@redhat.com, cornelia.huck@de.ibm.com, pbonzini@redhat.com Am 19.01.2015 um 15:35 schrieb Ekaterina Tumanova: > 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 its 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 > Reviewed-by: Markus Armbruster > --- > hw/block/block.c | 20 ++++++++++++++++++++ > hw/block/hd-geometry.c | 10 +++++++++- > 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 +++-- > include/hw/qdev-properties.h | 4 ++-- > 10 files changed, 41 insertions(+), 6 deletions(-) > > diff --git a/hw/block/block.c b/hw/block/block.c > index a625773..09dd5f1 100644 > --- a/hw/block/block.c > +++ b/hw/block/block.c > @@ -25,6 +25,26 @@ void blkconf_serial(BlockConf *conf, char **serial) > } > } > > +void blkconf_blocksizes(BlockConf *conf) > +{ > + BlockBackend *blk = conf->blk; > + BlockSizes blocksizes; > + int backend_ret; > + > + backend_ret = blk_probe_blocksizes(blk, &blocksizes); > + /* fill in detected values if they are not defined via qemu command line */ > + if (!conf->physical_block_size && !backend_ret) { > + conf->physical_block_size = blocksizes.phys; > + } else { > + conf->physical_block_size = BDRV_SECTOR_SIZE; > + } > + if (!conf->logical_block_size && !backend_ret) { > + conf->logical_block_size = blocksizes.log; > + } else { > + conf->logical_block_size = BDRV_SECTOR_SIZE; > + } When we are going to fix this, I found another bug: This code will fail when logical_block_size and physical_block_size are given at the command line AND detection (backend_ret != 0) did not work. It will use BDRV_SECTOR_SIZE instead of the command line value. With something like --- a/hw/block/block.c +++ b/hw/block/block.c @@ -33,15 +33,19 @@ void blkconf_blocksizes(BlockConf *conf) backend_ret = blk_probe_blocksizes(blk, &blocksizes); /* fill in detected values if they are not defined via qemu command line */ - if (!conf->physical_block_size && !backend_ret) { - conf->physical_block_size = blocksizes.phys; - } else { - conf->physical_block_size = BDRV_SECTOR_SIZE; + if (!conf->physical_block_size) { + if (!backend_ret) { + conf->physical_block_size = blocksizes.phys; + } else { + conf->physical_block_size = BDRV_SECTOR_SIZE; + } } - if (!conf->logical_block_size && !backend_ret) { - conf->logical_block_size = blocksizes.log; - } else { - conf->logical_block_size = BDRV_SECTOR_SIZE; + if (!conf->logical_block_size) { + if (!backend_ret) { + conf->logical_block_size = blocksizes.log; + } else { + conf->logical_block_size = BDRV_SECTOR_SIZE; + } } } No?