[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 18/18] qemu-sockets: add error propagation to Unix s
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 18/18] qemu-sockets: add error propagation to Unix socket functions |
Date: |
Wed, 3 Oct 2012 16:37:05 +0200 |
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
Signed-off-by: Paolo Bonzini <address@hidden>
---
qemu-sockets.c | 12 ++++++------
1 file modificato, 6 inserzioni(+), 6 rimozioni(-)
diff --git a/qemu-sockets.c b/qemu-sockets.c
index 55669e9..e28c63c 100644
--- a/qemu-sockets.c
+++ b/qemu-sockets.c
@@ -633,7 +633,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;
}
@@ -658,11 +658,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;
}
@@ -682,7 +682,7 @@ 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;
}
@@ -694,7 +694,7 @@ int unix_connect_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;
}
if (connect_state != NULL) {
@@ -726,7 +726,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);
return -1;
}
--
1.7.12.1
- Re: [Qemu-devel] [PATCH 15/18] qemu-sockets: add error propagation to inet_connect_addr, (continued)
[Qemu-devel] [PATCH 16/18] qemu-sockets: add error propagation to inet_dgram_opts, Paolo Bonzini, 2012/10/03
[Qemu-devel] [PATCH 13/18] vnc: add error propagation to vnc_display_open, Paolo Bonzini, 2012/10/03
[Qemu-devel] [PATCH 14/18] qemu-sockets: include strerror or gai_strerror output in error messages, Paolo Bonzini, 2012/10/03
[Qemu-devel] [PATCH 18/18] qemu-sockets: add error propagation to Unix socket functions,
Paolo Bonzini <=