summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaolo Bonzini2016-05-31 14:59:08 +0200
committerPaolo Bonzini2016-06-29 14:03:47 +0200
commit33df7bf3bf43ffa3001cadfe5d5faef2774522d0 (patch)
tree41eb4266d0c9c0552bb306a29879d72881cc4478
parentscsi: esp: fix migration (diff)
downloadqemu-33df7bf3bf43ffa3001cadfe5d5faef2774522d0.tar.gz
qemu-33df7bf3bf43ffa3001cadfe5d5faef2774522d0.tar.xz
qemu-33df7bf3bf43ffa3001cadfe5d5faef2774522d0.zip
vnc: generalize "VNC server running on ..." message
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>
-rw-r--r--include/ui/console.h7
-rw-r--r--ui/vnc.c23
-rw-r--r--vl.c7
3 files changed, 12 insertions, 25 deletions
diff --git a/include/ui/console.h b/include/ui/console.h
index 52a5f65673..7c1fdbad6f 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 95e4db763b..18c0b56c3a 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -3205,29 +3205,24 @@ 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;
+ return;
}
if (addr->type != SOCKET_ADDRESS_KIND_INET) {
qapi_free_SocketAddress(addr);
- return NULL;
+ return;
}
- ret = g_strdup_printf("%s:%s", addr->u.inet.data->host,
- addr->u.inet.data->port);
+ error_printf_unless_qmp("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 = {
@@ -3513,6 +3508,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;
@@ -3592,6 +3588,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;
@@ -3836,6 +3833,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 c85833a63c..64cfa968c9 100644
--- a/vl.c
+++ b/vl.c
@@ -2947,7 +2947,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;
@@ -4216,7 +4215,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
@@ -4565,11 +4563,6 @@ int main(int argc, char **argv, char **envp)
qemu_opts_foreach(qemu_find_opts("vnc"),
vnc_init_func, NULL, NULL);
#endif
- 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();