From 08e4acb73cb4804618b765617ab54bbf0286d71e Mon Sep 17 00:00:00 2001 From: Luiz Capitulino Date: Tue, 26 Jan 2010 18:53:44 -0200 Subject: [PATCH 6/9] QMP: Introduce VNC_CONNECTED event RH-Author: Luiz Capitulino Message-id: <1264532026-7620-7-git-send-email-lcapitulino@redhat.com> Patchwork-id: 6632 O-Subject: [PATCH RHEL6 qemu-kvm 6/8] QMP: Introduce VNC_CONNECTED event Bugzilla: 549759 RH-Acked-by: Markus Armbruster RH-Acked-by: Daniel P. Berrange RH-Acked-by: Juan Quintela It's emitted when a VNC client connects to QEMU, client's information such as port and IP address are provided. Note that this event is emitted right when the connection is established. This means that it happens before authentication procedure and session initialization. Event example: { "event": "VNC_CONNECTED", "timestamp": { "seconds": 1262976601, "microseconds": 975795 }, "data": { "server": { "auth": "sasl", "family": "ipv4", "service": "5901", "host": "0.0.0.0" }, "client": { "family": "ipv4", "service": "58425", "host": "127.0.0.1" } } } Signed-off-by: Luiz Capitulino Signed-off-by: Anthony Liguori (cherry picked from commit 586153d9520c4ec3e4352cffa683b92ef5f23925) --- QMP/qmp-events.txt | 7 +++++++ monitor.c | 3 +++ monitor.h | 1 + vnc.c | 25 +++++++++++++++++++++++++ 4 files changed, 36 insertions(+), 0 deletions(-) Signed-off-by: Eduardo Habkost --- QMP/qmp-events.txt | 7 +++++++ monitor.c | 3 +++ monitor.h | 1 + vnc.c | 25 +++++++++++++++++++++++++ 4 files changed, 36 insertions(+), 0 deletions(-) diff --git a/QMP/qmp-events.txt b/QMP/qmp-events.txt index 682a5e5..d36da46 100644 --- a/QMP/qmp-events.txt +++ b/QMP/qmp-events.txt @@ -24,3 +24,10 @@ Data: None. Description: Issued when the Virtual Machine enters debug mode. Data: None. + +4 VNC_CONNECTED +--------------- + +Description: Issued when a VNC client establishes a connection. +Data: 'server' and 'client' keys with the same keys as 'query-vnc', +except that authentication ID is not provided. diff --git a/monitor.c b/monitor.c index 613ee9d..93347e8 100644 --- a/monitor.c +++ b/monitor.c @@ -357,6 +357,9 @@ void monitor_protocol_event(MonitorEvent event, QObject *data) case QEVENT_STOP: event_name = "STOP"; break; + case QEVENT_VNC_CONNECTED: + event_name = "VNC_CONNECTED"; + break; default: abort(); break; diff --git a/monitor.h b/monitor.h index 6ed117a..4d57679 100644 --- a/monitor.h +++ b/monitor.h @@ -20,6 +20,7 @@ typedef enum MonitorEvent { QEVENT_RESET, QEVENT_POWERDOWN, QEVENT_STOP, + QEVENT_VNC_CONNECTED, QEVENT_MAX, } MonitorEvent; diff --git a/vnc.c b/vnc.c index 8680fee..4bd691a 100644 --- a/vnc.c +++ b/vnc.c @@ -269,6 +269,30 @@ static void vnc_client_cache_addr(VncState *client) client->info = QOBJECT(qdict); } +static void vnc_qmp_event(VncState *vs, MonitorEvent event) +{ + QDict *server; + QObject *data; + + if (!vs->info) { + return; + } + + server = qdict_new(); + if (vnc_server_info_put(server) < 0) { + QDECREF(server); + return; + } + + data = qobject_from_jsonf("{ 'client': %p, 'server': %p }", + vs->info, QOBJECT(server)); + + monitor_protocol_event(event, data); + + qobject_incref(vs->info); + qobject_decref(data); +} + static void info_vnc_iter(QObject *obj, void *opaque) { QDict *client; @@ -2398,6 +2422,7 @@ static void vnc_connect(VncDisplay *vd, int csock) qemu_set_fd_handler2(vs->csock, NULL, vnc_client_read, NULL, vs); vnc_client_cache_addr(vs); + vnc_qmp_event(vs, QEVENT_VNC_CONNECTED); vs->vd = vd; vs->ds = vd->ds; -- 1.6.3.rc4.29.g8146