mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
util: storagefile: Rename "canonPath" to "path" in virStorageFileMetadata
As for the previous patch, this change is needed to achieve compatibility with all the existing code, where we expect a fully qualified path of local files to be present.
This commit is contained in:
parent
f34b829692
commit
05bc536c83
@ -949,12 +949,12 @@ virStorageFileMetadataNew(const char *path,
|
|||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (virStorageIsFile(path)) {
|
if (virStorageIsFile(path)) {
|
||||||
if (!(ret->canonPath = canonicalize_file_name(path))) {
|
if (!(ret->path = canonicalize_file_name(path))) {
|
||||||
virReportSystemError(errno, _("unable to resolve '%s'"), path);
|
virReportSystemError(errno, _("unable to resolve '%s'"), path);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (VIR_STRDUP(ret->canonPath, path) < 0)
|
if (VIR_STRDUP(ret->path, path) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1047,7 +1047,7 @@ virStorageFileGetMetadataFromFDInternal(virStorageFileMetadataPtr meta,
|
|||||||
* file; therefore, no inclusion loop is possible, and we
|
* file; therefore, no inclusion loop is possible, and we
|
||||||
* don't need canonName or relDir. */
|
* don't need canonName or relDir. */
|
||||||
VIR_FREE(meta->relDir);
|
VIR_FREE(meta->relDir);
|
||||||
VIR_FREE(meta->canonPath);
|
VIR_FREE(meta->path);
|
||||||
meta->type = VIR_STORAGE_TYPE_DIR;
|
meta->type = VIR_STORAGE_TYPE_DIR;
|
||||||
meta->format = VIR_STORAGE_FILE_DIR;
|
meta->format = VIR_STORAGE_FILE_DIR;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
@ -1140,7 +1140,7 @@ virStorageFileGetMetadataRecurse(const char *path, const char *canonPath,
|
|||||||
if (virStorageIsFile(path)) {
|
if (virStorageIsFile(path)) {
|
||||||
if (VIR_STRDUP(meta->relPath, path) < 0)
|
if (VIR_STRDUP(meta->relPath, path) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
if (VIR_STRDUP(meta->canonPath, canonPath) < 0)
|
if (VIR_STRDUP(meta->path, canonPath) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
if (VIR_STRDUP(meta->relDir, directory) < 0)
|
if (VIR_STRDUP(meta->relDir, directory) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -1161,7 +1161,7 @@ virStorageFileGetMetadataRecurse(const char *path, const char *canonPath,
|
|||||||
* allow for non-raw images. */
|
* allow for non-raw images. */
|
||||||
if (VIR_STRDUP(meta->relPath, path) < 0)
|
if (VIR_STRDUP(meta->relPath, path) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
if (VIR_STRDUP(meta->canonPath, path) < 0)
|
if (VIR_STRDUP(meta->path, path) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
meta->type = VIR_STORAGE_TYPE_NETWORK;
|
meta->type = VIR_STORAGE_TYPE_NETWORK;
|
||||||
meta->format = VIR_STORAGE_FILE_RAW;
|
meta->format = VIR_STORAGE_FILE_RAW;
|
||||||
@ -1322,7 +1322,7 @@ virStorageFileFreeMetadata(virStorageFileMetadata *meta)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
VIR_FREE(meta->relPath);
|
VIR_FREE(meta->relPath);
|
||||||
VIR_FREE(meta->canonPath);
|
VIR_FREE(meta->path);
|
||||||
VIR_FREE(meta->relDir);
|
VIR_FREE(meta->relDir);
|
||||||
|
|
||||||
virStorageFileFreeMetadata(meta->backingMeta);
|
virStorageFileFreeMetadata(meta->backingMeta);
|
||||||
@ -1539,7 +1539,7 @@ virStorageFileChainLookup(virStorageFileMetadataPtr chain,
|
|||||||
const char *name, virStorageFileMetadataPtr *meta,
|
const char *name, virStorageFileMetadataPtr *meta,
|
||||||
const char **parent)
|
const char **parent)
|
||||||
{
|
{
|
||||||
const char *start = chain->canonPath;
|
const char *start = chain->path;
|
||||||
const char *tmp;
|
const char *tmp;
|
||||||
const char *parentDir = ".";
|
const char *parentDir = ".";
|
||||||
bool nameIsFile = virStorageIsFile(name);
|
bool nameIsFile = virStorageIsFile(name);
|
||||||
@ -1558,14 +1558,14 @@ virStorageFileChainLookup(virStorageFileMetadataPtr chain,
|
|||||||
if (nameIsFile && (chain->type == VIR_STORAGE_TYPE_FILE ||
|
if (nameIsFile && (chain->type == VIR_STORAGE_TYPE_FILE ||
|
||||||
chain->type == VIR_STORAGE_TYPE_BLOCK)) {
|
chain->type == VIR_STORAGE_TYPE_BLOCK)) {
|
||||||
int result = virFileRelLinkPointsTo(parentDir, name,
|
int result = virFileRelLinkPointsTo(parentDir, name,
|
||||||
chain->canonPath);
|
chain->path);
|
||||||
if (result < 0)
|
if (result < 0)
|
||||||
goto error;
|
goto error;
|
||||||
if (result > 0)
|
if (result > 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*parent = chain->canonPath;
|
*parent = chain->path;
|
||||||
parentDir = chain->relDir;
|
parentDir = chain->relDir;
|
||||||
chain = chain->backingMeta;
|
chain = chain->backingMeta;
|
||||||
}
|
}
|
||||||
@ -1573,7 +1573,7 @@ virStorageFileChainLookup(virStorageFileMetadataPtr chain,
|
|||||||
goto error;
|
goto error;
|
||||||
if (meta)
|
if (meta)
|
||||||
*meta = chain;
|
*meta = chain;
|
||||||
return chain->canonPath;
|
return chain->path;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
if (name)
|
if (name)
|
||||||
|
@ -124,7 +124,7 @@ struct _virStorageFileMetadata {
|
|||||||
char *relPath;
|
char *relPath;
|
||||||
/* Canonical name of the current file, used to detect loops in the
|
/* Canonical name of the current file, used to detect loops in the
|
||||||
* backing store chain. */
|
* backing store chain. */
|
||||||
char *canonPath;
|
char *path;
|
||||||
/* Directory to start from if backingStoreRaw is a relative file
|
/* Directory to start from if backingStoreRaw is a relative file
|
||||||
* name. */
|
* name. */
|
||||||
char *relDir;
|
char *relDir;
|
||||||
|
@ -237,7 +237,7 @@ struct _testFileData
|
|||||||
bool expEncrypted;
|
bool expEncrypted;
|
||||||
const char *pathRel;
|
const char *pathRel;
|
||||||
const char *pathAbs;
|
const char *pathAbs;
|
||||||
const char *canonPath;
|
const char *path;
|
||||||
const char *relDirRel;
|
const char *relDirRel;
|
||||||
const char *relDirAbs;
|
const char *relDirAbs;
|
||||||
int type;
|
int type;
|
||||||
@ -323,24 +323,24 @@ testStorageChain(const void *args)
|
|||||||
: data->files[i]->relDirRel;
|
: data->files[i]->relDirRel;
|
||||||
if (virAsprintf(&expect,
|
if (virAsprintf(&expect,
|
||||||
"store:%s\nraw:%s\nother:%lld %d\n"
|
"store:%s\nraw:%s\nother:%lld %d\n"
|
||||||
"relPath:%s\ncanon:%s\nrelDir:%s\ntype:%d %d\n",
|
"relPath:%s\npath:%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),
|
||||||
data->files[i]->expCapacity,
|
data->files[i]->expCapacity,
|
||||||
data->files[i]->expEncrypted,
|
data->files[i]->expEncrypted,
|
||||||
NULLSTR(expPath),
|
NULLSTR(expPath),
|
||||||
NULLSTR(data->files[i]->canonPath),
|
NULLSTR(data->files[i]->path),
|
||||||
NULLSTR(expRelDir),
|
NULLSTR(expRelDir),
|
||||||
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\nother:%lld %d\n"
|
"store:%s\nraw:%s\nother:%lld %d\n"
|
||||||
"relPath:%s\ncanon:%s\nrelDir:%s\ntype:%d %d\n",
|
"relPath:%s\npath:%s\nrelDir:%s\ntype:%d %d\n",
|
||||||
NULLSTR(elt->backingStore),
|
NULLSTR(elt->backingStore),
|
||||||
NULLSTR(elt->backingStoreRaw),
|
NULLSTR(elt->backingStoreRaw),
|
||||||
elt->capacity, !!elt->encryption,
|
elt->capacity, !!elt->encryption,
|
||||||
NULLSTR(elt->relPath),
|
NULLSTR(elt->relPath),
|
||||||
NULLSTR(elt->canonPath),
|
NULLSTR(elt->path),
|
||||||
NULLSTR(elt->relDir),
|
NULLSTR(elt->relDir),
|
||||||
elt->type, elt->format) < 0) {
|
elt->type, elt->format) < 0) {
|
||||||
VIR_FREE(expect);
|
VIR_FREE(expect);
|
||||||
@ -491,7 +491,7 @@ mymain(void)
|
|||||||
testFileData raw = {
|
testFileData raw = {
|
||||||
.pathRel = "raw",
|
.pathRel = "raw",
|
||||||
.pathAbs = canonraw,
|
.pathAbs = canonraw,
|
||||||
.canonPath = canonraw,
|
.path = canonraw,
|
||||||
.relDirRel = ".",
|
.relDirRel = ".",
|
||||||
.relDirAbs = datadir,
|
.relDirAbs = datadir,
|
||||||
.type = VIR_STORAGE_TYPE_FILE,
|
.type = VIR_STORAGE_TYPE_FILE,
|
||||||
@ -516,7 +516,7 @@ mymain(void)
|
|||||||
.expCapacity = 1024,
|
.expCapacity = 1024,
|
||||||
.pathRel = "qcow2",
|
.pathRel = "qcow2",
|
||||||
.pathAbs = canonqcow2,
|
.pathAbs = canonqcow2,
|
||||||
.canonPath = canonqcow2,
|
.path = canonqcow2,
|
||||||
.relDirRel = ".",
|
.relDirRel = ".",
|
||||||
.relDirAbs = datadir,
|
.relDirAbs = datadir,
|
||||||
.type = VIR_STORAGE_TYPE_FILE,
|
.type = VIR_STORAGE_TYPE_FILE,
|
||||||
@ -525,7 +525,7 @@ mymain(void)
|
|||||||
testFileData qcow2_as_raw = {
|
testFileData qcow2_as_raw = {
|
||||||
.pathRel = "qcow2",
|
.pathRel = "qcow2",
|
||||||
.pathAbs = canonqcow2,
|
.pathAbs = canonqcow2,
|
||||||
.canonPath = canonqcow2,
|
.path = canonqcow2,
|
||||||
.relDirRel = ".",
|
.relDirRel = ".",
|
||||||
.relDirAbs = datadir,
|
.relDirAbs = datadir,
|
||||||
.type = VIR_STORAGE_TYPE_FILE,
|
.type = VIR_STORAGE_TYPE_FILE,
|
||||||
@ -572,7 +572,7 @@ mymain(void)
|
|||||||
.expCapacity = 1024,
|
.expCapacity = 1024,
|
||||||
.pathRel = "wrap",
|
.pathRel = "wrap",
|
||||||
.pathAbs = abswrap,
|
.pathAbs = abswrap,
|
||||||
.canonPath = canonwrap,
|
.path = canonwrap,
|
||||||
.relDirRel = ".",
|
.relDirRel = ".",
|
||||||
.relDirAbs = datadir,
|
.relDirAbs = datadir,
|
||||||
.type = VIR_STORAGE_TYPE_FILE,
|
.type = VIR_STORAGE_TYPE_FILE,
|
||||||
@ -608,7 +608,7 @@ mymain(void)
|
|||||||
.expCapacity = 1024,
|
.expCapacity = 1024,
|
||||||
.pathRel = "wrap",
|
.pathRel = "wrap",
|
||||||
.pathAbs = abswrap,
|
.pathAbs = abswrap,
|
||||||
.canonPath = canonwrap,
|
.path = canonwrap,
|
||||||
.relDirRel = ".",
|
.relDirRel = ".",
|
||||||
.relDirAbs = datadir,
|
.relDirAbs = datadir,
|
||||||
.type = VIR_STORAGE_TYPE_FILE,
|
.type = VIR_STORAGE_TYPE_FILE,
|
||||||
@ -667,7 +667,7 @@ mymain(void)
|
|||||||
testFileData nbd = {
|
testFileData nbd = {
|
||||||
.pathRel = "nbd:example.org:6000",
|
.pathRel = "nbd:example.org:6000",
|
||||||
.pathAbs = "nbd:example.org:6000",
|
.pathAbs = "nbd:example.org:6000",
|
||||||
.canonPath = "nbd:example.org:6000",
|
.path = "nbd:example.org:6000",
|
||||||
.type = VIR_STORAGE_TYPE_NETWORK,
|
.type = VIR_STORAGE_TYPE_NETWORK,
|
||||||
.format = VIR_STORAGE_FILE_RAW,
|
.format = VIR_STORAGE_FILE_RAW,
|
||||||
};
|
};
|
||||||
@ -684,7 +684,7 @@ mymain(void)
|
|||||||
.expCapacity = 1024,
|
.expCapacity = 1024,
|
||||||
.pathRel = "qed",
|
.pathRel = "qed",
|
||||||
.pathAbs = absqed,
|
.pathAbs = absqed,
|
||||||
.canonPath = canonqed,
|
.path = canonqed,
|
||||||
.relDirRel = ".",
|
.relDirRel = ".",
|
||||||
.relDirAbs = datadir,
|
.relDirAbs = datadir,
|
||||||
.type = VIR_STORAGE_TYPE_FILE,
|
.type = VIR_STORAGE_TYPE_FILE,
|
||||||
@ -693,7 +693,7 @@ mymain(void)
|
|||||||
testFileData qed_as_raw = {
|
testFileData qed_as_raw = {
|
||||||
.pathRel = "qed",
|
.pathRel = "qed",
|
||||||
.pathAbs = absqed,
|
.pathAbs = absqed,
|
||||||
.canonPath = canonqed,
|
.path = canonqed,
|
||||||
.relDirRel = ".",
|
.relDirRel = ".",
|
||||||
.relDirAbs = datadir,
|
.relDirAbs = datadir,
|
||||||
.type = VIR_STORAGE_TYPE_FILE,
|
.type = VIR_STORAGE_TYPE_FILE,
|
||||||
@ -746,7 +746,7 @@ mymain(void)
|
|||||||
.expCapacity = 1024,
|
.expCapacity = 1024,
|
||||||
.pathRel = "../sub/link1",
|
.pathRel = "../sub/link1",
|
||||||
.pathAbs = "../sub/link1",
|
.pathAbs = "../sub/link1",
|
||||||
.canonPath = canonqcow2,
|
.path = canonqcow2,
|
||||||
.relDirRel = "sub/../sub",
|
.relDirRel = "sub/../sub",
|
||||||
.relDirAbs = datadir "/sub/../sub",
|
.relDirAbs = datadir "/sub/../sub",
|
||||||
.type = VIR_STORAGE_TYPE_FILE,
|
.type = VIR_STORAGE_TYPE_FILE,
|
||||||
@ -758,7 +758,7 @@ mymain(void)
|
|||||||
.expCapacity = 1024,
|
.expCapacity = 1024,
|
||||||
.pathRel = "sub/link2",
|
.pathRel = "sub/link2",
|
||||||
.pathAbs = abslink2,
|
.pathAbs = abslink2,
|
||||||
.canonPath = canonwrap,
|
.path = canonwrap,
|
||||||
.relDirRel = "sub",
|
.relDirRel = "sub",
|
||||||
.relDirAbs = datadir "/sub",
|
.relDirAbs = datadir "/sub",
|
||||||
.type = VIR_STORAGE_TYPE_FILE,
|
.type = VIR_STORAGE_TYPE_FILE,
|
||||||
@ -839,12 +839,12 @@ mymain(void)
|
|||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
TEST_LOOKUP(0, "bogus", NULL, NULL, NULL);
|
TEST_LOOKUP(0, "bogus", NULL, NULL, NULL);
|
||||||
TEST_LOOKUP(1, "wrap", chain->canonPath, chain, NULL);
|
TEST_LOOKUP(1, "wrap", chain->path, chain, NULL);
|
||||||
TEST_LOOKUP(2, abswrap, chain->canonPath, chain, NULL);
|
TEST_LOOKUP(2, abswrap, chain->path, chain, NULL);
|
||||||
TEST_LOOKUP(3, "qcow2", chain->backingStore, chain->backingMeta,
|
TEST_LOOKUP(3, "qcow2", chain->backingStore, chain->backingMeta,
|
||||||
chain->canonPath);
|
chain->path);
|
||||||
TEST_LOOKUP(4, absqcow2, chain->backingStore, chain->backingMeta,
|
TEST_LOOKUP(4, absqcow2, chain->backingStore, chain->backingMeta,
|
||||||
chain->canonPath);
|
chain->path);
|
||||||
TEST_LOOKUP(5, "raw", chain->backingMeta->backingStore,
|
TEST_LOOKUP(5, "raw", chain->backingMeta->backingStore,
|
||||||
chain->backingMeta->backingMeta, chain->backingStore);
|
chain->backingMeta->backingMeta, chain->backingStore);
|
||||||
TEST_LOOKUP(6, absraw, chain->backingMeta->backingStore,
|
TEST_LOOKUP(6, absraw, chain->backingMeta->backingStore,
|
||||||
@ -875,12 +875,12 @@ mymain(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_LOOKUP(8, "bogus", NULL, NULL, NULL);
|
TEST_LOOKUP(8, "bogus", NULL, NULL, NULL);
|
||||||
TEST_LOOKUP(9, "wrap", chain->canonPath, chain, NULL);
|
TEST_LOOKUP(9, "wrap", chain->path, chain, NULL);
|
||||||
TEST_LOOKUP(10, abswrap, chain->canonPath, chain, NULL);
|
TEST_LOOKUP(10, abswrap, chain->path, chain, NULL);
|
||||||
TEST_LOOKUP(11, "qcow2", chain->backingStore, chain->backingMeta,
|
TEST_LOOKUP(11, "qcow2", chain->backingStore, chain->backingMeta,
|
||||||
chain->canonPath);
|
chain->path);
|
||||||
TEST_LOOKUP(12, absqcow2, chain->backingStore, chain->backingMeta,
|
TEST_LOOKUP(12, absqcow2, chain->backingStore, chain->backingMeta,
|
||||||
chain->canonPath);
|
chain->path);
|
||||||
TEST_LOOKUP(13, "raw", chain->backingMeta->backingStore,
|
TEST_LOOKUP(13, "raw", chain->backingMeta->backingStore,
|
||||||
chain->backingMeta->backingMeta, chain->backingStore);
|
chain->backingMeta->backingMeta, chain->backingStore);
|
||||||
TEST_LOOKUP(14, absraw, chain->backingMeta->backingStore,
|
TEST_LOOKUP(14, absraw, chain->backingMeta->backingStore,
|
||||||
@ -905,14 +905,14 @@ mymain(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_LOOKUP(16, "bogus", NULL, NULL, NULL);
|
TEST_LOOKUP(16, "bogus", NULL, NULL, NULL);
|
||||||
TEST_LOOKUP(17, "sub/link2", chain->canonPath, chain, NULL);
|
TEST_LOOKUP(17, "sub/link2", chain->path, chain, NULL);
|
||||||
TEST_LOOKUP(18, "wrap", chain->canonPath, chain, NULL);
|
TEST_LOOKUP(18, "wrap", chain->path, chain, NULL);
|
||||||
TEST_LOOKUP(19, abswrap, chain->canonPath, chain, NULL);
|
TEST_LOOKUP(19, abswrap, chain->path, chain, NULL);
|
||||||
TEST_LOOKUP(20, "../qcow2", chain->backingStore, chain->backingMeta,
|
TEST_LOOKUP(20, "../qcow2", chain->backingStore, chain->backingMeta,
|
||||||
chain->canonPath);
|
chain->path);
|
||||||
TEST_LOOKUP(21, "qcow2", NULL, NULL, NULL);
|
TEST_LOOKUP(21, "qcow2", NULL, NULL, NULL);
|
||||||
TEST_LOOKUP(22, absqcow2, chain->backingStore, chain->backingMeta,
|
TEST_LOOKUP(22, absqcow2, chain->backingStore, chain->backingMeta,
|
||||||
chain->canonPath);
|
chain->path);
|
||||||
TEST_LOOKUP(23, "raw", chain->backingMeta->backingStore,
|
TEST_LOOKUP(23, "raw", chain->backingMeta->backingStore,
|
||||||
chain->backingMeta->backingMeta, chain->backingStore);
|
chain->backingMeta->backingMeta, chain->backingStore);
|
||||||
TEST_LOOKUP(24, absraw, chain->backingMeta->backingStore,
|
TEST_LOOKUP(24, absraw, chain->backingMeta->backingStore,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user