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 --- nbd.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'nbd.c') diff --git a/nbd.c b/nbd.c index 0698a023ad..97879ca204 100644 --- a/nbd.c +++ b/nbd.c @@ -218,6 +218,18 @@ int tcp_socket_outgoing_spec(const char *address_and_port) return fd; } +int tcp_socket_outgoing_opts(QemuOpts *opts) +{ + Error *local_err = NULL; + int fd = inet_connect_opts(opts, &local_err, NULL, NULL); + if (local_err != NULL) { + qerror_report_err(local_err); + error_free(local_err); + } + + return fd; +} + int tcp_socket_incoming(const char *address, uint16_t port) { char address_and_port[128]; -- cgit v1.2.1