[libvirt] [PATCH 11/14] Do lazy init of host PM features
Eric Blake
eblake at redhat.com
Tue Nov 29 16:48:31 UTC 2011
On 11/29/2011 08:44 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange at 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.
ACK.
--
Eric Blake eblake at redhat.com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20111129/96174fb1/attachment-0001.sig>
More information about the libvir-list
mailing list