Add QOM path to device deleted event. It now becomes useful to report it for devices which don't have an ID assigned. Signed-off-by: Michael S. Tsirkin <mst@xxxxxxxxxx> --- QMP/qmp-events.txt | 9 +++++---- hw/qdev.c | 11 ++++++++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/QMP/qmp-events.txt b/QMP/qmp-events.txt index 0ab5017..dcc826d 100644 --- a/QMP/qmp-events.txt +++ b/QMP/qmp-events.txt @@ -140,17 +140,18 @@ DEVICE_DELETED ----------------- Emitted whenever the device removal completion is acknowledged -by the guest. This event is only emitted for devices with -a user-specified ID. +by the guest. At this point, it's safe to reuse the specified device ID. Device removal can be initiated by the guest or by HMP/QMP commands. Data: -- "device": device name (json-string) +- "device": device name (json-string, optional) +- "path": device path (json-string) { "event": "DEVICE_DELETED", - "data": { "device": "virtio-net-pci-0" }, + "data": { "device": "virtio-net-pci-0", + "path": "/machine/peripheral/virtio-net-pci-0" }, "timestamp": { "seconds": 1265044230, "microseconds": 450486 } } DEVICE_TRAY_MOVED diff --git a/hw/qdev.c b/hw/qdev.c index 8ee8a97..2c861c1 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -761,6 +761,7 @@ static void device_unparent(Object *obj, const char *path) DeviceState *dev = DEVICE(obj); DeviceClass *dc = DEVICE_GET_CLASS(dev); BusState *bus; + QObject *event_data; while (dev->num_child_bus) { bus = QLIST_FIRST(&dev->child_bus); @@ -779,11 +780,15 @@ static void device_unparent(Object *obj, const char *path) object_unref(OBJECT(dev->parent_bus)); dev->parent_bus = NULL; } + if (dev->id) { - QObject *data = qobject_from_jsonf("{ 'device': %s }", dev->id); - monitor_protocol_event(QEVENT_DEVICE_DELETED, data); - qobject_decref(data); + event_data = qobject_from_jsonf("{ 'device': %s, 'path': %s }", + dev->id, path); + } else { + event_data = qobject_from_jsonf("{ 'path': %s }", path); } + monitor_protocol_event(QEVENT_DEVICE_DELETED, event_data); + qobject_decref(event_data); } static void device_class_init(ObjectClass *class, void *data) -- MST -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list