Commit 9e549d36 authored by Peter Maydell's avatar Peter Maydell
Browse files

Merge remote-tracking branch 'remotes/kraxel/tags/pull-vnc-20150520-1' into staging



vnc: misc fixes.

# gpg: Signature made Wed May 20 09:32:45 2015 BST using RSA key ID D3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"

* remotes/kraxel/tags/pull-vnc-20150520-1:
  qemu-sockets: Report explicit error if unlink fails
  vnc: Tweak error when init fails
  vnc: Don't assert if opening unix socket fails
  ui: remove check for failure of qemu_acl_init()
  Strip brackets from vnc host

Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
parents eba05e92 0ef705a2
Loading
Loading
Loading
Loading
+12 −11
Original line number Diff line number Diff line
@@ -3482,7 +3482,14 @@ void vnc_display_open(const char *id, Error **errp)

    h = strrchr(vnc, ':');
    if (h) {
        char *host = g_strndup(vnc, h - vnc);
        char *host;
        size_t hlen = h - vnc;

        if (vnc[0] == '[' && vnc[hlen - 1] == ']') {
            host = g_strndup(vnc + 1, hlen - 2);
        } else {
            host = g_strndup(vnc, hlen);
        }
        qemu_opt_set(sopts, "host", host, &error_abort);
        qemu_opt_set(wsopts, "host", host, &error_abort);
        qemu_opt_set(sopts, "port", h+1, &error_abort);
@@ -3602,10 +3609,6 @@ void vnc_display_open(const char *id, Error **errp)
            aclname = g_strdup_printf("vnc.%s.x509dname", vs->id);
        }
        vs->tls.acl = qemu_acl_init(aclname);
        if (!vs->tls.acl) {
            fprintf(stderr, "Failed to create x509 dname ACL\n");
            exit(1);
        }
        g_free(aclname);
    }
#endif
@@ -3619,10 +3622,6 @@ void vnc_display_open(const char *id, Error **errp)
            aclname = g_strdup_printf("vnc.%s.username", vs->id);
        }
        vs->sasl.acl = qemu_acl_init(aclname);
        if (!vs->sasl.acl) {
            fprintf(stderr, "Failed to create username ACL\n");
            exit(1);
        }
        g_free(aclname);
    }
#endif
@@ -3685,6 +3684,9 @@ void vnc_display_open(const char *id, Error **errp)
        /* listen for connects */
        if (strncmp(vnc, "unix:", 5) == 0) {
            vs->lsock = unix_listen(vnc+5, NULL, 0, errp);
            if (vs->lsock < 0) {
                goto fail;
            }
            vs->is_unix = true;
        } else {
            vs->lsock = inet_listen_opts(sopts, 5900, errp);
@@ -3777,8 +3779,7 @@ int vnc_init_func(QemuOpts *opts, void *opaque)
    vnc_display_init(id);
    vnc_display_open(id, &local_err);
    if (local_err != NULL) {
        error_report("Failed to start VNC server on `%s': %s",
                     qemu_opt_get(opts, "display"),
        error_report("Failed to start VNC server: %s",
                     error_get_pretty(local_err));
        error_free(local_err);
        exit(1);
+6 −1
Original line number Diff line number Diff line
@@ -729,7 +729,12 @@ int unix_listen_opts(QemuOpts *opts, Error **errp)
        qemu_opt_set(opts, "path", un.sun_path, &error_abort);
    }

    unlink(un.sun_path);
    if ((access(un.sun_path, F_OK) == 0) &&
        unlink(un.sun_path) < 0) {
        error_setg_errno(errp, errno,
                         "Failed to unlink socket %s", un.sun_path);
        goto err;
    }
    if (bind(sock, (struct sockaddr*) &un, sizeof(un)) < 0) {
        error_setg_errno(errp, errno, "Failed to bind socket to %s", un.sun_path);
        goto err;