* [Qemu-devel] [PATCH v3 0/3] vnc: Fixes for unix socket error handling
@ 2015-05-05 15:07 Cole Robinson
2015-05-05 15:07 ` [Qemu-devel] [PATCH v3 1/3] vnc: Don't assert if opening unix socket fails Cole Robinson
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Cole Robinson @ 2015-05-05 15:07 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Cole Robinson
Minor fixes for unix socket error handling, see patches for details
v3:
Scoop up the v2 of patch 3
Fix checkpatch warnings
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
ui/vnc.c | 6 ++++--
util/qemu-sockets.c | 7 ++++++-
2 files changed, 10 insertions(+), 3 deletions(-)
--
2.4.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH v3 1/3] vnc: Don't assert if opening unix socket fails
2015-05-05 15:07 [Qemu-devel] [PATCH v3 0/3] vnc: Fixes for unix socket error handling Cole Robinson
@ 2015-05-05 15:07 ` Cole Robinson
2015-05-05 15:07 ` [Qemu-devel] [PATCH v3 2/3] vnc: Tweak error when init fails Cole Robinson
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Cole Robinson @ 2015-05-05 15:07 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Cole Robinson
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>
---
v3:
Fix checkpatch warning
ui/vnc.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/ui/vnc.c b/ui/vnc.c
index 9f8ecd0..e1abf64 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -3685,6 +3685,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);
--
2.4.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH v3 2/3] vnc: Tweak error when init fails
2015-05-05 15:07 [Qemu-devel] [PATCH v3 0/3] vnc: Fixes for unix socket error handling Cole Robinson
2015-05-05 15:07 ` [Qemu-devel] [PATCH v3 1/3] vnc: Don't assert if opening unix socket fails Cole Robinson
@ 2015-05-05 15:07 ` Cole Robinson
2015-05-05 15:07 ` [Qemu-devel] [PATCH v3 3/3] qemu-sockets: Report explicit error if unlink fails Cole Robinson
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Cole Robinson @ 2015-05-05 15:07 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Cole Robinson
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>
---
v3:
No change
ui/vnc.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/ui/vnc.c b/ui/vnc.c
index e1abf64..b3450ec 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -3780,8 +3780,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);
--
2.4.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH v3 3/3] qemu-sockets: Report explicit error if unlink fails
2015-05-05 15:07 [Qemu-devel] [PATCH v3 0/3] vnc: Fixes for unix socket error handling Cole Robinson
2015-05-05 15:07 ` [Qemu-devel] [PATCH v3 1/3] vnc: Don't assert if opening unix socket fails Cole Robinson
2015-05-05 15:07 ` [Qemu-devel] [PATCH v3 2/3] vnc: Tweak error when init fails Cole Robinson
@ 2015-05-05 15:07 ` Cole Robinson
2015-05-05 15:20 ` [Qemu-devel] [PATCH v3 0/3] vnc: Fixes for unix socket error handling Eric Blake
2015-05-06 7:23 ` Gerd Hoffmann
4 siblings, 0 replies; 6+ messages in thread
From: Cole Robinson @ 2015-05-05 15:07 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Cole Robinson
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>
---
v3:
Fix checkpatch warning
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;
--
2.4.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v3 0/3] vnc: Fixes for unix socket error handling
2015-05-05 15:07 [Qemu-devel] [PATCH v3 0/3] vnc: Fixes for unix socket error handling Cole Robinson
` (2 preceding siblings ...)
2015-05-05 15:07 ` [Qemu-devel] [PATCH v3 3/3] qemu-sockets: Report explicit error if unlink fails Cole Robinson
@ 2015-05-05 15:20 ` Eric Blake
2015-05-06 7:23 ` Gerd Hoffmann
4 siblings, 0 replies; 6+ messages in thread
From: Eric Blake @ 2015-05-05 15:20 UTC (permalink / raw)
To: Cole Robinson, qemu-devel; +Cc: Gerd Hoffmann
[-- Attachment #1: Type: text/plain, Size: 659 bytes --]
On 05/05/2015 09:07 AM, Cole Robinson wrote:
> Minor fixes for unix socket error handling, see patches for details
>
> v3:
> Scoop up the v2 of patch 3
> Fix checkpatch warnings
Reviewed-by: Eric Blake <eblake@redhat.com>
>
> 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
>
> ui/vnc.c | 6 ++++--
> util/qemu-sockets.c | 7 ++++++-
> 2 files changed, 10 insertions(+), 3 deletions(-)
>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v3 0/3] vnc: Fixes for unix socket error handling
2015-05-05 15:07 [Qemu-devel] [PATCH v3 0/3] vnc: Fixes for unix socket error handling Cole Robinson
` (3 preceding siblings ...)
2015-05-05 15:20 ` [Qemu-devel] [PATCH v3 0/3] vnc: Fixes for unix socket error handling Eric Blake
@ 2015-05-06 7:23 ` Gerd Hoffmann
4 siblings, 0 replies; 6+ messages in thread
From: Gerd Hoffmann @ 2015-05-06 7:23 UTC (permalink / raw)
To: Cole Robinson; +Cc: qemu-devel
On Di, 2015-05-05 at 11:07 -0400, Cole Robinson wrote:
> Minor fixes for unix socket error handling, see patches for details
added to vnc queue.
thanks,
Gerd
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-05-06 7:23 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-05 15:07 [Qemu-devel] [PATCH v3 0/3] vnc: Fixes for unix socket error handling Cole Robinson
2015-05-05 15:07 ` [Qemu-devel] [PATCH v3 1/3] vnc: Don't assert if opening unix socket fails Cole Robinson
2015-05-05 15:07 ` [Qemu-devel] [PATCH v3 2/3] vnc: Tweak error when init fails Cole Robinson
2015-05-05 15:07 ` [Qemu-devel] [PATCH v3 3/3] qemu-sockets: Report explicit error if unlink fails Cole Robinson
2015-05-05 15:20 ` [Qemu-devel] [PATCH v3 0/3] vnc: Fixes for unix socket error handling Eric Blake
2015-05-06 7:23 ` Gerd Hoffmann
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.