提交 c919ed7e 编写于 作者: E Eric Blake

conf: delete useless backingStoreIsFile field

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: NEric Blake <eblake@redhat.com>
上级 86f71e0a
...@@ -866,14 +866,12 @@ virStorageFileGetMetadataInternal(const char *path, ...@@ -866,14 +866,12 @@ virStorageFileGetMetadataInternal(const char *path,
if (store == BACKING_STORE_ERROR) if (store == BACKING_STORE_ERROR)
goto cleanup; goto cleanup;
meta->backingStoreIsFile = false;
if (backing != NULL) { if (backing != NULL) {
if (VIR_STRDUP(meta->backingStore, backing) < 0) { if (VIR_STRDUP(meta->backingStore, backing) < 0) {
VIR_FREE(backing); VIR_FREE(backing);
goto cleanup; goto cleanup;
} }
if (virStorageIsFile(backing)) { if (virStorageIsFile(backing)) {
meta->backingStoreIsFile = true;
meta->backingStoreRaw = meta->backingStore; meta->backingStoreRaw = meta->backingStore;
meta->backingStore = NULL; meta->backingStore = NULL;
if (virFindBackingFile(directory, backing, if (virFindBackingFile(directory, backing,
...@@ -882,7 +880,6 @@ virStorageFileGetMetadataInternal(const char *path, ...@@ -882,7 +880,6 @@ virStorageFileGetMetadataInternal(const char *path,
/* the backing file is (currently) unavailable, treat this /* the backing file is (currently) unavailable, treat this
* file as standalone: * file as standalone:
* backingStoreRaw is kept to mark broken image chains */ * backingStoreRaw is kept to mark broken image chains */
meta->backingStoreIsFile = false;
backingFormat = VIR_STORAGE_FILE_NONE; backingFormat = VIR_STORAGE_FILE_NONE;
VIR_WARN("Backing file '%s' of image '%s' is missing.", VIR_WARN("Backing file '%s' of image '%s' is missing.",
meta->backingStoreRaw, path); meta->backingStoreRaw, path);
...@@ -1570,7 +1567,7 @@ virStorageFileChainLookup(virStorageFileMetadataPtr chain, const char *start, ...@@ -1570,7 +1567,7 @@ virStorageFileChainLookup(virStorageFileMetadataPtr chain, const char *start,
} else if (STREQ_NULLABLE(name, owner->backingStoreRaw) || } else if (STREQ_NULLABLE(name, owner->backingStoreRaw) ||
STREQ(name, owner->backingStore)) { STREQ(name, owner->backingStore)) {
break; break;
} else if (owner->backingStoreIsFile) { } else if (virStorageIsFile(owner->backingStore)) {
char *absName = NULL; char *absName = NULL;
if (virFindBackingFile(owner->directory, name, if (virFindBackingFile(owner->directory, name,
NULL, &absName) < 0) NULL, &absName) < 0)
......
...@@ -148,7 +148,6 @@ struct _virStorageFileMetadata { ...@@ -148,7 +148,6 @@ struct _virStorageFileMetadata {
char *backingStore; /* Canonical name (absolute file, or protocol). Should be same as backingMeta->canonPath */ 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 */ char *directory; /* The directory containing basename of backingStoreRaw. Should be same as backingMeta->relDir */
int backingStoreFormat; /* enum virStorageFileFormat. Should be same as backingMeta->format */ int backingStoreFormat; /* enum virStorageFileFormat. Should be same as backingMeta->format */
bool backingStoreIsFile; /* Should be same as backingMeta->type < VIR_STORAGE_TYPE_NETWORK */
}; };
......
...@@ -236,7 +236,6 @@ struct _testFileData ...@@ -236,7 +236,6 @@ struct _testFileData
const char *expBackingDirRel; const char *expBackingDirRel;
const char *expBackingDirAbs; const char *expBackingDirAbs;
enum virStorageFileFormat expBackingFormat; enum virStorageFileFormat expBackingFormat;
bool expIsFile;
unsigned long long expCapacity; unsigned long long expCapacity;
bool expEncrypted; bool expEncrypted;
const char *pathRel; const char *pathRel;
...@@ -329,13 +328,12 @@ testStorageChain(const void *args) ...@@ -329,13 +328,12 @@ testStorageChain(const void *args)
expRelDir = isAbs ? data->files[i]->relDirAbs expRelDir = isAbs ? data->files[i]->relDirAbs
: data->files[i]->relDirRel; : data->files[i]->relDirRel;
if (virAsprintf(&expect, 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", "path:%s\ncanon:%s\nrelDir:%s\ntype:%d %d\n",
NULLSTR(data->files[i]->expBackingStore), NULLSTR(data->files[i]->expBackingStore),
NULLSTR(data->files[i]->expBackingStoreRaw), NULLSTR(data->files[i]->expBackingStoreRaw),
NULLSTR(expBackingDirectory), NULLSTR(expBackingDirectory),
data->files[i]->expBackingFormat, data->files[i]->expBackingFormat,
data->files[i]->expIsFile,
data->files[i]->expCapacity, data->files[i]->expCapacity,
data->files[i]->expEncrypted, data->files[i]->expEncrypted,
NULLSTR(expPath), NULLSTR(expPath),
...@@ -344,12 +342,12 @@ testStorageChain(const void *args) ...@@ -344,12 +342,12 @@ testStorageChain(const void *args)
data->files[i]->type, data->files[i]->type,
data->files[i]->format) < 0 || data->files[i]->format) < 0 ||
virAsprintf(&actual, 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", "path:%s\ncanon:%s\nrelDir:%s\ntype:%d %d\n",
NULLSTR(elt->backingStore), NULLSTR(elt->backingStore),
NULLSTR(elt->backingStoreRaw), NULLSTR(elt->backingStoreRaw),
NULLSTR(elt->directory), NULLSTR(elt->directory),
elt->backingStoreFormat, elt->backingStoreIsFile, elt->backingStoreFormat,
elt->capacity, !!elt->encryption, elt->capacity, !!elt->encryption,
NULLSTR(elt->path), NULLSTR(elt->path),
NULLSTR(elt->canonPath), NULLSTR(elt->canonPath),
...@@ -461,7 +459,6 @@ mymain(void) ...@@ -461,7 +459,6 @@ mymain(void)
.expBackingDirRel = ".", .expBackingDirRel = ".",
.expBackingDirAbs = datadir, .expBackingDirAbs = datadir,
.expBackingFormat = VIR_STORAGE_FILE_RAW, .expBackingFormat = VIR_STORAGE_FILE_RAW,
.expIsFile = true,
.expCapacity = 1024, .expCapacity = 1024,
.pathRel = "qcow2", .pathRel = "qcow2",
.pathAbs = canonqcow2, .pathAbs = canonqcow2,
...@@ -523,7 +520,6 @@ mymain(void) ...@@ -523,7 +520,6 @@ mymain(void)
.expBackingDirRel = datadir, .expBackingDirRel = datadir,
.expBackingDirAbs = datadir, .expBackingDirAbs = datadir,
.expBackingFormat = VIR_STORAGE_FILE_QCOW2, .expBackingFormat = VIR_STORAGE_FILE_QCOW2,
.expIsFile = true,
.expCapacity = 1024, .expCapacity = 1024,
.pathRel = "wrap", .pathRel = "wrap",
.pathAbs = abswrap, .pathAbs = abswrap,
...@@ -565,7 +561,6 @@ mymain(void) ...@@ -565,7 +561,6 @@ mymain(void)
.expBackingDirRel = datadir, .expBackingDirRel = datadir,
.expBackingDirAbs = datadir, .expBackingDirAbs = datadir,
.expBackingFormat = VIR_STORAGE_FILE_RAW, .expBackingFormat = VIR_STORAGE_FILE_RAW,
.expIsFile = true,
.expCapacity = 1024, .expCapacity = 1024,
.pathRel = "wrap", .pathRel = "wrap",
.pathAbs = abswrap, .pathAbs = abswrap,
...@@ -591,7 +586,6 @@ mymain(void) ...@@ -591,7 +586,6 @@ mymain(void)
qcow2.expBackingStore = NULL; qcow2.expBackingStore = NULL;
qcow2.expBackingStoreRaw = datadir "/bogus"; qcow2.expBackingStoreRaw = datadir "/bogus";
qcow2.expBackingFormat = VIR_STORAGE_FILE_NONE; qcow2.expBackingFormat = VIR_STORAGE_FILE_NONE;
qcow2.expIsFile = false;
qcow2.pathRel = "qcow2"; qcow2.pathRel = "qcow2";
qcow2.relDirRel = "."; qcow2.relDirRel = ".";
...@@ -650,7 +644,6 @@ mymain(void) ...@@ -650,7 +644,6 @@ mymain(void)
.expBackingDirRel = datadir, .expBackingDirRel = datadir,
.expBackingDirAbs = datadir, .expBackingDirAbs = datadir,
.expBackingFormat = VIR_STORAGE_FILE_RAW, .expBackingFormat = VIR_STORAGE_FILE_RAW,
.expIsFile = true,
.expCapacity = 1024, .expCapacity = 1024,
.pathRel = "qed", .pathRel = "qed",
.pathAbs = absqed, .pathAbs = absqed,
...@@ -717,7 +710,6 @@ mymain(void) ...@@ -717,7 +710,6 @@ mymain(void)
.expBackingDirRel = "sub/../sub/..", .expBackingDirRel = "sub/../sub/..",
.expBackingDirAbs = datadir "/sub/../sub/..", .expBackingDirAbs = datadir "/sub/../sub/..",
.expBackingFormat = VIR_STORAGE_FILE_RAW, .expBackingFormat = VIR_STORAGE_FILE_RAW,
.expIsFile = true,
.expCapacity = 1024, .expCapacity = 1024,
.pathRel = "../sub/link1", .pathRel = "../sub/link1",
.pathAbs = "../sub/link1", .pathAbs = "../sub/link1",
...@@ -733,7 +725,6 @@ mymain(void) ...@@ -733,7 +725,6 @@ mymain(void)
.expBackingDirRel = "sub/../sub", .expBackingDirRel = "sub/../sub",
.expBackingDirAbs = datadir "/sub/../sub", .expBackingDirAbs = datadir "/sub/../sub",
.expBackingFormat = VIR_STORAGE_FILE_QCOW2, .expBackingFormat = VIR_STORAGE_FILE_QCOW2,
.expIsFile = true,
.expCapacity = 1024, .expCapacity = 1024,
.pathRel = "sub/link2", .pathRel = "sub/link2",
.pathAbs = abslink2, .pathAbs = abslink2,
...@@ -765,7 +756,6 @@ mymain(void) ...@@ -765,7 +756,6 @@ mymain(void)
qcow2.expBackingDirRel = "."; qcow2.expBackingDirRel = ".";
qcow2.expBackingDirAbs = datadir; qcow2.expBackingDirAbs = datadir;
qcow2.expBackingFormat= VIR_STORAGE_FILE_NONE; qcow2.expBackingFormat= VIR_STORAGE_FILE_NONE;
qcow2.expIsFile = true;
/* Behavior of an infinite loop chain */ /* Behavior of an infinite loop chain */
TEST_CHAIN(16, "qcow2", absqcow2, VIR_STORAGE_FILE_QCOW2, TEST_CHAIN(16, "qcow2", absqcow2, VIR_STORAGE_FILE_QCOW2,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册