From: Cole Robinson <crobinso@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>, Cole Robinson <crobinso@redhat.com>
Subject: [Qemu-devel] [PATCH 3/3] qemu-sockets: Report explicit error if unlink fails
Date: Wed, 29 Apr 2015 12:37:50 -0400 [thread overview]
Message-ID: <3d1c0b890723c377d9aa5c3bf416097e3cea90b3.1430325445.git.crobinso@redhat.com> (raw)
In-Reply-To: <cover.1430325445.git.crobinso@redhat.com>
In-Reply-To: <cover.1430325445.git.crobinso@redhat.com>
It's possible via libvirt for a user to request an explicit socket path
that qemu lacks permissions to unlink, but the error that's reported
is from bind(2), 'Address already in use'
bind(2) will fail if the unix socket path already exists, so we need to
unlink first. But we should report the unlink failure
Signed-off-by: Cole Robinson <crobinso@redhat.com>
---
util/qemu-sockets.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index 87c9bc6..9ef3f7c 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -729,7 +729,11 @@ 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) &&
+ 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.3.6
next prev parent reply other threads:[~2015-04-29 16:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-29 16:37 [Qemu-devel] [PATCH 0/3] vnc: Fixes for unix socket error handling Cole Robinson
2015-04-29 16:37 ` [Qemu-devel] [PATCH 1/3] vnc: Don't assert if opening unix socket fails Cole Robinson
2015-05-05 9:48 ` Gerd Hoffmann
2015-04-29 16:37 ` [Qemu-devel] [PATCH 2/3] vnc: Tweak error when init fails Cole Robinson
2015-04-29 16:37 ` Cole Robinson [this message]
2015-04-29 17:03 ` [Qemu-devel] [PATCH v2] qemu-sockets: Report explicit error if unlink fails Cole Robinson
2015-04-29 17:10 ` Eric Blake
2015-04-29 16:53 ` [Qemu-devel] [PATCH 0/3] vnc: Fixes for unix socket error handling Eric Blake
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3d1c0b890723c377d9aa5c3bf416097e3cea90b3.1430325445.git.crobinso@redhat.com \
--to=crobinso@redhat.com \
--cc=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).