提交 e71437ff 编写于 作者: P Peter Krempa

storage: Don't canonicalize paths unnecessarily

Store backing chain paths as non-canonical. The canonicalization step
will be already taken. This will allow to avoid storing unnecessary
amounts of data.
上级 4074ad2d
......@@ -1044,25 +1044,17 @@ virStorageFileGetMetadataFromFD(const char *path,
int *backingFormat)
{
virStorageSourcePtr ret = NULL;
char *canonPath = NULL;
if (!(canonPath = canonicalize_file_name(path))) {
virReportSystemError(errno, _("unable to resolve '%s'"), path);
goto cleanup;
}
virStorageSourcePtr ret;
if (!(ret = virStorageFileMetadataNew(canonPath, format)))
goto cleanup;
if (!(ret = virStorageFileMetadataNew(path, format)))
return NULL;
if (virStorageFileGetMetadataFromFDInternal(ret, fd, backingFormat) < 0) {
virStorageSourceFree(ret);
ret = NULL;
return NULL;
}
cleanup:
VIR_FREE(canonPath);
return ret;
}
......@@ -1641,15 +1633,6 @@ virStorageSourceNewFromBackingRelative(virStorageSourcePtr parent,
virReportOOMError();
goto error;
}
/* XXX we don't currently need to store the canonical path but the
* change would break the test suite. Get rid of this later */
char *tmp = ret->path;
if (!(ret->path = canonicalize_file_name(tmp))) {
ret->path = tmp;
tmp = NULL;
}
VIR_FREE(tmp);
} else {
ret->type = VIR_STORAGE_TYPE_NETWORK;
......@@ -1888,12 +1871,8 @@ virStorageSourceNewFromBackingAbsolute(const char *path)
goto error;
}
/* XXX we don't currently need to store the canonical path but the
* change would break the test suite. Get rid of this later */
if (!(ret->path = canonicalize_file_name(path))) {
if (VIR_STRDUP(ret->path, path) < 0)
goto error;
}
if (VIR_STRDUP(ret->path, path) < 0)
goto error;
} else {
ret->type = VIR_STORAGE_TYPE_NETWORK;
......
......@@ -121,10 +121,8 @@ testStorageFileGetMetadata(const char *path,
goto error;
}
if (!(ret->path = canonicalize_file_name(path))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "failed to resolve '%s'", path);
if (VIR_STRDUP(ret->path, path) < 0)
goto error;
}
if (virStorageFileGetMetadata(ret, uid, gid, allow_probe) < 0)
goto error;
......@@ -905,7 +903,7 @@ mymain(void)
.expBackingStoreRaw = "../raw",
.expCapacity = 1024,
.pathRel = "../sub/link1",
.path = canonqcow2,
.path = datadir "/sub/../sub/link1",
.relDir = datadir "/sub/../sub",
.type = VIR_STORAGE_TYPE_FILE,
.format = VIR_STORAGE_FILE_QCOW2,
......@@ -913,11 +911,13 @@ mymain(void)
testFileData link2 = {
.expBackingStoreRaw = "../sub/link1",
.expCapacity = 1024,
.path = canonwrap,
.path = abslink2,
.relDir = datadir "/sub",
.type = VIR_STORAGE_TYPE_FILE,
.format = VIR_STORAGE_FILE_QCOW2,
};
raw.path = datadir "/sub/../sub/../raw";
raw.pathRel = "../raw";
raw.relDir = datadir "/sub/../sub/..";
TEST_CHAIN(15, abslink2, VIR_STORAGE_FILE_QCOW2,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册