]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
cpu: Add support for overriding path to CPU map XML file
authorJiri Denemark <jdenemar@redhat.com>
Thu, 16 Sep 2010 14:56:07 +0000 (16:56 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Wed, 1 Dec 2010 13:12:54 +0000 (14:12 +0100)
src/cpu/cpu_map.c
src/cpu/cpu_map.h
src/libvirt_private.syms

index 0c5ff8a421bfd77aaefca858017ea455811258ed..86bc670b5fe200461e6136a614876ab2a54f6b64 100644 (file)
@@ -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;
+}
index e26c7c18479999e2d905f20818a10a02eef198a0..acf4cc4e037d70d39782346429829d08dff88845 100644 (file)
@@ -48,4 +48,7 @@ cpuMapLoad(const char *arch,
            cpuMapLoadCallback cb,
            void *data);
 
+extern int
+cpuMapOverride(const char *path);
+
 #endif /* __VIR_CPU_MAP_H__ */
index ef33f862680aa441b1d2e62dde2650eb28564593..310d8f415e629b49e47d3cd7cc248dafb26cbe5b 100644 (file)
@@ -105,6 +105,7 @@ cpuDecode;
 cpuEncode;
 cpuGuestData;
 cpuHasFeature;
+cpuMapOverride;
 cpuNodeData;
 cpuUpdate;