[PATCH 4/9] util: storage: use stored index to lookup disks

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

 



We can now use the backing store ID directly rather than counting the
number of images seen while looking up images.
---
 src/util/virstoragefile.c | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 2b9f4c892..9568a5068 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -1588,25 +1588,14 @@ virStorageFileChainLookup(virStorageSourcePtr chain,
     const char *start = chain->path;
     char *parentDir = NULL;
     bool nameIsFile = virStorageIsFile(name);
-    size_t i = 0;

     if (!parent)
         parent = &prev;
     *parent = NULL;

     if (startFrom) {
-        while (chain && chain != startFrom->backingStore) {
+        while (chain && chain != startFrom->backingStore)
             chain = chain->backingStore;
-            i++;
-        }
-
-        if (idx && idx < i) {
-            virReportError(VIR_ERR_INVALID_ARG,
-                           _("requested backing store index %u is above '%s' "
-                             "in chain for '%s'"),
-                           idx, NULLSTR(startFrom->path), NULLSTR(start));
-            return NULL;
-        }

         *parent = startFrom;
     }
@@ -1616,8 +1605,8 @@ virStorageFileChainLookup(virStorageSourcePtr chain,
             if (!chain->backingStore)
                 break;
         } else if (idx) {
-            VIR_DEBUG("%zu: %s", i, chain->path);
-            if (idx == i)
+            VIR_DEBUG("%u: %s", chain->id, chain->path);
+            if (idx == chain->id)
                 break;
         } else {
             if (STREQ_NULLABLE(name, chain->relPath) ||
@@ -1649,7 +1638,6 @@ virStorageFileChainLookup(virStorageSourcePtr chain,
         }
         *parent = chain;
         chain = chain->backingStore;
-        i++;
     }

     if (!chain)
-- 
2.14.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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