qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 0/5] vnc patch queue
@ 2015-05-20  8:34 Gerd Hoffmann
  2015-05-20  8:34 ` [Qemu-devel] [PULL 1/5] Strip brackets from vnc host Gerd Hoffmann
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2015-05-20  8:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

  Hi,

Flushing the vnc patch queue, with a collection of small bug fixes.

please pull,
  Gerd

The following changes since commit eba05e922e8e7f307bc5d4104a78797e55124e97:

  Merge remote-tracking branch 'remotes/kraxel/tags/pull-serial-20150519-1' into staging (2015-05-19 14:10:33 +0100)

are available in the git repository at:


  git://git.kraxel.org/qemu tags/pull-vnc-20150520-1

for you to fetch changes up to 0ef705a2653f09c15e44a644a98b6febc761431e:

  qemu-sockets: Report explicit error if unlink fails (2015-05-20 10:23:08 +0200)

----------------------------------------------------------------
vnc: misc fixes.

----------------------------------------------------------------
Cole Robinson (3):
      vnc: Don't assert if opening unix socket fails
      vnc: Tweak error when init fails
      qemu-sockets: Report explicit error if unlink fails

Daniel P. Berrange (1):
      ui: remove check for failure of qemu_acl_init()

Ján Tomko (1):
      Strip brackets from vnc host

 ui/vnc.c            | 23 ++++++++++++-----------
 util/qemu-sockets.c |  7 ++++++-
 2 files changed, 18 insertions(+), 12 deletions(-)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PULL 1/5] Strip brackets from vnc host
  2015-05-20  8:34 [Qemu-devel] [PULL 0/5] vnc patch queue Gerd Hoffmann
@ 2015-05-20  8:34 ` Gerd Hoffmann
  2015-05-20  8:34 ` [Qemu-devel] [PULL 2/5] ui: remove check for failure of qemu_acl_init() Gerd Hoffmann
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2015-05-20  8:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: Ján Tomko, Gerd Hoffmann

From: Ján Tomko <jtomko@redhat.com>

Commit v2.2.0-1530-ge556032 vnc: switch to inet_listen_opts
bypassed the use of inet_parse in inet_listen, making literal
IPv6 addresses enclosed in brackets fail:

qemu-kvm: -vnc [::1]:0: Failed to start VNC server on `(null)': address
resolution failed for [::1]:5900: Name or service not known

Strip the brackets to make it work again.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/vnc.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/ui/vnc.c b/ui/vnc.c
index 9f8ecd0..2dccae9 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -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);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PULL 2/5] ui: remove check for failure of qemu_acl_init()
  2015-05-20  8:34 [Qemu-devel] [PULL 0/5] vnc patch queue Gerd Hoffmann
  2015-05-20  8:34 ` [Qemu-devel] [PULL 1/5] Strip brackets from vnc host Gerd Hoffmann
@ 2015-05-20  8:34 ` Gerd Hoffmann
  2015-05-20  8:34 ` [Qemu-devel] [PULL 3/5] vnc: Don't assert if opening unix socket fails Gerd Hoffmann
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2015-05-20  8:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

From: "Daniel P. Berrange" <berrange@redhat.com>

The qemu_acl_init() function has long since stopped being able
to return NULL, since g_malloc will abort on OOM. As such the
checks for NULL were unreachable code.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/vnc.c | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/ui/vnc.c b/ui/vnc.c
index 2dccae9..076355d 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -3609,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
@@ -3626,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
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PULL 3/5] vnc: Don't assert if opening unix socket fails
  2015-05-20  8:34 [Qemu-devel] [PULL 0/5] vnc patch queue Gerd Hoffmann
  2015-05-20  8:34 ` [Qemu-devel] [PULL 1/5] Strip brackets from vnc host Gerd Hoffmann
  2015-05-20  8:34 ` [Qemu-devel] [PULL 2/5] ui: remove check for failure of qemu_acl_init() Gerd Hoffmann
@ 2015-05-20  8:34 ` Gerd Hoffmann
  2015-05-20  8:34 ` [Qemu-devel] [PULL 4/5] vnc: Tweak error when init fails Gerd Hoffmann
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2015-05-20  8:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Cole Robinson

From: Cole Robinson <crobinso@redhat.com>

Reproducer:

$ qemu-system-x86_64 -display vnc=unix:/root/i-cant-access-you.sock
qemu-system-x86_64: iohandler.c:60: qemu_set_fd_handler2: Assertion `fd >= 0' failed.
Aborted (core dumped)

Signed-off-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/vnc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/ui/vnc.c b/ui/vnc.c
index 076355d..fe4cd75 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -3684,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);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PULL 4/5] vnc: Tweak error when init fails
  2015-05-20  8:34 [Qemu-devel] [PULL 0/5] vnc patch queue Gerd Hoffmann
                   ` (2 preceding siblings ...)
  2015-05-20  8:34 ` [Qemu-devel] [PULL 3/5] vnc: Don't assert if opening unix socket fails Gerd Hoffmann
@ 2015-05-20  8:34 ` Gerd Hoffmann
  2015-05-20  8:34 ` [Qemu-devel] [PULL 5/5] qemu-sockets: Report explicit error if unlink fails Gerd Hoffmann
  2015-05-21  9:24 ` [Qemu-devel] [PULL 0/5] vnc patch queue Peter Maydell
  5 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2015-05-20  8:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Cole Robinson

From: Cole Robinson <crobinso@redhat.com>

Before:
qemu-system-x86_64: -display vnc=unix:/root/foo.sock: Failed to start VNC server on `(null)': Failed to bind socket to /root/foo.sock: Permission denied

After:
qemu-system-x86_64: -display vnc=unix:/root/foo.sock: Failed to start VNC server: Failed to bind socket to /root/foo.sock: Permission denied

Rather than tweak the string possibly show unix: value as well,
just drop the explicit display reporting. We already get the cli
string in the error message, that should be sufficient.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/vnc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/ui/vnc.c b/ui/vnc.c
index fe4cd75..1013ea5 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -3779,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);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PULL 5/5] qemu-sockets: Report explicit error if unlink fails
  2015-05-20  8:34 [Qemu-devel] [PULL 0/5] vnc patch queue Gerd Hoffmann
                   ` (3 preceding siblings ...)
  2015-05-20  8:34 ` [Qemu-devel] [PULL 4/5] vnc: Tweak error when init fails Gerd Hoffmann
@ 2015-05-20  8:34 ` Gerd Hoffmann
  2015-05-21  9:24 ` [Qemu-devel] [PULL 0/5] vnc patch queue Peter Maydell
  5 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2015-05-20  8:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Cole Robinson

From: Cole Robinson <crobinso@redhat.com>

Consider this case:

$ ls -ld ~/root-owned/
drwx--x--x. 2 root root 4096 Apr 29 12:55 /home/crobinso/root-owned/
$ ls -l ~/root-owned/foo.sock
-rwxrwxrwx. 1 crobinso crobinso 0 Apr 29 12:55 /home/crobinso/root-owned/foo.sock

$ qemu-system-x86_64 -vnc unix:~/root-owned/foo.sock
qemu-system-x86_64: -vnc unix:/home/crobinso/root-owned/foo.sock: Failed to start VNC server: Failed to bind socket to /home/crobinso/root-owned/foo.sock: Address already in use

...which is techinically true, but the real error is that we failed to
unlink. So report it.

This may seem pathological but it's a real possibility via libvirt.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 util/qemu-sockets.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index 87c9bc6..22c8c4c 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -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;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PULL 0/5] vnc patch queue
  2015-05-20  8:34 [Qemu-devel] [PULL 0/5] vnc patch queue Gerd Hoffmann
                   ` (4 preceding siblings ...)
  2015-05-20  8:34 ` [Qemu-devel] [PULL 5/5] qemu-sockets: Report explicit error if unlink fails Gerd Hoffmann
@ 2015-05-21  9:24 ` Peter Maydell
  5 siblings, 0 replies; 7+ messages in thread
From: Peter Maydell @ 2015-05-21  9:24 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: QEMU Developers

On 20 May 2015 at 09:34, Gerd Hoffmann <kraxel@redhat.com> wrote:
>   Hi,
>
> Flushing the vnc patch queue, with a collection of small bug fixes.
>
> please pull,
>   Gerd
>
> The following changes since commit eba05e922e8e7f307bc5d4104a78797e55124e97:
>
>   Merge remote-tracking branch 'remotes/kraxel/tags/pull-serial-20150519-1' into staging (2015-05-19 14:10:33 +0100)
>
> are available in the git repository at:
>
>
>   git://git.kraxel.org/qemu tags/pull-vnc-20150520-1
>
> for you to fetch changes up to 0ef705a2653f09c15e44a644a98b6febc761431e:
>
>   qemu-sockets: Report explicit error if unlink fails (2015-05-20 10:23:08 +0200)
>
> ----------------------------------------------------------------
> vnc: misc fixes.

Applied, thanks.

-- PMM

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-05-21  9:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-20  8:34 [Qemu-devel] [PULL 0/5] vnc patch queue Gerd Hoffmann
2015-05-20  8:34 ` [Qemu-devel] [PULL 1/5] Strip brackets from vnc host Gerd Hoffmann
2015-05-20  8:34 ` [Qemu-devel] [PULL 2/5] ui: remove check for failure of qemu_acl_init() Gerd Hoffmann
2015-05-20  8:34 ` [Qemu-devel] [PULL 3/5] vnc: Don't assert if opening unix socket fails Gerd Hoffmann
2015-05-20  8:34 ` [Qemu-devel] [PULL 4/5] vnc: Tweak error when init fails Gerd Hoffmann
2015-05-20  8:34 ` [Qemu-devel] [PULL 5/5] qemu-sockets: Report explicit error if unlink fails Gerd Hoffmann
2015-05-21  9:24 ` [Qemu-devel] [PULL 0/5] vnc patch queue Peter Maydell

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).