Received: from eggs.gnu.org ([2001:4830:134:3::10]:44578) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y0vWZ-0002Mp-0C for qemu-devel@nongnu.org; Tue, 16 Dec 2014 12:03:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y0vWS-0002i4-Sf for qemu-devel@nongnu.org; Tue, 16 Dec 2014 12:03:02 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41946) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y0vWS-0002ht-LJ for qemu-devel@nongnu.org; Tue, 16 Dec 2014 12:02:56 -0500 From: Markus Armbruster References: <1418728219-40595-1-git-send-email-tumanova@linux.vnet.ibm.com> <1418728219-40595-4-git-send-email-tumanova@linux.vnet.ibm.com> Date: Tue, 16 Dec 2014 18:02:15 +0100 In-Reply-To: <1418728219-40595-4-git-send-email-tumanova@linux.vnet.ibm.com> (Ekaterina Tumanova's message of "Tue, 16 Dec 2014 12:10:17 +0100") Message-ID: <87vblb5y08.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v4 3/5] block: Add driver methods to probe blocksizes and geometry List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Ekaterina Tumanova Cc: kwolf@redhat.com, thuth@linux.vnet.ibm.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: > Introduce driver methods of defining disk blocksizes (physical and > logical) and hard drive geometry. > Methods are only implemented for "host_device". For "raw" devices > driver calls child's method. > > For now geometry detection will only work for DASD devices. To check > that a local check_for_dasd function was introduced. It calls BIODASDINFO2 > ioctl and returns its rc. > > Blocksizes detection function will probe sizes for DASD devices and > set default for other devices. > > Signed-off-by: Ekaterina Tumanova > --- > block/raw-posix.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ > block/raw_bsd.c | 14 ++++++++ > 2 files changed, 111 insertions(+) > > diff --git a/block/raw-posix.c b/block/raw-posix.c > index 38172ca..e1e7b29 100644 > --- a/block/raw-posix.c > +++ b/block/raw-posix.c > @@ -56,6 +56,7 @@ > #include > #include > #include > +#include > #ifndef FS_NOCOW_FL > #define FS_NOCOW_FL 0x00800000 /* Do not cow file */ > #endif > @@ -90,6 +91,10 @@ > #include > #endif > > +#ifdef __s390__ > +#include > +#endif > + > //#define DEBUG_FLOPPY > > //#define DEBUG_BLOCK > @@ -238,6 +243,23 @@ static int probe_logical_blocksize(int fd, unsigned int *sector_size) > #undef SECTOR_SIZE > } > > +/** > + * Get physical block size of @fd. > + * On success, store it in @blk_size and return 0. > + * On failure, return -errno. > + */ > +static int probe_physical_blocksize(int fd, unsigned int *blk_size) > +{ > +#ifdef BLKPBSZGET > + if (ioctl(fd, BLKPBSZGET, blk_size) < 0) { > + return -errno; > + } > + return 0; > +#else > + return -ENOTSUP; > +#endif > +} > + > static void raw_probe_alignment(BlockDriverState *bs, int fd, Error **errp) > { > BDRVRawState *s = bs->opaque; > @@ -660,6 +682,79 @@ static void raw_refresh_limits(BlockDriverState *bs, Error **errp) > bs->bl.opt_mem_alignment = s->buf_align; > } > > +static int check_for_dasd(int fd) > +{ > +#ifdef BIODASDINFO2 > + struct dasd_information2_t info = {0}; > + > + return ioctl(fd, BIODASDINFO2, &info); > +#else > + return -ENOTSUP; > +#endif > +} This function is confused about its return value: 0/-1 vs. 0/-errno. Please return -1 instead of -ENOTSUP, or replace it by an is_dasd() returning bool. [...]