The following patch adds 3 configure options to turn on or off the support for Xen, QEMU/KVM and the test driver, as the output of configure --help shows: ... --with-xen add XEN support (on) --with-qemu add QEMU/KVM support (on) --with-test add test driver support (on) ... It uses compile time flags, is not really intrusive, it just pointed out a few strangeness, one of which was fixed (a Xen include) and the remaining ones are: - xml.c doesn't depend on Xen except for virDomainXMLDevID calling xenStoreDomainGetNetworkID() - libvirt.c still calls xenDaemonDomainLookupByName_ids from virDomainGetUUID() , I'm not sure if this can be avoided In the tests directory, sexpr2xmltest.c and xmconfigtest.c still depends on code in xen specific modules, trying to add them without xen being present was more complex than the value it may add (it also makes the patch smaller to cut at the module level). Plan to commit this before the release, unless this raises a problem, Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard@xxxxxxxxxx | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
Index: configure.in =================================================================== RCS file: /data/cvs/libxen/configure.in,v retrieving revision 1.64 diff -u -p -r1.64 configure.in --- configure.in 5 Mar 2007 11:10:06 -0000 1.64 +++ configure.in 14 Mar 2007 15:21:35 -0000 @@ -63,6 +63,14 @@ AC_ARG_WITH(html-subdir, AC_HELP_STRING( [HTML_DIR="$HTML_DIR/\$(PACKAGE)-\$(VERSION)/html"]) AC_SUBST(HTML_DIR) +dnl Allow to build without Xen, QEMU/KVM or test driver +AC_ARG_WITH(xen, +[ --with-xen add XEN support (on)]) +AC_ARG_WITH(qemu, +[ --with-qemu add QEMU/KVM support (on)]) +AC_ARG_WITH(test, +[ --with-test add test driver support (on)]) + dnl dnl specific tests to setup DV devel environments with debug etc ... dnl @@ -156,11 +164,35 @@ dnl AC_ARG_WITH(depends, [ --with-depends check for dependancies (on)]) +LIBVIRT_FEATURES= +WITH_XEN=0 + +if test "$with_qemu" = "no" ; then + echo "Disabling QEMU/KVM support" +else + LIBVIRT_FEATURES="$LIBVIRT_FEATURES -DWITH_QEMU" +fi + +if test "$with_test" = "no" ; then + echo "Disabling test driver support" +else + LIBVIRT_FEATURES="$LIBVIRT_FEATURES -DWITH_TEST" +fi + if test "$with_depends" != "no" then -dnl search for the Xen store library -AC_SEARCH_LIBS(xs_read, [xenstore], [], [AC_MSG_ERROR([Xen store library not found])]) +if test "$with_xen" = "no" ; then + echo Disabling XEN support +else + dnl search for the Xen store library + AC_SEARCH_LIBS(xs_read, [xenstore], + [WITH_XEN=1], + [AC_MSG_RESULT([Xen store library not found])]) + if test "$WITH_XEN" != "0" ; then + LIBVIRT_FEATURES="$LIBVIRT_FEATURES -DWITH_XEN" + fi +fi dnl dnl check for libsyfs (>= 2.0.0); allow disabling bridge parameters support altogether @@ -245,6 +277,9 @@ AC_SUBST(VIRSH_LIBS) # end of if with_depends fi +AC_SUBST(WITH_XEN) +AC_SUBST(LIBVIRT_FEATURES) + dnl dnl check for python dnl Index: proxy/Makefile.am =================================================================== RCS file: /data/cvs/libxen/proxy/Makefile.am,v retrieving revision 1.8 diff -u -p -r1.8 Makefile.am --- proxy/Makefile.am 1 Mar 2007 16:18:55 -0000 1.8 +++ proxy/Makefile.am 14 Mar 2007 15:21:36 -0000 @@ -3,7 +3,7 @@ INCLUDES = -I$(top_builddir)/include -I@top_srcdir@/include \ -I@top_srcdir@/proxy -I@top_srcdir@/src @LIBXML_CFLAGS@ \ -DPROXY -DLOCALEBASEDIR=\""$(datadir)/locale"\" \ - -DGETTEXT_PACKAGE=\"$(PACKAGE)\" $(WARN_CFLAGS) + -DGETTEXT_PACKAGE=\"$(PACKAGE)\" $(WARN_CFLAGS) $(LIBVIRT_FEATURES) libexec_PROGRAMS = libvirt_proxy Index: proxy/libvirt_proxy.c =================================================================== RCS file: /data/cvs/libxen/proxy/libvirt_proxy.c,v retrieving revision 1.13 diff -u -p -r1.13 libvirt_proxy.c --- proxy/libvirt_proxy.c 1 Mar 2007 16:01:39 -0000 1.13 +++ proxy/libvirt_proxy.c 14 Mar 2007 15:21:36 -0000 @@ -19,6 +19,8 @@ #include <sys/un.h> #include <locale.h> #include "internal.h" + +#ifdef WITH_XEN #include "proxy_internal.h" #include "xen_internal.h" #include "xend_internal.h" @@ -786,3 +788,9 @@ int main(int argc, char **argv) { proxyCloseUnixSocket(); exit(0); } +#else /* WITHOUT_XEN */ +int main(void) { + fprintf(stderr, "libvirt was compiled without Xen support\n"); + exit(1); +} +#endif /* WITH_XEN */ Index: src/Makefile.am =================================================================== RCS file: /data/cvs/libxen/src/Makefile.am,v retrieving revision 1.35 diff -u -p -r1.35 Makefile.am --- src/Makefile.am 1 Mar 2007 16:18:55 -0000 1.35 +++ src/Makefile.am 14 Mar 2007 15:21:36 -0000 @@ -3,7 +3,7 @@ INCLUDES = -I$(top_builddir)/include -I@top_srcdir@/include @LIBXML_CFLAGS@ -I@top_srcdir@/qemud \ -DBINDIR=\""$(libexecdir)"\" -DSBINDIR=\""$(sbindir)"\" -DLOCALEBASEDIR=\""$(datadir)/locale"\" \ -DLOCAL_STATE_DIR=\""$(localstatedir)"\" \ - -DGETTEXT_PACKAGE=\"$(PACKAGE)\" $(WARN_CFLAGS) + -DGETTEXT_PACKAGE=\"$(PACKAGE)\" $(WARN_CFLAGS) $(LIBVIRT_FEATURES) DEPS = libvirt.la LDADDS = @STATIC_BINARIES@ libvirt.la VIRSH_LIBS = @VIRSH_LIBS@ Index: src/libvirt.c =================================================================== RCS file: /data/cvs/libxen/src/libvirt.c,v retrieving revision 1.61 diff -u -p -r1.61 libvirt.c --- src/libvirt.c 8 Mar 2007 14:53:41 -0000 1.61 +++ src/libvirt.c 14 Mar 2007 15:21:36 -0000 @@ -21,14 +21,16 @@ #include <libxml/parser.h> #include <libxml/xpath.h> -#include <xs.h> - #include "internal.h" #include "driver.h" + +#ifdef WITH_XEN +#include <xs.h> #include "xen_internal.h" #include "xend_internal.h" #include "xs_internal.h" #include "xm_internal.h" +#endif #include "proxy_internal.h" #include "xml.h" #include "test.h" @@ -69,13 +71,19 @@ virInitialize(void) /* * Note that the order is important the first ones have a higher priority */ +#ifdef WITH_XEN xenHypervisorRegister(); xenProxyRegister(); xenDaemonRegister(); xenStoreRegister(); xenXMRegister(); +#endif +#ifdef WITH_TEST testRegister(); +#endif +#ifdef WITH_QEMU qemuRegister(); +#endif return(0); } @@ -1335,6 +1343,7 @@ virDomainGetUUID(virDomainPtr domain, un if (domain->id == 0) { memset(uuid, 0, VIR_UUID_BUFLEN); } else { +#ifdef WITH_XEN if ((domain->uuid[0] == 0) && (domain->uuid[1] == 0) && (domain->uuid[2] == 0) && (domain->uuid[3] == 0) && (domain->uuid[4] == 0) && (domain->uuid[5] == 0) && @@ -1345,6 +1354,7 @@ virDomainGetUUID(virDomainPtr domain, un (domain->uuid[14] == 0) && (domain->uuid[15] == 0)) xenDaemonDomainLookupByName_ids(domain->conn, domain->name, &domain->uuid[0]); +#endif memcpy(uuid, &domain->uuid[0], VIR_UUID_BUFLEN); } return (0); Index: src/qemu_internal.c =================================================================== RCS file: /data/cvs/libxen/src/qemu_internal.c,v retrieving revision 1.16 diff -u -p -r1.16 qemu_internal.c --- src/qemu_internal.c 8 Mar 2007 15:16:01 -0000 1.16 +++ src/qemu_internal.c 14 Mar 2007 15:21:36 -0000 @@ -21,6 +21,7 @@ * Author: Daniel P. Berrange <berrange@xxxxxxxxxx> */ +#ifdef WITH_QEMU #include <stdio.h> #include <string.h> #include <sys/time.h> @@ -1230,6 +1231,7 @@ void qemuRegister(void) { virRegisterDriver(&qemuDriver); virRegisterNetworkDriver(&qemuNetworkDriver); } +#endif /* WITH_QEMU */ /* * Local variables: Index: src/test.c =================================================================== RCS file: /data/cvs/libxen/src/test.c,v retrieving revision 1.22 diff -u -p -r1.22 test.c --- src/test.c 8 Mar 2007 08:31:07 -0000 1.22 +++ src/test.c 14 Mar 2007 15:21:36 -0000 @@ -21,6 +21,7 @@ * Daniel Berrange <berrange@xxxxxxxxxx> */ +#ifdef WITH_TEST #include <stdio.h> #include <string.h> #include <sys/time.h> @@ -1375,6 +1376,7 @@ int testDomainUndefine(virDomainPtr doma return (0); } +#endif /* WITH_TEST */ /* * Local variables: Index: src/xen_internal.c =================================================================== RCS file: /data/cvs/libxen/src/xen_internal.c,v retrieving revision 1.60 diff -u -p -r1.60 xen_internal.c --- src/xen_internal.c 8 Mar 2007 08:31:07 -0000 1.60 +++ src/xen_internal.c 14 Mar 2007 15:21:36 -0000 @@ -8,6 +8,8 @@ * Daniel Veillard <veillard@xxxxxxxxxx> */ +#ifdef WITH_XEN + #include <stdio.h> #include <string.h> /* required for uint8_t, uint32_t, etc ... */ @@ -1880,6 +1882,7 @@ xenHypervisorGetVcpuMax(virDomainPtr dom return maxcpu; } +#endif /* WITH_XEN */ /* * Local variables: * indent-tabs-mode: nil Index: src/xen_internal.h =================================================================== RCS file: /data/cvs/libxen/src/xen_internal.h,v retrieving revision 1.15 diff -u -p -r1.15 xen_internal.h --- src/xen_internal.h 8 Mar 2007 08:31:07 -0000 1.15 +++ src/xen_internal.h 14 Mar 2007 15:21:36 -0000 @@ -11,9 +11,6 @@ #ifndef __VIR_XEN_INTERNAL_H__ #define __VIR_XEN_INTERNAL_H__ -/* required for dom0_getdomaininfo_t and DOM0_INTERFACE_VERSION */ -#include <xen/dom0_ops.h> - #ifdef __cplusplus extern "C" { #endif Index: src/xend_internal.c =================================================================== RCS file: /data/cvs/libxen/src/xend_internal.c,v retrieving revision 1.102 diff -u -p -r1.102 xend_internal.c --- src/xend_internal.c 14 Mar 2007 13:14:51 -0000 1.102 +++ src/xend_internal.c 14 Mar 2007 15:21:36 -0000 @@ -10,6 +10,7 @@ * archive for more details. */ +#ifdef WITH_XEN #include <stdio.h> #include <sys/types.h> #include <sys/socket.h> @@ -37,6 +38,9 @@ #include "xen_internal.h" /* for DOM0_INTERFACE_VERSION */ #include "xs_internal.h" /* To extract VNC port & Serial console TTY */ +/* required for cpumap_t */ +#include <xen/dom0_ops.h> + #ifndef PROXY static const char * xenDaemonGetType(virConnectPtr conn); static int xenDaemonListDomains(virConnectPtr conn, int *ids, int maxids); @@ -3123,9 +3127,7 @@ error: } #endif /* ! PROXY */ - - - +#endif /* WITH_XEN */ /* * Local variables: Index: src/xm_internal.c =================================================================== RCS file: /data/cvs/libxen/src/xm_internal.c,v retrieving revision 1.18 diff -u -p -r1.18 xm_internal.c --- src/xm_internal.c 8 Mar 2007 14:12:06 -0000 1.18 +++ src/xm_internal.c 14 Mar 2007 15:21:37 -0000 @@ -22,6 +22,7 @@ * */ +#ifdef WITH_XEN #include <dirent.h> #include <time.h> #include <sys/stat.h> @@ -2261,6 +2262,7 @@ int xenXMNumOfDefinedDomains(virConnectP return virHashSize(nameConfigMap); } +#endif /* WITH_XEN */ /* * Local variables: * indent-tabs-mode: nil Index: src/xml.c =================================================================== RCS file: /data/cvs/libxen/src/xml.c,v retrieving revision 1.64 diff -u -p -r1.64 xml.c --- src/xml.c 8 Mar 2007 14:12:06 -0000 1.64 +++ src/xml.c 14 Mar 2007 15:21:37 -0000 @@ -14,7 +14,9 @@ #include <stdlib.h> #include <string.h> #include <stdarg.h> +#ifdef WITH_XEN #include <xs.h> +#endif #include <libxml/parser.h> #include <libxml/tree.h> #include <libxml/xpath.h> @@ -1340,7 +1342,9 @@ virDomainXMLDevID(virDomainPtr domain, c xmlDocPtr xml = NULL; xmlNodePtr node, cur; xmlChar *attr = NULL; +#ifdef WITH_XEN char *xref; +#endif /* WITH_XEN */ int ret = 0; xml = xmlReadDoc((const xmlChar *) xmldesc, "domain.xml", NULL, @@ -1372,6 +1376,7 @@ virDomainXMLDevID(virDomainPtr domain, c if (attr == NULL) goto error; +#ifdef WITH_XEN xref = xenStoreDomainGetNetworkID(domain->conn, domain->id, (char *) attr); if (xref != NULL) { @@ -1379,6 +1384,7 @@ virDomainXMLDevID(virDomainPtr domain, c free(xref); goto cleanup; } +#endif /* WITH_XEN */ goto error; } Index: src/xs_internal.c =================================================================== RCS file: /data/cvs/libxen/src/xs_internal.c,v retrieving revision 1.34 diff -u -p -r1.34 xs_internal.c --- src/xs_internal.c 8 Mar 2007 14:17:32 -0000 1.34 +++ src/xs_internal.c 14 Mar 2007 15:21:37 -0000 @@ -8,6 +8,7 @@ * Daniel Veillard <veillard@xxxxxxxxxx> */ +#ifdef WITH_XEN #include <stdio.h> #include <string.h> #include <unistd.h> @@ -836,3 +837,13 @@ xenStoreDomainGetNetworkID(virConnectPtr free(list); return(ret); } + +#endif /* WITH_XEN */ +/* + * Local variables: + * indent-tabs-mode: nil + * c-indent-level: 4 + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ Index: tests/Makefile.am =================================================================== RCS file: /data/cvs/libxen/tests/Makefile.am,v retrieving revision 1.16 diff -u -p -r1.16 Makefile.am --- tests/Makefile.am 1 Mar 2007 16:18:55 -0000 1.16 +++ tests/Makefile.am 14 Mar 2007 15:21:37 -0000 @@ -19,7 +19,8 @@ INCLUDES = \ -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L \ -DGETTEXT_PACKAGE=\"$(PACKAGE)\" \ $(COVERAGE_CFLAGS) \ - $(WARN_CFLAGS) + $(WARN_CFLAGS) \ + $(LIBVIRT_FEATURES) LDADDS = \ @STATIC_BINARIES@ \ Index: tests/sexpr2xmltest.c =================================================================== RCS file: /data/cvs/libxen/tests/sexpr2xmltest.c,v retrieving revision 1.9 diff -u -p -r1.9 sexpr2xmltest.c --- tests/sexpr2xmltest.c 13 Dec 2006 14:08:51 -0000 1.9 +++ tests/sexpr2xmltest.c 14 Mar 2007 15:21:37 -0000 @@ -1,6 +1,7 @@ #include <stdio.h> #include <string.h> +#ifdef WITH_XEN #include "xml.h" #include "xend_internal.h" #include "testutils.h" @@ -190,3 +191,19 @@ main(int argc, char **argv) exit(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE); } +#else /* WITHOUT_XEN */ +int +main(void) +{ + fprintf(stderr, "libvirt compiled without Xen support\n"); + exit(0); +} +#endif /* WITH_XEN */ +/* + * Local variables: + * indent-tabs-mode: nil + * c-indent-level: 4 + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ Index: tests/xmconfigtest.c =================================================================== RCS file: /data/cvs/libxen/tests/xmconfigtest.c,v retrieving revision 1.1 diff -u -p -r1.1 xmconfigtest.c --- tests/xmconfigtest.c 19 Jan 2007 20:30:05 -0000 1.1 +++ tests/xmconfigtest.c 14 Mar 2007 15:21:37 -0000 @@ -24,6 +24,7 @@ #include <stdio.h> #include <string.h> +#ifdef WITH_XEN #include "xm_internal.h" #include "testutils.h" #include "internal.h" @@ -214,7 +215,14 @@ main(int argc, char **argv) exit(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE); } - +#else /* WITHOUT_XEN */ +int +main(void) +{ + fprintf(stderr, "libvirt compiled without Xen support\n"); + exit(0); +} +#endif /* WITH_XEN */ /* * Local variables: