diff options
| author | Anthony Liguori <aliguori@us.ibm.com> | 2013-03-27 11:36:14 -0500 |
|---|---|---|
| committer | Anthony Liguori <aliguori@us.ibm.com> | 2013-04-02 08:15:25 -0500 |
| commit | b1ee58290d7cc2c6b1231fd701987c1753ad9ae3 (patch) | |
| tree | 1177e6794c1969010c5d198bcc375aefec3f9b89 | |
| parent | 8f0605cc9caacbcc647a6df9ae541ed2da4b9bb0 (diff) | |
| download | focaccia-qemu-b1ee58290d7cc2c6b1231fd701987c1753ad9ae3.tar.gz focaccia-qemu-b1ee58290d7cc2c6b1231fd701987c1753ad9ae3.zip | |
qdev: only send deleted event if device was realized
Reported-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Message-id: 1364402174-16580-1-git-send-email-aliguori@us.ibm.com
| -rw-r--r-- | hw/qdev.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/hw/qdev.c b/hw/qdev.c index 9b0f65246a..e2bb37dc37 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -767,7 +767,7 @@ static void device_unparent(Object *obj) DeviceClass *dc = DEVICE_GET_CLASS(dev); BusState *bus; QObject *event_data; - gchar *path = object_get_canonical_path(obj); + bool have_realized = dev->realized; while (dev->num_child_bus) { bus = QLIST_FIRST(&dev->child_bus); @@ -787,15 +787,20 @@ static void device_unparent(Object *obj) dev->parent_bus = NULL; } - if (dev->id) { - event_data = qobject_from_jsonf("{ 'device': %s, 'path': %s }", - dev->id, path); - } else { - event_data = qobject_from_jsonf("{ 'path': %s }", path); + /* Only send event if the device had been completely realized */ + if (have_realized) { + gchar *path = object_get_canonical_path(OBJECT(dev)); + + if (dev->id) { + 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); + g_free(path); } - monitor_protocol_event(QEVENT_DEVICE_DELETED, event_data); - qobject_decref(event_data); - g_free(path); } static void device_class_init(ObjectClass *class, void *data) |