From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44154) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WfwUi-0004Ql-Tq for qemu-devel@nongnu.org; Thu, 01 May 2014 15:18:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WfwUe-0006Jf-Fs for qemu-devel@nongnu.org; Thu, 01 May 2014 15:18:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:16575) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WfwUe-0006JW-8h for qemu-devel@nongnu.org; Thu, 01 May 2014 15:18:04 -0400 Message-ID: <53629DEA.8090905@redhat.com> Date: Thu, 01 May 2014 13:18:02 -0600 From: Eric Blake MIME-Version: 1.0 References: <1398762656-26079-1-git-send-email-cyliu@suse.com> <1398762656-26079-14-git-send-email-cyliu@suse.com> In-Reply-To: <1398762656-26079-14-git-send-email-cyliu@suse.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="s5gPhRffuKlF2dSLuBtdNqbt8bpf6WNLF" Subject: Re: [Qemu-devel] [PATCH V26 13/32] vvfat.c: handle cross_driver's create_options and create_opts List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Chunyan Liu , qemu-devel@nongnu.org Cc: stefanha@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --s5gPhRffuKlF2dSLuBtdNqbt8bpf6WNLF Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 04/29/2014 03:10 AM, Chunyan Liu wrote: > vvfat shares create options of qcow driver. To avoid vvfat broken when s/broken/breaking/ > qcow driver changes from QEMUOptionParameter to QemuOpts, let it able > to handle both cases. >=20 > Signed-off-by: Chunyan Liu > --- > block/vvfat.c | 19 ++++++++++++++----- > 1 file changed, 14 insertions(+), 5 deletions(-) >=20 > diff --git a/block/vvfat.c b/block/vvfat.c > index 155fc9b..b49ec96 100644 > --- a/block/vvfat.c > +++ b/block/vvfat.c > @@ -2907,7 +2907,8 @@ static BlockDriver vvfat_write_target =3D { > static int enable_write_target(BDRVVVFATState *s) > { > BlockDriver *bdrv_qcow; > - QEMUOptionParameter *options; > + QemuOptsList *create_opts =3D NULL; > + QemuOpts *opts =3D NULL; > Error *local_err =3D NULL; > int ret; > int size =3D sector2cluster(s, s->sector_count); > @@ -2922,11 +2923,17 @@ static int enable_write_target(BDRVVVFATState *= s) > } > =20 > bdrv_qcow =3D bdrv_find_format("qcow"); > - options =3D parse_option_parameters("", bdrv_qcow->create_options,= NULL); > - set_option_parameter_int(options, BLOCK_OPT_SIZE, s->sector_count = * 512); > - set_option_parameter(options, BLOCK_OPT_BACKING_FILE, "fat:"); > + assert(!(bdrv_qcow->create_opts && bdrv_qcow->create_options)); > + if (bdrv_qcow->create_options) { > + create_opts =3D params_to_opts(bdrv_qcow->create_options); allocated... > + } else { > + create_opts =3D bdrv_qcow->create_opts; vs. reference... > err: > + qemu_opts_del(opts); > + qemu_opts_free(create_opts); but unconditionally freed on either path. Calling g_free(bdrv_qcow->create_opts) is not nice. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --s5gPhRffuKlF2dSLuBtdNqbt8bpf6WNLF 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/ iQEcBAEBCAAGBQJTYp3qAAoJEKeha0olJ0Nq7MUIAKN//5meDUwSevbt8gWaZLv/ yekGSBZdapyux7+svSMb+L/u3yQeOlBzGVyBsq0inZgj68IrBn9gfznA/jiQOvLB yPZCVl0pBibp1Kuk5byN0laXrj+/xTzA0HzoWCTD1N2wVM2+iAlKlp2ESfI/7AU5 rVPEzhZMECgkHoam7mV9I4q6mmfWpe5eXnm99l2bYNL1pugZo81WqeXMI2HfEilu uNsxV82bayd0GlFuh3Qaj9qItVLhc4AiwFbHHD6nxN1gH+EDgpI+N9Xdo6SO5B3l wP+PVJScoCf5Rge+CDRZu4NBHCNwHoXV0Tuz/FKjqlNl3mk3rumqmlPbf751+5g= =mIM2 -----END PGP SIGNATURE----- --s5gPhRffuKlF2dSLuBtdNqbt8bpf6WNLF--