From patchwork Tue Jun 18 14:14:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 252355 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C63442C0174 for ; Wed, 19 Jun 2013 00:16:05 +1000 (EST) Received: from localhost ([::1]:50687 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UowhX-0006Ww-4h for incoming@patchwork.ozlabs.org; Tue, 18 Jun 2013 10:16:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35316) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uowg2-0004Z0-5i for qemu-devel@nongnu.org; Tue, 18 Jun 2013 10:14:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uowfx-0000XT-Hm for qemu-devel@nongnu.org; Tue, 18 Jun 2013 10:14:30 -0400 Received: from mail-wg0-x236.google.com ([2a00:1450:400c:c00::236]:44588) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uowfx-0000Wu-BW; Tue, 18 Jun 2013 10:14:25 -0400 Received: by mail-wg0-f54.google.com with SMTP id n11so3470259wgh.33 for ; Tue, 18 Jun 2013 07:14:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=k0aeEuNbh6iNPvowWfFDKhV4FHDN1BeDH1DxVFTfWSs=; b=obWgeF+kXpVN8riGb7ifD+bqaaicQ1i6wETeLfsioDS/HiXiz+Bhd8SiQuUeC8zrse OxAVSF8nhgjIyN//WkJ4kAwZ1d9MuzQlEZQTn5q8qpkJALM0+Ht493AFAPO9Ggi+3MnN MZtQbuRrxKcH07N6S/LQGOU+tUCi/DCI3XUN8Sep6EcGtUBUWwMb/+ni9TKB7OxHRVq7 ggpjr/MFj8d1RrCOExUnCjk3MzFZcQjE3MSIHjrIKtuub2LPzPJDfSpJpnUdleQs4tkQ UF6a0GNO8GdUae8NcEwTzXrTkaGfm/QDtlNOivsykkb+gr5qV5i82RDnRwxtfJA1dkxx FCmg== X-Received: by 10.194.157.99 with SMTP id wl3mr10971730wjb.76.1371564864545; Tue, 18 Jun 2013 07:14:24 -0700 (PDT) Received: from playground.lan (net-37-116-217-184.cust.dsl.vodafone.it. [37.116.217.184]) by mx.google.com with ESMTPSA id x13sm2380289wib.3.2013.06.18.07.14.22 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 18 Jun 2013 07:14:23 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 18 Jun 2013 16:14:14 +0200 Message-Id: <1371564854-2248-3-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1371564854-2248-1-git-send-email-pbonzini@redhat.com> References: <1371564854-2248-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c00::236 Cc: =?UTF-8?q?J=C3=A1n=20Tomko?= , qemu-stable@nongnu.org Subject: [Qemu-devel] [PATCH 2/2] nbd: strip braces from literal IPv6 address in URI X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Ján Tomko 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 Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini --- block/nbd.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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));