[libvirt] [PATCH RFC 04/40] qemu: domain: Split out setup of virStorageSource from qemu driver config

Daniel Henrique Barboza danielhb413 at gmail.com
Fri Oct 18 18:44:39 UTC 2019



On 10/18/19 1:10 PM, Peter Krempa wrote:
> qemuDomainPrepareDiskSourceData historically prepared everything but
> we'we split out the majority of the functionality so that it sets up
> predominantely only according to the configuration of the disk. There
> was one leftover bit of setting the gluster debug level from the config.
> 
> Split this out into a separate function so that
> qemuDomainPrepareDiskSourceData only perpares based on the disk.

s/perpares/prepares


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

> 
> Signed-off-by: Peter Krempa <pkrempa at redhat.com>
> ---
>   src/qemu/qemu_domain.c | 51 +++++++++++++++++++++++++++++-------------
>   src/qemu/qemu_domain.h |  4 +---
>   tests/qemublocktest.c  |  2 +-
>   3 files changed, 38 insertions(+), 19 deletions(-)
> 
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index a97bf65e7f..6a93dd5293 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -10251,6 +10251,32 @@ qemuDomainStorageSourceValidateDepth(virStorageSourcePtr src,
>   }
> 
> 
> +/**
> + * qemuDomainPrepareStorageSourceConfig:
> + * @src: storage source to configure
> + * @cfg: qemu driver config object
> + * @qemuCaps: capabilities of qemu
> + *
> + * Set properties of @src based on the qemu driver config @cfg.
> + *
> + */
> +static void
> +qemuDomainPrepareStorageSourceConfig(virStorageSourcePtr src,
> +                                     virQEMUDriverConfigPtr cfg,
> +                                     virQEMUCapsPtr qemuCaps)
> +{
> +    if (!cfg)
> +        return;
> +
> +    if (src->type == VIR_STORAGE_TYPE_NETWORK &&
> +        src->protocol == VIR_STORAGE_NET_PROTOCOL_GLUSTER &&
> +        virQEMUCapsGet(qemuCaps, QEMU_CAPS_GLUSTER_DEBUG_LEVEL)) {
> +        src->debug = true;
> +        src->debugLevel = cfg->glusterDebugLevel;
> +    }
> +}
> +
> +
>   /**
>    * qemuDomainDetermineDiskChain:
>    * @driver: qemu driver object
> @@ -10356,7 +10382,9 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
>           if (qemuDomainValidateStorageSource(n, priv->qemuCaps) < 0)
>               return -1;
> 
> -        if (qemuDomainPrepareDiskSourceData(disk, n, cfg, priv->qemuCaps) < 0)
> +        qemuDomainPrepareStorageSourceConfig(n, cfg, priv->qemuCaps);
> +
> +        if (qemuDomainPrepareDiskSourceData(disk, n) < 0)
>               return -1;
> 
>           if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV) &&
> @@ -15060,7 +15088,6 @@ qemuDomainCheckCCWS390AddressSupport(const virDomainDef *def,
>    *
>    * @disk: Disk config object
>    * @src: source to start from
> - * @cfg: qemu driver config object
>    *
>    * Prepares various aspects of a storage source belonging to a disk backing
>    * chain. This function should be also called for detected backing chain
> @@ -15068,22 +15095,12 @@ qemuDomainCheckCCWS390AddressSupport(const virDomainDef *def,
>    */
>   int
>   qemuDomainPrepareDiskSourceData(virDomainDiskDefPtr disk,
> -                                virStorageSourcePtr src,
> -                                virQEMUDriverConfigPtr cfg,
> -                                virQEMUCapsPtr qemuCaps)
> +                                virStorageSourcePtr src)
>   {
>       /* transfer properties valid only for the top level image */
>       if (src == disk->src)
>           src->detect_zeroes = disk->detect_zeroes;
> 
> -    if (cfg &&
> -        src->type == VIR_STORAGE_TYPE_NETWORK &&
> -        src->protocol == VIR_STORAGE_NET_PROTOCOL_GLUSTER &&
> -        virQEMUCapsGet(qemuCaps, QEMU_CAPS_GLUSTER_DEBUG_LEVEL)) {
> -        src->debug = true;
> -        src->debugLevel = cfg->glusterDebugLevel;
> -    }
> -
>       /* transfer properties valid for the full chain */
>       src->iomode = disk->iomode;
>       src->cachemode = disk->cachemode;
> @@ -15144,7 +15161,9 @@ qemuDomainPrepareDiskSourceLegacy(virDomainDiskDefPtr disk,
>       if (qemuDomainValidateStorageSource(disk->src, priv->qemuCaps) < 0)
>           return -1;
> 
> -    if (qemuDomainPrepareDiskSourceData(disk, disk->src, cfg, priv->qemuCaps) < 0)
> +    qemuDomainPrepareStorageSourceConfig(disk->src, cfg, priv->qemuCaps);
> +
> +    if (qemuDomainPrepareDiskSourceData(disk, disk->src) < 0)
>           return -1;
> 
>       if (qemuDomainSecretStorageSourcePrepare(priv, disk->src,
> @@ -15178,7 +15197,9 @@ qemuDomainPrepareStorageSourceBlockdev(virDomainDiskDefPtr disk,
>       if (qemuDomainValidateStorageSource(src, priv->qemuCaps) < 0)
>           return -1;
> 
> -    if (qemuDomainPrepareDiskSourceData(disk, src, cfg, priv->qemuCaps) < 0)
> +    qemuDomainPrepareStorageSourceConfig(src, cfg, priv->qemuCaps);
> +
> +    if (qemuDomainPrepareDiskSourceData(disk, src) < 0)
>           return -1;
> 
>       if (qemuDomainSecretStorageSourcePrepare(priv, src,
> diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
> index d703417862..14367f7320 100644
> --- a/src/qemu/qemu_domain.h
> +++ b/src/qemu/qemu_domain.h
> @@ -1169,9 +1169,7 @@ qemuDomainCheckCCWS390AddressSupport(const virDomainDef *def,
> 
>   int
>   qemuDomainPrepareDiskSourceData(virDomainDiskDefPtr disk,
> -                                virStorageSourcePtr src,
> -                                virQEMUDriverConfigPtr cfg,
> -                                virQEMUCapsPtr qemuCaps)
> +                                virStorageSourcePtr src)
>       G_GNUC_WARN_UNUSED_RESULT;
> 
> 
> diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c
> index 0f073682ca..9b7abceb40 100644
> --- a/tests/qemublocktest.c
> +++ b/tests/qemublocktest.c
> @@ -223,7 +223,7 @@ testQemuDiskXMLToProps(const void *opaque)
>           if (qemuDomainValidateStorageSource(n, data->qemuCaps) < 0)
>               goto cleanup;
> 
> -        if (qemuDomainPrepareDiskSourceData(disk, n, NULL, data->qemuCaps) < 0)
> +        if (qemuDomainPrepareDiskSourceData(disk, n) < 0)
>               goto cleanup;
> 
>           if (!(formatProps = qemuBlockStorageSourceGetBlockdevProps(n, n->backingStore)) ||
> 




More information about the libvir-list mailing list