From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37806) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VFSYG-0008RI-KJ for qemu-devel@nongnu.org; Fri, 30 Aug 2013 13:32:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VFSYC-00023Z-DE for qemu-devel@nongnu.org; Fri, 30 Aug 2013 13:32:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:62054) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VFSYC-00023U-6E for qemu-devel@nongnu.org; Fri, 30 Aug 2013 13:32:00 -0400 Message-ID: <5220D708.7050802@redhat.com> Date: Fri, 30 Aug 2013 11:31:52 -0600 From: Eric Blake MIME-Version: 1.0 References: <1377508321-16507-1-git-send-email-alex@alex.org.uk> <1377508321-16507-2-git-send-email-alex@alex.org.uk> In-Reply-To: <1377508321-16507-2-git-send-email-alex@alex.org.uk> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ME1kAdIlqHNQL4ELfT4XpvcntNWIf1H0W" Subject: Re: [Qemu-devel] [PATCHv5] add qemu-img convert -n option (skip target volume creation) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alex Bligh Cc: Kevin Wolf , Anthony Liguori , Fam Zheng , qemu-devel@nongnu.org, Alexandre Derumier , Stefan Hajnoczi , Paolo Bonzini This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --ME1kAdIlqHNQL4ELfT4XpvcntNWIf1H0W Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 08/26/2013 03:12 AM, Alex Bligh wrote: > From: Alexandre Derumier >=20 > Add a -n option to skip volume creation on qemu-img convert. > This is useful for targets such as rbd / ceph, where the > target volume may already exist; we cannot always rely on > qemu-img convert to create the image, as dependent on the > output format, there may be parameters which are not possible > to specify through the qemu-img convert command line. >=20 > Signed-off-by: Alexandre Derumier > Signed-off-by: Alex Bligh > --- > static int img_convert(int argc, char **argv) > { > - int c, ret =3D 0, n, n1, bs_n, bs_i, compress, cluster_size, clust= er_sectors; > + int c, ret =3D 0, n, n1, bs_n, bs_i, compress, cluster_size, > + cluster_sectors, skip_create; Pre-existing usage, but this new variable is used only as a bool, so it might be better to type it (and others like it) correctly... > int progress =3D 0, flags; > const char *fmt, *out_fmt, *cache, *out_baseimg, *out_filename; > BlockDriver *drv, *proto_drv; > @@ -1139,8 +1142,9 @@ static int img_convert(int argc, char **argv) > cache =3D "unsafe"; > out_baseimg =3D NULL; > compress =3D 0; > + skip_create =3D 0; =2E..which would mean using 'false' instead of '0' here, and so forth. A= s at least 'compress' is also impacted, I'm okay deferring the type cleanup to a separate patch. > for(;;) { > - c =3D getopt(argc, argv, "f:O:B:s:hce6o:pS:t:q"); > + c =3D getopt(argc, argv, "f:O:B:s:hce6o:pS:t:qn"); The order here... > if (c =3D=3D -1) { > break; > } > @@ -1161,6 +1165,9 @@ static int img_convert(int argc, char **argv) > case 'c': > compress =3D 1; > break; > + case 'n': > + skip_create =3D 1; > + break; =2E..and the order of the case statements, are unrelated. Which makes maintenance a bit harder. Personally, I like to keep my optstring in case-insensitive order, then my case statements in the same order. But that's cosmetic, it doesn't affect the correctness of the patch. > +++ b/tests/qemu-iotests/060 > @@ -0,0 +1,101 @@ > +#!/bin/bash > +# > +# test of qemu-img convert -n - convert without creation > +# > +# Copyright (C) 2009 Red Hat, Inc. Where have you been the last 4 years? I could understand a range of years, if this test borrows significantly from another file that old, but I suspect that just 2013 is probably more accurate. Fix that, and you can add: Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --ME1kAdIlqHNQL4ELfT4XpvcntNWIf1H0W 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/ iQEcBAEBCAAGBQJSINcIAAoJEKeha0olJ0NqqWEH/RGMMoILKFmzJUJ3T516/Roz X7NRCo2Ar3Cka3pJA0P7mZOijZQljTU6gLWQ7JNRltI5Yc1+/sUOzGY/motaL5Or ueVyAd3WDPkn56ZcMQ68KzviZbZ45oOiyPckEVV7YFVgDJE4wArqNpckNV5dWojU Gqs69Xp06XjlF6sbJWg9NigPdNfGd0d2bVQ1qpiCx5cZ9yd4TmGarpZGVbdt2TVq 707zr+0Umujy8FElUogjUCi87LproXG9/Eoy19y0YYb+JtchgMHpz/opHckbZ8z0 rmQS7x5o/zfCUzKeKR0BAHCGHGYzrc/v3DRWAAPxZhxjaTvqN2fCMY0bWhjrNzk= =np+h -----END PGP SIGNATURE----- --ME1kAdIlqHNQL4ELfT4XpvcntNWIf1H0W--