aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2014-07-29 12:24:55 +0200
committerGerd Hoffmann <kraxel@redhat.com>2015-01-22 11:18:46 +0100
commit14f7143ede7c601cce02ce0f8c7f01c41148128b (patch)
treed3fefe8d59016440b37ade0b74a99f463ac173dc
parentd616ccc5dd771024e04b9b15d7ca30bc7fe8fce3 (diff)
vnc: remove unused DisplayState parameter, add id instead.
DisplayState isn't used anywhere, drop it. Add the vnc server ID as parameter instead, so it is possible to specify the server instance. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Gonglei <arei.gonglei@huawei.com>
-rw-r--r--include/ui/console.h16
-rw-r--r--ui/vnc.c29
-rw-r--r--vl.c7
3 files changed, 26 insertions, 26 deletions
diff --git a/include/ui/console.h b/include/ui/console.h
index 047b6dab8d..03358b4886 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -331,19 +331,19 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame);
void cocoa_display_init(DisplayState *ds, int full_screen);
/* vnc.c */
-void vnc_display_init(DisplayState *ds);
-void vnc_display_open(DisplayState *ds, const char *display, Error **errp);
-void vnc_display_add_client(DisplayState *ds, int csock, bool skipauth);
-char *vnc_display_local_addr(DisplayState *ds);
+void vnc_display_init(const char *id);
+void vnc_display_open(const char *id, const char *display, Error **errp);
+void vnc_display_add_client(const char *id, int csock, bool skipauth);
+char *vnc_display_local_addr(const char *id);
#ifdef CONFIG_VNC
-int vnc_display_password(DisplayState *ds, const char *password);
-int vnc_display_pw_expire(DisplayState *ds, time_t expires);
+int vnc_display_password(const char *id, const char *password);
+int vnc_display_pw_expire(const char *id, time_t expires);
#else
-static inline int vnc_display_password(DisplayState *ds, const char *password)
+static inline int vnc_display_password(const char *id, const char *password)
{
return -ENODEV;
}
-static inline int vnc_display_pw_expire(DisplayState *ds, time_t expires)
+static inline int vnc_display_pw_expire(const char *id, time_t expires)
{
return -ENODEV;
};
diff --git a/ui/vnc.c b/ui/vnc.c
index 27e4d26349..d9882752ca 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -2968,10 +2968,11 @@ static const DisplayChangeListenerOps dcl_ops = {
.dpy_cursor_define = vnc_dpy_cursor_define,
};
-void vnc_display_init(DisplayState *ds)
+void vnc_display_init(const char *id)
{
VncDisplay *vs = g_malloc0(sizeof(*vs));
+ vs->id = strdup(id);
QTAILQ_INSERT_TAIL(&vnc_displays, vs, next);
vs->lsock = -1;
@@ -3000,10 +3001,8 @@ void vnc_display_init(DisplayState *ds)
}
-static void vnc_display_close(DisplayState *ds)
+static void vnc_display_close(VncDisplay *vs)
{
- VncDisplay *vs = vnc_display_find(NULL);
-
if (!vs)
return;
g_free(vs->display);
@@ -3029,9 +3028,9 @@ static void vnc_display_close(DisplayState *ds)
#endif
}
-int vnc_display_password(DisplayState *ds, const char *password)
+int vnc_display_password(const char *id, const char *password)
{
- VncDisplay *vs = vnc_display_find(NULL);
+ VncDisplay *vs = vnc_display_find(id);
if (!vs) {
return -EINVAL;
@@ -3048,9 +3047,9 @@ int vnc_display_password(DisplayState *ds, const char *password)
return 0;
}
-int vnc_display_pw_expire(DisplayState *ds, time_t expires)
+int vnc_display_pw_expire(const char *id, time_t expires)
{
- VncDisplay *vs = vnc_display_find(NULL);
+ VncDisplay *vs = vnc_display_find(id);
if (!vs) {
return -EINVAL;
@@ -3060,16 +3059,16 @@ int vnc_display_pw_expire(DisplayState *ds, time_t expires)
return 0;
}
-char *vnc_display_local_addr(DisplayState *ds)
+char *vnc_display_local_addr(const char *id)
{
- VncDisplay *vs = vnc_display_find(NULL);
+ VncDisplay *vs = vnc_display_find(id);
return vnc_socket_local_addr("%s:%s", vs->lsock);
}
-void vnc_display_open(DisplayState *ds, const char *display, Error **errp)
+void vnc_display_open(const char *id, const char *display, Error **errp)
{
- VncDisplay *vs = vnc_display_find(NULL);
+ VncDisplay *vs = vnc_display_find(id);
const char *options;
int password = 0;
int reverse = 0;
@@ -3089,7 +3088,7 @@ void vnc_display_open(DisplayState *ds, const char *display, Error **errp)
error_setg(errp, "VNC display not active");
return;
}
- vnc_display_close(ds);
+ vnc_display_close(vs);
if (strcmp(display, "none") == 0)
return;
@@ -3382,9 +3381,9 @@ fail:
#endif /* CONFIG_VNC_WS */
}
-void vnc_display_add_client(DisplayState *ds, int csock, bool skipauth)
+void vnc_display_add_client(const char *id, int csock, bool skipauth)
{
- VncDisplay *vs = vnc_display_find(NULL);
+ VncDisplay *vs = vnc_display_find(id);
if (!vs) {
return;
diff --git a/vl.c b/vl.c
index fbf4240145..9fb32c13df 100644
--- a/vl.c
+++ b/vl.c
@@ -4288,8 +4288,9 @@ int main(int argc, char **argv, char **envp)
/* init remote displays */
if (vnc_display) {
Error *local_err = NULL;
- vnc_display_init(ds);
- vnc_display_open(ds, vnc_display, &local_err);
+ const char *id = "default";
+ vnc_display_init(id);
+ vnc_display_open(id, vnc_display, &local_err);
if (local_err != NULL) {
error_report("Failed to start VNC server on `%s': %s",
vnc_display, error_get_pretty(local_err));
@@ -4298,7 +4299,7 @@ int main(int argc, char **argv, char **envp)
}
if (show_vnc_port) {
- printf("VNC server running on `%s'\n", vnc_display_local_addr(ds));
+ printf("VNC server running on `%s'\n", vnc_display_local_addr(id));
}
}
#endif