qemu-sockets: Simplify setting numeric and boolean options
Don't convert numbers or bools to strings for use with qemu_opt_set(), simply use qemu_opt_set_number() or qemu_opt_set_bool() instead. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
a8b18f8fd2
commit
62b3de6934
|
@ -199,12 +199,12 @@ listen:
|
||||||
freeaddrinfo(res);
|
freeaddrinfo(res);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
snprintf(uport, sizeof(uport), "%d", inet_getport(e) - port_offset);
|
|
||||||
qemu_opt_set(opts, "host", uaddr, &error_abort);
|
qemu_opt_set(opts, "host", uaddr, &error_abort);
|
||||||
qemu_opt_set(opts, "port", uport, &error_abort);
|
qemu_opt_set_number(opts, "port", inet_getport(e) - port_offset,
|
||||||
qemu_opt_set(opts, "ipv6", (e->ai_family == PF_INET6) ? "on" : "off",
|
|
||||||
&error_abort);
|
&error_abort);
|
||||||
qemu_opt_set(opts, "ipv4", (e->ai_family != PF_INET6) ? "on" : "off",
|
qemu_opt_set_bool(opts, "ipv6", e->ai_family == PF_INET6,
|
||||||
|
&error_abort);
|
||||||
|
qemu_opt_set_bool(opts, "ipv4", e->ai_family != PF_INET6,
|
||||||
&error_abort);
|
&error_abort);
|
||||||
freeaddrinfo(res);
|
freeaddrinfo(res);
|
||||||
return slisten;
|
return slisten;
|
||||||
|
@ -586,9 +586,7 @@ static void inet_addr_to_opts(QemuOpts *opts, const InetSocketAddress *addr)
|
||||||
qemu_opt_set_bool(opts, "ipv6", ipv6, &error_abort);
|
qemu_opt_set_bool(opts, "ipv6", ipv6, &error_abort);
|
||||||
}
|
}
|
||||||
if (addr->has_to) {
|
if (addr->has_to) {
|
||||||
char to[20];
|
qemu_opt_set_number(opts, "to", addr->to, &error_abort);
|
||||||
snprintf(to, sizeof(to), "%d", addr->to);
|
|
||||||
qemu_opt_set(opts, "to", to, &error_abort);
|
|
||||||
}
|
}
|
||||||
qemu_opt_set(opts, "host", addr->host, &error_abort);
|
qemu_opt_set(opts, "host", addr->host, &error_abort);
|
||||||
qemu_opt_set(opts, "port", addr->port, &error_abort);
|
qemu_opt_set(opts, "port", addr->port, &error_abort);
|
||||||
|
|
Loading…
Reference in a new issue