From patchwork Thu Jan 22 11:04:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 431761 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id E334C1402A5 for ; Thu, 22 Jan 2015 22:05:07 +1100 (AEDT) Received: from localhost ([::1]:52303 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEFZR-0007dh-15 for incoming@patchwork.ozlabs.org; Thu, 22 Jan 2015 06:05:05 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38516) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEFYl-0006M8-Fq for qemu-devel@nongnu.org; Thu, 22 Jan 2015 06:04:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YEFYf-0002ZW-3P for qemu-devel@nongnu.org; Thu, 22 Jan 2015 06:04:23 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38700) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEFYe-0002Z5-Qo for qemu-devel@nongnu.org; Thu, 22 Jan 2015 06:04:17 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0MB4EVZ007509 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 22 Jan 2015 06:04:14 -0500 Received: from nilsson.home.kraxel.org (ovpn-116-36.ams2.redhat.com [10.36.116.36]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t0MB4DMe021421; Thu, 22 Jan 2015 06:04:13 -0500 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 0927780E6B; Thu, 22 Jan 2015 12:04:11 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 22 Jan 2015 12:04:06 +0100 Message-Id: <1421924648-21963-9-git-send-email-kraxel@redhat.com> In-Reply-To: <1421924648-21963-1-git-send-email-kraxel@redhat.com> References: <1421924648-21963-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Gerd Hoffmann , Anthony Liguori Subject: [Qemu-devel] [PULL 08/10] vnc: factor out qmp_query_client_list X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org so we can reuse it for the new vnc query command. Signed-off-by: Gerd Hoffmann --- ui/vnc.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/ui/vnc.c b/ui/vnc.c index 8c40c8f..cd757a3 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -385,6 +385,20 @@ static VncDisplay *vnc_display_find(const char *id) return NULL; } +static VncClientInfoList *qmp_query_client_list(VncDisplay *vd) +{ + VncClientInfoList *cinfo, *prev = NULL; + VncState *client; + + QTAILQ_FOREACH(client, &vd->clients, next) { + cinfo = g_new0(VncClientInfoList, 1); + cinfo->value = qmp_query_vnc_client(client); + cinfo->next = prev; + prev = cinfo; + } + return prev; +} + VncInfo *qmp_query_vnc(Error **errp) { VncInfo *info = g_malloc0(sizeof(*info)); @@ -393,30 +407,16 @@ VncInfo *qmp_query_vnc(Error **errp) if (vd == NULL || vd->display == NULL) { info->enabled = false; } else { - VncClientInfoList *cur_item = NULL; struct sockaddr_storage sa; socklen_t salen = sizeof(sa); char host[NI_MAXHOST]; char serv[NI_MAXSERV]; - VncState *client; info->enabled = true; /* for compatibility with the original command */ info->has_clients = true; - - QTAILQ_FOREACH(client, &vd->clients, next) { - VncClientInfoList *cinfo = g_malloc0(sizeof(*info)); - cinfo->value = qmp_query_vnc_client(client); - - /* XXX: waiting for the qapi to support GSList */ - if (!cur_item) { - info->clients = cur_item = cinfo; - } else { - cur_item->next = cinfo; - cur_item = cinfo; - } - } + info->clients = qmp_query_client_list(vd); if (vd->lsock == -1) { return info;