From f17c90bed11a6e277614b5a5d16434004f24d572 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Fri, 15 Mar 2013 11:55:29 +0100 Subject: nbd: Keep hostname and port separate The NBD block supports an URL syntax, for which a URL parser returns separate hostname and port fields. It also supports the traditional qemu syntax encoded in a filename. Until now, after parsing the URL to get each piece of information, a new string is built to be fed to socket functions. Instead of building a string in the URL case that is immediately parsed again, parse the string in both cases and use the QemuOpts interface to qemu-sockets.c. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- util/qemu-sockets.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'util') diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 39717d0..dc7524d 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -485,7 +485,7 @@ err: } /* compatibility wrapper */ -static InetSocketAddress *inet_parse(const char *str, Error **errp) +InetSocketAddress *inet_parse(const char *str, Error **errp) { InetSocketAddress *addr; const char *optstr, *h; @@ -555,7 +555,7 @@ fail: return NULL; } -static void inet_addr_to_opts(QemuOpts *opts, InetSocketAddress *addr) +static void inet_addr_to_opts(QemuOpts *opts, const InetSocketAddress *addr) { bool ipv4 = addr->ipv4 || !addr->has_ipv4; bool ipv6 = addr->ipv6 || !addr->has_ipv6; @@ -622,7 +622,7 @@ int inet_connect(const char *str, Error **errp) addr = inet_parse(str, errp); if (addr != NULL) { - opts = qemu_opts_create_nofail(&dummy_opts); + opts = qemu_opts_create_nofail(&socket_optslist); inet_addr_to_opts(opts, addr); qapi_free_InetSocketAddress(addr); sock = inet_connect_opts(opts, errp, NULL, NULL); -- cgit v1.1