From: Alexander Burluka Date: Thu, 5 Jun 2014 05:50:06 +0000 (+0400) Subject: Parallels: Include CPU info in the capabilities XML X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=4d06af97d38c3648937eb8f732704379b3cd9e59;p=libvirt.git Parallels: Include CPU info in the capabilities XML 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 --- diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c index 96d2e45660..87e540e2ed 100644 --- a/src/parallels/parallels_driver.c +++ b/src/parallels/parallels_driver.c @@ -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 *