|
|
9ae3a8 |
From b9295fa6535d7092f9234e63ed6b5670bd862d0c Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
Date: Tue, 22 Jul 2014 18:31:22 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 02/11] virtio-serial: report frontend connection state via monitor
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Message-id: <1406053883-21237-2-git-send-email-lersek@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 60229
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.1 qemu-kvm PATCH 1/2] virtio-serial: report frontend connection state via monitor
|
|
|
9ae3a8 |
Bugzilla: 1122151
|
|
|
9ae3a8 |
RH-Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Amit Shah <amit.shah@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Eric Blake <eblake@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Libvirt wants to know about the guest-side connection state of some
|
|
|
9ae3a8 |
virtio-serial ports (in particular the one(s) assigned to guest agent(s)).
|
|
|
9ae3a8 |
Report such states with a new monitor event.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1080376
|
|
|
9ae3a8 |
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Amit Shah <amit.shah@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RHEL-7 notes: manual reimplementation of upstream commit
|
|
|
9ae3a8 |
e2ae6159de2482ee5e22532301eb7f2795828d07, because we don't have Wenchao
|
|
|
9ae3a8 |
Xia's qapi-event series.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
include/monitor/monitor.h | 1 +
|
|
|
9ae3a8 |
hw/char/virtio-console.c | 17 ++++++++++++++---
|
|
|
9ae3a8 |
monitor.c | 2 ++
|
|
|
9ae3a8 |
QMP/qmp-events.txt | 16 ++++++++++++++++
|
|
|
9ae3a8 |
4 files changed, 33 insertions(+), 3 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
QMP/qmp-events.txt | 16 ++++++++++++++++
|
|
|
9ae3a8 |
hw/char/virtio-console.c | 17 ++++++++++++++---
|
|
|
9ae3a8 |
include/monitor/monitor.h | 1 +
|
|
|
9ae3a8 |
monitor.c | 2 ++
|
|
|
9ae3a8 |
4 files changed, 33 insertions(+), 3 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/QMP/qmp-events.txt b/QMP/qmp-events.txt
|
|
|
9ae3a8 |
index fc4b7db..ec4e4b9 100644
|
|
|
9ae3a8 |
--- a/QMP/qmp-events.txt
|
|
|
9ae3a8 |
+++ b/QMP/qmp-events.txt
|
|
|
9ae3a8 |
@@ -485,6 +485,22 @@ Example:
|
|
|
9ae3a8 |
"host": "127.0.0.1", "sasl_username": "luiz" } },
|
|
|
9ae3a8 |
"timestamp": { "seconds": 1263475302, "microseconds": 150772 } }
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+VSERPORT_CHANGE
|
|
|
9ae3a8 |
+---------------
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+Emitted when the guest opens or closes a virtio-serial port.
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+Data:
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+- "id": device identifier of the virtio-serial port (json-string)
|
|
|
9ae3a8 |
+- "open": true if the guest has opened the virtio-serial port (json-bool)
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+Example:
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+{ "event": "VSERPORT_CHANGE",
|
|
|
9ae3a8 |
+ "data": { "id": "channel0", "open": true },
|
|
|
9ae3a8 |
+ "timestamp": { "seconds": 1401385907, "microseconds": 422329 } }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
WAKEUP
|
|
|
9ae3a8 |
------
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/hw/char/virtio-console.c b/hw/char/virtio-console.c
|
|
|
9ae3a8 |
index 2e00ad2..1b01dcd 100644
|
|
|
9ae3a8 |
--- a/hw/char/virtio-console.c
|
|
|
9ae3a8 |
+++ b/hw/char/virtio-console.c
|
|
|
9ae3a8 |
@@ -14,6 +14,8 @@
|
|
|
9ae3a8 |
#include "qemu/error-report.h"
|
|
|
9ae3a8 |
#include "trace.h"
|
|
|
9ae3a8 |
#include "hw/virtio/virtio-serial.h"
|
|
|
9ae3a8 |
+#include "monitor/monitor.h"
|
|
|
9ae3a8 |
+#include "qapi/qmp/qjson.h"
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
typedef struct VirtConsole {
|
|
|
9ae3a8 |
VirtIOSerialPort port;
|
|
|
9ae3a8 |
@@ -76,11 +78,20 @@ static ssize_t flush_buf(VirtIOSerialPort *port,
|
|
|
9ae3a8 |
static void set_guest_connected(VirtIOSerialPort *port, int guest_connected)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
|
|
|
9ae3a8 |
+ DeviceState *dev = DEVICE(port);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- if (!vcon->chr) {
|
|
|
9ae3a8 |
- return;
|
|
|
9ae3a8 |
+ if (vcon->chr) {
|
|
|
9ae3a8 |
+ qemu_chr_fe_set_open(vcon->chr, guest_connected);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
- qemu_chr_fe_set_open(vcon->chr, guest_connected);
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ if (dev->id) {
|
|
|
9ae3a8 |
+ QObject *data;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ data = qobject_from_jsonf("{ 'id': %s, 'open': %i }",
|
|
|
9ae3a8 |
+ dev->id, guest_connected);
|
|
|
9ae3a8 |
+ monitor_protocol_event(QEVENT_VSERPORT_CHANGE, data);
|
|
|
9ae3a8 |
+ qobject_decref(data);
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
/* Readiness of the guest to accept data on a port */
|
|
|
9ae3a8 |
diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h
|
|
|
9ae3a8 |
index dcce609..6c128e9 100644
|
|
|
9ae3a8 |
--- a/include/monitor/monitor.h
|
|
|
9ae3a8 |
+++ b/include/monitor/monitor.h
|
|
|
9ae3a8 |
@@ -52,6 +52,7 @@ typedef enum MonitorEvent {
|
|
|
9ae3a8 |
QEVENT_SPICE_MIGRATE_COMPLETED,
|
|
|
9ae3a8 |
QEVENT_GUEST_PANICKED,
|
|
|
9ae3a8 |
QEVENT_BLOCK_IMAGE_CORRUPTED,
|
|
|
9ae3a8 |
+ QEVENT_VSERPORT_CHANGE,
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
/* Add to 'monitor_event_names' array in monitor.c when
|
|
|
9ae3a8 |
* defining new events here */
|
|
|
9ae3a8 |
diff --git a/monitor.c b/monitor.c
|
|
|
9ae3a8 |
index a6abfb5..798885d 100644
|
|
|
9ae3a8 |
--- a/monitor.c
|
|
|
9ae3a8 |
+++ b/monitor.c
|
|
|
9ae3a8 |
@@ -506,6 +506,7 @@ static const char *monitor_event_names[] = {
|
|
|
9ae3a8 |
[QEVENT_SPICE_MIGRATE_COMPLETED] = "SPICE_MIGRATE_COMPLETED",
|
|
|
9ae3a8 |
[QEVENT_GUEST_PANICKED] = "GUEST_PANICKED",
|
|
|
9ae3a8 |
[QEVENT_BLOCK_IMAGE_CORRUPTED] = "BLOCK_IMAGE_CORRUPTED",
|
|
|
9ae3a8 |
+ [QEVENT_VSERPORT_CHANGE] = "VSERPORT_CHANGE",
|
|
|
9ae3a8 |
};
|
|
|
9ae3a8 |
QEMU_BUILD_BUG_ON(ARRAY_SIZE(monitor_event_names) != QEVENT_MAX)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -642,6 +643,7 @@ static void monitor_protocol_event_init(void)
|
|
|
9ae3a8 |
monitor_protocol_event_throttle(QEVENT_RTC_CHANGE, 1000);
|
|
|
9ae3a8 |
monitor_protocol_event_throttle(QEVENT_BALLOON_CHANGE, 1000);
|
|
|
9ae3a8 |
monitor_protocol_event_throttle(QEVENT_WATCHDOG, 1000);
|
|
|
9ae3a8 |
+ monitor_protocol_event_throttle(QEVENT_VSERPORT_CHANGE, 1000);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
/**
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|