diff mbox series

[19/30] storagefile: Fill in meta->externalDataStore

Message ID 429e602ae44341aef3aaed8186ef032d80a1e6a9.1570482718.git.crobinso@redhat.com
State Accepted
Commit 527f377a922bd26bd7c3a322c7d7d7e9b091f8b7
Headers show
Series storagefile, security: qcow2 data_file support | expand

Commit Message

Cole Robinson Oct. 7, 2019, 9:49 p.m. UTC
Add virStorageSourceNewFromExternalData, similar to
virStorageSourceNewFromBacking and use it to fill in a
virStorageSource for externalDataStore

Signed-off-by: Cole Robinson <crobinso@redhat.com>

---
 src/util/virstoragefile.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

-- 
2.23.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Comments

Daniel Henrique Barboza Oct. 10, 2019, 3:14 p.m. UTC | #1
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@redhat.com>

> ---


Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>



>   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@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
diff mbox series

Patch

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: