]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Wipe nodeinfo structure before filling it
authorJiri Denemark <jdenemar@redhat.com>
Tue, 9 Mar 2010 13:54:01 +0000 (14:54 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Tue, 9 Mar 2010 16:31:15 +0000 (17:31 +0100)
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@redhat.com>
src/nodeinfo.c

index 2dab5b29c87dbc680916e3cd0cf736d5197f5ef5..1ee37096a8c05358bc1301cdcacbfcf8352dbcda 100644 (file)
@@ -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__