aboutsummaryrefslogtreecommitdiff
path: root/util/qemu-sockets.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2015-02-12 17:52:20 +0100
committerMarkus Armbruster <armbru@redhat.com>2015-02-26 14:49:31 +0100
commitf43e47dbf6de24db20ec9b588bb6cc762093dd69 (patch)
treee6236f3afaabde624458eab11e8daaa7e0dd4878 /util/qemu-sockets.c
parent6be4194b9215ed29f258543ce34a1b4b2003864d (diff)
QemuOpts: Drop qemu_opt_set(), rename qemu_opt_set_err(), fix use
qemu_opt_set() is a wrapper around qemu_opt_set() that reports the error with qerror_report_err(). Most of its users assume the function can't fail. Make them use qemu_opt_set_err() with &error_abort, so that should the assumption ever break, it'll break noisily. Just two users remain, in util/qemu-config.c. Switch them to qemu_opt_set_err() as well, then rename qemu_opt_set_err() to qemu_opt_set(). Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'util/qemu-sockets.c')
-rw-r--r--util/qemu-sockets.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index 7205dad820..e9085237c6 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -200,10 +200,12 @@ listen:
return -1;
}
snprintf(uport, sizeof(uport), "%d", inet_getport(e) - port_offset);
- qemu_opt_set(opts, "host", uaddr);
- qemu_opt_set(opts, "port", uport);
- qemu_opt_set(opts, "ipv6", (e->ai_family == PF_INET6) ? "on" : "off");
- qemu_opt_set(opts, "ipv4", (e->ai_family != PF_INET6) ? "on" : "off");
+ qemu_opt_set(opts, "host", uaddr, &error_abort);
+ qemu_opt_set(opts, "port", uport, &error_abort);
+ qemu_opt_set(opts, "ipv6", (e->ai_family == PF_INET6) ? "on" : "off",
+ &error_abort);
+ qemu_opt_set(opts, "ipv4", (e->ai_family != PF_INET6) ? "on" : "off",
+ &error_abort);
freeaddrinfo(res);
return slisten;
}
@@ -586,10 +588,10 @@ static void inet_addr_to_opts(QemuOpts *opts, const InetSocketAddress *addr)
if (addr->has_to) {
char to[20];
snprintf(to, sizeof(to), "%d", addr->to);
- qemu_opt_set(opts, "to", to);
+ qemu_opt_set(opts, "to", to, &error_abort);
}
- qemu_opt_set(opts, "host", addr->host);
- qemu_opt_set(opts, "port", addr->port);
+ qemu_opt_set(opts, "host", addr->host, &error_abort);
+ qemu_opt_set(opts, "port", addr->port, &error_abort);
}
int inet_listen(const char *str, char *ostr, int olen,
@@ -726,7 +728,7 @@ int unix_listen_opts(QemuOpts *opts, Error **errp)
goto err;
}
close(fd);
- qemu_opt_set(opts, "path", un.sun_path);
+ qemu_opt_set(opts, "path", un.sun_path, &error_abort);
}
unlink(un.sun_path);
@@ -838,11 +840,11 @@ int unix_listen(const char *str, char *ostr, int olen, Error **errp)
if (len) {
path = g_malloc(len+1);
snprintf(path, len+1, "%.*s", len, str);
- qemu_opt_set(opts, "path", path);
+ qemu_opt_set(opts, "path", path, &error_abort);
g_free(path);
}
} else {
- qemu_opt_set(opts, "path", str);
+ qemu_opt_set(opts, "path", str, &error_abort);
}
sock = unix_listen_opts(opts, errp);
@@ -859,7 +861,7 @@ int unix_connect(const char *path, Error **errp)
int sock;
opts = qemu_opts_create(&socket_optslist, NULL, 0, &error_abort);
- qemu_opt_set(opts, "path", path);
+ qemu_opt_set(opts, "path", path, &error_abort);
sock = unix_connect_opts(opts, errp, NULL, NULL);
qemu_opts_del(opts);
return sock;
@@ -876,7 +878,7 @@ int unix_nonblocking_connect(const char *path,
g_assert(callback != NULL);
opts = qemu_opts_create(&socket_optslist, NULL, 0, &error_abort);
- qemu_opt_set(opts, "path", path);
+ qemu_opt_set(opts, "path", path, &error_abort);
sock = unix_connect_opts(opts, errp, callback, opaque);
qemu_opts_del(opts);
return sock;
@@ -933,7 +935,7 @@ int socket_connect(SocketAddress *addr, Error **errp,
break;
case SOCKET_ADDRESS_KIND_UNIX:
- qemu_opt_set(opts, "path", addr->q_unix->path);
+ qemu_opt_set(opts, "path", addr->q_unix->path, &error_abort);
fd = unix_connect_opts(opts, errp, callback, opaque);
break;
@@ -965,7 +967,7 @@ int socket_listen(SocketAddress *addr, Error **errp)
break;
case SOCKET_ADDRESS_KIND_UNIX:
- qemu_opt_set(opts, "path", addr->q_unix->path);
+ qemu_opt_set(opts, "path", addr->q_unix->path, &error_abort);
fd = unix_listen_opts(opts, errp);
break;
@@ -990,8 +992,8 @@ int socket_dgram(SocketAddress *remote, SocketAddress *local, Error **errp)
case SOCKET_ADDRESS_KIND_INET:
inet_addr_to_opts(opts, remote->inet);
if (local) {
- qemu_opt_set(opts, "localaddr", local->inet->host);
- qemu_opt_set(opts, "localport", local->inet->port);
+ qemu_opt_set(opts, "localaddr", local->inet->host, &error_abort);
+ qemu_opt_set(opts, "localport", local->inet->port, &error_abort);
}
fd = inet_dgram_opts(opts, errp);
break;