mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-27 08:05:24 +00:00
conf: Fix domain disk path iterator to work with networked storage
Skip networked storage but continue iteration through backing chain to iterate through all the local paths in the backing chain.
This commit is contained in:
parent
0620bd42ad
commit
b52e1ad961
@ -18686,34 +18686,37 @@ virDomainDiskDefForeachPath(virDomainDiskDefPtr disk,
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
size_t depth = 0;
|
size_t depth = 0;
|
||||||
virStorageSourcePtr tmp;
|
virStorageSourcePtr tmp;
|
||||||
const char *path = virDomainDiskGetSource(disk);
|
char *brokenRaw = NULL;
|
||||||
int type = virDomainDiskGetType(disk);
|
|
||||||
|
|
||||||
if (!path || type == VIR_STORAGE_TYPE_NETWORK ||
|
if (!ignoreOpenFailure) {
|
||||||
(type == VIR_STORAGE_TYPE_VOLUME &&
|
if (virStorageFileChainGetBroken(&disk->src, &brokenRaw) < 0)
|
||||||
disk->src.srcpool &&
|
|
||||||
disk->src.srcpool->mode == VIR_STORAGE_SOURCE_POOL_MODE_DIRECT))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (iter(disk, path, 0, opaque) < 0)
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
tmp = disk->src.backingStore;
|
if (brokenRaw) {
|
||||||
while (tmp && virStorageIsFile(tmp->path)) {
|
|
||||||
if (!ignoreOpenFailure && tmp->backingStoreRaw && !tmp->backingStore) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("unable to visit backing chain file %s"),
|
_("unable to visit backing chain file %s"),
|
||||||
tmp->backingStoreRaw);
|
brokenRaw);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if (iter(disk, tmp->path, ++depth, opaque) < 0)
|
}
|
||||||
|
|
||||||
|
for (tmp = &disk->src; tmp; tmp = tmp->backingStore) {
|
||||||
|
int actualType = virStorageSourceGetActualType(tmp);
|
||||||
|
/* execute the callback only for local storage */
|
||||||
|
if (actualType != VIR_STORAGE_TYPE_NETWORK &&
|
||||||
|
actualType != VIR_STORAGE_TYPE_VOLUME &&
|
||||||
|
tmp->path) {
|
||||||
|
if (iter(disk, tmp->path, depth, opaque) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
tmp = tmp->backingStore;
|
}
|
||||||
|
|
||||||
|
depth++;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
VIR_FREE(brokenRaw);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user