mirror of https://github.com/xemu-project/xemu.git
qdev: add user-specified identifier to devices.
Add id field to DeviceState. Make "info qtree" print it. This helps users and management apps identifying devices in monitor output, which is especially useful with otherwise identical devices such as two virtio disks. This patch doesn't add a way to set the id, followup patches will do. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
96cc181089
commit
ccb63de38e
|
@ -114,7 +114,8 @@ void qdev_init(DeviceState *dev)
|
||||||
void qdev_free(DeviceState *dev)
|
void qdev_free(DeviceState *dev)
|
||||||
{
|
{
|
||||||
LIST_REMOVE(dev, sibling);
|
LIST_REMOVE(dev, sibling);
|
||||||
free(dev);
|
qemu_free(dev->id);
|
||||||
|
qemu_free(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get a character (serial) device interface. */
|
/* Get a character (serial) device interface. */
|
||||||
|
@ -266,7 +267,8 @@ static void qdev_print_props(Monitor *mon, DeviceState *dev, Property *props,
|
||||||
static void qdev_print(Monitor *mon, DeviceState *dev, int indent)
|
static void qdev_print(Monitor *mon, DeviceState *dev, int indent)
|
||||||
{
|
{
|
||||||
BusState *child;
|
BusState *child;
|
||||||
qdev_printf("dev: %s\n", dev->info->name);
|
qdev_printf("dev: %s, id \"%s\"\n", dev->info->name,
|
||||||
|
dev->id ? dev->id : "");
|
||||||
indent += 2;
|
indent += 2;
|
||||||
if (dev->num_gpio_in) {
|
if (dev->num_gpio_in) {
|
||||||
qdev_printf("gpio-in %d\n", dev->num_gpio_in);
|
qdev_printf("gpio-in %d\n", dev->num_gpio_in);
|
||||||
|
|
|
@ -19,6 +19,7 @@ typedef struct BusInfo BusInfo;
|
||||||
/* This structure should not be accessed directly. We declare it here
|
/* This structure should not be accessed directly. We declare it here
|
||||||
so that it can be embedded in individual device state structures. */
|
so that it can be embedded in individual device state structures. */
|
||||||
struct DeviceState {
|
struct DeviceState {
|
||||||
|
char *id;
|
||||||
DeviceInfo *info;
|
DeviceInfo *info;
|
||||||
BusState *parent_bus;
|
BusState *parent_bus;
|
||||||
int num_gpio_out;
|
int num_gpio_out;
|
||||||
|
|
Loading…
Reference in New Issue