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

util: virstoragefile: Don't use "backingStore" directly

As a temporary step to allow killing of the "backingStore" field of
struct virStorageFileMetadata the recursive metadata retrieval function
will be converted not to use the field in the lookup process.
上级 05bc536c
...@@ -1122,6 +1122,7 @@ virStorageFileGetMetadataRecurse(const char *path, const char *canonPath, ...@@ -1122,6 +1122,7 @@ virStorageFileGetMetadataRecurse(const char *path, const char *canonPath,
int fd; int fd;
int ret = -1; int ret = -1;
int backingFormat; int backingFormat;
char *backingPath = NULL;
char *backingDirectory = NULL; 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",
...@@ -1175,7 +1176,7 @@ virStorageFileGetMetadataRecurse(const char *path, const char *canonPath, ...@@ -1175,7 +1176,7 @@ virStorageFileGetMetadataRecurse(const char *path, const char *canonPath,
if (virFindBackingFile(directory, if (virFindBackingFile(directory,
meta->backingStoreRaw, meta->backingStoreRaw,
&backingDirectory, &backingDirectory,
&meta->backingStore) < 0) { &backingPath) < 0) {
/* the backing file is (currently) unavailable, treat this /* the backing file is (currently) unavailable, treat this
* file as standalone: * file as standalone:
* backingStoreRaw is kept to mark broken image chains */ * backingStoreRaw is kept to mark broken image chains */
...@@ -1185,17 +1186,20 @@ virStorageFileGetMetadataRecurse(const char *path, const char *canonPath, ...@@ -1185,17 +1186,20 @@ virStorageFileGetMetadataRecurse(const char *path, const char *canonPath,
return 0; return 0;
} }
} else { } else {
if (VIR_STRDUP(meta->backingStore, meta->backingStoreRaw) < 0) if (VIR_STRDUP(backingPath, meta->backingStoreRaw) < 0)
return -1; return -1;
} }
if (VIR_STRDUP(meta->backingStore, backingPath) < 0)
return -1;
if (backingFormat == VIR_STORAGE_FILE_AUTO && !allow_probe) if (backingFormat == VIR_STORAGE_FILE_AUTO && !allow_probe)
backingFormat = VIR_STORAGE_FILE_RAW; backingFormat = VIR_STORAGE_FILE_RAW;
else if (backingFormat == VIR_STORAGE_FILE_AUTO_SAFE) else if (backingFormat == VIR_STORAGE_FILE_AUTO_SAFE)
backingFormat = VIR_STORAGE_FILE_AUTO; backingFormat = VIR_STORAGE_FILE_AUTO;
if (VIR_ALLOC(backing) < 0 || if (VIR_ALLOC(backing) < 0 ||
virStorageFileGetMetadataRecurse(meta->backingStoreRaw, virStorageFileGetMetadataRecurse(meta->backingStoreRaw,
meta->backingStore, backingPath,
backingDirectory, backingFormat, backingDirectory, backingFormat,
uid, gid, allow_probe, uid, gid, allow_probe,
cycle, backing) < 0) { cycle, backing) < 0) {
...@@ -1206,7 +1210,9 @@ virStorageFileGetMetadataRecurse(const char *path, const char *canonPath, ...@@ -1206,7 +1210,9 @@ virStorageFileGetMetadataRecurse(const char *path, const char *canonPath,
meta->backingMeta = backing; meta->backingMeta = backing;
} }
} }
VIR_FREE(backingDirectory); VIR_FREE(backingDirectory);
VIR_FREE(backingPath);
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册