mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 01:34:11 +03:00
Use virFileFindResource to locate CPU map XML
Replace use of cpuMapOverride with virFileFindResource to locate CPU map from build dir. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
bc2f42a094
commit
dd477238bc
@ -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;
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
@ -48,7 +48,4 @@ cpuMapLoad(const char *arch,
|
||||
cpuMapLoadCallback cb,
|
||||
void *data);
|
||||
|
||||
extern int
|
||||
cpuMapOverride(const char *path);
|
||||
|
||||
#endif /* __VIR_CPU_MAP_H__ */
|
||||
|
@ -744,7 +744,6 @@ cpuEncode;
|
||||
cpuGetModels;
|
||||
cpuGuestData;
|
||||
cpuHasFeature;
|
||||
cpuMapOverride;
|
||||
cpuNodeData;
|
||||
cpuUpdate;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user