aboutsummaryrefslogtreecommitdiff
path: root/hw/qdev.c
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2013-03-06 14:58:59 +0200
committerMichael S. Tsirkin <mst@redhat.com>2013-03-17 13:27:27 +0200
commit0402a5d65ec004df5345d1f736e2ddaa7aee6665 (patch)
tree585662c4509f2033a15c317a576d2473b4dbb8dc /hw/qdev.c
parentb1999e87b4d42305419329cae459e1b43f706d96 (diff)
qdev: DEVICE_DELETED event
libvirt has a long-standing bug: when removing the device, it can request removal but does not know when the removal completes. Add an event so we can fix this in a robust way. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/qdev.c')
-rw-r--r--hw/qdev.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/hw/qdev.c b/hw/qdev.c
index 0b20280133..5e8a89c06e 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -30,6 +30,8 @@
#include "qapi/error.h"
#include "qapi/qmp/qerror.h"
#include "qapi/visitor.h"
+#include "qapi/qmp/qjson.h"
+#include "monitor/monitor.h"
int qdev_hotplug = 0;
static bool qdev_hot_added = false;
@@ -761,6 +763,7 @@ static void device_unparent(Object *obj)
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,6 +782,14 @@ static void device_unparent(Object *obj)
object_unref(OBJECT(dev->parent_bus));
dev->parent_bus = NULL;
}
+
+ if (dev->id) {
+ event_data = qobject_from_jsonf("{ 'device': %s }", dev->id);
+ } else {
+ event_data = qobject_from_jsonf("{ }");
+ }
+ monitor_protocol_event(QEVENT_DEVICE_DELETED, event_data);
+ qobject_decref(event_data);
}
static void device_class_init(ObjectClass *class, void *data)