[libvirt] [PATCH 10/14] Remove powerMgmt_valid field from capabilities struct

Srivatsa S. Bhat srivatsa.bhat at linux.vnet.ibm.com
Tue Nov 29 17:03:32 UTC 2011


On 11/29/2011 09:14 PM, Daniel P. Berrange wrote:

> From: "Daniel P. Berrange" <berrange at redhat.com>
> 
> If we ensure that virNodeSuspendGetTargetMask always resets
> *bitmask to zero upon failure, there is no need for the
> powerMgmt_valid field.
> 
> * src/util/virnodesuspend.c: Ensure *bitmask is zero upon
>   failure
> * src/conf/capabilities.c, src/conf/capabilities.h: Remove
>   powerMgmt_valid field
> * src/qemu/qemu_capabilities.c: Remove powerMgmt_valid
> ---
>  src/conf/capabilities.c      |   30 ++++++++++++++----------------
>  src/conf/capabilities.h      |    1 -
>  src/qemu/qemu_capabilities.c |    5 +----
>  src/util/virnodesuspend.c    |   10 +++++++---
>  4 files changed, 22 insertions(+), 24 deletions(-)
> 
> diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
> index df5ff23..ac050df 100644
> --- a/src/conf/capabilities.c
> +++ b/src/conf/capabilities.c
> @@ -696,23 +696,21 @@ virCapabilitiesFormatXML(virCapsPtr caps)
> 
>      virBufferAddLit(&xml, "    </cpu>\n");
> 
> -    if (caps->host.powerMgmt_valid) {
> -        /* The PM query was successful. */
> -        if (caps->host.powerMgmt) {
> -            /* The host supports some PM features. */
> -            unsigned int pm = caps->host.powerMgmt;
> -            virBufferAddLit(&xml, "    <power_management>\n");
> -            while (pm) {
> -                int bit = ffs(pm) - 1;
> -                virBufferAsprintf(&xml, "      <%s/>\n",
> -                    virCapsHostPMTargetTypeToString(bit));
> -                pm &= ~(1U << bit);
> -            }
> -            virBufferAddLit(&xml, "    </power_management>\n");
> -        } else {
> -            /* The host does not support any PM feature. */
> -            virBufferAddLit(&xml, "    <power_management/>\n");
> +    /* The PM query was successful. */

          ^^^^^^^^^^^^^
Considering the point that Eric brought out about the original design
of the <power_management> tag (which I also intended to bring out
in fact), if you decide to go with the new design, the comment above
might not make much sense. We might as well remove it.
 

> +    if (caps->host.powerMgmt) {
> +        /* The host supports some PM features. */
> +        unsigned int pm = caps->host.powerMgmt;
> +        virBufferAddLit(&xml, "    <power_management>\n");
> +        while (pm) {
> +            int bit = ffs(pm) - 1;
> +            virBufferAsprintf(&xml, "      <%s/>\n",
> +                              virCapsHostPMTargetTypeToString(bit));
> +            pm &= ~(1U << bit);
>          }
> +        virBufferAddLit(&xml, "    </power_management>\n");
> +    } else {
> +        /* The host does not support any PM feature. */
> +        virBufferAddLit(&xml, "    <power_management/>\n");
>      }
> 


-- 

Regards,
Srivatsa S. Bhat
IBM Linux Technology Center




More information about the libvir-list mailing list