diff options
author | Kevin Wolf <kwolf@redhat.com> | 2013-03-15 11:55:29 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2013-03-22 17:51:31 +0100 |
commit | f17c90bed11a6e277614b5a5d16434004f24d572 (patch) | |
tree | 5994d06681764c31bf5c679163ae1a3c9d1229df /util/qemu-sockets.c | |
parent | e62be8888a83aa0ab7f50eeb954deb2ec4e7201d (diff) |
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 <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'util/qemu-sockets.c')
-rw-r--r-- | util/qemu-sockets.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 39717d0a5b..dc7524d829 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); |