static int test_virCapabilities(const void *opaque) { struct virCapabilitiesData *data = (struct virCapabilitiesData *) opaque; const char *archStr = virArchToString(data->arch); virCapsPtr caps = NULL; char *capsXML = NULL; char *path = NULL; char *dir = NULL; char *resctrl = NULL; int ret = -1; /* * We want to keep our directory structure clean, so if there's both resctrl * and system used, we need to use slightly different path; a subdir. */ if (virAsprintf(&dir, "%s/vircaps2xmldata/linux-%s%s", abs_srcdir, data->filename, data->resctrl ? "/system" : "") < 0) goto cleanup; if (virAsprintf(&resctrl, "%s/vircaps2xmldata/linux-%s/resctrl", abs_srcdir, data->filename) < 0) goto cleanup; virFileWrapperAddPrefix("/sys/devices/system", dir); virFileWrapperAddPrefix("/sys/fs/resctrl", resctrl); caps = virCapabilitiesNew(data->arch, data->offlineMigrate, data->liveMigrate); if (!caps) goto cleanup; if (virCapabilitiesInitNUMA(caps) < 0 || virCapabilitiesInitCaches(caps) < 0) goto cleanup; virFileWrapperClearPrefixes(); if (!(capsXML = virCapabilitiesFormatXML(caps))) goto cleanup; if (virAsprintf(&path, "%s/vircaps2xmldata/vircaps-%s-%s.xml", abs_srcdir, archStr, data->filename) < 0) goto cleanup; if (virTestCompareToFile(capsXML, path) < 0) goto cleanup; ret = 0; cleanup: VIR_FREE(dir); VIR_FREE(resctrl); VIR_FREE(path); VIR_FREE(capsXML); virObjectUnref(caps); return ret; }
virCapsPtr umlCapsInit(void) { virCapsPtr caps; virCapsGuestPtr guest; if ((caps = virCapabilitiesNew(virArchFromHost(), false, false)) == NULL) goto error; /* Some machines have problematic NUMA toplogy causing * unexpected failures. We don't want to break the QEMU * driver in this scenario, so log errors & carry on */ if (virCapabilitiesInitNUMA(caps) < 0) { virCapabilitiesFreeNUMAInfo(caps); VIR_WARN("Failed to query host NUMA topology, disabling NUMA capabilities"); } if (virCapabilitiesInitCaches(caps) < 0) VIR_WARN("Failed to get host CPU cache info"); if (virNodeSuspendGetTargetMask(&caps->host.powerMgmt) < 0) VIR_WARN("Failed to get host power management capabilities"); if (virGetHostUUID(caps->host.host_uuid)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("cannot get the host uuid")); goto error; } if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_UML, caps->host.arch, NULL, NULL, 0, NULL)) == NULL) goto error; if (virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_UML, NULL, NULL, 0, NULL) == NULL) goto error; return caps; error: virObjectUnref(caps); return NULL; }
virCapsPtr lxctoolsCapabilitiesInit(void) { virCapsPtr caps; virCapsGuestPtr guest; if ((caps = virCapabilitiesNew(virArchFromHost(), true, true)) == NULL) goto no_memory; if (virCapabilitiesInitNUMA(caps) < 0) goto no_memory; if (virCapabilitiesAddHostMigrateTransport(caps, "tcp") < 0) goto no_memory; if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_EXE, caps->host.arch, NULL, NULL, 0, NULL)) == NULL) goto no_memory; if (virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_LXCTOOLS, NULL, NULL, 0, NULL) == NULL) goto no_memory; return caps; no_memory: virObjectUnref(caps); return NULL; }