mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 23:33:54 -06:00
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>
This commit is contained in:
parent
e62be8888a
commit
f17c90bed1
5 changed files with 58 additions and 12 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue