qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH for-2.7 v2] block/qdev: Let 'drive' property fall back to node name
@ 2016-08-04 12:09 Kevin Wolf
  2016-08-04 15:54 ` Eric Blake
  2016-08-05 10:36 ` Kevin Wolf
  0 siblings, 2 replies; 3+ messages in thread
From: Kevin Wolf @ 2016-08-04 12:09 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel

If a qdev block device is created with an anonymous BlockBackend (i.e.
a node name rather than a BB name was given for the drive property),
qdev used to return an empty string when the property was read. This
patch fixes it to return the node name instead.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
v2:
- Check whether the BB has even a BDS inserted. Fixes a segfault with
  empty anonymous BlockBackends.

 hw/core/qdev-properties-system.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index 2ba2504..e55afe6 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -126,7 +126,16 @@ static void release_drive(Object *obj, const char *name, void *opaque)
 
 static char *print_drive(void *ptr)
 {
-    return g_strdup(blk_name(ptr));
+    const char *name;
+
+    name = blk_name(ptr);
+    if (!*name) {
+        BlockDriverState *bs = blk_bs(ptr);
+        if (bs) {
+            name = bdrv_get_node_name(bs);
+        }
+    }
+    return g_strdup(name);
 }
 
 static void get_drive(Object *obj, Visitor *v, const char *name, void *opaque,
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.7 v2] block/qdev: Let 'drive' property fall back to node name
  2016-08-04 12:09 [Qemu-devel] [PATCH for-2.7 v2] block/qdev: Let 'drive' property fall back to node name Kevin Wolf
@ 2016-08-04 15:54 ` Eric Blake
  2016-08-05 10:36 ` Kevin Wolf
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Blake @ 2016-08-04 15:54 UTC (permalink / raw)
  To: Kevin Wolf, qemu-block; +Cc: qemu-devel

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

On 08/04/2016 06:09 AM, Kevin Wolf wrote:
> If a qdev block device is created with an anonymous BlockBackend (i.e.
> a node name rather than a BB name was given for the drive property),
> qdev used to return an empty string when the property was read. This
> patch fixes it to return the node name instead.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
> v2:
> - Check whether the BB has even a BDS inserted. Fixes a segfault with
>   empty anonymous BlockBackends.
> 

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
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 --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.7 v2] block/qdev: Let 'drive' property fall back to node name
  2016-08-04 12:09 [Qemu-devel] [PATCH for-2.7 v2] block/qdev: Let 'drive' property fall back to node name Kevin Wolf
  2016-08-04 15:54 ` Eric Blake
@ 2016-08-05 10:36 ` Kevin Wolf
  1 sibling, 0 replies; 3+ messages in thread
From: Kevin Wolf @ 2016-08-05 10:36 UTC (permalink / raw)
  To: qemu-block; +Cc: qemu-devel

Am 04.08.2016 um 14:09 hat Kevin Wolf geschrieben:
> If a qdev block device is created with an anonymous BlockBackend (i.e.
> a node name rather than a BB name was given for the drive property),
> qdev used to return an empty string when the property was read. This
> patch fixes it to return the node name instead.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>

Applied to the block branch.

Kevin

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-08-05 10:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-04 12:09 [Qemu-devel] [PATCH for-2.7 v2] block/qdev: Let 'drive' property fall back to node name Kevin Wolf
2016-08-04 15:54 ` Eric Blake
2016-08-05 10:36 ` Kevin Wolf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).