qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 10/15] virtio-serial: Add QMP events for failed port


From: Amit Shah
Subject: [Qemu-devel] [PATCH 10/15] virtio-serial: Add QMP events for failed port/device add
Date: Wed, 24 Mar 2010 20:19:28 +0530

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 <address@hidden>
CC: Luiz Capitulino <address@hidden>
---
 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;
 
-- 
1.6.2.5





reply via email to

[Prev in Thread] Current Thread [Next in Thread]