Message ID | 3d1c0b890723c377d9aa5c3bf416097e3cea90b3.1430325445.git.crobinso@redhat.com |
---|---|
State | New |
Headers | show |
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;
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(-)