[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v3 1/6] block/qdev: Allow node name for drive pr
From: |
Max Reitz |
Subject: |
Re: [Qemu-devel] [PATCH v3 1/6] block/qdev: Allow node name for drive properties |
Date: |
Fri, 8 Jul 2016 17:15:04 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 |
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 <address@hidden>
> ---
> 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 <address@hidden>
> +
> + 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
- [Qemu-devel] [PATCH v3 0/6] block: Move BB options from blockdev-add to qdev, Kevin Wolf, 2016/07/06
- [Qemu-devel] [PATCH v3 3/6] commit: Fix use of error handling policy, Kevin Wolf, 2016/07/06
- [Qemu-devel] [PATCH v3 5/6] qemu-iotests: Test setting WCE with qdev, Kevin Wolf, 2016/07/06
- [Qemu-devel] [PATCH v3 1/6] block/qdev: Allow node name for drive properties, Kevin Wolf, 2016/07/06
- [Qemu-devel] [PATCH v3 6/6] block: Remove BB options from blockdev-add, Kevin Wolf, 2016/07/06
- [Qemu-devel] [PATCH v3 4/6] block/qdev: Allow configuring rerror/werror with qdev properties, Kevin Wolf, 2016/07/06
- [Qemu-devel] [PATCH v3 2/6] block/qdev: Allow configuring WCE with qdev properties, Kevin Wolf, 2016/07/06
- Re: [Qemu-devel] [PATCH v3 0/6] block: Move BB options from blockdev-add to qdev, Kevin Wolf, 2016/07/08