提交 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,
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);
......
......@@ -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 */
};
......
......@@ -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),
......@@ -520,8 +513,6 @@ mymain(void)
testFileData qcow2 = {
.expBackingStore = canonraw,
.expBackingStoreRaw = "raw",
.expBackingDirRel = ".",
.expBackingDirAbs = datadir,
.expCapacity = 1024,
.pathRel = "qcow2",
.pathAbs = canonqcow2,
......@@ -558,7 +549,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;
......@@ -579,8 +569,6 @@ mymain(void)
testFileData wrap = {
.expBackingStore = canonqcow2,
.expBackingStoreRaw = absqcow2,
.expBackingDirRel = datadir,
.expBackingDirAbs = datadir,
.expCapacity = 1024,
.pathRel = "wrap",
.pathAbs = abswrap,
......@@ -617,8 +605,6 @@ mymain(void)
testFileData wrap_as_raw = {
.expBackingStore = canonqcow2,
.expBackingStoreRaw = absqcow2,
.expBackingDirRel = datadir,
.expBackingDirAbs = datadir,
.expCapacity = 1024,
.pathRel = "wrap",
.pathAbs = abswrap,
......@@ -676,8 +662,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 = {
......@@ -697,8 +681,6 @@ mymain(void)
testFileData qed = {
.expBackingStore = canonraw,
.expBackingStoreRaw = absraw,
.expBackingDirRel = datadir,
.expBackingDirAbs = datadir,
.expCapacity = 1024,
.pathRel = "qed",
.pathAbs = absqed,
......@@ -761,8 +743,6 @@ mymain(void)
testFileData link1 = {
.expBackingStore = canonraw,
.expBackingStoreRaw = "../raw",
.expBackingDirRel = "sub/../sub/..",
.expBackingDirAbs = datadir "/sub/../sub/..",
.expCapacity = 1024,
.pathRel = "../sub/link1",
.pathAbs = "../sub/link1",
......@@ -775,8 +755,6 @@ mymain(void)
testFileData link2 = {
.expBackingStore = canonqcow2,
.expBackingStoreRaw = "../sub/link1",
.expBackingDirRel = "sub/../sub",
.expBackingDirAbs = datadir "/sub/../sub",
.expCapacity = 1024,
.pathRel = "sub/link2",
.pathAbs = abslink2,
......@@ -805,8 +783,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,
......@@ -828,7 +804,6 @@ mymain(void)
if (virCommandRun(cmd, NULL) < 0)
ret = -1;
qcow2.expBackingStoreRaw = "wrap";
qcow2.expBackingDirRel = datadir;
qcow2.pathRel = absqcow2;
qcow2.relDirRel = datadir;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册