From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35818) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y714W-0004J1-As for qemu-devel@nongnu.org; Fri, 02 Jan 2015 07:11:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y714R-0003nv-5f for qemu-devel@nongnu.org; Fri, 02 Jan 2015 07:11:16 -0500 Received: from mail-wi0-x233.google.com ([2a00:1450:400c:c05::233]:33493) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y714Q-0003nr-Us for qemu-devel@nongnu.org; Fri, 02 Jan 2015 07:11:11 -0500 Received: by mail-wi0-f179.google.com with SMTP id ex7so27687041wid.12 for ; Fri, 02 Jan 2015 04:11:10 -0800 (PST) Date: Fri, 2 Jan 2015 12:11:06 +0000 From: Stefan Hajnoczi Message-ID: <20150102121106.GD10823@stefanha-thinkpad.redhat.com> References: <1418901484-12988-1-git-send-email-tumanova@linux.vnet.ibm.com> <1418901484-12988-4-git-send-email-tumanova@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="rqzD5py0kzyFAOWN" Content-Disposition: inline In-Reply-To: <1418901484-12988-4-git-send-email-tumanova@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [PATCH v5 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, armbru@redhat.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 --rqzD5py0kzyFAOWN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Dec 18, 2014 at 12:18:02PM +0100, Ekaterina Tumanova wrote: > @@ -90,6 +91,10 @@ > #include > #endif > =20 > +#ifdef __s390__ > +#include > +#endif #if defined(__linux__) && defined(__s390__) Or you could move it inside #ifdef __linux__ earlier in the file. > +/** > + * Try to get @bs's geometry (cyls, heads, sectos) > + * On success, store them in @geo and return 0. > + * On failure return -errno. > + * (as for 12/2014 only DASDs are supported) This comment isn't useful because it's apparent from the code and it could get outdated. It might be better to remove it and instead document that this function allows the block driver to assign default geometry values that the guest sees. > + */ > +static int hdev_probe_geometry(BlockDriverState *bs, HDGeometry *geo) > +{ > + BDRVRawState *s =3D bs->opaque; > + struct hd_geometry ioctl_geo =3D {0}; > + uint32_t blksize; > + > + /* If DASD, get it's geometry */ > + if (check_for_dasd(s->fd) < 0) { > + return -ENOTSUP; > + } > + if (ioctl(s->fd, HDIO_GETGEO, &ioctl_geo) < 0) { This is a Linux ioctl, won't this break compilation on non-Linux hosts? > + return -errno; > + } > + /* HDIO_GETGEO may return success even though geo contains zeros > + (e.g. certain multipath setups) */ > + if (!ioctl_geo.heads || !ioctl_geo.sectors || !ioctl_geo.cylinders) { > + return -ENOTSUP; > + } > + /* Do not return a geometry for partition */ > + if (ioctl_geo.start !=3D 0) { > + return -ENOTSUP; > + } > + geo->heads =3D ioctl_geo.heads; > + geo->sectors =3D ioctl_geo.sectors; > + if (!probe_physical_blocksize(s->fd, &blksize)) { > + /* overwrite cyls: HDIO_GETGEO result is incorrect for big drive= s */ > + geo->cylinders =3D bs->total_sectors / (blksize / BDRV_SECTOR_SI= ZE) > + / (geo->heads * geo->sectors); Please use bdrv_nb_sectors(bs) instead of bs->total_sectors. bs->total_sectors is a cached value that is basically private to block.c and should not be accessed directly. --rqzD5py0kzyFAOWN Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJUporaAAoJEJykq7OBq3PIR/wH/jgXQFCbuz+XZCqhXDhaDiA5 qkQ0TnBZf2WjGTEsqx1L+JEqq6OubusFtylBBNqNIf4I0ddVunrRZvG3j462aie3 80VrGo2HWatDeGH3gn8DF8rRW4Bp/J1YhIR6N9WT+ZGlC0CDnnDznfrPVHoJTLll UVn0vWYbgrKlpCsL4RHPQvttsGQno7duhPB+9YtgvdMVksKpqewsAXy97d/alBD9 fBKpq5ZojEcbv5MzIQGqaQ2/r4lupX8ZiOSDGCVwiGdY5VTZTsF83pa4TRyXc6TC i2bHai2a5eKjZut8osKytgFwzPs3dhKwtYyYl9tqCHDCWCCld6D4Z3WnIPfhHgk= =BESl -----END PGP SIGNATURE----- --rqzD5py0kzyFAOWN--