From patchwork Wed Mar 24 14:49:28 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Shah X-Patchwork-Id: 48429 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 70CD3B7CF1 for ; Thu, 25 Mar 2010 02:11:38 +1100 (EST) Received: from localhost ([127.0.0.1]:38747 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NuSF5-0008AN-8c for incoming@patchwork.ozlabs.org; Wed, 24 Mar 2010 11:11:35 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NuRvj-0001oG-Nt for qemu-devel@nongnu.org; Wed, 24 Mar 2010 10:51:35 -0400 Received: from [140.186.70.92] (port=60903 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NuRvh-0001nN-T5 for qemu-devel@nongnu.org; Wed, 24 Mar 2010 10:51:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NuRvf-0006Ur-JJ for qemu-devel@nongnu.org; Wed, 24 Mar 2010 10:51:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:26335) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NuRvf-0006Uh-BT for qemu-devel@nongnu.org; Wed, 24 Mar 2010 10:51:31 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2OEpUWw009139 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 24 Mar 2010 10:51:30 -0400 Received: from localhost (vpn-11-150.rdu.redhat.com [10.11.11.150]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2OEpSGI029888; Wed, 24 Mar 2010 10:51:29 -0400 From: Amit Shah To: qemu list Date: Wed, 24 Mar 2010 20:19:28 +0530 Message-Id: <1269442173-18421-11-git-send-email-amit.shah@redhat.com> In-Reply-To: <1269442173-18421-10-git-send-email-amit.shah@redhat.com> References: <1269442173-18421-1-git-send-email-amit.shah@redhat.com> <1269442173-18421-2-git-send-email-amit.shah@redhat.com> <1269442173-18421-3-git-send-email-amit.shah@redhat.com> <1269442173-18421-4-git-send-email-amit.shah@redhat.com> <1269442173-18421-5-git-send-email-amit.shah@redhat.com> <1269442173-18421-6-git-send-email-amit.shah@redhat.com> <1269442173-18421-7-git-send-email-amit.shah@redhat.com> <1269442173-18421-8-git-send-email-amit.shah@redhat.com> <1269442173-18421-9-git-send-email-amit.shah@redhat.com> <1269442173-18421-10-git-send-email-amit.shah@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Amit Shah , Luiz Capitulino , Juan Quintela , Gerd Hoffmann , "Michael S. Tsirkin" Subject: [Qemu-devel] [PATCH 10/15] virtio-serial: Add QMP events for failed port/device add X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org When adding a port or a device to the guest fails, management software might be interested in knowing and then cleaning up the host-side of the port. Introduce QMP events to signal such errors. Signed-off-by: Amit Shah CC: Luiz Capitulino --- QMP/qmp-events.txt | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ hw/virtio-serial-bus.c | 15 +++++++++++++++ monitor.c | 3 +++ monitor.h | 1 + 4 files changed, 67 insertions(+), 0 deletions(-) diff --git a/QMP/qmp-events.txt b/QMP/qmp-events.txt index a94e9b4..f13cf45 100644 --- a/QMP/qmp-events.txt +++ b/QMP/qmp-events.txt @@ -188,3 +188,51 @@ Example: Note: If action is "reset", "shutdown", or "pause" the WATCHDOG event is followed respectively by the RESET, SHUTDOWN, or STOP events. + +VIRTIO_SERIAL +------------- + +Emitted when errors occur in guest port add or guest device add. + +Data: + +- "device": The virtio-serial device that triggered the event {json-string} + This is the name given to the bus on the command line: + -device virtio-serial,id="foo" + here, the device name is "foo" + +- "port": The port number that triggered the event {json-number} + This is the number given to the port on the command line: + -device virtserialport,nr=2 + here, the port number is 2. If not mentioned on the command + line, the number is auto-assigned. + +- "result": The result of the operation {json-string} + This is one of the following: + "pass", "fail" + +- "operation": The operation that triggered the event {json-sring} + This is one of the following: + "port_add", "device_add" + +Example: + +Port 0 add failure in the guest: + +{ "timestamp": {"seconds": 1269438649, "microseconds": 851170}, + "event": "VIRTIO_SERIAL", + "data": { + "device": "virtio-serial-bus.0", + "port": 0, + "result": "fail", + "operation": "port_add" } } + +Device add failure in the guest: + +{ "timestamp": {"seconds": 1269438702, "microseconds": 78114}, + "event": "VIRTIO_SERIAL", + "data": { + "device": "virtio-serial-bus.0", + "port": 4294967295, + "result": "fail", + "operation": "device_add" } } diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c index 33083af..efcc66c 100644 --- a/hw/virtio-serial-bus.c +++ b/hw/virtio-serial-bus.c @@ -16,6 +16,7 @@ */ #include "monitor.h" +#include "qemu-objects.h" #include "qemu-queue.h" #include "sysbus.h" #include "virtio-serial.h" @@ -204,6 +205,17 @@ size_t virtio_serial_guest_ready(VirtIOSerialPort *port) return 0; } +static void mon_event(const char *device, const uint32_t port_id, + const char *operation, const char *result) +{ + QObject *data; + + data = qobject_from_jsonf("{ 'device': %s, 'port': %ld, 'operation': %s, 'result': %s }", + device, (int64_t)port_id, operation, result); + monitor_protocol_event(QEVENT_VIRTIO_SERIAL, data); + qobject_decref(data); +} + /* Guest wants to notify us of some event */ static void handle_control_message(VirtIOSerial *vser, void *buf) { @@ -226,6 +238,8 @@ static void handle_control_message(VirtIOSerial *vser, void *buf) if (!cpkt.value) { error_report("virtio-serial-bus: Guest failure in adding device %s\n", vser->bus->qbus.name); + mon_event(vser->bus->qbus.name, VIRTIO_CONSOLE_BAD_ID, + "device_add", "fail"); break; } /* @@ -241,6 +255,7 @@ static void handle_control_message(VirtIOSerial *vser, void *buf) if (!cpkt.value) { error_report("virtio-serial-bus: Guest failure in adding port %u for device %s\n", port->id, vser->bus->qbus.name); + mon_event(vser->bus->qbus.name, port->id, "port_add", "fail"); break; } /* diff --git a/monitor.c b/monitor.c index 0448a70..9e5bfe7 100644 --- a/monitor.c +++ b/monitor.c @@ -441,6 +441,9 @@ void monitor_protocol_event(MonitorEvent event, QObject *data) case QEVENT_WATCHDOG: event_name = "WATCHDOG"; break; + case QEVENT_VIRTIO_SERIAL: + event_name = "VIRTIO_SERIAL"; + break; default: abort(); break; diff --git a/monitor.h b/monitor.h index bd4ae34..ea4df8a 100644 --- a/monitor.h +++ b/monitor.h @@ -28,6 +28,7 @@ typedef enum MonitorEvent { QEVENT_BLOCK_IO_ERROR, QEVENT_RTC_CHANGE, QEVENT_WATCHDOG, + QEVENT_VIRTIO_SERIAL, QEVENT_MAX, } MonitorEvent;