提交 e2ae6159 编写于 作者: L Laszlo Ersek 提交者: Luiz Capitulino

virtio-serial: report frontend connection state via monitor

Libvirt wants to know about the guest-side connection state of some
virtio-serial ports (in particular the one(s) assigned to guest agent(s)).
Report such states with a new monitor event.

RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1080376Signed-off-by: NLaszlo Ersek <lersek@redhat.com>
Reviewed-by: NEric Blake <eblake@redhat.com>
Reviewed-by: NAmit Shah <amit.shah@redhat.com>
Signed-off-by: NLuiz Capitulino <lcapitulino@redhat.com>
上级 dfab4892
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "qemu/error-report.h" #include "qemu/error-report.h"
#include "trace.h" #include "trace.h"
#include "hw/virtio/virtio-serial.h" #include "hw/virtio/virtio-serial.h"
#include "qapi-event.h"
#define TYPE_VIRTIO_CONSOLE_SERIAL_PORT "virtserialport" #define TYPE_VIRTIO_CONSOLE_SERIAL_PORT "virtserialport"
#define VIRTIO_CONSOLE(obj) \ #define VIRTIO_CONSOLE(obj) \
...@@ -81,11 +82,16 @@ static ssize_t flush_buf(VirtIOSerialPort *port, ...@@ -81,11 +82,16 @@ static ssize_t flush_buf(VirtIOSerialPort *port,
static void set_guest_connected(VirtIOSerialPort *port, int guest_connected) static void set_guest_connected(VirtIOSerialPort *port, int guest_connected)
{ {
VirtConsole *vcon = VIRTIO_CONSOLE(port); VirtConsole *vcon = VIRTIO_CONSOLE(port);
DeviceState *dev = DEVICE(port);
if (!vcon->chr) { if (vcon->chr) {
return; qemu_chr_fe_set_open(vcon->chr, guest_connected);
}
if (dev->id) {
qapi_event_send_vserport_change(dev->id, guest_connected,
&error_abort);
} }
qemu_chr_fe_set_open(vcon->chr, guest_connected);
} }
/* Readiness of the guest to accept data on a port */ /* Readiness of the guest to accept data on a port */
......
...@@ -588,6 +588,7 @@ static void monitor_qapi_event_init(void) ...@@ -588,6 +588,7 @@ static void monitor_qapi_event_init(void)
monitor_qapi_event_throttle(QAPI_EVENT_BALLOON_CHANGE, 1000); monitor_qapi_event_throttle(QAPI_EVENT_BALLOON_CHANGE, 1000);
monitor_qapi_event_throttle(QAPI_EVENT_QUORUM_REPORT_BAD, 1000); monitor_qapi_event_throttle(QAPI_EVENT_QUORUM_REPORT_BAD, 1000);
monitor_qapi_event_throttle(QAPI_EVENT_QUORUM_FAILURE, 1000); monitor_qapi_event_throttle(QAPI_EVENT_QUORUM_FAILURE, 1000);
monitor_qapi_event_throttle(QAPI_EVENT_VSERPORT_CHANGE, 1000);
qmp_event_set_func_emit(monitor_qapi_event_queue); qmp_event_set_func_emit(monitor_qapi_event_queue);
} }
......
...@@ -316,3 +316,17 @@ ...@@ -316,3 +316,17 @@
{ 'event': 'QUORUM_REPORT_BAD', { 'event': 'QUORUM_REPORT_BAD',
'data': { '*error': 'str', 'node-name': 'str', 'data': { '*error': 'str', 'node-name': 'str',
'sector-num': 'int', 'sector-count': 'int' } } 'sector-num': 'int', 'sector-count': 'int' } }
##
# @VSERPORT_CHANGE
#
# Emitted when the guest opens or closes a virtio-serial port.
#
# @id: device identifier of the virtio-serial port
#
# @open: true if the guest has opened the virtio-serial port
#
# Since: 2.1
##
{ 'event': 'VSERPORT_CHANGE',
'data': { 'id': 'str', 'open': 'bool' } }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册