]> Git Repo - qemu.git/commitdiff
qdev: add user-specified identifier to devices.
authorGerd Hoffmann <[email protected]>
Wed, 15 Jul 2009 11:43:34 +0000 (13:43 +0200)
committerAnthony Liguori <[email protected]>
Thu, 16 Jul 2009 22:28:53 +0000 (17:28 -0500)
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 <[email protected]>
Signed-off-by: Anthony Liguori <[email protected]>
hw/qdev.c
hw/qdev.h

index b76ba5bb3ead3d9f9c9c5da11b1850e13b07b912..001c74ce0e69a72264c13019b6a4cbb2e7140a81 100644 (file)
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -114,7 +114,8 @@ void qdev_init(DeviceState *dev)
 void qdev_free(DeviceState *dev)
 {
     LIST_REMOVE(dev, sibling);
-    free(dev);
+    qemu_free(dev->id);
+    qemu_free(dev);
 }
 
 /* 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)
 {
     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;
     if (dev->num_gpio_in) {
         qdev_printf("gpio-in %d\n", dev->num_gpio_in);
index 73d19fa6990f198edd406e68a75d564c3ffaffb5..11744fa5396c7b92677dc3e96f03c1e09b2f2196 100644 (file)
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -19,6 +19,7 @@ typedef struct BusInfo BusInfo;
 /* This structure should not be accessed directly.  We declare it here
    so that it can be embedded in individual device state structures.  */
 struct DeviceState {
+    char *id;
     DeviceInfo *info;
     BusState *parent_bus;
     int num_gpio_out;
This page took 0.029623 seconds and 4 git commands to generate.