block/qdev: Allow node name for drive properties
commit8daea510951dd309a44cea8de415c685c43851cf
authorKevin Wolf <kwolf@redhat.com>
Tue, 21 Jun 2016 18:46:05 +0000 (21 20:46 +0200)
committerKevin Wolf <kwolf@redhat.com>
Wed, 13 Jul 2016 11:28:00 +0000 (13 13:28 +0200)
treeea98591f6d38d987d463f1a481f896d79b28a331
parent0b8b8753e4d94901627b3e86431230f2319215c4
block/qdev: Allow node name for drive properties

If a node name instead of a BlockBackend name is specified as the driver
for a guest device, an anonymous BlockBackend is created now.

The order of operations in release_drive() must be reversed in order to
avoid a use-after-free bug because now blk_detach_dev() frees the last
reference if an anonymous BlockBackend is used.

usb-storage uses a hack where it forwards its BlockBackend as a property
to another device that it internally creates. This hack must be updated
so that it doesn't drop its original BB before it can be passed to the
other device. This used to work because we always had the monitor
reference around, but with node-names the device reference is the only
one now.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
hw/core/qdev-properties-system.c
hw/usb/dev-storage.c