[libvirt] [PATCH 19/30] storagefile: Fill in meta->externalDataStore
Daniel Henrique Barboza
danielhb413 at gmail.com
Thu Oct 10 15:14:36 UTC 2019
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 at redhat.com>
> ---
Reviewed-by: Daniel Henrique Barboza <danielhb413 at 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:
More information about the libvir-list
mailing list