From nobody Sun Oct 5 19:07:09 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581474740772142.11282827755315; Tue, 11 Feb 2020 18:32:20 -0800 (PST) Received: from localhost ([::1]:59268 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j1hp3-0008Un-1d for importer@patchew.org; Tue, 11 Feb 2020 21:32:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34170) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j1ho6-0007zG-C0 for qemu-devel@nongnu.org; Tue, 11 Feb 2020 21:31:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j1ho3-000398-PK for qemu-devel@nongnu.org; Tue, 11 Feb 2020 21:31:16 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:43137 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j1ho1-0002vg-KK for qemu-devel@nongnu.org; Tue, 11 Feb 2020 21:31:13 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-336-GHA5L5nmO_apbw2klnd-QQ-1; Tue, 11 Feb 2020 21:31:06 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 15E148010D6; Wed, 12 Feb 2020 02:31:05 +0000 (UTC) Received: from blue.redhat.com (ovpn-116-180.phx2.redhat.com [10.3.116.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2411A83861; Wed, 12 Feb 2020 02:31:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581474669; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=VeAisc8y0P6jIDwsPqIx4DCj4izSZ7iAKd57+mgH+fs=; b=PLSa1CEs90gWv4gLwPXMpK1xWzkPx+lPz33dXjN3xhrEfVqWVew9aIyz/pwxgEv0INfrpY aIkmUWqhE7X+d9YjBALyVDC15QqpjrdmRvrUGsUMq1/84TbidUI0vn8E3mOQstnFjHeOEW OBAJdnFOY4u7DxrKGufaKRZlV1tZcaM= From: Eric Blake To: qemu-devel@nongnu.org Subject: [PATCH] nbd-client: Support leading / in NBD URI Date: Tue, 11 Feb 2020 20:31:01 -0600 Message-Id: <20200212023101.1162686-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: GHA5L5nmO_apbw2klnd-QQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , vsementsov@virtuozzo.com, rjones@redhat.com, "open list:Network Block Dev..." , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The NBD URI specification [1] states that only one leading slash at the beginning of the URI path component is stripped, not all such slashes. This becomes important to a patch I just proposed to nbdkit [2], which would allow the exportname to select a file embedded within an ext2 image: ext2fs demands an absolute pathname beginning with '/', and because qemu was inadvertantly stripping it, my nbdkit patch had to work around the behavior. [1] https://github.com/NetworkBlockDevice/nbd/blob/master/doc/uri.md [2] https://www.redhat.com/archives/libguestfs/2020-February/msg00109.html Note that the qemu bug only affects handling of URIs such as nbd://host:port//abs/path (where '/abs/path' should be the export name); it is still possible to use --image-opts and pass the desired export name with a leading slash directly through JSON even without this patch. Signed-off-by: Eric Blake Reviewed-by: J=C3=A1n Tomko --- block/nbd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/block/nbd.c b/block/nbd.c index d085554f21ea..82f9b7ef50a5 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -1516,8 +1516,10 @@ static int nbd_parse_uri(const char *filename, QDict= *options) goto out; } - p =3D uri->path ? uri->path : "/"; - p +=3D strspn(p, "/"); + p =3D uri->path ? uri->path : ""; + if (p[0] =3D=3D '/') { + p++; + } if (p[0]) { qdict_put_str(options, "export", p); } --=20 2.24.1