[PATCH] storage: zfs: split pool and volume names properly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Before, the volume name was determined as the last token after any /
character. This does not work with zvols below the top level of the
pool: /dev/zvols/pool/images/vm1 is truncated to /dev/zvols/pool/vm1.
This patch removes the pool name only, so when using the pool "pool",
the volume path "images/vm1" is used.
---
 src/storage/storage_backend_zfs.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/storage/storage_backend_zfs.c b/src/storage/storage_backend_zfs.c
index 2a5d74357d..397ea7f386 100644
--- a/src/storage/storage_backend_zfs.c
+++ b/src/storage/storage_backend_zfs.c
@@ -104,7 +104,7 @@ virStorageBackendZFSParseVol(virStoragePoolObj *pool,
     virStorageVolDef *volume = NULL;
     virStoragePoolDef *def = virStoragePoolObjGetDef(pool);
     g_auto(GStrv) tokens = NULL;
-    char *tmp;
+    char *pool_name = def->source.name;
 
     if (!(tokens = g_strsplit(volume_string, "\t", 0)))
         return -1;
@@ -113,8 +113,9 @@ virStorageBackendZFSParseVol(virStoragePoolObj *pool,
         goto cleanup;
 
     vol_name = tokens[0];
-    if ((tmp = strrchr(vol_name, '/')))
-        vol_name = tmp + 1;
+    if (strlen(vol_name) > strlen(pool_name) &&
+        STRPREFIX(vol_name, pool_name))
+        vol_name += strlen(pool_name) + 1;
 
     if (vol == NULL)
         volume = virStorageVolDefFindByName(pool, vol_name);
-- 
2.36.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux