qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Anthony Liguori <aliguori@us.ibm.com>,
	Markus Armbruster <armbru@redhat.com>
Cc: "Kevin Wolf" <kwolf@redhat.com>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	libvir-list@redhat.com, "Stefan Hajnoczi" <stefanha@gmail.com>,
	qemu-devel@nongnu.org, "Luiz Capitulino" <lcapitulino@redhat.com>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	Andreas =?utf-8?Q?F=C3=A4rber?= <afaerber@suse.de>
Subject: [Qemu-devel] [PATCHv5 3/3] qmp: add path to device_deleted event
Date: Mon, 11 Mar 2013 20:06:14 +0200	[thread overview]
Message-ID: <7280a9f7817eff8410fcac56b3ef7d690d96fb5a.1363025039.git.mst@redhat.com> (raw)
In-Reply-To: <cover.1363025039.git.mst@redhat.com>

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@redhat.com>
---
 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

  parent reply	other threads:[~2013-03-11 18:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-11 18:05 [Qemu-devel] [PATCHv5 0/3] DEVICE_DELETED event Michael S. Tsirkin
2013-03-11 18:05 ` [Qemu-devel] [PATCHv5 1/3] qdev: " Michael S. Tsirkin
2013-03-11 18:06 ` [Qemu-devel] [PATCHv5 2/3] qom: pass original path to unparent method Michael S. Tsirkin
2013-03-11 18:06 ` Michael S. Tsirkin [this message]
2013-03-13  7:45 ` [Qemu-devel] [PATCHv5 0/3] DEVICE_DELETED event Markus Armbruster
2013-03-13 16:41   ` Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7280a9f7817eff8410fcac56b3ef7d690d96fb5a.1363025039.git.mst@redhat.com \
    --to=mst@redhat.com \
    --cc=afaerber@suse.de \
    --cc=aliguori@us.ibm.com \
    --cc=armbru@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=libvir-list@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).