Another field no longer needed, getting us one step closer to
merging virStorageFileMetadata and virStorageSource.
* src/util/virstoragefile.h (_virStorageFileMetadata): Drop
field.
* src/util/virstoragefile.c (virStorageFileGetMetadataInternal)
(virStorageFileGetMetadataFromFDInternal): Alter signature.
(virStorageFileFreeMetadata, virStorageFileGetMetadataFromBuf)
(virStorageFileGetMetadataFromFD): Adjust clients.
* tests/virstoragetest.c (_testFileData, testStorageChain)
(mymain): Simplify test.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
src/util/virstoragefile.c | 22 +++++++++++++---------
src/util/virstoragefile.h | 1 -
tests/virstoragetest.c | 29 ++---------------------------
3 files changed, 15 insertions(+), 37 deletions(-)
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index e33f6ef..0c03797 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -799,7 +799,8 @@ virStorageFileGetMetadataInternal(const char *path,
int format,
virStorageFileMetadataPtr meta,
char **backingStore,
- int *backingFormat)
+ int *backingFormat,
+ char **backingDirectory)
{
int ret = -1;
@@ -877,7 +878,7 @@ virStorageFileGetMetadataInternal(const char *path,
meta->backingStoreRaw = meta->backingStore;
meta->backingStore = NULL;
if (virFindBackingFile(directory, backing,
- &meta->directory,
+ backingDirectory,
&meta->backingStore) < 0) {
/* the backing file is (currently) unavailable, treat this
* file as standalone:
@@ -1017,7 +1018,7 @@ virStorageFileGetMetadataFromBuf(const char *path,
if (virStorageFileGetMetadataInternal(path, canonPath, ".", buf, len,
format, ret, backing,
- backingFormat) < 0) {
+ backingFormat, NULL) < 0) {
virStorageFileFreeMetadata(ret);
ret = NULL;
}
@@ -1036,7 +1037,8 @@ virStorageFileGetMetadataFromFDInternal(const char *path,
int fd,
int format,
virStorageFileMetadataPtr meta,
- int *backingFormat)
+ int *backingFormat,
+ char **backingDirectory)
{
char *buf = NULL;
ssize_t len = VIR_STORAGE_MAX_HEADER;
@@ -1079,7 +1081,7 @@ virStorageFileGetMetadataFromFDInternal(const char *path,
ret = virStorageFileGetMetadataInternal(path, canonPath, directory,
buf, len, format, meta,
&meta->backingStoreRaw,
- backingFormat);
+ backingFormat, backingDirectory);
if (ret == 0) {
if (S_ISREG(sb.st_mode))
@@ -1121,7 +1123,8 @@ virStorageFileGetMetadataFromFD(const char *path,
if (VIR_ALLOC(ret) < 0)
goto cleanup;
if (virStorageFileGetMetadataFromFDInternal(path, canonPath, ".",
- fd, format, ret, NULL) < 0) {
+ fd, format, ret,
+ NULL, NULL) < 0) {
virStorageFileFreeMetadata(ret);
ret = NULL;
}
@@ -1143,6 +1146,7 @@ virStorageFileGetMetadataRecurse(const char *path, const char
*canonPath,
int fd;
int ret = -1;
int backingFormat;
+ char *backingDirectory = NULL;
VIR_DEBUG("path=%s canonPath=%s dir=%s format=%d uid=%d gid=%d probe=%d",
path, canonPath, NULLSTR(directory), format,
@@ -1166,7 +1170,8 @@ virStorageFileGetMetadataRecurse(const char *path, const char
*canonPath,
ret = virStorageFileGetMetadataFromFDInternal(path, canonPath,
directory,
fd, format, meta,
- &backingFormat);
+ &backingFormat,
+ &backingDirectory);
if (VIR_CLOSE(fd) < 0)
VIR_WARN("could not close file %s", path);
@@ -1193,7 +1198,7 @@ virStorageFileGetMetadataRecurse(const char *path, const char
*canonPath,
if (VIR_ALLOC(backing) < 0 ||
virStorageFileGetMetadataRecurse(meta->backingStoreRaw,
meta->backingStore,
- meta->directory, backingFormat,
+ backingDirectory, backingFormat,
uid, gid, allow_probe,
cycle, backing) < 0) {
/* If we failed to get backing data, mark the chain broken */
@@ -1332,7 +1337,6 @@ virStorageFileFreeMetadata(virStorageFileMetadata *meta)
VIR_FREE(meta->backingStore);
VIR_FREE(meta->backingStoreRaw);
VIR_FREE(meta->compat);
- VIR_FREE(meta->directory);
virBitmapFree(meta->features);
virStorageEncryptionFree(meta->encryption);
VIR_FREE(meta);
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index caf1d2f..8294e62 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -146,7 +146,6 @@ struct _virStorageFileMetadata {
* query the parent metadata for details about the backing
* store. */
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 */
};
diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c
index 37f41bd..bb5c173 100644
--- a/tests/virstoragetest.c
+++ b/tests/virstoragetest.c
@@ -233,8 +233,6 @@ struct _testFileData
{
const char *expBackingStore;
const char *expBackingStoreRaw;
- const char *expBackingDirRel;
- const char *expBackingDirAbs;
unsigned long long expCapacity;
bool expEncrypted;
const char *pathRel;
@@ -311,7 +309,6 @@ testStorageChain(const void *args)
while (elt) {
char *expect = NULL;
char *actual = NULL;
- const char *expBackingDirectory;
const char *expPath;
const char *expRelDir;
@@ -320,18 +317,15 @@ testStorageChain(const void *args)
goto cleanup;
}
- expBackingDirectory = isAbs ? data->files[i]->expBackingDirAbs
- : data->files[i]->expBackingDirRel;
expPath = isAbs ? data->files[i]->pathAbs
: data->files[i]->pathRel;
expRelDir = isAbs ? data->files[i]->relDirAbs
: data->files[i]->relDirRel;
if (virAsprintf(&expect,
- "store:%s\nraw:%s\ndirectory:%s\nother:%lld %d\n"
+ "store:%s\nraw:%s\nother:%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]->expCapacity,
data->files[i]->expEncrypted,
NULLSTR(expPath),
@@ -340,11 +334,10 @@ testStorageChain(const void *args)
data->files[i]->type,
data->files[i]->format) < 0 ||
virAsprintf(&actual,
- "store:%s\nraw:%s\ndirectory:%s\nother:%lld %d\n"
+ "store:%s\nraw:%s\nother:%lld %d\n"
"path:%s\ncanon:%s\nrelDir:%s\ntype:%d %d\n",
NULLSTR(elt->backingStore),
NULLSTR(elt->backingStoreRaw),
- NULLSTR(elt->directory),
elt->capacity, !!elt->encryption,
NULLSTR(elt->path),
NULLSTR(elt->canonPath),
@@ -518,8 +511,6 @@ mymain(void)
testFileData qcow2 = {
.expBackingStore = canonraw,
.expBackingStoreRaw = "raw",
- .expBackingDirRel = ".",
- .expBackingDirAbs = datadir,
.expCapacity = 1024,
.pathRel = "qcow2",
.pathAbs = canonqcow2,
@@ -556,7 +547,6 @@ mymain(void)
if (virCommandRun(cmd, NULL) < 0)
ret = -1;
qcow2.expBackingStoreRaw = absraw;
- qcow2.expBackingDirRel = datadir;
raw.pathRel = absraw;
raw.pathAbs = absraw;
raw.relDirRel = datadir;
@@ -577,8 +567,6 @@ mymain(void)
testFileData wrap = {
.expBackingStore = canonqcow2,
.expBackingStoreRaw = absqcow2,
- .expBackingDirRel = datadir,
- .expBackingDirAbs = datadir,
.expCapacity = 1024,
.pathRel = "wrap",
.pathAbs = abswrap,
@@ -615,8 +603,6 @@ mymain(void)
testFileData wrap_as_raw = {
.expBackingStore = canonqcow2,
.expBackingStoreRaw = absqcow2,
- .expBackingDirRel = datadir,
- .expBackingDirAbs = datadir,
.expCapacity = 1024,
.pathRel = "wrap",
.pathAbs = abswrap,
@@ -674,8 +660,6 @@ mymain(void)
ret = -1;
qcow2.expBackingStore = "nbd:example.org:6000";
qcow2.expBackingStoreRaw = "nbd:example.org:6000";
- qcow2.expBackingDirRel = NULL;
- qcow2.expBackingDirAbs = NULL;
/* Qcow2 file with backing protocol instead of file */
testFileData nbd = {
@@ -695,8 +679,6 @@ mymain(void)
testFileData qed = {
.expBackingStore = canonraw,
.expBackingStoreRaw = absraw,
- .expBackingDirRel = datadir,
- .expBackingDirAbs = datadir,
.expCapacity = 1024,
.pathRel = "qed",
.pathAbs = absqed,
@@ -759,8 +741,6 @@ mymain(void)
testFileData link1 = {
.expBackingStore = canonraw,
.expBackingStoreRaw = "../raw",
- .expBackingDirRel = "sub/../sub/..",
- .expBackingDirAbs = datadir "/sub/../sub/..",
.expCapacity = 1024,
.pathRel = "../sub/link1",
.pathAbs = "../sub/link1",
@@ -773,8 +753,6 @@ mymain(void)
testFileData link2 = {
.expBackingStore = canonqcow2,
.expBackingStoreRaw = "../sub/link1",
- .expBackingDirRel = "sub/../sub",
- .expBackingDirAbs = datadir "/sub/../sub",
.expCapacity = 1024,
.pathRel = "sub/link2",
.pathAbs = abslink2,
@@ -803,8 +781,6 @@ mymain(void)
ret = -1;
qcow2.expBackingStore = NULL;
qcow2.expBackingStoreRaw = "qcow2";
- qcow2.expBackingDirRel = ".";
- qcow2.expBackingDirAbs = datadir;
/* Behavior of an infinite loop chain */
TEST_CHAIN(16, "qcow2", absqcow2, VIR_STORAGE_FILE_QCOW2,
@@ -826,7 +802,6 @@ mymain(void)
if (virCommandRun(cmd, NULL) < 0)
ret = -1;
qcow2.expBackingStoreRaw = "wrap";
- qcow2.expBackingDirRel = datadir;
qcow2.pathRel = absqcow2;
qcow2.relDirRel = datadir;
--
1.9.0