From nobody Thu May 15 10:07:38 2025 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 150971953375860.234498240570815; Fri, 3 Nov 2017 07:32:13 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6236D4E90D; Fri, 3 Nov 2017 14:32:12 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 15F7A5EE02; Fri, 3 Nov 2017 14:32:12 +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 BD04714B1C; Fri, 3 Nov 2017 14:32:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vA3ETrFg028720 for ; Fri, 3 Nov 2017 10:29:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3C4AC60618; Fri, 3 Nov 2017 14:29:53 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id B724C60619 for ; Fri, 3 Nov 2017 14:29:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6236D4E90D Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 3 Nov 2017 15:29:20 +0100 Message-Id: <8cf0392318993ab406948ce4e2de098a7b7cc94f.1509719227.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 03/12] storage: Don't store leading '/' in image name when splitting out volume 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: , MIME-Version: 1.0 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 03 Nov 2017 14:32:12 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Libvirt historically stores storage source path including the volume as one string in the XML, but that is not really flexible enough when dealing with the fields in the code. Previously we'd store the slash separating the two as part of the image name. This was fine for gluster but it's not necessary and does not scale well when converting other protocols. Don't store the slash as part of the path. The resulting change from absolute to relative path within the gluster driver should be okay, as the root directory is the default when accessing gluster. --- src/conf/domain_conf.c | 4 ++= -- src/qemu/qemu_block.c | 2 +- src/util/virstoragefile.c | 4 ++= -- tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-gluster.args | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 77c20c697..01cd3811c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8398,7 +8398,7 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node, src->volume =3D src->path; - if (VIR_STRDUP(src->path, tmp) < 0) + if (VIR_STRDUP(src->path, tmp + 1) < 0) goto cleanup; tmp[0] =3D '\0'; @@ -22158,7 +22158,7 @@ virDomainDiskSourceFormatNetwork(virBufferPtr attrB= uf, virStorageNetProtocolTypeToString(src->protocol)); if (src->volume) { - if (virAsprintf(&path, "%s%s", src->volume, src->path) < 0) + if (virAsprintf(&path, "%s/%s", src->volume, src->path) < 0) return -1; } diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 018d7c7ec..08020d797 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -426,7 +426,7 @@ qemuBlockStorageSourceGetURI(virStorageSourcePtr src) if (src->path) { if (src->volume) { - if (virAsprintf(&uri->path, "/%s%s", + if (virAsprintf(&uri->path, "/%s/%s", src->volume, src->path) < 0) goto cleanup; } else { diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 3a2d2aa05..d48358abb 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2450,7 +2450,7 @@ virStorageSourceParseBackingURI(virStorageSourcePtr s= rc, src->volume =3D src->path; - if (VIR_STRDUP(src->path, tmp) < 0) + if (VIR_STRDUP(src->path, tmp + 1) < 0) goto cleanup; tmp[0] =3D '\0'; @@ -2931,7 +2931,7 @@ virStorageSourceParseBackingJSONGluster(virStorageSou= rcePtr src, src->protocol =3D VIR_STORAGE_NET_PROTOCOL_GLUSTER; if (VIR_STRDUP(src->volume, volume) < 0 || - virAsprintf(&src->path, "/%s", path) < 0) + VIR_STRDUP(src->path, path) < 0) return -1; nservers =3D virJSONValueArraySize(server); diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-gluster= .args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-gluster.args index 990616955..6cfbe36fe 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-gluster.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-gluster.args @@ -27,7 +27,7 @@ id=3Dvirtio-disk0 \ format=3Draw,if=3Dnone,id=3Ddrive-virtio-disk1' \ -device virtio-blk-pci,bus=3Dpci.0,addr=3D0x4,drive=3Ddrive-virtio-disk1,\ id=3Dvirtio-disk1 \ --drive file.driver=3Dgluster,file.volume=3DVolume3,file.path=3D/Image.qcow= 2,\ +-drive file.driver=3Dgluster,file.volume=3DVolume3,file.path=3DImage.qcow2= ,\ file.server.0.type=3Dtcp,file.server.0.host=3Dexample.org,file.server.0.po= rt=3D6000,\ file.server.1.type=3Dtcp,file.server.1.host=3Dexample.org,file.server.1.po= rt=3D24007,\ file.server.2.type=3Dunix,file.server.2.socket=3D/path/to/sock,file.debug= =3D4,\ --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list