Skip to content
Snippets Groups Projects
Commit bd7c4176 authored by Kevin Wolf's avatar Kevin Wolf
Browse files

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: default avatarKevin Wolf <kwolf@redhat.com>
Reviewed-by: default avatarEric Blake <eblake@redhat.com>
parent cf5198d5
No related branches found
No related tags found
No related merge requests found
...@@ -126,7 +126,16 @@ static void release_drive(Object *obj, const char *name, void *opaque) ...@@ -126,7 +126,16 @@ static void release_drive(Object *obj, const char *name, void *opaque)
static char *print_drive(void *ptr) 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, static void get_drive(Object *obj, Visitor *v, const char *name, void *opaque,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment