]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Load CPU map from builddir when run uninstalled
authorJiri Denemark <jdenemar@redhat.com>
Mon, 10 Mar 2014 15:00:49 +0000 (16:00 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Wed, 12 Mar 2014 15:31:57 +0000 (16:31 +0100)
When libvirtd is run from a build directory without being installed, it
should not depend on files from a libvirt package installed in the
system. Not only because there may not be any libvirt installed at all.
We already do a good job for plugins but cpu_map.xml was still loaded
from the system.

The Makefile.am change is necessary to make this all work from VPATH
builds since libvirtd has no idea where to find libvirt sources. It only
knows the path from which it was started, i.e, a builddir.

https://bugzilla.redhat.com/show_bug.cgi?id=1074327
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
daemon/libvirtd.c
src/Makefile.am
src/cpu/cpu_map.c

index 36adaf09c755157d5e9784b79b8a84e488c294a3..a471b3b01f19a4247660a004afa35fbcbb5c4d0f 100644 (file)
 #include "configmake.h"
 
 #include "virdbus.h"
+#include "cpu/cpu_map.h"
 
 #if WITH_SASL
 virNetSASLContextPtr saslCtxt = NULL;
@@ -1157,13 +1158,16 @@ int main(int argc, char **argv) {
     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';
         char *driverdir;
-        if (virAsprintfQuiet(&driverdir, "%s/../../src/.libs", argv[0]) < 0) {
+        if (virAsprintfQuiet(&driverdir, "%s/../../src/.libs", argv[0]) < 0 ||
+            virAsprintfQuiet(&cpumap, "%s/../../src/cpu/cpu_map.xml",
+                             argv[0]) < 0) {
             fprintf(stderr, _("%s: initialization failed\n"), argv[0]);
             exit(EXIT_FAILURE);
         }
@@ -1176,6 +1180,7 @@ int main(int argc, char **argv) {
 #ifdef WITH_DRIVER_MODULES
         virDriverModuleInitialize(driverdir);
 #endif
+        cpuMapOverride(cpumap);
         *tmp = '/';
         /* Must not free 'driverdir' - it is still used */
     }
index 25b33a7f03400f16574148a752d8b5e13262f7de..d4d7b2b2a7293b5e8a50b5331e7ac752f82e65a1 100644 (file)
@@ -976,6 +976,10 @@ libvirt_la_BUILT_LIBADD += libvirt_cpu.la
 libvirt_cpu_la_CFLAGS = \
                -I$(top_srcdir)/src/conf $(AM_CFLAGS)
 libvirt_cpu_la_SOURCES = $(CPU_SOURCES)
+libvirt_cpu_la_DEPENDENCIES = $(abs_builddir)/cpu/cpu_map.xml
+
+$(abs_builddir)/cpu/cpu_map.xml:
+       $(AM_V_GEN)ln -s $(abs_srcdir)/cpu/cpu_map.xml $@
 
 if WITH_VMX
 noinst_LTLIBRARIES += libvirt_vmx.la
index 7c2bdec01e198e6067584ffbc250ada64e587405..f6c63d49c2c670b82741a11afd941c43df2e8a21 100644 (file)
@@ -28,6 +28,7 @@
 #include "cpu_map.h"
 #include "configmake.h"
 #include "virstring.h"
+#include "virlog.h"
 
 #define VIR_FROM_THIS VIR_FROM_CPU
 
@@ -86,6 +87,8 @@ int cpuMapLoad(const char *arch,
     int element;
     const char *mapfile = (cpumap ? cpumap : CPUMAPFILE);
 
+    VIR_DEBUG("Loading CPU map from %s", mapfile);
+
     if (arch == NULL) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        "%s", _("undefined hardware architecture"));