mirror of
https://github.com/mii443/qemu.git
synced 2025-12-03 11:08:25 +00:00
qdev-monitor: Add blk_by_qdev_id()
This finds the BlockBackend attached to the device model identified by its qdev ID. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include "qemu/config-file.h"
|
||||
#include "qemu/error-report.h"
|
||||
#include "qemu/help_option.h"
|
||||
#include "sysemu/block-backend.h"
|
||||
|
||||
/*
|
||||
* Aliases were a bad idea from the start. Let's keep them
|
||||
@@ -838,6 +839,23 @@ void qmp_device_del(const char *id, Error **errp)
|
||||
}
|
||||
}
|
||||
|
||||
BlockBackend *blk_by_qdev_id(const char *id, Error **errp)
|
||||
{
|
||||
DeviceState *dev;
|
||||
BlockBackend *blk;
|
||||
|
||||
dev = find_device_state(id, errp);
|
||||
if (dev == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
blk = blk_by_dev(dev);
|
||||
if (!blk) {
|
||||
error_setg(errp, "Device does not have a block device backend");
|
||||
}
|
||||
return blk;
|
||||
}
|
||||
|
||||
void qdev_machine_init(void)
|
||||
{
|
||||
qdev_get_peripheral_anon();
|
||||
|
||||
Reference in New Issue
Block a user