[libvirt] [PATCH 07/34] conf: Add helper to retrieve bitmap of active vcpus for a definition

John Ferlan jferlan at redhat.com
Sat Jan 16 14:57:25 UTC 2016



On 01/14/2016 11:26 AM, Peter Krempa wrote:
> In some cases it may be better to have a bitmap representing state of
> individual vcpus rather than iterating the definition. The new helper
> creates a bitmap representing the state from the domain definition.
> ---
>  src/conf/domain_conf.c   | 24 ++++++++++++++++++++++++
>  src/conf/domain_conf.h   |  1 +
>  src/libvirt_private.syms |  1 +
>  3 files changed, 26 insertions(+)
> 
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index a9706b0..36286d3 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -1374,6 +1374,30 @@ virDomainDefGetVcpus(const virDomainDef *def)
>  }
> 
> 
> +/**
> + * virDomainDefGetVcpumap:

Seems this would be better named virDomainDefGetOnlineVcpuMap

At the very least it could be Map instead of map.

Your call on this - just a suggestion.

John
> + * @def: domain definition
> + *
> + * Returns a bitmap representing state of individual vcpus.
> + */
> +virBitmapPtr
> +virDomainDefGetVcpumap(const virDomainDef *def)
> +{
> +    virBitmapPtr ret = NULL;
> +    size_t i;
> +
> +    if (!(ret = virBitmapNew(def->maxvcpus)))
> +        return NULL;
> +
> +    for (i = 0; i < def->maxvcpus; i++) {
> +        if (def->vcpus[i].online)
> +            ignore_value(virBitmapSetBit(ret, i));
> +    }
> +
> +    return ret;
> +}
> +
> +
>  virDomainVcpuInfoPtr
>  virDomainDefGetVcpu(virDomainDefPtr def,
>                      unsigned int vcpu)
> diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
> index 0141009..f15b558 100644
> --- a/src/conf/domain_conf.h
> +++ b/src/conf/domain_conf.h
> @@ -2358,6 +2358,7 @@ bool virDomainDefHasVcpusOffline(const virDomainDef *def);
>  unsigned int virDomainDefGetVcpusMax(const virDomainDef *def);
>  int virDomainDefSetVcpus(virDomainDefPtr def, unsigned int vcpus);
>  unsigned int virDomainDefGetVcpus(const virDomainDef *def);
> +virBitmapPtr virDomainDefGetVcpumap(const virDomainDef *def);
>  virDomainVcpuInfoPtr virDomainDefGetVcpu(virDomainDefPtr def, unsigned int vcpu)
>      ATTRIBUTE_RETURN_CHECK;
> 
> diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
> index 83f6e2c..e8efdc6 100644
> --- a/src/libvirt_private.syms
> +++ b/src/libvirt_private.syms
> @@ -217,6 +217,7 @@ virDomainDefGetMemoryActual;
>  virDomainDefGetMemoryInitial;
>  virDomainDefGetSecurityLabelDef;
>  virDomainDefGetVcpu;
> +virDomainDefGetVcpumap;
>  virDomainDefGetVcpus;
>  virDomainDefGetVcpusMax;
>  virDomainDefHasDeviceAddress;
> 




More information about the libvir-list mailing list