From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51931) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1br5Ac-00014D-79 for qemu-devel@nongnu.org; Mon, 03 Oct 2016 11:28:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1br5AZ-0001cF-Uf for qemu-devel@nongnu.org; Mon, 03 Oct 2016 11:28:45 -0400 References: <598de7ff27e32fcb1b7f677f40fb8da4f0a1f512.1475434971.git.tgolembi@redhat.com> From: Eric Blake Message-ID: Date: Mon, 3 Oct 2016 10:28:34 -0500 MIME-Version: 1.0 In-Reply-To: <598de7ff27e32fcb1b7f677f40fb8da4f0a1f512.1475434971.git.tgolembi@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="1ag36DGPAXOOi42OvG4UkMF7nHox9cOHk" Subject: Re: [Qemu-devel] [PATCH] raw-posix: add 'offset' and 'size' options List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?B?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= , qemu-block@nongnu.org Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --1ag36DGPAXOOi42OvG4UkMF7nHox9cOHk From: Eric Blake To: =?UTF-8?B?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= , qemu-block@nongnu.org Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz Message-ID: Subject: Re: [Qemu-devel] [PATCH] raw-posix: add 'offset' and 'size' options References: <598de7ff27e32fcb1b7f677f40fb8da4f0a1f512.1475434971.git.tgolembi@redhat.com> In-Reply-To: <598de7ff27e32fcb1b7f677f40fb8da4f0a1f512.1475434971.git.tgolembi@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 10/02/2016 02:13 PM, Tom=C3=A1=C5=A1 Golembiovsk=C3=BD wrote: > Added two new options 'offset' and 'size'. This makes it possible to us= e > only part of the file as a device. This can be used e.g. to limit the > access only to single partition in a disk image or use a disk inside a > tar archive (like OVA). >=20 > For now this is only possible for files in read-only mode. It should be= > possible to extend it later to allow read-write mode, but would probabl= y > require that the size of the device is kept constant (i.e. no resizing)= =2E >=20 > Signed-off-by: Tom=C3=A1=C5=A1 Golembiovsk=C3=BD > --- > block/raw-posix.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++= ++++---- > 1 file changed, 91 insertions(+), 6 deletions(-) >=20 > + s->offset =3D qemu_opt_get_size(opts, "offset", 0); > + s->assumed_size =3D qemu_opt_get_size(opts, BLOCK_OPT_SIZE, 0); > + > + if (((bs->drv !=3D &bdrv_file) || !bs->read_only) && > + ((s->offset > 0) || (s->assumed_size > 0))) { Over-parenthesized. > @@ -443,6 +468,23 @@ static int raw_open_common(BlockDriverState *bs, Q= Dict *options, > } > s->fd =3D fd; > =20 > + /* Check size and offset */ > + real_size =3D raw_getlength_real(bs); > + if (real_size < (s->offset + s->assumed_size)) { > + if (s->assumed_size =3D=3D 0) { > + error_setg(errp, "The offset has to be smaller than actual= size " > + "of the containing file (%ld) ", > + real_size); Won't compile on 32-bit platforms. %ld is not necessarily synonymous with int64_t; you need to use PRId64 instead. Multiple times through your patch. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --1ag36DGPAXOOi42OvG4UkMF7nHox9cOHk Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJX8nkjAAoJEKeha0olJ0NqWCcH/3LQEJ5YTkcyRmg9W5BtGqTV bgUW07ZIa0ng+8bJiaJf/wOvT7NDnq8Ksp6sX0TjxHxt0yzCW5iwkSXZgk5dDS1s j0JzXaCjYuuiL1fPsWhZ8TmeSBG78of0YpPLL+llOi80WKsVeDk/5qGaws9RIBdg FBx9peunVrR/zr4wkCd7ZR5OiPbu/JeTuvyiUaE++3xfpx481Hp5qCezB7OylTFK H5GLNOEij0QCBD804iUQjjzPz/FnrkpCdThfd+5606LpHh55sk27UsjFQhkMniV0 84ekN4uTHEWoh8VW+vV7dX+I1SVMaIl06emXZF8cj/pf8OXbsiXw3RZi/PBjxPU= =nH4v -----END PGP SIGNATURE----- --1ag36DGPAXOOi42OvG4UkMF7nHox9cOHk--