From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55303) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQzUp-0000cM-3E for qemu-devel@nongnu.org; Wed, 03 Feb 2016 10:37:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aQzUo-0007EI-1G for qemu-devel@nongnu.org; Wed, 03 Feb 2016 10:37:31 -0500 References: <1454417864-18774-1-git-send-email-berrange@redhat.com> <1454417864-18774-6-git-send-email-berrange@redhat.com> From: Eric Blake Message-ID: <56B21EAB.1000308@redhat.com> Date: Wed, 3 Feb 2016 08:37:15 -0700 MIME-Version: 1.0 In-Reply-To: <1454417864-18774-6-git-send-email-berrange@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Vf3vIshCClcDh6Kw0wDWQO9CPMVPHLFfx" Subject: Re: [Qemu-devel] [PATCH v5 05/10] 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) --Vf3vIshCClcDh6Kw0wDWQO9CPMVPHLFfx Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 02/02/2016 05:57 AM, Daniel P. Berrange wrote: > Currently qemu-io allows an image filename to be passed on the > command line, but unless using the JSON format, it 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 >=20 > This adds a --image-opts arg that indicates that the positional > filename should be interpreted as a full option string, not > just a filename. >=20 > qemu-io --image-opts driver=3Dhttps,url=3Dhttps://127.0.0.1/images,ssl= verify=3Doff > qemu-io --image-opts driver=3Dfile,filename=3D/home/berrange/demo.qcow= 2 >=20 > This flag is mutually exclusive with the '-f' flag. I guess it's easier to enforce the mutual exclusion, than it is to try and figure out how to make -f work with the --image-opts filename as long as the two aren't specifying conflicting formats. Seems okay as long as it is documented well. >=20 > Signed-off-by: Daniel P. Berrange > --- > qemu-io.c | 31 ++++++++++++++++++++++++++++++- > 1 file changed, 30 insertions(+), 1 deletion(-) >=20 > @@ -515,7 +531,20 @@ int main(int argc, char **argv) > flags |=3D BDRV_O_RDWR; > } > =20 > - if ((argc - optind) =3D=3D 1) { > + if (imageOpts) { > + QemuOpts *qopts; > + qopts =3D qemu_opts_parse_noisily(&file_opts, argv[optind], fa= lse); Ouch. If argc =3D=3D optind (possible if I type 'qemu-io --image-opts' without a filename), then argv[optind] =3D=3D NULL, and you end up callin= g strncmp(NULL, "id=3D", 3) inside opts_parse(). Also, I noticed that running 'qemu-io' without arguments puts you into a shell mode, where you can then open files after the fact via the open_f() callback function (the 'open' command) - either that function should that function be given --image-opts support, or use of --image-opts from the command line should globally affect all subsequent use of open_f(). --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --Vf3vIshCClcDh6Kw0wDWQO9CPMVPHLFfx 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/ iQEcBAEBCAAGBQJWsh6rAAoJEKeha0olJ0Nqo40H/R12rU3LPhFzOxkqx/0gDL8v +x+9gT4IxEedei1WFZr3wHrbVvaxWAa9S9UFxhVCF51YqhWiZjFZWCTp86glQYs2 o1l4uWSvQsrnxgnK6HDe6NYT3JQvmwkkoIZ0mqCauq/ErKoVl5S+OJkiQEhmNrGM KBbuvAmXUIL1CSKlvxHNibIthHKZq43RrY/Krer6rQVE2kwhum0vPRu7mvNnXzls 7V6cQ4VtEqbqQCkoLIX9xvjeSgeOoz9rZ/GlZzk58ppuz3RNbHdxKQE6iOzUuxiv 29jJj1ELuzNxWUw6DEnC3662AsQtlp2hcRkQZxNtgn1xY1wsVbdQDnMD4BvMXv8= =OX7f -----END PGP SIGNATURE----- --Vf3vIshCClcDh6Kw0wDWQO9CPMVPHLFfx--