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@xxxxxxxx> --- configure.ac | 47 +++++++++++++++++++++++++++++++++-------------- src/libxl/libxl_conf.c | 7 ++----- src/libxl/libxl_conf.h | 8 ++++++++ 3 files changed, 43 insertions(+), 19 deletions(-) diff --git a/configure.ac b/configure.ac index 412a23d..b1193a6 100644 --- a/configure.ac +++ b/configure.ac @@ -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"]) diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 80dd5a8..9b3c949 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -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) { diff --git a/src/libxl/libxl_conf.h b/src/libxl/libxl_conf.h index 5d6f87d..59389d1 100644 --- a/src/libxl/libxl_conf.h +++ b/src/libxl/libxl_conf.h @@ -55,6 +55,14 @@ # 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 -- 1.8.4.5 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list