From patchwork Mon Jun 6 12:01:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 9157985 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 71FF060572 for ; Mon, 6 Jun 2016 12:01:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6372225218 for ; Mon, 6 Jun 2016 12:01:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 583A4254F7; Mon, 6 Jun 2016 12:01:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EC80325218 for ; Mon, 6 Jun 2016 12:01:52 +0000 (UTC) Received: from localhost ([::1]:41778 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9tE8-0007Ra-5x for patchwork-qemu-devel@patchwork.kernel.org; Mon, 06 Jun 2016 08:01:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47489) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9tDb-0007Nw-QA for qemu-devel@nongnu.org; Mon, 06 Jun 2016 08:01:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b9tDX-0003Em-SI for qemu-devel@nongnu.org; Mon, 06 Jun 2016 08:01:19 -0400 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:33874) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9tDX-0003Eg-IM for qemu-devel@nongnu.org; Mon, 06 Jun 2016 08:01:15 -0400 Received: by mail-wm0-x244.google.com with SMTP id n184so15906836wmn.1 for ; Mon, 06 Jun 2016 05:01:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id; bh=AnuZYcOBkk8n/sZ/U6mdn8LP/JhQE8H5QYaYOMTJuQI=; b=fy88Sgy7Gixz9w5JLp5pkdxwRrFRs9eOKfZBe9fV1cTc9H4vJONzS/A7GXpb62amDv HWFMJj4RD3AsK1AXJMfgJIaPjaaMG6vzygCwmLkouYRnegBD/SPfVYaR8kDcmccYQwYY J+kznq1QhwI59TBUP3hD69eb0M2ioUEaFXfO/E3v3okUQGZarHO+0YuR0oVi5TKiW1J/ zxYBPbvPoVekot0npv4xy/MMXpguG5K8aqD62a4L7OZk9Z1F1fWqJXTuLgF1DKzNEUog 9gaFwHQl95+Gul+mo2AvQ3ovjOtqbCeygzu4u09yANxm6txhCUWWXXch5LHVuQiCxKg1 BloA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:subject:date:message-id; bh=AnuZYcOBkk8n/sZ/U6mdn8LP/JhQE8H5QYaYOMTJuQI=; b=TbRY51Tt1oHaPwBBP/RYT6y0cYykajRl7DeidScpCFmqPlV/frYumBC6mM4t0+Mu3i /BFA9IAgasDfnHB0zqXbRbcRxZGCmr0efL4GamMDgn5VDhQfcJOWuhm5Qp+GGYWrgF6A 0pp2or0t4kIVIWaQWAfj7zNUx+MZa8TgD3rOqhPZO9ajIv/+MHYQA8W+2Fkh3rL1NlN1 iV/ln6G3iw3bsXFu2K9MR/M9k0ZeTTznFw7aC7sttxIMdlA09VnRXQBgGx/PfQWGX3zE e3wX1VVvGYksz3wLHj77xwV0HWi8w37mKg0UYzwrF3u05JJG5xXKOv2ruWnz74OP5V1E s8Zw== X-Gm-Message-State: ALyK8tLUeuHnjln69rgQBF2h2osa3IOyuKXg6A0cFyd2sWkN7lPU8nYzvanm88g7wAuUrg== X-Received: by 10.28.186.132 with SMTP id k126mr11779325wmf.103.1465214474739; Mon, 06 Jun 2016 05:01:14 -0700 (PDT) Received: from donizetti.lan (94-39-188-118.adsl-ull.clienti.tiscali.it. [94.39.188.118]) by smtp.gmail.com with ESMTPSA id u6sm19922590wjy.17.2016.06.06.05.01.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Jun 2016 05:01:14 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 6 Jun 2016 14:01:10 +0200 Message-Id: <1465214470-12515-1-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 2.5.5 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::244 Subject: [Qemu-devel] [PATCH] vnc: generalize "VNC server running on ..." message X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The message is useful whenever the user specifies "-vnc to=XX". Move it to ui/vnc.c. Signed-off-by: Paolo Bonzini --- include/ui/console.h | 7 ------- ui/vnc.c | 16 ++++++++-------- vl.c | 7 ------- 3 files changed, 8 insertions(+), 22 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index 52a5f65..7c1fdba 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -460,7 +460,6 @@ void vnc_display_add_client(const char *id, int csock, bool skipauth); #ifdef CONFIG_VNC int vnc_display_password(const char *id, const char *password); int vnc_display_pw_expire(const char *id, time_t expires); -char *vnc_display_local_addr(const char *id); QemuOpts *vnc_parse(const char *str, Error **errp); int vnc_init_func(void *opaque, QemuOpts *opts, Error **errp); #else @@ -482,12 +481,6 @@ static inline int vnc_init_func(void *opaque, QemuOpts *opts, Error **errp) error_setg(errp, "VNC support is disabled"); return -1; } -static inline char *vnc_display_local_addr(const char *id) -{ - /* This must never be called if CONFIG_VNC is disabled */ - error_report("VNC support is disabled"); - abort(); -} #endif /* curses.c */ diff --git a/ui/vnc.c b/ui/vnc.c index c862fdc..a2bf535 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -3207,15 +3207,11 @@ int vnc_display_pw_expire(const char *id, time_t expires) return 0; } -char *vnc_display_local_addr(const char *id) +static void vnc_display_print_local_addr(VncDisplay *vs) { - VncDisplay *vs = vnc_display_find(id); SocketAddress *addr; - char *ret; Error *err = NULL; - assert(vs); - addr = qio_channel_socket_get_local_address(vs->lsock, &err); if (!addr) { return NULL; @@ -3225,11 +3221,9 @@ char *vnc_display_local_addr(const char *id) qapi_free_SocketAddress(addr); return NULL; } - ret = g_strdup_printf("%s;%s", addr->u.inet.data->host, + printf("VNC server running on '%s:%s;\n", addr->u.inet.data->host, addr->u.inet.data->port); qapi_free_SocketAddress(addr); - - return ret; } static QemuOptsList qemu_vnc_opts = { @@ -3515,6 +3509,7 @@ void vnc_display_open(const char *id, Error **errp) const char *vnc; char *h; const char *credid; + int show_vnc_port = 0; bool sasl = false; #ifdef CONFIG_VNC_SASL int saslErr; @@ -3594,6 +3589,7 @@ void vnc_display_open(const char *id, Error **errp) if (to) { inet->has_to = true; inet->to = to + 5900; + show_vnc_port = 1; } inet->ipv4 = ipv4; inet->has_ipv4 = has_ipv4; @@ -3838,6 +3834,10 @@ void vnc_display_open(const char *id, Error **errp) } } + if (show_vnc_port) { + vnc_display_print_local_addr(vs); + } + qapi_free_SocketAddress(saddr); qapi_free_SocketAddress(wsaddr); return; diff --git a/vl.c b/vl.c index 17e6b5e..d47d558 100644 --- a/vl.c +++ b/vl.c @@ -2960,7 +2960,6 @@ int main(int argc, char **argv, char **envp) const char *qtest_log = NULL; const char *pid_file = NULL; const char *incoming = NULL; - int show_vnc_port = 0; bool defconfig = true; bool userconfig = true; bool nographic = false; @@ -4219,7 +4218,6 @@ int main(int argc, char **argv, char **envp) display_type = DT_COCOA; #elif defined(CONFIG_VNC) vnc_parse("localhost:0,to=99,id=default", &error_abort); - show_vnc_port = 1; #else display_type = DT_NONE; #endif @@ -4566,11 +4564,6 @@ int main(int argc, char **argv, char **envp) /* init remote displays */ qemu_opts_foreach(qemu_find_opts("vnc"), vnc_init_func, NULL, NULL); - if (show_vnc_port) { - char *ret = vnc_display_local_addr("default"); - printf("VNC server running on '%s'\n", ret); - g_free(ret); - } if (using_spice) { qemu_spice_display_init();