From nobody Sun May 5 02:51:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1564586581; cv=none; d=zoho.com; s=zohoarc; b=lNzs/+bIzjTocOPGOivUFdz2sWRmG/6z5URbUGAcZ+dBXVit4wMOOBsml+CWHF7tRsxydptpfMF6VSsrniFy3crhlxD556Y4KaiaxWJ7XBF5u0dFxNixtWWTnI4MWKW1Az8W9zPv0XfziaAC7I/kYMz/vqL3m4ZKUZlrGgFhrI8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564586581; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=ZZR9mk7kQISGztZMhKNujes8+qlJqkrDPDkPByVGnJw=; b=Spx9snYlKYsKFc0VYL0z6DrchKFOIJFW5g5P4QD4AvqngPgQ6JDH6QOfHkjgZjKBdzaF6kGCXXRURrfznYjvPUj8QgagP/Ky+aA83i6lTnJnv9M+R6ni0hAcw8wR0kOJbo4a+yRHdibTe6+HWAjiyalC7roxZ/NkAhtMnzR11KE= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1564586581088739.0009741817279; Wed, 31 Jul 2019 08:23:01 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9C0C730C1321; Wed, 31 Jul 2019 15:22:58 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F390D5D9C5; Wed, 31 Jul 2019 15:22:56 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9558B180B7B0; Wed, 31 Jul 2019 15:22:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6VFMqI4007296 for ; Wed, 31 Jul 2019 11:22:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3F711600F8; Wed, 31 Jul 2019 15:22:52 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id BD269600C4 for ; Wed, 31 Jul 2019 15:22:49 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 31 Jul 2019 17:22:48 +0200 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] util: storage: Fix parsing of 'exportname' from legacy NBD strings X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Wed, 31 Jul 2019 15:23:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" If the nbd export name contains a colon, our parser would not parse it properly as we split the string by colons. Modify the code to look up the exportname and copy any trailing characters as the export name is supposed to be at the end of the string. https://bugzilla.redhat.com/show_bug.cgi?id=3D1733044 Signed-off-by: Peter Krempa Reviewed-by: Jiri Denemark --- src/util/virstoragefile.c | 6 ++++-- tests/virstoragetest.c | 8 ++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index a6de6a1e45..ffafeef9d8 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2928,6 +2928,7 @@ virStorageSourceParseNBDColonString(const char *nbdst= r, virStorageSourcePtr src) { VIR_AUTOSTRINGLIST backing =3D NULL; + const char *exportname; if (!(backing =3D virStringSplit(nbdstr, ":", 0))) return -1; @@ -2975,8 +2976,9 @@ virStorageSourceParseNBDColonString(const char *nbdst= r, return -1; } - if (backing[3] && STRPREFIX(backing[3], "exportname=3D")) { - if (VIR_STRDUP(src->path, backing[3] + strlen("exportname=3D")) < = 0) + if ((exportname =3D strstr(nbdstr, "exportname=3D"))) { + exportname +=3D strlen("exportname=3D"); + if (VIR_STRDUP(src->path, exportname) < 0) return -1; } diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index ef16b3c6e0..f558eea622 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -1262,6 +1262,14 @@ mymain(void) "\n" " \n" "\n"); + TEST_BACKING_PARSE("nbd:example.org:6000:exportname=3D:", + "\n" + " \n" + "\n"); + TEST_BACKING_PARSE("nbd:example.org:6000:exportname=3D:test", + "\n" + " \n" + "\n"); TEST_BACKING_PARSE("nbd://example.org:1234", "\n" " \n" --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list