[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH 11/14] Do lazy init of host PM features

On 11/29/2011 08:44 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange redhat com>
> To avoid probing the host power management features on any
> call to virInitialize, only initialize the mutex in
> virNodeSuspendInit. Do lazy load of the supported PM target
> mask when it is actually needed
> * src/util/virnodesuspend.c: Lazy init of supported features
> ---
>  src/util/virnodesuspend.c |   99 +++++++++++++++++++++++----------------------
>  1 files changed, 50 insertions(+), 49 deletions(-)
> diff --git a/src/util/virnodesuspend.c b/src/util/virnodesuspend.c
> index 6420f5b..75a8c2f 100644
> --- a/src/util/virnodesuspend.c
> +++ b/src/util/virnodesuspend.c
> @@ -46,9 +46,10 @@
>   * Bitmask to hold the Power Management features supported by the host,
>   * such as Suspend-to-RAM, Suspend-to-Disk, Hybrid-Suspend etc.
>   */
> -static unsigned int hostPMFeatures;
> +static unsigned int nodeSuspendTargetMask = 0;
> +static bool nodeSuspendTargetMaskInit = false;

C89 and later guarantee that static variables are 0-initialized unless
you state otherwise.  Meanwhile, explicit initialization penalizes old
compilers that stick the variables into .data instead of .bss.  gcc is
smart enough to generate 0-init'd variables into .bss for smaller
executables, but since not all compilers are that smart, you may want to
remove these explicit initializations to 0.


Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]