Signed-off-by: Nikolai Barybin <nikolai.barybin@xxxxxxxxxxxxx> --- src/storage_file/storage_source.c | 28 ++++++++++++++++++++++++++++ src/storage_file/storage_source.h | 3 +++ 2 files changed, 31 insertions(+) diff --git a/src/storage_file/storage_source.c b/src/storage_file/storage_source.c index 2cfe3bc325..20d5b30c6c 100644 --- a/src/storage_file/storage_source.c +++ b/src/storage_file/storage_source.c @@ -543,6 +543,22 @@ virStorageSourceNewFromBacking(virStorageSource *parent, } +int virStorageSourceNewFromDataFile(virStorageSource *parent, + virStorageSource **dataFileSrc) +{ + int rc; + + if ((rc = virStorageSourceNewFromChild(parent, + parent->dataFileRaw, + dataFileSrc)) < 0) + return rc; + + (*dataFileSrc)->format = VIR_STORAGE_FILE_RAW; + (*dataFileSrc)->readonly = parent->readonly; + return rc; +} + + /** * @src: disk source definition structure * @fd: file descriptor @@ -1391,6 +1407,18 @@ virStorageSourceGetMetadataRecurse(virStorageSource *src, } } + if (src->dataFileRaw) { + g_autoptr(virStorageSource) dataFileStore = NULL; + if ((rv = virStorageSourceNewFromDataFile(src, &dataFileStore)) < 0) + return -1; + + /* the data file would not be usable for VM usage */ + if (rv == 1) + return 0; + + src->dataFileStore = g_steal_pointer(&dataFileStore); + } + if (src->backingStoreRaw) { if ((rv = virStorageSourceNewFromBacking(src, &backingStore)) < 0) return -1; diff --git a/src/storage_file/storage_source.h b/src/storage_file/storage_source.h index 63fefb6919..0514ff2364 100644 --- a/src/storage_file/storage_source.h +++ b/src/storage_file/storage_source.h @@ -72,6 +72,9 @@ int virStorageSourceNewFromBacking(virStorageSource *parent, virStorageSource **backing); +int virStorageSourceNewFromDataFile(virStorageSource *parent, + virStorageSource **dataFileSrc); + int virStorageSourceGetRelativeBackingPath(virStorageSource *top, virStorageSource *base, -- 2.43.5