aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2012-10-18 09:01:01 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2012-10-23 13:54:56 +0200
commit007fcd3ee9673b3d00baacf3765bd501296155cd (patch)
tree108ad32fc0bb1dfde71f5d1c9e5c75114e246672
parent1ce52c78ab90c4303bcb110f2c614410386d79a2 (diff)
vnc: reorganize code for reverse mode
Avoid the dance between csock and vs->lsock. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--console.h2
-rw-r--r--qmp.c6
-rw-r--r--ui/vnc.c20
3 files changed, 12 insertions, 16 deletions
diff --git a/console.h b/console.h
index f990684ef4..6099d8d710 100644
--- a/console.h
+++ b/console.h
@@ -378,7 +378,7 @@ void cocoa_display_init(DisplayState *ds, int full_screen);
/* vnc.c */
void vnc_display_init(DisplayState *ds);
void vnc_display_close(DisplayState *ds);
-int vnc_display_open(DisplayState *ds, const char *display);
+void vnc_display_open(DisplayState *ds, const char *display, Error **errp);
void vnc_display_add_client(DisplayState *ds, int csock, int skipauth);
int vnc_display_disable_login(DisplayState *ds);
char *vnc_display_local_addr(DisplayState *ds);
diff --git a/qmp.c b/qmp.c
index 36c54c57cf..31bc3bfdd1 100644
--- a/qmp.c
+++ b/qmp.c
@@ -349,11 +349,9 @@ void qmp_change_vnc_password(const char *password, Error **errp)
}
}
-static void qmp_change_vnc_listen(const char *target, Error **err)
+static void qmp_change_vnc_listen(const char *target, Error **errp)
{
- if (vnc_display_open(NULL, target) < 0) {
- error_set(err, QERR_VNC_SERVER_FAILED, target);
- }
+ vnc_display_open(NULL, target, errp);
}
static void qmp_change_vnc(const char *target, bool has_arg, const char *arg,
diff --git a/ui/vnc.c b/ui/vnc.c
index 72d6f68897..46de820c80 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -3053,19 +3053,17 @@ int vnc_display_open(DisplayState *ds, const char *display)
if (reverse) {
/* connect to viewer */
- if (strncmp(display, "unix:", 5) == 0)
- vs->lsock = unix_connect(display+5, NULL);
- else
- vs->lsock = inet_connect(display, NULL);
- if (vs->lsock < 0) {
- goto fail;
+ int csock;
+ vs->lsock = -1;
+ if (strncmp(display, "unix:", 5) == 0) {
+ csock = unix_connect(display+5, NULL);
} else {
- int csock = vs->lsock;
- vs->lsock = -1;
- vnc_connect(vs, csock, 0);
+ csock = inet_connect(display, NULL);
}
- return 0;
-
+ if (csock < 0) {
+ goto fail;
+ }
+ vnc_connect(vs, csock, 0);
} else {
/* listen for connects */
char *dpy;