On 10/7/19 6:49 PM, Cole Robinson wrote:
Add virStorageSourceNewFromExternalData, similar to
virStorageSourceNewFromBacking and use it to fill in a
virStorageSource for externalDataStore
Signed-off-by: Cole Robinson <crobinso@xxxxxxxxxx>
---
Reviewed-by: Daniel Henrique Barboza <danielhb413@xxxxxxxxx>
src/util/virstoragefile.c | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index ce669b6e0b..4aa70d71b1 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -3799,6 +3799,24 @@ virStorageSourceNewFromBacking(virStorageSourcePtr parent,
}
+static int
+virStorageSourceNewFromExternalData(virStorageSourcePtr parent,
+ virStorageSourcePtr *externalDataStore)
+{
+ int rc;
+
+ if ((rc = virStorageSourceNewFromChild(parent,
+ parent->externalDataStoreRaw,
+ externalDataStore)) < 0)
+ return rc;
+
+ /* qcow2 data_file can only be raw */
+ (*externalDataStore)->format = VIR_STORAGE_FILE_RAW;
+ (*externalDataStore)->readonly = parent->readonly;
+ return rc;
+}
+
+
/**
* @src: disk source definition structure
* @fd: file descriptor
@@ -5007,6 +5025,23 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr src,
}
VIR_STEAL_PTR(src->backingStore, backingStore);
+
+ if (src->externalDataStoreRaw) {
+ VIR_AUTOUNREF(virStorageSourcePtr) externalDataStore = NULL;
+
+ if ((rv = virStorageSourceNewFromExternalData(src,
+ &externalDataStore)) < 0)
+ goto cleanup;
+
+ if (rv == 1) {
+ /* the file would not be usable for VM usage */
+ ret = 0;
+ goto cleanup;
+ }
+
+ VIR_STEAL_PTR(src->externalDataStore, externalDataStore);
+ }
+
ret = 0;
cleanup:
--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list