Skip to content

Commit

Permalink
block/qdev: Let 'drive' property fall back to node name
Browse files Browse the repository at this point in the history
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>
Reviewed-by: Eric Blake <eblake@redhat.com>
  • Loading branch information
kevmw committed Aug 8, 2016
1 parent cf5198d commit bd7c417
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion hw/core/qdev-properties-system.c
Expand Up @@ -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,
Expand Down

0 comments on commit bd7c417

Please sign in to comment.