From: Kevin Wolf Date: Thu, 4 Aug 2016 12:09:07 +0000 (+0200) Subject: block/qdev: Let 'drive' property fall back to node name X-Git-Tag: v2.7.0-rc2~2^2~3 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=bd7c41765b9afa93a7f1a42e1ee353282230e2b7;p=users%2Fdwmw2%2Fqemu.git block/qdev: Let 'drive' property fall back to node name 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 Reviewed-by: Eric Blake --- diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c index 2ba2504ea0..e55afe6bf2 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,