From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59211) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VF1Un-0003AX-7F for qemu-devel@nongnu.org; Thu, 29 Aug 2013 08:38:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VF1Ui-0005yf-BN for qemu-devel@nongnu.org; Thu, 29 Aug 2013 08:38:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34292) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VF1Ui-0005yW-2x for qemu-devel@nongnu.org; Thu, 29 Aug 2013 08:38:36 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r7TCcZ82022457 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 29 Aug 2013 08:38:35 -0400 Message-ID: <521F40CA.2080605@redhat.com> Date: Thu, 29 Aug 2013 06:38:34 -0600 From: Eric Blake MIME-Version: 1.0 References: <1377775241-26278-1-git-send-email-mreitz@redhat.com> <1377775241-26278-2-git-send-email-mreitz@redhat.com> In-Reply-To: <1377775241-26278-2-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="PbeJxWweLHSomluhvMIWLaEevqDLCmuFp" Subject: Re: [Qemu-devel] [PATCH v2 1/3] block: Image file option amendment List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz Cc: Kevin Wolf , qemu-devel@nongnu.org, Stefan Hajnoczi This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --PbeJxWweLHSomluhvMIWLaEevqDLCmuFp Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 08/29/2013 05:20 AM, Max Reitz wrote: > This patch adds the "amend" option to qemu-img which allows changing > image options on existing image files. It also adds the generic bdrv > implementation which is basically just a wrapper for the image format > specific function. >=20 > Signed-off-by: Max Reitz > --- > =20 > +static int img_amend(int argc, char **argv) > +{ > + int c, ret =3D 0; > + char *options =3D NULL; > + QEMUOptionParameter *create_options =3D NULL, *options_param =3D N= ULL; > + const char *fmt =3D NULL, *filename; > + bool quiet =3D false; > + BlockDriverState *bs =3D NULL; > + > + for (;;) { > + c =3D getopt(argc, argv, "h?qf:o:"); ? is not usually listed in the string to getopt() (doing so is not portable to POSIX). Besides, use of an unknown option (such as -x) will get mapped to '?' by getopt anyways, so your goal... > + if (c =3D=3D -1) { > + break; > + } > + > + switch (c) { > + case 'h': > + case '?': > + help(); > + break; =2E..of printing help on unknown options is already met without the need for an explicit '-?' option. > + > + filename =3D argv[argc - 1]; > + > + bs =3D bdrv_new_open(filename, fmt, BDRV_O_FLAGS | BDRV_O_RDWR, tr= ue, quiet); > + if (!bs) { > + error_report("Could not open image."); We generally avoid trailing '.' in error messages; it might also be nice to report WHICH image could not be opened. > + options_param =3D parse_option_parameters(options, create_options,= > + options_param); > + if (options_param =3D=3D NULL) { > + error_report("Invalid options for file format '%s'.", fmt); again, no trailing '.' > +++ b/qemu-img.texi > @@ -282,6 +282,11 @@ sizes accordingly. Failure to do so will result i= n data loss! > After using this command to grow a disk image, you must use file syste= m and > partitioning tools inside the VM to actually begin using the new space= on the > device. > + > +@item amend [-f @var{fmt}] -o @var{options} @var{filename} > + > +Amends the image format specific @var{options} for the image file > +@var{filename}. Only the format @code{qcow2} supports this. We might add support for other file formats in the future; we'd have to remember to update this sentence at that time. Could you use a more generic statement, such as "not all file formats support this", so we don't end up with stale docs if we forget to touch it down the road? --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --PbeJxWweLHSomluhvMIWLaEevqDLCmuFp Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.14 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJSH0DKAAoJEKeha0olJ0NqTr8H/jP3fdsck8cPe7ivaADshhaI ompYTNRodSxpEAHbq/LYhVTAwE3jbby5wUvv8XUie6bawGcK0gbqey1o9qzaFaKT xp/7dOW6aepZr3KbMm5NfT+XmcVRyLi7UEjuVSHfCL/iBcCpCrJrsC8d5+wNs+Dg /g8/ATdF/z2ROXrZY5WBX+a8vNplWENxVaICYmeMxd+CxcKKpT47veiGEEDzLwxV Jpu+LIWyfQgn2SNR7lifQjz0rnHOIAc5dG8tOkcr2IfxiPu/WrBf5woP8ZQPiYXR g9EXpHOUSuf2dk73iL51onrQCjXcCk0jSKUHzwWfXYwq5V+FRwvR5AIdYy1/nzk= =9n4e -----END PGP SIGNATURE----- --PbeJxWweLHSomluhvMIWLaEevqDLCmuFp--