From: "Daniel P. Berrange" <berrange@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] vnc: generalize "VNC server running on ..." message
Date: Mon, 6 Jun 2016 13:06:29 +0100 [thread overview]
Message-ID: <20160606120629.GC5581@redhat.com> (raw)
In-Reply-To: <1465214470-12515-1-git-send-email-pbonzini@redhat.com>
On Mon, Jun 06, 2016 at 02:01:10PM +0200, Paolo Bonzini wrote:
> The message is useful whenever the user specifies "-vnc to=XX".
> Move it to ui/vnc.c.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> 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;
By calling this from vnc_display_open, you'll cause it to
print to stdout, even when using QMP, because qmp_change_vnc_listen
calls vnc_display_open.
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
next prev parent reply other threads:[~2016-06-06 12:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-06 12:01 [Qemu-devel] [PATCH] vnc: generalize "VNC server running on ..." message Paolo Bonzini
2016-06-06 12:06 ` Daniel P. Berrange [this message]
2016-06-06 14:08 ` Paolo Bonzini
2016-06-06 15:07 ` Markus Armbruster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160606120629.GC5581@redhat.com \
--to=berrange@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).