From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37802) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aBQO2-0002AJ-Nw for qemu-devel@nongnu.org; Tue, 22 Dec 2015 12:06:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aBQO1-0004DZ-FC for qemu-devel@nongnu.org; Tue, 22 Dec 2015 12:06:10 -0500 References: <1450782389-17326-1-git-send-email-berrange@redhat.com> <1450782389-17326-6-git-send-email-berrange@redhat.com> From: Eric Blake Message-ID: <567982F8.3090202@redhat.com> Date: Tue, 22 Dec 2015 10:06:00 -0700 MIME-Version: 1.0 In-Reply-To: <1450782389-17326-6-git-send-email-berrange@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="MftmS12wVHbGGsp5Sjja3glQhN8FtRpDO" Subject: Re: [Qemu-devel] [PATCH 5/7] qemu-io: allow specifying image as a set of options args List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" , qemu-devel@nongnu.org Cc: Kevin Wolf , Paolo Bonzini , Markus Armbruster , qemu-block@nongnu.org, =?UTF-8?Q?Andreas_F=c3=a4rber?= This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --MftmS12wVHbGGsp5Sjja3glQhN8FtRpDO Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 12/22/2015 04:06 AM, Daniel P. Berrange wrote: > Currently qemu-io allows an image filename to be passed on the > command line, but does not have a way to set any options except > the format eg >=20 > qemu-io https://127.0.0.1/images/centos7.iso > qemu-io /home/berrange/demo.qcow2 Well, you CAN set the options by specifying the file as: qemu-io json:{...} but that's a mouthful to type, so I don't mind adding the new syntax. >=20 > This adds a --source arg (that is mutually exclusive with a > positional filename arg and -f arg) that accepts a full option > string, as well as the original syntax eg >=20 > qemu-io --source driver=3Dhttp,url=3Dhttps://127.0.0.1/images,sslverif= y=3Doff > qemu-io --source https://127.0.0.1/images/centos7.iso > qemu-io --source file=3D/home/berrange/demo.qcow2 > qemu-io --source /home/berrange/demo.qcow2 >=20 > Signed-off-by: Daniel P. Berrange > --- > qemu-io.c | 37 ++++++++++++++++++++++++++++++++++++- > 1 file changed, 36 insertions(+), 1 deletion(-) >=20 > @@ -572,7 +590,24 @@ int main(int argc, char **argv) > flags |=3D BDRV_O_RDWR; > } > =20 > - if ((argc - optind) =3D=3D 1) { > + qopts =3D qemu_opts_find(&file_opts, NULL); > + if (qopts) { > + char *file; > + if (opts) { > + error_report("--source and -f are mutually exclusive"); > + exit(1); > + } > + if ((argc - optind) =3D=3D 1) { What if I specify more than one option? Shouldn't this be >=3D, rather than =3D=3D? Also, the inner () are redundant. > + error_report("--source and filename are mutually exclusive= "); > + exit(1); > + } > + file =3D g_strdup(qemu_opt_get(qopts, "file")); > + qemu_opt_unset(qopts, "file"); > + opts =3D qemu_opts_to_qdict(qopts, NULL); > + qemu_opts_reset(&file_opts); > + openfile(file, flags, opts); > + g_free(file); > + } else if ((argc - optind) =3D=3D 1) { Pre-existing, but the inner () are redundant. > openfile(argv[optind], flags, opts); > } > command_loop(); >=20 --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --MftmS12wVHbGGsp5Sjja3glQhN8FtRpDO 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/ iQEcBAEBCAAGBQJWeYL4AAoJEKeha0olJ0NqTSUH/2sEIB3J2da9ogs2WJnaMSSv 98LTlPYvVwW3kLXvCUnq8YGzFnVirDeZdScWVKe1HziSU3hfkY8CnBEKIAVWLGV3 +ZQ9ka8S6xJA41R9YQ5rB1vqCo8jcR2j+gjCHn72RJpvxokOTQdUfi/zFbC8h6op wrfHEA3WUAIcvFg48j9/4zJ/7/tblIYb4nvKH4+p0juVDd+t3gi7kYBGl981V3K6 QN5JnSXfUTHH+wZFSj1o/hva5uNHmlS5ku3pseUD2LMcF7ZYxmZvL78VSfMujVGX kQSNisp8CRkaSRUHEfuOfmDW4xUOpU5EpamuWGPugP8I6PJQKZujlUjfWXBZu8M= =jN1e -----END PGP SIGNATURE----- --MftmS12wVHbGGsp5Sjja3glQhN8FtRpDO--