Commit ccb63de38e63bd8cdcd3db7aeaebc8a34a02ded8
Committed by
Anthony Liguori
1 parent
96cc1810
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>
Showing
2 changed files
with
5 additions
and
2 deletions
hw/qdev.c
... | ... | @@ -114,7 +114,8 @@ void qdev_init(DeviceState *dev) |
114 | 114 | void qdev_free(DeviceState *dev) |
115 | 115 | { |
116 | 116 | LIST_REMOVE(dev, sibling); |
117 | - free(dev); | |
117 | + qemu_free(dev->id); | |
118 | + qemu_free(dev); | |
118 | 119 | } |
119 | 120 | |
120 | 121 | /* Get a character (serial) device interface. */ |
... | ... | @@ -266,7 +267,8 @@ static void qdev_print_props(Monitor *mon, DeviceState *dev, Property *props, |
266 | 267 | static void qdev_print(Monitor *mon, DeviceState *dev, int indent) |
267 | 268 | { |
268 | 269 | BusState *child; |
269 | - qdev_printf("dev: %s\n", dev->info->name); | |
270 | + qdev_printf("dev: %s, id \"%s\"\n", dev->info->name, | |
271 | + dev->id ? dev->id : ""); | |
270 | 272 | indent += 2; |
271 | 273 | if (dev->num_gpio_in) { |
272 | 274 | qdev_printf("gpio-in %d\n", dev->num_gpio_in); | ... | ... |
hw/qdev.h
... | ... | @@ -19,6 +19,7 @@ typedef struct BusInfo BusInfo; |
19 | 19 | /* This structure should not be accessed directly. We declare it here |
20 | 20 | so that it can be embedded in individual device state structures. */ |
21 | 21 | struct DeviceState { |
22 | + char *id; | |
22 | 23 | DeviceInfo *info; |
23 | 24 | BusState *parent_bus; |
24 | 25 | int num_gpio_out; | ... | ... |