From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39097) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGVv8-0007l7-J9 for qemu-devel@nongnu.org; Thu, 20 Feb 2014 10:52:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WGVv1-0002Jq-Sp for qemu-devel@nongnu.org; Thu, 20 Feb 2014 10:52:18 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60545) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGVv1-0002Ja-K4 for qemu-devel@nongnu.org; Thu, 20 Feb 2014 10:52:11 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s1KFq9RI008502 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 20 Feb 2014 10:52:10 -0500 Message-ID: <530624A8.6090403@redhat.com> Date: Thu, 20 Feb 2014 08:52:08 -0700 From: Eric Blake MIME-Version: 1.0 References: <1392908243-8835-1-git-send-email-kwolf@redhat.com> <1392908243-8835-3-git-send-email-kwolf@redhat.com> In-Reply-To: <1392908243-8835-3-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="IPoDKM6SHWRvqIPb4rH14jcsIqCmukKv3" Subject: Re: [Qemu-devel] [PATCH v2 2/6] qemu-img create: Support multiple -o options List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf , qemu-devel@nongnu.org Cc: famz@redhat.com, armbru@redhat.com, stefanha@redhat.com, mreitz@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --IPoDKM6SHWRvqIPb4rH14jcsIqCmukKv3 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 02/20/2014 07:57 AM, Kevin Wolf wrote: > If you specified multiple -o options for qemu-img create, it would > silently ignore all but the last one. This patch fixes the problem. >=20 > Now multiple -o options has the same meaning as having a single option > with all settings in the order of their respective -o options. >=20 > Signed-off-by: Kevin Wolf > --- > qemu-img.c | 24 ++++++++++++++++++------ > 1 file changed, 18 insertions(+), 6 deletions(-) Much nicer than v1! Reviewed-by: Eric Blake > case 'o': > - options =3D optarg; > + if (!options) { > + options =3D g_strdup(optarg); > + } else { > + char *old_options =3D options; > + options =3D g_strdup_printf("%s,%s", options, optarg);= > + g_free(old_options); > + } Corner case: Previously: qemu-img create -f qcow2 -o backing_file=3D/dev/null, xyz 1M creates xyz with a backing file of /dev/null and unspecified backing format (and ignores the empty trailing option). Now: qemu-img create -f qcow2 -o backing_file=3D/dev/null, \ -o backing_fmt=3Dqcow2 xyz 1M creates xyz with a backing file of '/dev/null,backing_fmt=3Dqcow2' and with an unspecified backing format (and NOT with a backing format of qcow2). Yikes! What we thought was an empty trailing option instead got turned into a literal comma in the backing_file option. Maybe you should add a followup patch that errors out on trailing commas, so that we don't end up creating ',,' in the concatenated version. And maybe patch get_opt_value() to detect and reject empty trailing options as well. But as this patch is already a strict improvement, it does not have to be done in this commit. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --IPoDKM6SHWRvqIPb4rH14jcsIqCmukKv3 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 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJTBiSoAAoJEKeha0olJ0NqBjcH/igtb5sqlMob2IHj/PxMFFfX 6bxjVhB6trFW/6r39UzGJawQHL3zRfLseSbo8sLgap3JBBG4YYJSFGyK2WPkLMTx Di+0LTCTp7Gnblv5kBNlZi4c9pE2UDGox4LfMh9C2r9DVscDz0Gu/+whyKmADGiA ZtwIWrcQxQoYp2jWXa4ccMXtIqyORH6A3vSfCqmHRvS6H6H0Y1VSMIhw7g4Zolh4 nt64jSa4DvJQda+1/RM2yfc4nMmAbxfRNz4zj81CqVU/hgEQHGQ+4etCarqlA48t t4V1WLW6AimR935Y14vkrUgaNo3Gi1BH5mL2sPJmwIjb9dSIaeZfRFHB6OCUaWU= =GG3t -----END PGP SIGNATURE----- --IPoDKM6SHWRvqIPb4rH14jcsIqCmukKv3--