diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c index e549783d40773b8c7607a0e16309dd33bec47846..4c926b384b5fbb8e6d7835fbac2327703d8ed52f 100644 --- a/daemon/libvirtd.c +++ b/daemon/libvirtd.c @@ -1158,25 +1158,6 @@ int main(int argc, char **argv) { virFileActivateDirOverride(argv[0]); - if (strstr(argv[0], "lt-libvirtd") || - strstr(argv[0], "/daemon/.libs/libvirtd")) { - char *tmp = strrchr(argv[0], '/'); - char *cpumap; - if (!tmp) { - fprintf(stderr, _("%s: cannot identify driver directory\n"), argv[0]); - exit(EXIT_FAILURE); - } - *tmp = '\0'; - if (virAsprintfQuiet(&cpumap, "%s/../../src/cpu/cpu_map.xml", - argv[0]) < 0) { - fprintf(stderr, _("%s: initialization failed\n"), argv[0]); - exit(EXIT_FAILURE); - } - cpuMapOverride(cpumap); - VIR_FREE(cpumap); - *tmp = '/'; - } - while (1) { int optidx = 0; int c; diff --git a/src/cpu/cpu_map.c b/src/cpu/cpu_map.c index fca306e2b0c21e2415eecfdbc776a01e14fd3fc8..68d287a98c522e50f52abb3d7313e12b2f179592 100644 --- a/src/cpu/cpu_map.c +++ b/src/cpu/cpu_map.c @@ -24,6 +24,7 @@ #include #include "viralloc.h" +#include "virfile.h" #include "cpu.h" #include "cpu_map.h" #include "configmake.h" @@ -34,10 +35,6 @@ VIR_LOG_INIT("cpu.cpu_map"); -#define CPUMAPFILE PKGDATADIR "/cpu_map.xml" - -static char *cpumap; - VIR_ENUM_IMPL(cpuMapElement, CPU_MAP_ELEMENT_LAST, "vendor", "feature", @@ -87,20 +84,25 @@ int cpuMapLoad(const char *arch, char *xpath = NULL; int ret = -1; int element; - const char *mapfile = (cpumap ? cpumap : CPUMAPFILE); + char *mapfile; + + if (!(mapfile = virFileFindResource("cpu_map.xml", + "src/cpu", + PKGDATADIR))) + return -1; VIR_DEBUG("Loading CPU map from %s", mapfile); if (arch == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("undefined hardware architecture")); - return -1; + goto cleanup; } if (cb == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no callback provided")); - return -1; + goto cleanup; } if ((xml = xmlParseFile(mapfile)) == NULL) { @@ -141,6 +143,7 @@ int cpuMapLoad(const char *arch, xmlXPathFreeContext(ctxt); xmlFreeDoc(xml); VIR_FREE(xpath); + VIR_FREE(mapfile); return ret; @@ -148,17 +151,3 @@ int cpuMapLoad(const char *arch, virReportOOMError(); goto cleanup; } - - -int -cpuMapOverride(const char *path) -{ - char *map; - - if (VIR_STRDUP(map, path) < 0) - return -1; - - VIR_FREE(cpumap); - cpumap = map; - return 0; -} diff --git a/src/cpu/cpu_map.h b/src/cpu/cpu_map.h index 8d27bcd372d666843fee18d430e003d3bb6fcc5d..23ce888f309772c76580ce081bb6a70cacf3502f 100644 --- a/src/cpu/cpu_map.h +++ b/src/cpu/cpu_map.h @@ -48,7 +48,4 @@ 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 c8a2682d8ccbd75a75e1352ac238c43128c38c4b..6c482342522db3bab277c3daf97c7a74bcf9f870 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -744,7 +744,6 @@ cpuEncode; cpuGetModels; cpuGuestData; cpuHasFeature; -cpuMapOverride; cpuNodeData; cpuUpdate; diff --git a/tests/cputest.c b/tests/cputest.c index 8903f8276603e1830e4385f5b73f9dad2eecd7ae..3766c2f2df43d9b554bf28ace241cd2c623e2f2f 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -40,8 +40,6 @@ #include "cpu/cpu_map.h" #include "virstring.h" -static const char *abs_top_srcdir; - #define VIR_FROM_THIS VIR_FROM_CPU enum cpuTestBoolWithError { @@ -504,17 +502,6 @@ static int mymain(void) { int ret = 0; - char *map = NULL; - - abs_top_srcdir = getenv("abs_top_srcdir"); - if (!abs_top_srcdir) - abs_top_srcdir = abs_srcdir "/.."; - - if (virAsprintf(&map, "%s/src/cpu/cpu_map.xml", abs_top_srcdir) < 0 || - cpuMapOverride(map) < 0) { - VIR_FREE(map); - return EXIT_FAILURE; - } #define DO_TEST(arch, api, name, host, cpu, \ models, nmodels, preferred, flags, result) \ @@ -657,7 +644,6 @@ mymain(void) DO_TEST_GUESTDATA("ppc64", "host", "guest", ppc_models, NULL, 0); DO_TEST_GUESTDATA("ppc64", "host", "guest-nofallback", ppc_models, "POWER7_v2.1", -1); - VIR_FREE(map); return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index d43a4de266850af37d3cf7f22b7852b0cd4262a5..a1ef2b8002b0cda30738d90fe08227ebb0b1bffe 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -483,7 +483,6 @@ static int mymain(void) { int ret = 0; - char *map = NULL; bool skipLegacyCPUs = false; abs_top_srcdir = getenv("abs_top_srcdir"); @@ -530,11 +529,6 @@ mymain(void) driver.config->spiceTLS = 1; if (VIR_STRDUP_QUIET(driver.config->spicePassword, "123456") < 0) return EXIT_FAILURE; - if (virAsprintf(&map, "%s/src/cpu/cpu_map.xml", abs_top_srcdir) < 0 || - cpuMapOverride(map) < 0) { - VIR_FREE(map); - return EXIT_FAILURE; - } # define DO_TEST_FULL(name, migrateFrom, migrateFd, flags, ...) \ do { \ @@ -1364,7 +1358,6 @@ mymain(void) virObjectUnref(driver.config); virObjectUnref(driver.caps); virObjectUnref(driver.xmlopt); - VIR_FREE(map); return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/tests/qemuxmlnstest.c b/tests/qemuxmlnstest.c index 30bb7235152d8892e9a9f9c4a128910cb33b4a3b..e8f70d6a7f10e0095d3c416dfd6f1b421b08ebb0 100644 --- a/tests/qemuxmlnstest.c +++ b/tests/qemuxmlnstest.c @@ -205,7 +205,6 @@ static int mymain(void) { int ret = 0; - char *map = NULL; bool json = false; abs_top_srcdir = getenv("abs_top_srcdir"); @@ -217,11 +216,6 @@ mymain(void) return EXIT_FAILURE; if (!(driver.xmlopt = virQEMUDriverCreateXMLConf(&driver))) return EXIT_FAILURE; - if (virAsprintf(&map, "%s/src/cpu/cpu_map.xml", abs_top_srcdir) < 0 || - cpuMapOverride(map) < 0) { - VIR_FREE(map); - return EXIT_FAILURE; - } # define DO_TEST_FULL(name, migrateFrom, migrateFd, expectError, ...) \ do { \ @@ -266,7 +260,6 @@ mymain(void) virObjectUnref(driver.config); virObjectUnref(driver.caps); virObjectUnref(driver.xmlopt); - VIR_FREE(map); return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; }