提交 72bce49d 编写于 作者: J Jiri Denemark

cpu: Add support for overriding path to CPU map XML file

上级 1b6f13bb
...@@ -32,6 +32,8 @@ ...@@ -32,6 +32,8 @@
#define CPUMAPFILE PKGDATADIR "/cpu_map.xml" #define CPUMAPFILE PKGDATADIR "/cpu_map.xml"
static char *cpumap;
VIR_ENUM_IMPL(cpuMapElement, CPU_MAP_ELEMENT_LAST, VIR_ENUM_IMPL(cpuMapElement, CPU_MAP_ELEMENT_LAST,
"vendor", "vendor",
"feature", "feature",
...@@ -81,6 +83,7 @@ int cpuMapLoad(const char *arch, ...@@ -81,6 +83,7 @@ int cpuMapLoad(const char *arch,
char *xpath = NULL; char *xpath = NULL;
int ret = -1; int ret = -1;
int element; int element;
const char *mapfile = (cpumap ? cpumap : CPUMAPFILE);
if (arch == NULL) { if (arch == NULL) {
virCPUReportError(VIR_ERR_INTERNAL_ERROR, virCPUReportError(VIR_ERR_INTERNAL_ERROR,
...@@ -94,10 +97,10 @@ int cpuMapLoad(const char *arch, ...@@ -94,10 +97,10 @@ int cpuMapLoad(const char *arch,
return -1; return -1;
} }
if ((xml = xmlParseFile(CPUMAPFILE)) == NULL) { if ((xml = xmlParseFile(mapfile)) == NULL) {
virCPUReportError(VIR_ERR_INTERNAL_ERROR, virCPUReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse CPU map file: %s"), _("cannot parse CPU map file: %s"),
CPUMAPFILE); mapfile);
goto cleanup; goto cleanup;
} }
...@@ -139,3 +142,17 @@ no_memory: ...@@ -139,3 +142,17 @@ no_memory:
virReportOOMError(); virReportOOMError();
goto cleanup; goto cleanup;
} }
int
cpuMapOverride(const char *path)
{
char *map;
if (!(map = strdup(path)))
return -1;
VIR_FREE(cpumap);
cpumap = map;
return 0;
}
...@@ -48,4 +48,7 @@ cpuMapLoad(const char *arch, ...@@ -48,4 +48,7 @@ cpuMapLoad(const char *arch,
cpuMapLoadCallback cb, cpuMapLoadCallback cb,
void *data); void *data);
extern int
cpuMapOverride(const char *path);
#endif /* __VIR_CPU_MAP_H__ */ #endif /* __VIR_CPU_MAP_H__ */
...@@ -105,6 +105,7 @@ cpuDecode; ...@@ -105,6 +105,7 @@ cpuDecode;
cpuEncode; cpuEncode;
cpuGuestData; cpuGuestData;
cpuHasFeature; cpuHasFeature;
cpuMapOverride;
cpuNodeData; cpuNodeData;
cpuUpdate; cpuUpdate;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册