From ddc4c1f74c04ec401d4df2dc7c0926aa6a1b0379 Mon Sep 17 00:00:00 2001 Message-Id: In-Reply-To: <707b9b97153063374d2530e72c49b1499fc21af9.1367947969.git.minovotn@redhat.com> References: <707b9b97153063374d2530e72c49b1499fc21af9.1367947969.git.minovotn@redhat.com> From: Laszlo Ersek Date: Mon, 6 May 2013 19:27:36 +0200 Subject: [PATCH 071/114] qemu-sockets: add Error ** to all functions RH-Author: Laszlo Ersek Message-id: <1367868499-27603-14-git-send-email-lersek@redhat.com> Patchwork-id: 51112 O-Subject: [RHEL-6.5 qemu-kvm PATCH v2 13/56] qemu-sockets: add Error ** to all functions Bugzilla: 952873 RH-Acked-by: Jeffrey Cody RH-Acked-by: Gerd Hoffmann RH-Acked-by: Paolo Bonzini This lets me adjust the clients to do proper error propagation first, thus avoiding temporary regressions in the quality of the error messages. Reviewed-by: Luiz Capitulino Signed-off-by: Paolo Bonzini (cherry picked from commit 7fc4e63ec018a0ef6d420ddb7f6cbf68387d4995) Conflicts: nbd.c ui/vnc.c RHEL-6 note: nbd.c doesn't use unix_listen / unix_connect Signed-off-by: Laszlo Ersek --- qemu_socket.h | 10 +++++----- qemu-char.c | 6 +++--- qemu-sockets.c | 22 +++++++++++----------- qga/channel-posix.c | 2 +- vnc.c | 4 ++-- 5 files changed, 22 insertions(+), 22 deletions(-) Signed-off-by: Michal Novotny --- qemu-char.c | 6 +++--- qemu-sockets.c | 22 +++++++++++----------- qemu_socket.h | 10 +++++----- qga/channel-posix.c | 2 +- vnc.c | 4 ++-- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/qemu-char.c b/qemu-char.c index 0e42bdb..1c086b3 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -1980,7 +1980,7 @@ static CharDriverState *qemu_chr_open_udp(QemuOpts *opts) chr = qemu_mallocz(sizeof(CharDriverState)); s = qemu_mallocz(sizeof(NetCharDriver)); - fd = inet_dgram_opts(opts); + fd = inet_dgram_opts(opts, NULL); if (fd < 0) { fprintf(stderr, "inet_dgram_opts failed\n"); goto return_err; @@ -2342,9 +2342,9 @@ static CharDriverState *qemu_chr_open_socket(QemuOpts *opts) if (is_unix) { if (is_listen) { - fd = unix_listen_opts(opts); + fd = unix_listen_opts(opts, NULL); } else { - fd = unix_connect_opts(opts); + fd = unix_connect_opts(opts, NULL); } } else { if (is_listen) { diff --git a/qemu-sockets.c b/qemu-sockets.c index a2a1e68..0625d75 100644 --- a/qemu-sockets.c +++ b/qemu-sockets.c @@ -401,7 +401,7 @@ int inet_connect_opts(QemuOpts *opts, Error **errp, return sock; } -int inet_dgram_opts(QemuOpts *opts) +int inet_dgram_opts(QemuOpts *opts, Error **errp) { struct addrinfo ai, *peer = NULL, *local = NULL; const char *addr; @@ -651,7 +651,7 @@ int inet_nonblocking_connect(const char *str, #ifndef _WIN32 -int unix_listen_opts(QemuOpts *opts) +int unix_listen_opts(QemuOpts *opts, Error **errp) { struct sockaddr_un un; const char *path = qemu_opt_get(opts, "path"); @@ -699,7 +699,7 @@ err: return -1; } -int unix_connect_opts(QemuOpts *opts) +int unix_connect_opts(QemuOpts *opts, Error **errp) { struct sockaddr_un un; const char *path = qemu_opt_get(opts, "path"); @@ -729,7 +729,7 @@ int unix_connect_opts(QemuOpts *opts) } /* compatibility wrapper */ -int unix_listen(const char *str, char *ostr, int olen) +int unix_listen(const char *str, char *ostr, int olen, Error **errp) { QemuOpts *opts; char *path, *optstr; @@ -750,7 +750,7 @@ int unix_listen(const char *str, char *ostr, int olen) qemu_opt_set(opts, "path", str); } - sock = unix_listen_opts(opts); + sock = unix_listen_opts(opts, errp); if (sock != -1 && ostr) snprintf(ostr, olen, "%s%s", qemu_opt_get(opts, "path"), optstr ? optstr : ""); @@ -758,39 +758,39 @@ int unix_listen(const char *str, char *ostr, int olen) return sock; } -int unix_connect(const char *path) +int unix_connect(const char *path, Error **errp) { QemuOpts *opts; int sock; opts = qemu_opts_create(&dummy_opts, NULL, 0); qemu_opt_set(opts, "path", path); - sock = unix_connect_opts(opts); + sock = unix_connect_opts(opts, errp); qemu_opts_del(opts); return sock; } #else -int unix_listen_opts(QemuOpts *opts) +int unix_listen_opts(QemuOpts *opts, Error **errp) { fprintf(stderr, "unix sockets are not available on windows\n"); return -1; } -int unix_connect_opts(QemuOpts *opts) +int unix_connect_opts(QemuOpts *opts, Error **errp) { fprintf(stderr, "unix sockets are not available on windows\n"); return -1; } -int unix_listen(const char *path, char *ostr, int olen) +int unix_listen(const char *path, char *ostr, int olen, Error **errp) { fprintf(stderr, "unix sockets are not available on windows\n"); return -1; } -int unix_connect(const char *path) +int unix_connect(const char *path, Error **errp) { fprintf(stderr, "unix sockets are not available on windows\n"); return -1; diff --git a/qemu_socket.h b/qemu_socket.h index 3c07fad..bb439d1 100644 --- a/qemu_socket.h +++ b/qemu_socket.h @@ -54,13 +54,13 @@ int inet_nonblocking_connect(const char *str, NonBlockingConnectHandler *callback, void *opaque, Error **errp); -int inet_dgram_opts(QemuOpts *opts); +int inet_dgram_opts(QemuOpts *opts, Error **errp); const char *inet_strfamily(int family); -int unix_listen_opts(QemuOpts *opts); -int unix_listen(const char *path, char *ostr, int olen); -int unix_connect_opts(QemuOpts *opts); -int unix_connect(const char *path); +int unix_listen_opts(QemuOpts *opts, Error **errp); +int unix_listen(const char *path, char *ostr, int olen, Error **errp); +int unix_connect_opts(QemuOpts *opts, Error **errp); +int unix_connect(const char *path, Error **errp); /* Old, ipv4 only bits. Don't use for new code. */ int parse_host_port(struct sockaddr_in *saddr, const char *str); diff --git a/qga/channel-posix.c b/qga/channel-posix.c index 57eea06..e22eee6 100644 --- a/qga/channel-posix.c +++ b/qga/channel-posix.c @@ -181,7 +181,7 @@ static gboolean ga_channel_open(GAChannel *c, const gchar *path, GAChannelMethod break; } case GA_CHANNEL_UNIX_LISTEN: { - int fd = unix_listen(path, NULL, strlen(path)); + int fd = unix_listen(path, NULL, strlen(path), NULL); if (fd == -1) { g_critical("error opening path: %s", strerror(errno)); return false; diff --git a/vnc.c b/vnc.c index 61a4def..624fecb 100644 --- a/vnc.c +++ b/vnc.c @@ -2852,7 +2852,7 @@ int vnc_display_open(DisplayState *ds, const char *display) if (reverse) { /* connect to viewer */ if (strncmp(display, "unix:", 5) == 0) - vs->lsock = unix_connect(display+5); + vs->lsock = unix_connect(display+5, NULL); else vs->lsock = inet_connect(display, NULL); if (-1 == vs->lsock) { @@ -2872,7 +2872,7 @@ int vnc_display_open(DisplayState *ds, const char *display) dpy = qemu_malloc(256); if (strncmp(display, "unix:", 5) == 0) { pstrcpy(dpy, 256, "unix:"); - vs->lsock = unix_listen(display+5, dpy+5, 256-5); + vs->lsock = unix_listen(display+5, dpy+5, 256-5, NULL); } else { vs->lsock = inet_listen(display, dpy, 256, SOCK_STREAM, 5900, NULL); -- 1.7.11.7