Re: [libvirt] [PATCH] Wipe nodeinfo structure before filling it

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

 



On 03/09/2010 08:54 AM, Jiri Denemark wrote:
> The nodeinfo structure wasn't initialized in qemu driver and with the
> recent change in CPU topology parsing, old value of nodeinfo->sockets
> could be used and incremented giving totally bogus results.
> 
> Let's just wipe the structure completely.
> 
> Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
> ---
>  src/nodeinfo.c |    9 ++++-----
>  1 files changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/src/nodeinfo.c b/src/nodeinfo.c
> index 2dab5b2..1ee3709 100644
> --- a/src/nodeinfo.c
> +++ b/src/nodeinfo.c
> @@ -251,18 +251,17 @@ int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo,
>  
>  int nodeGetInfo(virConnectPtr conn,
>                  virNodeInfoPtr nodeinfo) {
> +    memset(nodeinfo, 0, sizeof(*nodeinfo));
> +
>  #ifdef HAVE_UNAME
> +    {
>      struct utsname info;
>  
>      uname(&info);
>  
>      if (virStrcpyStatic(nodeinfo->model, info.machine) == NULL)
>          return -1;
> -
> -#else /* !HAVE_UNAME */
> -
> -    nodeinfo->model[0] = '\0';
> -
> +    }
>  #endif /* !HAVE_UNAME */
>  
>  #ifdef __linux__

Yeah, this makes sense.

ACK

-- 
Chris Lalancette

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]