From 72bce49dcca92acf08a6ed65e30fdbc5cce5f094 Mon Sep 17 00:00:00 2001 From: Jiri Denemark Date: Thu, 16 Sep 2010 16:56:07 +0200 Subject: [PATCH] cpu: Add support for overriding path to CPU map XML file --- src/cpu/cpu_map.c | 21 +++++++++++++++++++-- src/cpu/cpu_map.h | 3 +++ src/libvirt_private.syms | 1 + 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/cpu/cpu_map.c b/src/cpu/cpu_map.c index 0c5ff8a421..86bc670b5f 100644 --- a/src/cpu/cpu_map.c +++ b/src/cpu/cpu_map.c @@ -32,6 +32,8 @@ #define CPUMAPFILE PKGDATADIR "/cpu_map.xml" +static char *cpumap; + VIR_ENUM_IMPL(cpuMapElement, CPU_MAP_ELEMENT_LAST, "vendor", "feature", @@ -81,6 +83,7 @@ int cpuMapLoad(const char *arch, char *xpath = NULL; int ret = -1; int element; + const char *mapfile = (cpumap ? cpumap : CPUMAPFILE); if (arch == NULL) { virCPUReportError(VIR_ERR_INTERNAL_ERROR, @@ -94,10 +97,10 @@ int cpuMapLoad(const char *arch, return -1; } - if ((xml = xmlParseFile(CPUMAPFILE)) == NULL) { + if ((xml = xmlParseFile(mapfile)) == NULL) { virCPUReportError(VIR_ERR_INTERNAL_ERROR, _("cannot parse CPU map file: %s"), - CPUMAPFILE); + mapfile); goto cleanup; } @@ -139,3 +142,17 @@ no_memory: virReportOOMError(); goto cleanup; } + + +int +cpuMapOverride(const char *path) +{ + char *map; + + if (!(map = strdup(path))) + return -1; + + VIR_FREE(cpumap); + cpumap = map; + return 0; +} diff --git a/src/cpu/cpu_map.h b/src/cpu/cpu_map.h index e26c7c1847..acf4cc4e03 100644 --- a/src/cpu/cpu_map.h +++ b/src/cpu/cpu_map.h @@ -48,4 +48,7 @@ cpuMapLoad(const char *arch, cpuMapLoadCallback cb, void *data); +extern int +cpuMapOverride(const char *path); + #endif /* __VIR_CPU_MAP_H__ */ diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index ef33f86268..310d8f415e 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -105,6 +105,7 @@ cpuDecode; cpuEncode; cpuGuestData; cpuHasFeature; +cpuMapOverride; cpuNodeData; cpuUpdate; -- GitLab