From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50769) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WhlV4-0007sF-Hq for qemu-devel@nongnu.org; Tue, 06 May 2014 15:58:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WhlUz-0002PC-KF for qemu-devel@nongnu.org; Tue, 06 May 2014 15:58:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:30281) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WhlUz-0002P0-CK for qemu-devel@nongnu.org; Tue, 06 May 2014 15:57:57 -0400 Message-ID: <53693EC1.3080303@redhat.com> Date: Tue, 06 May 2014 13:57:53 -0600 From: Eric Blake MIME-Version: 1.0 References: <1399404625-6093-1-git-send-email-mreitz@redhat.com> <1399404625-6093-4-git-send-email-mreitz@redhat.com> In-Reply-To: <1399404625-6093-4-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="opi6Nf1SP4ScnNTGsVtJCQlBGC8J58Nhc" Subject: Re: [Qemu-devel] [PATCH 3/4] block: Allow JSON filenames List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz , qemu-devel@nongnu.org Cc: Kevin Wolf , =?UTF-8?B?QmVub8OudCBDYW5ldA==?= , Stefan Hajnoczi This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --opi6Nf1SP4ScnNTGsVtJCQlBGC8J58Nhc Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 05/06/2014 01:30 PM, Max Reitz wrote: > If the filename given to bdrv_open() is prefixed with "json:", parse th= e > rest as a JSON object and use the result as the options QDict. >=20 > Signed-off-by: Max Reitz > --- > block.c | 41 +++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 41 insertions(+) >=20 > /* > * Opens a disk image (raw, qcow2, vmdk, ...) > * > @@ -1337,6 +1364,20 @@ int bdrv_open(BlockDriverState **pbs, const char= *filename, > options =3D qdict_new(); > } > =20 > + if (filename && g_str_has_prefix(filename, "json:")) { > + QDict *json_options =3D parse_json_filename(filename, &local_e= rr); > + if (local_err) { > + ret =3D -EINVAL; > + goto fail; > + } > + > + qdict_join(options, json_options, true); > + assert(qdict_size(json_options) =3D=3D 0); Would it be better to pass false to qdict_join(), and then raise an error if the user specified conflicting options? For example (untested, just typing off the top of my head here), -drive file=3D'json:{"driver":"qcow2","file.filename":"foo","backing.file.driver= ":"raw"}',backing.file.driver=3Dqcow2 looks like it specifies conflicting backing.file.driver options. Passing true means that qdict_join silently overwrites the value in options to instead be the value in the json string; passing false means you could flag the user error. > + QDECREF(json_options); > + > + filename =3D NULL; > + } > + > bs->options =3D options; > options =3D qdict_clone_shallow(options); > =20 >=20 --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --opi6Nf1SP4ScnNTGsVtJCQlBGC8J58Nhc 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/ iQEcBAEBCAAGBQJTaT7BAAoJEKeha0olJ0NqOx4H/0E+XJLjH4mja8JqEIUayzNT RK0KZ1QMWL/L5p7yHNv3sXMEivpV9Y2/G+eUZm/D+MN6ST886JNXR1a80pNh+s+0 Bl5IrkRNvpgol/34opsqNw2L0xaU39VIs2NEyFMPUvPplEu9M1StJUKZH0soPU0+ i6A9I7f0pT4LAhyab6LlC6+UwRe7V2uR3GQMU8nclaPBKajk56hIe6JWdsl4IV4I 6BptroVuqwZ0bM4dQOiSZ9gZd8r7kPi3K582bBI/Zf5gu78E9/zeFiQuYxpNYtxw h9L2QyH4G+3yeWeb08p0ytv/MQ/jYcfedVBq3TqldudO7FaMpEUTX5VWXkSW/5k= =slTa -----END PGP SIGNATURE----- --opi6Nf1SP4ScnNTGsVtJCQlBGC8J58Nhc--