]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
libxl: use xenlight pkgconfig file if present
authorJim Fehlig <jfehlig@suse.com>
Tue, 17 Mar 2015 20:10:28 +0000 (14:10 -0600)
committerJim Fehlig <jfehlig@suse.com>
Thu, 19 Mar 2015 22:13:26 +0000 (16:13 -0600)
xen.git commit babeca32 added a pkgconfig file for libxenlight,
allowing libxl apps to determine the location of Xen binaries
such as firmware blobs, device emulator, etc.

This patch adds support for xenlight.pc in the libxl driver, falling
back to the previous configure logic if not found.  It introduces
LIBXL_FIRMWARE_DIR and LIBXL_EXECBIN_DIR to define the firmware and
libexec_bin locations.  If xenlight.pc does not exist, the defines
are set to the current hardcoded paths.  The capabilities'
<emulator> and <loader> elements are updated to use the paths.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
configure.ac
src/libxl/libxl_conf.c
src/libxl/libxl_conf.h

index 412a23d05ff5c8d9af8beab91d9717f54c6d22e3..b1193a67f3fb90fca4a801ca8603169a00f4bc37 100644 (file)
@@ -873,24 +873,37 @@ old_LIBS="$LIBS"
 old_CFLAGS="$CFLAGS"
 LIBXL_LIBS=""
 LIBXL_CFLAGS=""
+LIBXL_FIRMWARE_DIR=""
+LIBXL_EXECBIN_DIR=""
+
 dnl search for libxl, aka libxenlight
+dnl Xen > 4.5 introduced a pkgconfig file, check for it first
 fail=0
 if test "$with_libxl" != "no" ; then
-    if test "$with_libxl" != "yes" && test "$with_libxl" != "check" ; then
-        LIBXL_CFLAGS="-I$with_libxl/include"
-        LIBXL_LIBS="-L$with_libxl"
-    fi
-    CFLAGS="$CFLAGS $LIBXL_CFLAGS"
-    LIBS="$LIBS $LIBXL_LIBS"
-    AC_CHECK_LIB([xenlight], [libxl_ctx_alloc], [
-        with_libxl=yes
-        LIBXL_LIBS="$LIBXL_LIBS -lxenlight -lxenctrl"
-    ],[
-        if test "$with_libxl" = "yes"; then
-            fail=1
+    PKG_CHECK_MODULES([LIBXL], [xenlight], [
+     LIBXL_FIRMWARE_DIR=`$PKG_CONFIG --variable xenfirmwaredir xenlight`
+     LIBXL_EXECBIN_DIR=`$PKG_CONFIG --variable libexec_bin xenlight`
+     LIBXL_LIBS="$LIBXL_LIBS -lxenctrl"
+     with_libxl=yes
+    ], [LIBXL_FOUND=no])
+    if test "$LIBXL_FOUND" = "no"; then
+        dnl No xenlight pkg-config file
+        if test "$with_libxl" != "yes" && test "$with_libxl" != "check" ; then
+            LIBXL_CFLAGS="-I$with_libxl/include"
+            LIBXL_LIBS="-L$with_libxl"
         fi
-        with_libxl=no
-    ])
+        CFLAGS="$CFLAGS $LIBXL_CFLAGS"
+        LIBS="$LIBS $LIBXL_LIBS"
+        AC_CHECK_LIB([xenlight], [libxl_ctx_alloc], [
+            with_libxl=yes
+            LIBXL_LIBS="$LIBXL_LIBS -lxenlight -lxenctrl"
+        ],[
+            if test "$with_libxl" = "yes"; then
+                fail=1
+            fi
+            with_libxl=no
+        ])
+    fi
 fi
 
 LIBS="$old_LIBS"
@@ -905,6 +918,12 @@ if test "$with_libxl" = "yes"; then
     AC_CHECK_HEADERS([libxlutil.h])
     LIBXL_LIBS="$LIBXL_LIBS -lxlutil"
     AC_DEFINE_UNQUOTED([WITH_LIBXL], 1, [whether libxenlight driver is enabled])
+    if test "x$LIBXL_FIRMWARE_DIR" != "x"; then
+        AC_DEFINE_UNQUOTED([LIBXL_FIRMWARE_DIR], ["$LIBXL_FIRMWARE_DIR"], [directory containing Xen firmware blobs])
+    fi
+    if test "x$LIBXL_EXECBIN_DIR" != "x"; then
+        AC_DEFINE_UNQUOTED([LIBXL_EXECBIN_DIR], ["$LIBXL_EXECBIN_DIR"], [directory containing Xen libexec binaries])
+    fi
 fi
 AM_CONDITIONAL([WITH_LIBXL], [test "$with_libxl" = "yes"])
 
index 80dd5a884f9aec6e6b784d975ef5abf5915bb72d..9b3c949f4ce29b84fda27c63c3699808d8c7b8c1 100644 (file)
@@ -305,7 +305,6 @@ libxlCapsInitGuests(libxl_ctx *ctx, virCapsPtr caps)
     regmatch_t subs[4];
     char *saveptr = NULL;
     size_t i;
-    virArch hostarch = caps->host.arch;
 
     struct guest_arch guest_archs[32];
     int nr_guest_archs = 0;
@@ -428,11 +427,9 @@ libxlCapsInitGuests(libxl_ctx *ctx, virCapsPtr caps)
         if ((guest = virCapabilitiesAddGuest(caps,
                                              guest_archs[i].hvm ? "hvm" : "xen",
                                              guest_archs[i].arch,
-                                             ((hostarch == VIR_ARCH_X86_64) ?
-                                              "/usr/lib64/xen/bin/qemu-dm" :
-                                              "/usr/lib/xen/bin/qemu-dm"),
+                                             LIBXL_EXECBIN_DIR "/qemu-system-i386",
                                              (guest_archs[i].hvm ?
-                                              "/usr/lib/xen/boot/hvmloader" :
+                                              LIBXL_FIRMWARE_DIR "/hvmloader" :
                                               NULL),
                                              1,
                                              machines)) == NULL) {
index 5d6f87d461f4f71165836f3a112fad77bb6d1980..59389d1296f8af604647741af679946b540652c3 100644 (file)
 # define LIBXL_DUMP_DIR LIBXL_LIB_DIR "/dump"
 # define LIBXL_BOOTLOADER_PATH "pygrub"
 
+# ifndef LIBXL_FIRMWARE_DIR
+#  define LIBXL_FIRMWARE_DIR "/usr/lib/xen/boot"
+# endif
+# ifndef LIBXL_EXECBIN_DIR
+#  define LIBXL_EXECBIN_DIR "/usr/lib/xen/bin"
+# endif
+
+
 /* libxl interface for setting VCPU affinity changed in 4.5. In fact, a new
  * parameter has been added, representative of 'VCPU soft affinity'. If one
  * does not care about it (and that's libvirt case), passing NULL is the