]> xenbits.xensource.com Git - libvirt.git/commitdiff
storage: Don't store leading '/' in image name when splitting out volume
authorPeter Krempa <pkrempa@redhat.com>
Mon, 23 Oct 2017 14:39:49 +0000 (16:39 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 7 Nov 2017 13:58:04 +0000 (14:58 +0100)
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
src/qemu/qemu_block.c
src/util/virstoragefile.c
tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-gluster.args

index aefc7a4f15329f768cc9f1df13cf7f1115b77f66..75b4b99dcfff19d7863360b71da121abc4a1657d 100644 (file)
@@ -8403,7 +8403,7 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node,
 
         src->volume = src->path;
 
-        if (VIR_STRDUP(src->path, tmp) < 0)
+        if (VIR_STRDUP(src->path, tmp + 1) < 0)
             goto cleanup;
 
         tmp[0] = '\0';
@@ -22167,7 +22167,7 @@ virDomainDiskSourceFormatNetwork(virBufferPtr attrBuf,
                       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;
     }
 
index 77e48bed8370a4042844ae18620bcf4e4a803e71..408817dfc661fa5213a10591c0eaa7d546583bed 100644 (file)
@@ -427,7 +427,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 {
index 3a2d2aa0568aeb6dc548f2cc032a3445ad29c6a2..d48358abb0667e62b24c14cd6bb5eda57d6f3509 100644 (file)
@@ -2450,7 +2450,7 @@ virStorageSourceParseBackingURI(virStorageSourcePtr src,
 
         src->volume = src->path;
 
-        if (VIR_STRDUP(src->path, tmp) < 0)
+        if (VIR_STRDUP(src->path, tmp + 1) < 0)
             goto cleanup;
 
         tmp[0] = '\0';
@@ -2931,7 +2931,7 @@ virStorageSourceParseBackingJSONGluster(virStorageSourcePtr src,
     src->protocol = 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 = virJSONValueArraySize(server);
index 9906169559755e5a0c90feb15ab26a8e24dfe068..6cfbe36feb92423176401f071f79a34197c8cfdc 100644 (file)
@@ -27,7 +27,7 @@ id=virtio-disk0 \
 format=raw,if=none,id=drive-virtio-disk1' \
 -device virtio-blk-pci,bus=pci.0,addr=0x4,drive=drive-virtio-disk1,\
 id=virtio-disk1 \
--drive file.driver=gluster,file.volume=Volume3,file.path=/Image.qcow2,\
+-drive file.driver=gluster,file.volume=Volume3,file.path=Image.qcow2,\
 file.server.0.type=tcp,file.server.0.host=example.org,file.server.0.port=6000,\
 file.server.1.type=tcp,file.server.1.host=example.org,file.server.1.port=24007,\
 file.server.2.type=unix,file.server.2.socket=/path/to/sock,file.debug=4,\