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

conf: delete internal directory field

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: NEric Blake <eblake@redhat.com>
上级 d193b34d
...@@ -799,7 +799,8 @@ virStorageFileGetMetadataInternal(const char *path, ...@@ -799,7 +799,8 @@ virStorageFileGetMetadataInternal(const char *path,
int format, int format,
virStorageFileMetadataPtr meta, virStorageFileMetadataPtr meta,
char **backingStore, char **backingStore,
int *backingFormat) int *backingFormat,
char **backingDirectory)
{ {
int ret = -1; int ret = -1;
...@@ -877,7 +878,7 @@ virStorageFileGetMetadataInternal(const char *path, ...@@ -877,7 +878,7 @@ virStorageFileGetMetadataInternal(const char *path,
meta->backingStoreRaw = meta->backingStore; meta->backingStoreRaw = meta->backingStore;
meta->backingStore = NULL; meta->backingStore = NULL;
if (virFindBackingFile(directory, backing, if (virFindBackingFile(directory, backing,
&meta->directory, backingDirectory,
&meta->backingStore) < 0) { &meta->backingStore) < 0) {
/* the backing file is (currently) unavailable, treat this /* the backing file is (currently) unavailable, treat this
* file as standalone: * file as standalone:
...@@ -1017,7 +1018,7 @@ virStorageFileGetMetadataFromBuf(const char *path, ...@@ -1017,7 +1018,7 @@ virStorageFileGetMetadataFromBuf(const char *path,
if (virStorageFileGetMetadataInternal(path, canonPath, ".", buf, len, if (virStorageFileGetMetadataInternal(path, canonPath, ".", buf, len,
format, ret, backing, format, ret, backing,
backingFormat) < 0) { backingFormat, NULL) < 0) {
virStorageFileFreeMetadata(ret); virStorageFileFreeMetadata(ret);
ret = NULL; ret = NULL;
} }
...@@ -1036,7 +1037,8 @@ virStorageFileGetMetadataFromFDInternal(const char *path, ...@@ -1036,7 +1037,8 @@ virStorageFileGetMetadataFromFDInternal(const char *path,
int fd, int fd,
int format, int format,
virStorageFileMetadataPtr meta, virStorageFileMetadataPtr meta,
int *backingFormat) int *backingFormat,
char **backingDirectory)
{ {
char *buf = NULL; char *buf = NULL;
ssize_t len = VIR_STORAGE_MAX_HEADER; ssize_t len = VIR_STORAGE_MAX_HEADER;
...@@ -1079,7 +1081,7 @@ virStorageFileGetMetadataFromFDInternal(const char *path, ...@@ -1079,7 +1081,7 @@ virStorageFileGetMetadataFromFDInternal(const char *path,
ret = virStorageFileGetMetadataInternal(path, canonPath, directory, ret = virStorageFileGetMetadataInternal(path, canonPath, directory,
buf, len, format, meta, buf, len, format, meta,
&meta->backingStoreRaw, &meta->backingStoreRaw,
backingFormat); backingFormat, backingDirectory);
if (ret == 0) { if (ret == 0) {
if (S_ISREG(sb.st_mode)) if (S_ISREG(sb.st_mode))
...@@ -1121,7 +1123,8 @@ virStorageFileGetMetadataFromFD(const char *path, ...@@ -1121,7 +1123,8 @@ virStorageFileGetMetadataFromFD(const char *path,
if (VIR_ALLOC(ret) < 0) if (VIR_ALLOC(ret) < 0)
goto cleanup; goto cleanup;
if (virStorageFileGetMetadataFromFDInternal(path, canonPath, ".", if (virStorageFileGetMetadataFromFDInternal(path, canonPath, ".",
fd, format, ret, NULL) < 0) { fd, format, ret,
NULL, NULL) < 0) {
virStorageFileFreeMetadata(ret); virStorageFileFreeMetadata(ret);
ret = NULL; ret = NULL;
} }
...@@ -1143,6 +1146,7 @@ virStorageFileGetMetadataRecurse(const char *path, const char *canonPath, ...@@ -1143,6 +1146,7 @@ virStorageFileGetMetadataRecurse(const char *path, const char *canonPath,
int fd; int fd;
int ret = -1; int ret = -1;
int backingFormat; int backingFormat;
char *backingDirectory = NULL;
VIR_DEBUG("path=%s canonPath=%s dir=%s format=%d uid=%d gid=%d probe=%d", VIR_DEBUG("path=%s canonPath=%s dir=%s format=%d uid=%d gid=%d probe=%d",
path, canonPath, NULLSTR(directory), format, path, canonPath, NULLSTR(directory), format,
...@@ -1166,7 +1170,8 @@ virStorageFileGetMetadataRecurse(const char *path, const char *canonPath, ...@@ -1166,7 +1170,8 @@ virStorageFileGetMetadataRecurse(const char *path, const char *canonPath,
ret = virStorageFileGetMetadataFromFDInternal(path, canonPath, ret = virStorageFileGetMetadataFromFDInternal(path, canonPath,
directory, directory,
fd, format, meta, fd, format, meta,
&backingFormat); &backingFormat,
&backingDirectory);
if (VIR_CLOSE(fd) < 0) if (VIR_CLOSE(fd) < 0)
VIR_WARN("could not close file %s", path); VIR_WARN("could not close file %s", path);
...@@ -1193,7 +1198,7 @@ virStorageFileGetMetadataRecurse(const char *path, const char *canonPath, ...@@ -1193,7 +1198,7 @@ virStorageFileGetMetadataRecurse(const char *path, const char *canonPath,
if (VIR_ALLOC(backing) < 0 || if (VIR_ALLOC(backing) < 0 ||
virStorageFileGetMetadataRecurse(meta->backingStoreRaw, virStorageFileGetMetadataRecurse(meta->backingStoreRaw,
meta->backingStore, meta->backingStore,
meta->directory, backingFormat, backingDirectory, backingFormat,
uid, gid, allow_probe, uid, gid, allow_probe,
cycle, backing) < 0) { cycle, backing) < 0) {
/* If we failed to get backing data, mark the chain broken */ /* If we failed to get backing data, mark the chain broken */
...@@ -1332,7 +1337,6 @@ virStorageFileFreeMetadata(virStorageFileMetadata *meta) ...@@ -1332,7 +1337,6 @@ virStorageFileFreeMetadata(virStorageFileMetadata *meta)
VIR_FREE(meta->backingStore); VIR_FREE(meta->backingStore);
VIR_FREE(meta->backingStoreRaw); VIR_FREE(meta->backingStoreRaw);
VIR_FREE(meta->compat); VIR_FREE(meta->compat);
VIR_FREE(meta->directory);
virBitmapFree(meta->features); virBitmapFree(meta->features);
virStorageEncryptionFree(meta->encryption); virStorageEncryptionFree(meta->encryption);
VIR_FREE(meta); VIR_FREE(meta);
......
...@@ -146,7 +146,6 @@ struct _virStorageFileMetadata { ...@@ -146,7 +146,6 @@ struct _virStorageFileMetadata {
* query the parent metadata for details about the backing * query the parent metadata for details about the backing
* store. */ * store. */
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 */
}; };
......
...@@ -233,8 +233,6 @@ struct _testFileData ...@@ -233,8 +233,6 @@ struct _testFileData
{ {
const char *expBackingStore; const char *expBackingStore;
const char *expBackingStoreRaw; const char *expBackingStoreRaw;
const char *expBackingDirRel;
const char *expBackingDirAbs;
unsigned long long expCapacity; unsigned long long expCapacity;
bool expEncrypted; bool expEncrypted;
const char *pathRel; const char *pathRel;
...@@ -311,7 +309,6 @@ testStorageChain(const void *args) ...@@ -311,7 +309,6 @@ testStorageChain(const void *args)
while (elt) { while (elt) {
char *expect = NULL; char *expect = NULL;
char *actual = NULL; char *actual = NULL;
const char *expBackingDirectory;
const char *expPath; const char *expPath;
const char *expRelDir; const char *expRelDir;
...@@ -320,18 +317,15 @@ testStorageChain(const void *args) ...@@ -320,18 +317,15 @@ testStorageChain(const void *args)
goto cleanup; goto cleanup;
} }
expBackingDirectory = isAbs ? data->files[i]->expBackingDirAbs
: data->files[i]->expBackingDirRel;
expPath = isAbs ? data->files[i]->pathAbs expPath = isAbs ? data->files[i]->pathAbs
: data->files[i]->pathRel; : data->files[i]->pathRel;
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:%lld %d\n" "store:%s\nraw:%s\nother:%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),
data->files[i]->expCapacity, data->files[i]->expCapacity,
data->files[i]->expEncrypted, data->files[i]->expEncrypted,
NULLSTR(expPath), NULLSTR(expPath),
...@@ -340,11 +334,10 @@ testStorageChain(const void *args) ...@@ -340,11 +334,10 @@ 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:%lld %d\n" "store:%s\nraw:%s\nother:%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),
elt->capacity, !!elt->encryption, elt->capacity, !!elt->encryption,
NULLSTR(elt->path), NULLSTR(elt->path),
NULLSTR(elt->canonPath), NULLSTR(elt->canonPath),
...@@ -520,8 +513,6 @@ mymain(void) ...@@ -520,8 +513,6 @@ mymain(void)
testFileData qcow2 = { testFileData qcow2 = {
.expBackingStore = canonraw, .expBackingStore = canonraw,
.expBackingStoreRaw = "raw", .expBackingStoreRaw = "raw",
.expBackingDirRel = ".",
.expBackingDirAbs = datadir,
.expCapacity = 1024, .expCapacity = 1024,
.pathRel = "qcow2", .pathRel = "qcow2",
.pathAbs = canonqcow2, .pathAbs = canonqcow2,
...@@ -558,7 +549,6 @@ mymain(void) ...@@ -558,7 +549,6 @@ mymain(void)
if (virCommandRun(cmd, NULL) < 0) if (virCommandRun(cmd, NULL) < 0)
ret = -1; ret = -1;
qcow2.expBackingStoreRaw = absraw; qcow2.expBackingStoreRaw = absraw;
qcow2.expBackingDirRel = datadir;
raw.pathRel = absraw; raw.pathRel = absraw;
raw.pathAbs = absraw; raw.pathAbs = absraw;
raw.relDirRel = datadir; raw.relDirRel = datadir;
...@@ -579,8 +569,6 @@ mymain(void) ...@@ -579,8 +569,6 @@ mymain(void)
testFileData wrap = { testFileData wrap = {
.expBackingStore = canonqcow2, .expBackingStore = canonqcow2,
.expBackingStoreRaw = absqcow2, .expBackingStoreRaw = absqcow2,
.expBackingDirRel = datadir,
.expBackingDirAbs = datadir,
.expCapacity = 1024, .expCapacity = 1024,
.pathRel = "wrap", .pathRel = "wrap",
.pathAbs = abswrap, .pathAbs = abswrap,
...@@ -617,8 +605,6 @@ mymain(void) ...@@ -617,8 +605,6 @@ mymain(void)
testFileData wrap_as_raw = { testFileData wrap_as_raw = {
.expBackingStore = canonqcow2, .expBackingStore = canonqcow2,
.expBackingStoreRaw = absqcow2, .expBackingStoreRaw = absqcow2,
.expBackingDirRel = datadir,
.expBackingDirAbs = datadir,
.expCapacity = 1024, .expCapacity = 1024,
.pathRel = "wrap", .pathRel = "wrap",
.pathAbs = abswrap, .pathAbs = abswrap,
...@@ -676,8 +662,6 @@ mymain(void) ...@@ -676,8 +662,6 @@ mymain(void)
ret = -1; ret = -1;
qcow2.expBackingStore = "nbd:example.org:6000"; qcow2.expBackingStore = "nbd:example.org:6000";
qcow2.expBackingStoreRaw = "nbd:example.org:6000"; qcow2.expBackingStoreRaw = "nbd:example.org:6000";
qcow2.expBackingDirRel = NULL;
qcow2.expBackingDirAbs = NULL;
/* Qcow2 file with backing protocol instead of file */ /* Qcow2 file with backing protocol instead of file */
testFileData nbd = { testFileData nbd = {
...@@ -697,8 +681,6 @@ mymain(void) ...@@ -697,8 +681,6 @@ mymain(void)
testFileData qed = { testFileData qed = {
.expBackingStore = canonraw, .expBackingStore = canonraw,
.expBackingStoreRaw = absraw, .expBackingStoreRaw = absraw,
.expBackingDirRel = datadir,
.expBackingDirAbs = datadir,
.expCapacity = 1024, .expCapacity = 1024,
.pathRel = "qed", .pathRel = "qed",
.pathAbs = absqed, .pathAbs = absqed,
...@@ -761,8 +743,6 @@ mymain(void) ...@@ -761,8 +743,6 @@ mymain(void)
testFileData link1 = { testFileData link1 = {
.expBackingStore = canonraw, .expBackingStore = canonraw,
.expBackingStoreRaw = "../raw", .expBackingStoreRaw = "../raw",
.expBackingDirRel = "sub/../sub/..",
.expBackingDirAbs = datadir "/sub/../sub/..",
.expCapacity = 1024, .expCapacity = 1024,
.pathRel = "../sub/link1", .pathRel = "../sub/link1",
.pathAbs = "../sub/link1", .pathAbs = "../sub/link1",
...@@ -775,8 +755,6 @@ mymain(void) ...@@ -775,8 +755,6 @@ mymain(void)
testFileData link2 = { testFileData link2 = {
.expBackingStore = canonqcow2, .expBackingStore = canonqcow2,
.expBackingStoreRaw = "../sub/link1", .expBackingStoreRaw = "../sub/link1",
.expBackingDirRel = "sub/../sub",
.expBackingDirAbs = datadir "/sub/../sub",
.expCapacity = 1024, .expCapacity = 1024,
.pathRel = "sub/link2", .pathRel = "sub/link2",
.pathAbs = abslink2, .pathAbs = abslink2,
...@@ -805,8 +783,6 @@ mymain(void) ...@@ -805,8 +783,6 @@ mymain(void)
ret = -1; ret = -1;
qcow2.expBackingStore = NULL; qcow2.expBackingStore = NULL;
qcow2.expBackingStoreRaw = "qcow2"; qcow2.expBackingStoreRaw = "qcow2";
qcow2.expBackingDirRel = ".";
qcow2.expBackingDirAbs = datadir;
/* 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,
...@@ -828,7 +804,6 @@ mymain(void) ...@@ -828,7 +804,6 @@ mymain(void)
if (virCommandRun(cmd, NULL) < 0) if (virCommandRun(cmd, NULL) < 0)
ret = -1; ret = -1;
qcow2.expBackingStoreRaw = "wrap"; qcow2.expBackingStoreRaw = "wrap";
qcow2.expBackingDirRel = datadir;
qcow2.pathRel = absqcow2; qcow2.pathRel = absqcow2;
qcow2.relDirRel = datadir; qcow2.relDirRel = datadir;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册