[libvirt] [PATCH 08/18] util: storagefile: Rename "canonPath" to "path" in virStorageFileMetadata

Peter Krempa pkrempa at redhat.com
Sun Apr 20 22:13:12 UTC 2014


As for the previous patch, this change is needed to achieve
compatibility with all the existing code, where we expect a fully
qualified path of local files to be present.
---
 src/util/virstoragefile.c | 18 +++++++--------
 src/util/virstoragefile.h |  2 +-
 tests/virstoragetest.c    | 56 +++++++++++++++++++++++------------------------
 3 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index f11dd36..d4d8427 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -948,7 +948,7 @@ virStorageFileMetadataNew(const char *path,
     if (VIR_STRDUP(ret->relPath, path) < 0)
         goto error;

-    if (!(ret->canonPath = canonicalize_file_name(path))) {
+    if (!(ret->path = canonicalize_file_name(path))) {
         virReportSystemError(errno, _("unable to resolve '%s'"), path);
         goto error;
     }
@@ -1042,7 +1042,7 @@ virStorageFileGetMetadataFromFDInternal(virStorageFileMetadataPtr meta,
          * file; therefore, no inclusion loop is possible, and we
          * don't need canonName or relDir.  */
         VIR_FREE(meta->relDir);
-        VIR_FREE(meta->canonPath);
+        VIR_FREE(meta->path);
         meta->type = VIR_STORAGE_TYPE_DIR;
         meta->format = VIR_STORAGE_FILE_DIR;
         ret = 0;
@@ -1134,7 +1134,7 @@ virStorageFileGetMetadataRecurse(const char *path, const char *canonPath,
     if (virStorageIsFile(path)) {
         if (VIR_STRDUP(meta->relPath, path) < 0)
             return -1;
-        if (VIR_STRDUP(meta->canonPath, canonPath) < 0)
+        if (VIR_STRDUP(meta->path, canonPath) < 0)
             return -1;
         if (VIR_STRDUP(meta->relDir, directory) < 0)
             return -1;
@@ -1155,7 +1155,7 @@ virStorageFileGetMetadataRecurse(const char *path, const char *canonPath,
          * allow for non-raw images.  */
         if (VIR_STRDUP(meta->relPath, path) < 0)
             return -1;
-        if (VIR_STRDUP(meta->canonPath, path) < 0)
+        if (VIR_STRDUP(meta->path, path) < 0)
             return -1;
         meta->type = VIR_STORAGE_TYPE_NETWORK;
         meta->format = VIR_STORAGE_FILE_RAW;
@@ -1317,7 +1317,7 @@ virStorageFileFreeMetadata(virStorageFileMetadata *meta)
         return;

     VIR_FREE(meta->relPath);
-    VIR_FREE(meta->canonPath);
+    VIR_FREE(meta->path);
     VIR_FREE(meta->relDir);

     virStorageFileFreeMetadata(meta->backingMeta);
@@ -1534,7 +1534,7 @@ virStorageFileChainLookup(virStorageFileMetadataPtr chain,
                           const char *name, virStorageFileMetadataPtr *meta,
                           const char **parent)
 {
-    const char *start = chain->canonPath;
+    const char *start = chain->path;
     const char *tmp;
     const char *parentDir = ".";
     bool nameIsFile = virStorageIsFile(name);
@@ -1553,14 +1553,14 @@ virStorageFileChainLookup(virStorageFileMetadataPtr chain,
             if (nameIsFile && (chain->type == VIR_STORAGE_TYPE_FILE ||
                                chain->type == VIR_STORAGE_TYPE_BLOCK)) {
                 int result = virFileRelLinkPointsTo(parentDir, name,
-                                                    chain->canonPath);
+                                                    chain->path);
                 if (result < 0)
                     goto error;
                 if (result > 0)
                     break;
             }
         }
-        *parent = chain->canonPath;
+        *parent = chain->path;
         parentDir = chain->relDir;
         chain = chain->backingMeta;
     }
@@ -1568,7 +1568,7 @@ virStorageFileChainLookup(virStorageFileMetadataPtr chain,
         goto error;
     if (meta)
         *meta = chain;
-    return chain->canonPath;
+    return chain->path;

  error:
     if (name)
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index 867214e..3f072b6 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -124,7 +124,7 @@ struct _virStorageFileMetadata {
     char *relPath;
     /* Canonical name of the current file, used to detect loops in the
      * backing store chain.  */
-    char *canonPath;
+    char *path;
     /* Directory to start from if backingStoreRaw is a relative file
      * name.  */
     char *relDir;
diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c
index b0de438..dabaa99 100644
--- a/tests/virstoragetest.c
+++ b/tests/virstoragetest.c
@@ -237,7 +237,7 @@ struct _testFileData
     bool expEncrypted;
     const char *pathRel;
     const char *pathAbs;
-    const char *canonPath;
+    const char *path;
     const char *relDirRel;
     const char *relDirAbs;
     int type;
@@ -323,24 +323,24 @@ testStorageChain(const void *args)
             : data->files[i]->relDirRel;
         if (virAsprintf(&expect,
                         "store:%s\nraw:%s\nother:%lld %d\n"
-                        "relPath:%s\ncanon:%s\nrelDir:%s\ntype:%d %d\n",
+                        "relPath:%s\npath:%s\nrelDir:%s\ntype:%d %d\n",
                         NULLSTR(data->files[i]->expBackingStore),
                         NULLSTR(data->files[i]->expBackingStoreRaw),
                         data->files[i]->expCapacity,
                         data->files[i]->expEncrypted,
                         NULLSTR(expPath),
-                        NULLSTR(data->files[i]->canonPath),
+                        NULLSTR(data->files[i]->path),
                         NULLSTR(expRelDir),
                         data->files[i]->type,
                         data->files[i]->format) < 0 ||
             virAsprintf(&actual,
                         "store:%s\nraw:%s\nother:%lld %d\n"
-                        "relPath:%s\ncanon:%s\nrelDir:%s\ntype:%d %d\n",
+                        "relPath:%s\npath:%s\nrelDir:%s\ntype:%d %d\n",
                         NULLSTR(elt->backingStore),
                         NULLSTR(elt->backingStoreRaw),
                         elt->capacity, !!elt->encryption,
                         NULLSTR(elt->relPath),
-                        NULLSTR(elt->canonPath),
+                        NULLSTR(elt->path),
                         NULLSTR(elt->relDir),
                         elt->type, elt->format) < 0) {
             VIR_FREE(expect);
@@ -491,7 +491,7 @@ mymain(void)
     testFileData raw = {
         .pathRel = "raw",
         .pathAbs = canonraw,
-        .canonPath = canonraw,
+        .path = canonraw,
         .relDirRel = ".",
         .relDirAbs = datadir,
         .type = VIR_STORAGE_TYPE_FILE,
@@ -516,7 +516,7 @@ mymain(void)
         .expCapacity = 1024,
         .pathRel = "qcow2",
         .pathAbs = canonqcow2,
-        .canonPath = canonqcow2,
+        .path = canonqcow2,
         .relDirRel = ".",
         .relDirAbs = datadir,
         .type = VIR_STORAGE_TYPE_FILE,
@@ -525,7 +525,7 @@ mymain(void)
     testFileData qcow2_as_raw = {
         .pathRel = "qcow2",
         .pathAbs = canonqcow2,
-        .canonPath = canonqcow2,
+        .path = canonqcow2,
         .relDirRel = ".",
         .relDirAbs = datadir,
         .type = VIR_STORAGE_TYPE_FILE,
@@ -572,7 +572,7 @@ mymain(void)
         .expCapacity = 1024,
         .pathRel = "wrap",
         .pathAbs = abswrap,
-        .canonPath = canonwrap,
+        .path = canonwrap,
         .relDirRel = ".",
         .relDirAbs = datadir,
         .type = VIR_STORAGE_TYPE_FILE,
@@ -608,7 +608,7 @@ mymain(void)
         .expCapacity = 1024,
         .pathRel = "wrap",
         .pathAbs = abswrap,
-        .canonPath = canonwrap,
+        .path = canonwrap,
         .relDirRel = ".",
         .relDirAbs = datadir,
         .type = VIR_STORAGE_TYPE_FILE,
@@ -667,7 +667,7 @@ mymain(void)
     testFileData nbd = {
         .pathRel = "nbd:example.org:6000",
         .pathAbs = "nbd:example.org:6000",
-        .canonPath = "nbd:example.org:6000",
+        .path = "nbd:example.org:6000",
         .type = VIR_STORAGE_TYPE_NETWORK,
         .format = VIR_STORAGE_FILE_RAW,
     };
@@ -684,7 +684,7 @@ mymain(void)
         .expCapacity = 1024,
         .pathRel = "qed",
         .pathAbs = absqed,
-        .canonPath = canonqed,
+        .path = canonqed,
         .relDirRel = ".",
         .relDirAbs = datadir,
         .type = VIR_STORAGE_TYPE_FILE,
@@ -693,7 +693,7 @@ mymain(void)
     testFileData qed_as_raw = {
         .pathRel = "qed",
         .pathAbs = absqed,
-        .canonPath = canonqed,
+        .path = canonqed,
         .relDirRel = ".",
         .relDirAbs = datadir,
         .type = VIR_STORAGE_TYPE_FILE,
@@ -746,7 +746,7 @@ mymain(void)
         .expCapacity = 1024,
         .pathRel = "../sub/link1",
         .pathAbs = "../sub/link1",
-        .canonPath = canonqcow2,
+        .path = canonqcow2,
         .relDirRel = "sub/../sub",
         .relDirAbs = datadir "/sub/../sub",
         .type = VIR_STORAGE_TYPE_FILE,
@@ -758,7 +758,7 @@ mymain(void)
         .expCapacity = 1024,
         .pathRel = "sub/link2",
         .pathAbs = abslink2,
-        .canonPath = canonwrap,
+        .path = canonwrap,
         .relDirRel = "sub",
         .relDirAbs = datadir "/sub",
         .type = VIR_STORAGE_TYPE_FILE,
@@ -839,12 +839,12 @@ mymain(void)
     } while (0)

     TEST_LOOKUP(0, "bogus", NULL, NULL, NULL);
-    TEST_LOOKUP(1, "wrap", chain->canonPath, chain, NULL);
-    TEST_LOOKUP(2, abswrap, chain->canonPath, chain, NULL);
+    TEST_LOOKUP(1, "wrap", chain->path, chain, NULL);
+    TEST_LOOKUP(2, abswrap, chain->path, chain, NULL);
     TEST_LOOKUP(3, "qcow2", chain->backingStore, chain->backingMeta,
-                chain->canonPath);
+                chain->path);
     TEST_LOOKUP(4, absqcow2, chain->backingStore, chain->backingMeta,
-                chain->canonPath);
+                chain->path);
     TEST_LOOKUP(5, "raw", chain->backingMeta->backingStore,
                 chain->backingMeta->backingMeta, chain->backingStore);
     TEST_LOOKUP(6, absraw, chain->backingMeta->backingStore,
@@ -875,12 +875,12 @@ mymain(void)
     }

     TEST_LOOKUP(8, "bogus", NULL, NULL, NULL);
-    TEST_LOOKUP(9, "wrap", chain->canonPath, chain, NULL);
-    TEST_LOOKUP(10, abswrap, chain->canonPath, chain, NULL);
+    TEST_LOOKUP(9, "wrap", chain->path, chain, NULL);
+    TEST_LOOKUP(10, abswrap, chain->path, chain, NULL);
     TEST_LOOKUP(11, "qcow2", chain->backingStore, chain->backingMeta,
-                chain->canonPath);
+                chain->path);
     TEST_LOOKUP(12, absqcow2, chain->backingStore, chain->backingMeta,
-                chain->canonPath);
+                chain->path);
     TEST_LOOKUP(13, "raw", chain->backingMeta->backingStore,
                 chain->backingMeta->backingMeta, chain->backingStore);
     TEST_LOOKUP(14, absraw, chain->backingMeta->backingStore,
@@ -905,14 +905,14 @@ mymain(void)
     }

     TEST_LOOKUP(16, "bogus", NULL, NULL, NULL);
-    TEST_LOOKUP(17, "sub/link2", chain->canonPath, chain, NULL);
-    TEST_LOOKUP(18, "wrap", chain->canonPath, chain, NULL);
-    TEST_LOOKUP(19, abswrap, chain->canonPath, chain, NULL);
+    TEST_LOOKUP(17, "sub/link2", chain->path, chain, NULL);
+    TEST_LOOKUP(18, "wrap", chain->path, chain, NULL);
+    TEST_LOOKUP(19, abswrap, chain->path, chain, NULL);
     TEST_LOOKUP(20, "../qcow2", chain->backingStore, chain->backingMeta,
-                chain->canonPath);
+                chain->path);
     TEST_LOOKUP(21, "qcow2", NULL, NULL, NULL);
     TEST_LOOKUP(22, absqcow2, chain->backingStore, chain->backingMeta,
-                chain->canonPath);
+                chain->path);
     TEST_LOOKUP(23, "raw", chain->backingMeta->backingStore,
                 chain->backingMeta->backingMeta, chain->backingStore);
     TEST_LOOKUP(24, absraw, chain->backingMeta->backingStore,
-- 
1.9.1




More information about the libvir-list mailing list