From patchwork Mon Mar 11 18:06:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 226631 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 284132C0292 for ; Tue, 12 Mar 2013 05:06:47 +1100 (EST) Received: from localhost ([::1]:52948 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UF77V-0008Lx-6x for incoming@patchwork.ozlabs.org; Mon, 11 Mar 2013 14:06:45 -0400 Received: from eggs.gnu.org ([208.118.235.92]:58425) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UF76w-0008BV-I4 for qemu-devel@nongnu.org; Mon, 11 Mar 2013 14:06:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UF76j-000834-15 for qemu-devel@nongnu.org; Mon, 11 Mar 2013 14:06:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:3348) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UF76i-000829-QY for qemu-devel@nongnu.org; Mon, 11 Mar 2013 14:05:56 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r2BI5tZa029533 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 11 Mar 2013 14:05:55 -0400 Received: from redhat.com (vpn1-7-40.ams2.redhat.com [10.36.7.40]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id r2BI5nlk006273; Mon, 11 Mar 2013 14:05:50 -0400 Date: Mon, 11 Mar 2013 20:06:14 +0200 From: "Michael S. Tsirkin" To: Anthony Liguori , Markus Armbruster Message-ID: <7280a9f7817eff8410fcac56b3ef7d690d96fb5a.1363025039.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Eduardo Habkost , libvir-list@redhat.com, Stefan Hajnoczi , qemu-devel@nongnu.org, Luiz Capitulino , Gerd Hoffmann , Paolo Bonzini , Andreas =?us-ascii?B?PT91dGYtOD9RP0Y9QzM9QTRyYmVyPz0=?= Subject: [Qemu-devel] [PATCHv5 3/3] qmp: add path to device_deleted event X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- 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)