From patchwork Fri Jan 8 21:47:15 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 42540 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 75981B7C19 for ; Sat, 9 Jan 2010 09:04:49 +1100 (EST) Received: from localhost ([127.0.0.1]:38239 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NTMrC-0007ED-KN for incoming@patchwork.ozlabs.org; Fri, 08 Jan 2010 16:58:58 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NTMgO-0002wT-Mi for qemu-devel@nongnu.org; Fri, 08 Jan 2010 16:47:48 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NTMgI-0002tF-Q4 for qemu-devel@nongnu.org; Fri, 08 Jan 2010 16:47:47 -0500 Received: from [199.232.76.173] (port=58800 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NTMgI-0002t8-Do for qemu-devel@nongnu.org; Fri, 08 Jan 2010 16:47:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:32551) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NTMgH-0007hW-TR for qemu-devel@nongnu.org; Fri, 08 Jan 2010 16:47:42 -0500 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o08LlegP008699 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 8 Jan 2010 16:47:41 -0500 Received: from localhost (vpn-11-153.rdu.redhat.com [10.11.11.153]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o08LldoC008131; Fri, 8 Jan 2010 16:47:40 -0500 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Fri, 8 Jan 2010 19:47:15 -0200 Message-Id: <1262987236-2943-7-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1262987236-2943-1-git-send-email-lcapitulino@redhat.com> References: <1262987236-2943-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: aliguori@us.ibm.com Subject: [Qemu-devel] [PATCH 6/7] QMP: Introduce QMP disconnect 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 everytime a VNC client disconnects from QEMU, client's information such as port and IP address is provided. Note that if any kind of authentication is enabled, this event is only emitted if the disconnection happens after the client has been authenticated. For example: { "event": "VNC_DISCONNECT", "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", "sasl_username": "foo" } } } Signed-off-by: Luiz Capitulino --- monitor.c | 3 +++ monitor.h | 1 + vnc.c | 28 ++++++++++++++++++++++++++-- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/monitor.c b/monitor.c index 7536c1e..78fd33a 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_DISCONNECT: + event_name = "VNC_DISCONNECT"; + break; default: abort(); break; diff --git a/monitor.h b/monitor.h index 6ed117a..e836dd6 100644 --- a/monitor.h +++ b/monitor.h @@ -20,6 +20,7 @@ typedef enum MonitorEvent { QEVENT_RESET, QEVENT_POWERDOWN, QEVENT_STOP, + QEVENT_VNC_DISCONNECT, QEVENT_MAX, } MonitorEvent; diff --git a/vnc.c b/vnc.c index f340d08..f2f0ef3 100644 --- a/vnc.c +++ b/vnc.c @@ -1068,6 +1068,29 @@ static void vnc_disconnect_start(VncState *vs) vs->csock = -1; } +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_decref(data); /* will also free 'vs->info' */ +} + static void vnc_disconnect_finish(VncState *vs) { if (vs->input.buffer) { @@ -1078,6 +1101,9 @@ static void vnc_disconnect_finish(VncState *vs) qemu_free(vs->output.buffer); vs->output.buffer = NULL; } + + vnc_qmp_event(vs, QEVENT_VNC_DISCONNECT); + #ifdef CONFIG_VNC_TLS vnc_tls_client_cleanup(vs); #endif /* CONFIG_VNC_TLS */ @@ -1100,8 +1126,6 @@ static void vnc_disconnect_finish(VncState *vs) if (!vs->vd->clients) dcl->idle = 1; - qobject_decref(vs->info); - vnc_remove_timer(vs->vd); qemu_free(vs); }