From patchwork Thu Jan 14 16:50:57 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 42914 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 61128B7CD1 for ; Fri, 15 Jan 2010 04:07:22 +1100 (EST) Received: from localhost ([127.0.0.1]:36266 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NVTAF-0005er-Cg for incoming@patchwork.ozlabs.org; Thu, 14 Jan 2010 12:07:19 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NVSvf-0007JC-9l for qemu-devel@nongnu.org; Thu, 14 Jan 2010 11:52:15 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NVSvZ-0007ED-GR for qemu-devel@nongnu.org; Thu, 14 Jan 2010 11:52:13 -0500 Received: from [199.232.76.173] (port=44458 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NVSvY-0007E7-FG for qemu-devel@nongnu.org; Thu, 14 Jan 2010 11:52:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:5733) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NVSvX-0002EG-Ut for qemu-devel@nongnu.org; Thu, 14 Jan 2010 11:52:08 -0500 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 o0EGq7aa023280 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 14 Jan 2010 11:52:07 -0500 Received: from localhost (vpn-10-170.rdu.redhat.com [10.11.10.170]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o0EGq5gd023096; Thu, 14 Jan 2010 11:52:06 -0500 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Thu, 14 Jan 2010 14:50:57 -0200 Message-Id: <1263487859-6318-7-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1263487859-6318-1-git-send-email-lcapitulino@redhat.com> References: <1263487859-6318-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: armbru@redhat.com Subject: [Qemu-devel] [PATCH 6/8] QMP: Introduce VNC_CONNECTED event 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 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 --- 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 8e00f68..4a6af42 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 d37fa60..6d488e5 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; @@ -2396,6 +2420,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;