aboutsummaryrefslogtreecommitdiff
path: root/qemu-sockets.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2012-09-19 13:54:39 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2012-10-23 13:54:57 +0200
commit58899664de29c250229f8d306fcf04f852cf5cc6 (patch)
treeb495c60380aec5e9c2ea99f3a10ab2c4219574ee /qemu-sockets.c
parent2f002c43ebded28604c26787c9215c4d3594f0ec (diff)
downloadqemu-58899664de29c250229f8d306fcf04f852cf5cc6.zip
qemu-58899664de29c250229f8d306fcf04f852cf5cc6.tar.gz
qemu-58899664de29c250229f8d306fcf04f852cf5cc6.tar.bz2
qemu-sockets: add error propagation to Unix socket functions
Before: $ qemu-system-x86_64 -monitor unix:/vvv,server=off connect(unix:/vvv): No such file or directory chardev: opening backend "socket" failed After: $ x86_64-softmmu/qemu-system-x86_64 -monitor unix:/vvv,server=off qemu-system-x86_64: -monitor unix:/vvv,server=off: Failed to connect to socket: No such file or directory chardev: opening backend "socket" failed Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'qemu-sockets.c')
-rw-r--r--qemu-sockets.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/qemu-sockets.c b/qemu-sockets.c
index fb9c4c9..daff8e6 100644
--- a/qemu-sockets.c
+++ b/qemu-sockets.c
@@ -632,7 +632,7 @@ int unix_listen_opts(QemuOpts *opts, Error **errp)
sock = qemu_socket(PF_UNIX, SOCK_STREAM, 0);
if (sock < 0) {
- perror("socket(unix)");
+ error_set_errno(errp, errno, QERR_SOCKET_CREATE_FAILED);
return -1;
}
@@ -657,11 +657,11 @@ int unix_listen_opts(QemuOpts *opts, Error **errp)
unlink(un.sun_path);
if (bind(sock, (struct sockaddr*) &un, sizeof(un)) < 0) {
- fprintf(stderr, "bind(unix:%s): %s\n", un.sun_path, strerror(errno));
+ error_set_errno(errp, errno, QERR_SOCKET_BIND_FAILED);
goto err;
}
if (listen(sock, 1) < 0) {
- fprintf(stderr, "listen(unix:%s): %s\n", un.sun_path, strerror(errno));
+ error_set_errno(errp, errno, QERR_SOCKET_LISTEN_FAILED);
goto err;
}
@@ -681,13 +681,13 @@ int unix_connect_opts(QemuOpts *opts, Error **errp,
int sock, rc;
if (NULL == path) {
- fprintf(stderr, "unix connect: no path specified\n");
+ error_setg(errp, "unix connect: no path specified\n");
return -1;
}
sock = qemu_socket(PF_UNIX, SOCK_STREAM, 0);
if (sock < 0) {
- perror("socket(unix)");
+ error_set_errno(errp, errno, QERR_SOCKET_CREATE_FAILED);
return -1;
}
if (callback != NULL) {
@@ -722,7 +722,7 @@ int unix_connect_opts(QemuOpts *opts, Error **errp,
}
if (rc < 0) {
- fprintf(stderr, "connect(unix:%s): %s\n", path, strerror(errno));
+ error_set_errno(errp, -rc, QERR_SOCKET_CONNECT_FAILED);
close(sock);
sock = -1;
}
@@ -735,7 +735,7 @@ int unix_connect_opts(QemuOpts *opts, Error **errp,
int unix_listen_opts(QemuOpts *opts, Error **errp)
{
- fprintf(stderr, "unix sockets are not available on windows\n");
+ error_setg(errp, "unix sockets are not available on windows");
errno = ENOTSUP;
return -1;
}
@@ -743,7 +743,7 @@ int unix_listen_opts(QemuOpts *opts, Error **errp)
int unix_connect_opts(QemuOpts *opts, Error **errp,
NonBlockingConnectHandler *callback, void *opaque)
{
- fprintf(stderr, "unix sockets are not available on windows\n");
+ error_setg(errp, "unix sockets are not available on windows");
errno = ENOTSUP;
return -1;
}