[PATCH 3/5] conf: delete useless backingStoreIsFile field

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

 



Finally starting to prune away some of the old fields that have
been made redundant by the new fields, on my way towards directly
reusing virStorageSource.

* src/util/virstoragefile.h (_virStorageFileMetadata): Drop
field.
* src/util/virstoragefile.c (virStorageFileGetMetadataInternal)
(virStorageFileChainLookup): Adjust callers.
* tests/virstoragetest.c (_testFileData, testStorageChain)
(mymain): Simplify test.

Signed-off-by: Eric Blake <eblake@xxxxxxxxxx>
---
 src/util/virstoragefile.c |  5 +----
 src/util/virstoragefile.h |  1 -
 tests/virstoragetest.c    | 16 +++-------------
 3 files changed, 4 insertions(+), 18 deletions(-)

diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index cb66da4..fe8144a 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -866,14 +866,12 @@ virStorageFileGetMetadataInternal(const char *path,
         if (store == BACKING_STORE_ERROR)
             goto cleanup;

-        meta->backingStoreIsFile = false;
         if (backing != NULL) {
             if (VIR_STRDUP(meta->backingStore, backing) < 0) {
                 VIR_FREE(backing);
                 goto cleanup;
             }
             if (virStorageIsFile(backing)) {
-                meta->backingStoreIsFile = true;
                 meta->backingStoreRaw = meta->backingStore;
                 meta->backingStore = NULL;
                 if (virFindBackingFile(directory, backing,
@@ -882,7 +880,6 @@ virStorageFileGetMetadataInternal(const char *path,
                     /* the backing file is (currently) unavailable, treat this
                      * file as standalone:
                      * backingStoreRaw is kept to mark broken image chains */
-                    meta->backingStoreIsFile = false;
                     backingFormat = VIR_STORAGE_FILE_NONE;
                     VIR_WARN("Backing file '%s' of image '%s' is missing.",
                              meta->backingStoreRaw, path);
@@ -1569,7 +1566,7 @@ virStorageFileChainLookup(virStorageFileMetadataPtr chain, const char *start,
         } else if (STREQ_NULLABLE(name, owner->backingStoreRaw) ||
                    STREQ(name, owner->backingStore)) {
             break;
-        } else if (owner->backingStoreIsFile) {
+        } else if (virStorageIsFile(owner->backingStore)) {
             char *absName = NULL;
             if (virFindBackingFile(owner->directory, name,
                                    NULL, &absName) < 0)
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index 6c08c31..4da160b 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -148,7 +148,6 @@ struct _virStorageFileMetadata {
     char *backingStore; /* Canonical name (absolute file, or protocol). Should be same as backingMeta->canonPath */
     char *directory; /* The directory containing basename of backingStoreRaw. Should be same as backingMeta->relDir */
     int backingStoreFormat; /* enum virStorageFileFormat. Should be same as backingMeta->format */
-    bool backingStoreIsFile; /* Should be same as backingMeta->type < VIR_STORAGE_TYPE_NETWORK */
 };


diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c
index e8409f6..846d130 100644
--- a/tests/virstoragetest.c
+++ b/tests/virstoragetest.c
@@ -233,7 +233,6 @@ struct _testFileData
     const char *expBackingDirRel;
     const char *expBackingDirAbs;
     enum virStorageFileFormat expBackingFormat;
-    bool expIsFile;
     unsigned long long expCapacity;
     bool expEncrypted;
     const char *pathRel;
@@ -326,13 +325,12 @@ testStorageChain(const void *args)
         expRelDir = isAbs ? data->files[i]->relDirAbs
             : data->files[i]->relDirRel;
         if (virAsprintf(&expect,
-                        "store:%s\nraw:%s\ndirectory:%s\nother:%d %d %lld %d\n"
+                        "store:%s\nraw:%s\ndirectory:%s\nother:%d %lld %d\n"
                         "path:%s\ncanon:%s\nrelDir:%s\ntype:%d %d\n",
                         NULLSTR(data->files[i]->expBackingStore),
                         NULLSTR(data->files[i]->expBackingStoreRaw),
                         NULLSTR(expBackingDirectory),
                         data->files[i]->expBackingFormat,
-                        data->files[i]->expIsFile,
                         data->files[i]->expCapacity,
                         data->files[i]->expEncrypted,
                         NULLSTR(expPath),
@@ -341,12 +339,12 @@ testStorageChain(const void *args)
                         data->files[i]->type,
                         data->files[i]->format) < 0 ||
             virAsprintf(&actual,
-                        "store:%s\nraw:%s\ndirectory:%s\nother:%d %d %lld %d\n"
+                        "store:%s\nraw:%s\ndirectory:%s\nother:%d %lld %d\n"
                         "path:%s\ncanon:%s\nrelDir:%s\ntype:%d %d\n",
                         NULLSTR(elt->backingStore),
                         NULLSTR(elt->backingStoreRaw),
                         NULLSTR(elt->directory),
-                        elt->backingStoreFormat, elt->backingStoreIsFile,
+                        elt->backingStoreFormat,
                         elt->capacity, !!elt->encryption,
                         NULLSTR(elt->path),
                         NULLSTR(elt->canonPath),
@@ -458,7 +456,6 @@ mymain(void)
         .expBackingDirRel = ".",
         .expBackingDirAbs = datadir,
         .expBackingFormat = VIR_STORAGE_FILE_RAW,
-        .expIsFile = true,
         .expCapacity = 1024,
         .pathRel = "qcow2",
         .pathAbs = canonqcow2,
@@ -520,7 +517,6 @@ mymain(void)
         .expBackingDirRel = datadir,
         .expBackingDirAbs = datadir,
         .expBackingFormat = VIR_STORAGE_FILE_QCOW2,
-        .expIsFile = true,
         .expCapacity = 1024,
         .pathRel = "wrap",
         .pathAbs = abswrap,
@@ -562,7 +558,6 @@ mymain(void)
         .expBackingDirRel = datadir,
         .expBackingDirAbs = datadir,
         .expBackingFormat = VIR_STORAGE_FILE_RAW,
-        .expIsFile = true,
         .expCapacity = 1024,
         .pathRel = "wrap",
         .pathAbs = abswrap,
@@ -588,7 +583,6 @@ mymain(void)
     qcow2.expBackingStore = NULL;
     qcow2.expBackingStoreRaw = datadir "/bogus";
     qcow2.expBackingFormat = VIR_STORAGE_FILE_NONE;
-    qcow2.expIsFile = false;
     qcow2.pathRel = "qcow2";
     qcow2.relDirRel = ".";

@@ -647,7 +641,6 @@ mymain(void)
         .expBackingDirRel = datadir,
         .expBackingDirAbs = datadir,
         .expBackingFormat = VIR_STORAGE_FILE_RAW,
-        .expIsFile = true,
         .expCapacity = 1024,
         .pathRel = "qed",
         .pathAbs = absqed,
@@ -714,7 +707,6 @@ mymain(void)
         .expBackingDirRel = "sub/../sub/..",
         .expBackingDirAbs = datadir "/sub/../sub/..",
         .expBackingFormat = VIR_STORAGE_FILE_RAW,
-        .expIsFile = true,
         .expCapacity = 1024,
         .pathRel = "../sub/link1",
         .pathAbs = "../sub/link1",
@@ -730,7 +722,6 @@ mymain(void)
         .expBackingDirRel = "sub/../sub",
         .expBackingDirAbs = datadir "/sub/../sub",
         .expBackingFormat = VIR_STORAGE_FILE_QCOW2,
-        .expIsFile = true,
         .expCapacity = 1024,
         .pathRel = "sub/link2",
         .pathAbs = abslink2,
@@ -762,7 +753,6 @@ mymain(void)
     qcow2.expBackingDirRel = ".";
     qcow2.expBackingDirAbs = datadir;
     qcow2.expBackingFormat= VIR_STORAGE_FILE_NONE;
-    qcow2.expIsFile = true;

     /* Behavior of an infinite loop chain */
     TEST_CHAIN(16, "qcow2", absqcow2, VIR_STORAGE_FILE_QCOW2,
-- 
1.9.0

--
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]