On 06.07.2016 16:45, Kevin Wolf wrote: > If a node name instead of a BlockBackend name is specified as the driver > for a guest device, an anonymous BlockBackend is created now. > > usb-storage uses a hack where it forwards its BlockBackend as a property > 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. > > Signed-off-by: Kevin Wolf <[email protected]> > --- > hw/core/qdev-properties-system.c | 37 ++++++++++++++++++++++++++++++++----- > hw/usb/dev-storage.c | 5 ++++- > 2 files changed, 36 insertions(+), 6 deletions(-) > > 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 = {
> 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 = 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 <[email protected]>
> +
> + if (value) {
> + ref = blk_name(value);
> + if (!*ref) {
> + BlockDriverState *bs = blk_bs(value);
> + if (bs) {
> + ref = bdrv_get_node_name(bs);
> + }
> + }
> + }
> +
> + object_property_set_str(OBJECT(dev), ref, name, errp);
> }
>
> void qdev_prop_set_chr(DeviceState *dev, const char *name,
signature.asc
Description: OpenPGP digital signature
