All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>, qemu-block@nongnu.org
Cc: armbru@redhat.com, stefanha@redhat.com, mreitz@redhat.com,
	famz@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [RFC PATCH 1/7] block/qdev: Allow node name for drive properties
Date: Fri, 24 Jun 2016 11:35:59 -0600	[thread overview]
Message-ID: <576D6F7F.6020904@redhat.com> (raw)
In-Reply-To: <1466692592-9551-2-git-send-email-kwolf@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 2158 bytes --]

On 06/23/2016 08:36 AM, 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.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  hw/core/qdev-properties-system.c | 18 +++++++++++++++++-
>  1 file changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
> index df38b8a..c5cc9cf 100644
> --- a/hw/core/qdev-properties-system.c
> +++ b/hw/core/qdev-properties-system.c
> @@ -72,9 +72,18 @@ static void parse_drive(DeviceState *dev, const char *str, void **ptr,
>                          const char *propname, Error **errp)
>  {
>      BlockBackend *blk;
> +    bool blk_created = false;
>  
>      blk = blk_by_name(str);
>      if (!blk) {
> +        BlockDriverState *bs = bdrv_lookup_bs(NULL, str, NULL);

So BB name takes priority, but if one is not found, you try a BDS lookup
(node name) and create an anonymous BB to match.  Seems okay.

> +        if (bs) {
> +            blk = blk_new();
> +            blk_insert_bs(blk, bs);
> +            blk_created = true;
> +        }
> +    }
> +    if (!blk) {
>          error_setg(errp, "Property '%s.%s' can't find value '%s'",
>                     object_get_typename(OBJECT(dev)), propname, str);
>          return;

This return is safe, but looks a bit odd...

> @@ -91,9 +100,16 @@ static void parse_drive(DeviceState *dev, const char *str, void **ptr,
>              error_setg(errp, "Drive '%s' is already in use by another device",
>                         str);
>          }
> -        return;
> +        goto fail;

...given that you had to convert this return to a goto.

>      }
> +
>      *ptr = blk;
> +
> +fail:
> +    if (blk_created) {
> +        /* If we need to keep a reference, blk_attach_dev() took it */
> +        blk_unref(blk);
> +    }
>  }
>  
>  static void release_drive(Object *obj, const char *name, void *opaque)
> 

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  reply	other threads:[~2016-06-24 17:36 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-23 14:36 [Qemu-devel] [RFC PATCH 0/7] BlockBackends, nodes and guest devices Kevin Wolf
2016-06-23 14:36 ` [Qemu-devel] [RFC PATCH 1/7] block/qdev: Allow node name for drive properties Kevin Wolf
2016-06-24 17:35   ` Eric Blake [this message]
2016-06-24 17:54     ` Kevin Wolf
2016-06-23 14:36 ` [Qemu-devel] [RFC PATCH 2/7] block: Add blk_by_dev() Kevin Wolf
2016-06-24 17:39   ` Eric Blake
2016-06-23 14:36 ` [Qemu-devel] [RFC PATCH 3/7] qdev-monitor: Factor out find_device_state() Kevin Wolf
2016-06-24 17:41   ` Eric Blake
2016-06-23 14:36 ` [Qemu-devel] [RFC PATCH 4/7] qdev-monitor: Add blk_by_qdev_id() Kevin Wolf
2016-06-24 20:22   ` Eric Blake
2016-06-23 14:36 ` [Qemu-devel] [RFC PATCH 5/7] block: Accept device model name for blockdev-open/close-tray Kevin Wolf
2016-06-24 20:39   ` Eric Blake
2016-06-27  8:53     ` Kevin Wolf
2016-06-23 14:36 ` [Qemu-devel] [RFC PATCH 6/7] block: Accept node-name for block-stream Kevin Wolf
2016-06-24 20:57   ` Eric Blake
2016-06-23 14:36 ` [Qemu-devel] [RFC PATCH 7/7] block/qdev: Allow configuring WCE with qdev properties Kevin Wolf
2016-06-24 21:10   ` Eric Blake
2016-06-23 21:26 ` [Qemu-devel] [RFC PATCH 0/7] BlockBackends, nodes and guest devices Paolo Bonzini
2016-06-27 16:13 ` Max Reitz
2016-06-27 16:38   ` Kevin Wolf
2016-06-27 16:40     ` Max Reitz
2016-07-12  0:13 ` [Qemu-devel] [Qemu-block] " John Snow
2016-07-12  8:14   ` Kevin Wolf
2016-07-12 17:11     ` John Snow

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=576D6F7F.6020904@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=famz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.