From patchwork Thu Jan 14 16:50:53 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 42917 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 5C057B7CD1 for ; Fri, 15 Jan 2010 04:13:40 +1100 (EST) Received: from localhost ([127.0.0.1]:48641 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NVT17-0002IG-7x for incoming@patchwork.ozlabs.org; Thu, 14 Jan 2010 11:57:53 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NVSvW-0007CU-BK for qemu-devel@nongnu.org; Thu, 14 Jan 2010 11:52:06 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NVSvP-00078H-Ne for qemu-devel@nongnu.org; Thu, 14 Jan 2010 11:52:03 -0500 Received: from [199.232.76.173] (port=44451 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NVSvP-00078A-DD for qemu-devel@nongnu.org; Thu, 14 Jan 2010 11:51:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:27332) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NVSvO-0002Bb-Ip for qemu-devel@nongnu.org; Thu, 14 Jan 2010 11:51:58 -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 o0EGpvVw031870 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 14 Jan 2010 11:51:57 -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 o0EGpuwg023020; Thu, 14 Jan 2010 11:51:56 -0500 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Thu, 14 Jan 2010 14:50:53 -0200 Message-Id: <1263487859-6318-3-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 2/8] VNC: Make 'auth' key mandatory 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 There is no reason to have it as optional and the code in the server and client gets slightly simpler if the key is mandatory. While there also do some cleanup on how the server info is collected. Signed-off-by: Luiz Capitulino --- vnc.c | 26 ++++++++++++++------------ 1 files changed, 14 insertions(+), 12 deletions(-) diff --git a/vnc.c b/vnc.c index ef86ef7..b5f3b64 100644 --- a/vnc.c +++ b/vnc.c @@ -122,7 +122,7 @@ static int put_addr_qdict(QDict *qdict, struct sockaddr_storage *sa, return 0; } -static int vnc_qdict_local_addr(QDict *qdict, int fd) +static int vnc_server_addr_put(QDict *qdict, int fd) { struct sockaddr_storage sa; socklen_t salen; @@ -199,6 +199,16 @@ static const char *vnc_auth_name(VncDisplay *vd) { return "unknown"; } +static int vnc_server_info_put(QDict *qdict) +{ + if (vnc_server_addr_put(qdict, vnc_display->lsock) < 0) { + return -1; + } + + qdict_put(qdict, "auth", qstring_from_str(vnc_auth_name(vnc_display))); + return 0; +} + static QDict *do_info_vnc_client(Monitor *mon, VncState *client) { QDict *qdict; @@ -263,8 +273,7 @@ void do_info_vnc_print(Monitor *mon, const QObject *data) monitor_printf(mon, " address: %s:%s\n", qdict_get_str(server, "host"), qdict_get_str(server, "service")); - monitor_printf(mon, " auth: %s\n", - qdict_haskey(server, "auth") ? qdict_get_str(server, "auth") : "none"); + monitor_printf(mon, " auth: %s\n", qdict_get_str(server, "auth")); clients = qdict_get_qlist(server, "clients"); if (qlist_empty(clients)) { @@ -285,7 +294,7 @@ void do_info_vnc_print(Monitor *mon, const QObject *data) * - "enabled": true or false * - "host": server's IP address * - "service": server's port number - * - "auth": authentication method (optional) + * - "auth": authentication method * - "clients": a QList of all connected clients * * Clients are described by a QDict, with the following information: @@ -323,14 +332,7 @@ void do_info_vnc(Monitor *mon, QObject **ret_data) QOBJECT(clist)); assert(*ret_data != NULL); - qdict = qobject_to_qdict(*ret_data); - - if (vnc_display->auth != VNC_AUTH_NONE) { - qdict_put(qdict, "auth", - qstring_from_str(vnc_auth_name(vnc_display))); - } - - if (vnc_qdict_local_addr(qdict, vnc_display->lsock) < 0) { + if (vnc_server_info_put(qobject_to_qdict(*ret_data)) < 0) { qobject_decref(*ret_data); *ret_data = NULL; }