]> xenbits.xensource.com Git - libvirt.git/commitdiff
Parallels: Include CPU info in the capabilities XML
authorAlexander Burluka <aburluka@parallels.com>
Thu, 5 Jun 2014 05:50:06 +0000 (09:50 +0400)
committerEric Blake <eblake@redhat.com>
Fri, 6 Jun 2014 12:30:09 +0000 (06:30 -0600)
Openstack uses (or will start to using) CPU info from the
capabilities XML. So this section is expanded, added CPU info
about arch, type and info about number of cores, sockets and threads.

Signed-off-by: Eric Blake <eblake@redhat.com>
src/parallels/parallels_driver.c

index 96d2e45660d37d1f7df029e51e4abb71f33258a8..87e540e2ed51b1313997562c7817d3f672466bde 100644 (file)
@@ -118,8 +118,11 @@ parallelsDomObjFreePrivate(void *p)
 static virCapsPtr
 parallelsBuildCapabilities(void)
 {
-    virCapsPtr caps;
+    virCapsPtr caps = NULL;
+    virCPUDefPtr cpu = NULL;
+    virCPUDataPtr data = NULL;
     virCapsGuestPtr guest;
+    virNodeInfo nodeinfo;
 
     if ((caps = virCapabilitiesNew(virArchFromHost(),
                                    0, 0)) == NULL)
@@ -148,11 +151,32 @@ parallelsBuildCapabilities(void)
                                       "parallels", NULL, NULL, 0, NULL) == NULL)
         goto error;
 
+    if (VIR_ALLOC(cpu) < 0)
+        goto error;
+
+    if (nodeGetInfo(&nodeinfo))
+        goto error;
+
+    cpu->arch = caps->host.arch;
+    cpu->type = VIR_CPU_TYPE_HOST;
+    cpu->sockets = nodeinfo.sockets;
+    cpu->cores = nodeinfo.cores;
+    cpu->threads = nodeinfo.threads;
+
+    caps->host.cpu = cpu;
+
+    if (!(data = cpuNodeData(cpu->arch))
+        || cpuDecode(cpu, data, NULL, 0, NULL) < 0) {
+        goto cleanup;
+    }
+
+ cleanup:
+    cpuDataFree(data);
     return caps;
 
  error:
     virObjectUnref(caps);
-    return NULL;
+    goto cleanup;
 }
 
 static char *