summaryrefslogtreecommitdiffstats
path: root/hw/core/qdev-properties-system.c
diff options
context:
space:
mode:
authorMarkus Armbruster2014-10-07 13:59:18 +0200
committerKevin Wolf2014-10-20 14:02:25 +0200
commit4be746345f13e99e468c60acbd3a355e8183e3ce (patch)
tree16509218f940129beb113cf3b1be158c3501ec1d /hw/core/qdev-properties-system.c
parentvirtio-blk: Rename VirtIOBlkConf variables to conf (diff)
downloadqemu-4be746345f13e99e468c60acbd3a355e8183e3ce.tar.gz
qemu-4be746345f13e99e468c60acbd3a355e8183e3ce.tar.xz
qemu-4be746345f13e99e468c60acbd3a355e8183e3ce.zip
hw: Convert from BlockDriverState to BlockBackend, mostly
Device models should access their block backends only through the block-backend.h API. Convert them, and drop direct includes of inappropriate headers. Just four uses of BlockDriverState are left: * The Xen paravirtual block device backend (xen_disk.c) opens images itself when set up via xenbus, bypassing blockdev.c. I figure it should go through qmp_blockdev_add() instead. * Device model "usb-storage" prompts for keys. No other device model does, and this one probably shouldn't do it, either. * ide_issue_trim_cb() uses bdrv_aio_discard() instead of blk_aio_discard() because it fishes its backend out of a BlockAIOCB, which has only the BlockDriverState. * PC87312State has an unused BlockDriverState[] member. The next two commits take care of the latter two. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'hw/core/qdev-properties-system.c')
-rw-r--r--hw/core/qdev-properties-system.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index f2bd954be5..65901ef10e 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -13,6 +13,7 @@
#include "net/net.h"
#include "hw/qdev.h"
#include "qapi/qmp/qerror.h"
+#include "sysemu/block-backend.h"
#include "sysemu/blockdev.h"
#include "hw/block/block.h"
#include "net/hub.h"
@@ -68,16 +69,16 @@ static void set_pointer(Object *obj, Visitor *v, Property *prop,
static int parse_drive(DeviceState *dev, const char *str, void **ptr)
{
- BlockDriverState *bs;
+ BlockBackend *blk;
- bs = bdrv_find(str);
- if (bs == NULL) {
+ blk = blk_by_name(str);
+ if (!blk) {
return -ENOENT;
}
- if (bdrv_attach_dev(bs, dev) < 0) {
+ if (blk_attach_dev(blk, dev) < 0) {
return -EEXIST;
}
- *ptr = bs;
+ *ptr = blk;
return 0;
}
@@ -85,17 +86,17 @@ static void release_drive(Object *obj, const char *name, void *opaque)
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- BlockDriverState **ptr = qdev_get_prop_ptr(dev, prop);
+ BlockBackend **ptr = qdev_get_prop_ptr(dev, prop);
if (*ptr) {
- bdrv_detach_dev(*ptr, dev);
+ blk_detach_dev(*ptr, dev);
blockdev_auto_del(*ptr);
}
}
static char *print_drive(void *ptr)
{
- return g_strdup(bdrv_get_device_name(ptr));
+ return g_strdup(blk_name(ptr));
}
static void get_drive(Object *obj, Visitor *v, void *opaque,
@@ -335,12 +336,11 @@ PropertyInfo qdev_prop_vlan = {
};
int qdev_prop_set_drive(DeviceState *dev, const char *name,
- BlockDriverState *value)
+ BlockBackend *value)
{
Error *err = NULL;
- const char *bdrv_name = value ? bdrv_get_device_name(value) : "";
- object_property_set_str(OBJECT(dev), bdrv_name,
- name, &err);
+ object_property_set_str(OBJECT(dev),
+ value ? blk_name(value) : "", name, &err);
if (err) {
qerror_report_err(err);
error_free(err);
@@ -350,7 +350,7 @@ int qdev_prop_set_drive(DeviceState *dev, const char *name,
}
void qdev_prop_set_drive_nofail(DeviceState *dev, const char *name,
- BlockDriverState *value)
+ BlockBackend *value)
{
if (qdev_prop_set_drive(dev, name, value) < 0) {
exit(1);