Received: from eggs.gnu.org ([2001:4830:134:3::10]:36501) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLXV0-0004EH-By for qemu-devel@nongnu.org; Fri, 08 Jul 2016 11:15:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bLXUu-00059c-Dv for qemu-devel@nongnu.org; Fri, 08 Jul 2016 11:15:25 -0400 References: <1467816309-16657-1-git-send-email-kwolf@redhat.com> <1467816309-16657-2-git-send-email-kwolf@redhat.com> From: Max Reitz Message-ID: Date: Fri, 8 Jul 2016 17:15:04 +0200 MIME-Version: 1.0 In-Reply-To: <1467816309-16657-2-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="CKVO8LAItWdGUrHx1b61aHH8hnR8pmKNb" Subject: Re: [Qemu-devel] [PATCH v3 1/6] block/qdev: Allow node name for drive properties List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf , qemu-block@nongnu.org Cc: eblake@redhat.com, qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --CKVO8LAItWdGUrHx1b61aHH8hnR8pmKNb From: Max Reitz To: Kevin Wolf , qemu-block@nongnu.org Cc: eblake@redhat.com, qemu-devel@nongnu.org Message-ID: Subject: Re: [PATCH v3 1/6] block/qdev: Allow node name for drive properties References: <1467816309-16657-1-git-send-email-kwolf@redhat.com> <1467816309-16657-2-git-send-email-kwolf@redhat.com> In-Reply-To: <1467816309-16657-2-git-send-email-kwolf@redhat.com> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 06.07.2016 16:45, Kevin Wolf wrote: > If a node name instead of a BlockBackend name is specified as the drive= r > for a guest device, an anonymous BlockBackend is created now. >=20 > usb-storage uses a hack where it forwards its BlockBackend as a propert= y > to another device that it internally creates. This hack must be updated= > so that it doesn't drop its original BB before it can be passed to the > other device. This used to work because we always had the monitor > reference around, but with node-names the device reference is the only > one now. >=20 > Signed-off-by: Kevin Wolf > --- > hw/core/qdev-properties-system.c | 37 ++++++++++++++++++++++++++++++++= ----- > hw/usb/dev-storage.c | 5 ++++- > 2 files changed, 36 insertions(+), 6 deletions(-) >=20 > diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties= -system.c > index df38b8a..615c191 100644 > --- a/hw/core/qdev-properties-system.c > +++ b/hw/core/qdev-properties-system.c [...] > @@ -362,8 +378,19 @@ PropertyInfo qdev_prop_vlan =3D { > void qdev_prop_set_drive(DeviceState *dev, const char *name, > BlockBackend *value, Error **errp) > { > - object_property_set_str(OBJECT(dev), value ? blk_name(value) : "",= > - name, errp); > + const char *ref =3D NULL; This should be "", otherwise strlen() called by qstring_from_str() called by object_property_set_str() will probably segfault. With that fixed: Reviewed-by: Max Reitz > + > + if (value) { > + ref =3D blk_name(value); > + if (!*ref) { > + BlockDriverState *bs =3D blk_bs(value); > + if (bs) { > + ref =3D bdrv_get_node_name(bs); > + } > + } > + } > + > + object_property_set_str(OBJECT(dev), ref, name, errp); > } > =20 > void qdev_prop_set_chr(DeviceState *dev, const char *name, --CKVO8LAItWdGUrHx1b61aHH8hnR8pmKNb 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 iQEvBAEBCAAZBQJXf8N4EhxtcmVpdHpAcmVkaGF0LmNvbQAKCRA7sUIC6DisrTky CACPHJSEcSolIEhZq188G+yB/GC707wj7Dp9TlreFbFZMNfr63QdwQQG3rYa4YLo krtfJu+unmKhxG7LIsED9FTKGreB2Y6mm1vy72BJGCs4xh05xm2M+bKO4rmGOKkd L4eKmCUgY//NtgChyeaN8SVGR5cakGH3pHl3W5wz4WDNc9CU+3pKMQtlNOPr0AH2 p4T6AdcWsny92Ze488gaOiwb67Ccw+2oSChmMbgbzQjPbo1XCroD0E6rOvdQyyK3 7Os07JBWERX1Ii/pxDpZTzMloGjdhRVX0E0OGPJfc0TZOkqUWoKkObl4IFLNX2V9 NsmAQPD5UorZAvAuewcftLgP =tf+Q -----END PGP SIGNATURE----- --CKVO8LAItWdGUrHx1b61aHH8hnR8pmKNb--