aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJán Tomko <jtomko@redhat.com>2013-06-03 17:54:56 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2013-06-18 11:43:00 +0200
commit23307908790cd8fad91220863d7712c571ddc977 (patch)
treef78118f8b492563090836b8148fbb0ed2130d9a0
parent391b7b9701ba3318e890ec0cba97a3c654bfa667 (diff)
downloadqemu-23307908790cd8fad91220863d7712c571ddc977.zip
qemu-23307908790cd8fad91220863d7712c571ddc977.tar.gz
qemu-23307908790cd8fad91220863d7712c571ddc977.tar.bz2
nbd: strip braces from literal IPv6 address in URI
Otherwise they would get passed to getaddrinfo and fail with: address resolution failed for [::1]:1234: Name or service not known (Broken by commit v1.4.0-736-gf17c90b) Signed-off-by: Ján Tomko <jtomko@redhat.com> Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--block/nbd.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/block/nbd.c b/block/nbd.c
index 30e3b78..9c480b8 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -118,13 +118,22 @@ static int nbd_parse_uri(const char *filename, QDict *options)
}
qdict_put(options, "path", qstring_from_str(qp->p[0].value));
} else {
+ QString *host;
/* nbd[+tcp]://host[:port]/export */
if (!uri->server) {
ret = -EINVAL;
goto out;
}
- qdict_put(options, "host", qstring_from_str(uri->server));
+ /* strip braces from literal IPv6 address */
+ if (uri->server[0] == '[') {
+ host = qstring_from_substr(uri->server, 1,
+ strlen(uri->server) - 2);
+ } else {
+ host = qstring_from_str(uri->server);
+ }
+
+ qdict_put(options, "host", host);
if (uri->port) {
char* port_str = g_strdup_printf("%d", uri->port);
qdict_put(options, "port", qstring_from_str(port_str));