Permalink
Browse files

Require libxml2.

libxml2 is very commonly available on Linux distros and has also been
ported (and is widely available) on Mac OS X and Windows.  Therefore
simply require libxml2, and remove a lot of conditional code.
  • Loading branch information...
1 parent 349300a commit 2f0a4d7c18e622c48e33edc3f80dbd593c6398bc @rwmjones rwmjones committed Apr 16, 2013
Showing with 27 additions and 121 deletions.
  1. +2 −2 README
  2. +2 −2 align/scan.c
  3. +6 −12 configure.ac
  4. +0 −4 df/main.c
  5. +0 −20 fish/options.c
  6. +0 −6 fish/options.h
  7. +0 −4 inspector/Makefile.am
  8. +0 −2 src/alloc.c
  9. +0 −22 src/cleanup.c
  10. +2 −4 src/guestfs-internal-frontend.h
  11. +3 −8 src/handle.c
  12. +4 −7 src/launch-libvirt.c
  13. +4 −6 src/libvirt-auth.c
  14. +4 −6 src/libvirt-domain.c
  15. +0 −16 src/osinfo.c
View
4 README
@@ -98,6 +98,8 @@ The full requirements are described below.
+--------------+-------------+---+-----------------------------------------+
| genisoimage | | R | mkisofs may work. |
+--------------+-------------+---+-----------------------------------------+
+| libxml2 | | R | Popular XML library. |
++--------------+-------------+---+-----------------------------------------+
| po4a | |R/O| Required if compiling from git. |
| | | | Optional if compiling from tarball. |
| | | | For localizing man pages. |
@@ -109,8 +111,6 @@ The full requirements are described below.
| libvirt | | O | >= 0.10.2 is needed if you want to use |
| | | | libvirt to manage transient VMs. |
+--------------+-------------+---+-----------------------------------------+
-| libxml2 | | O | Popular XML library. |
-+--------------+-------------+---+-----------------------------------------+
| xmllint | | O | Part of libxml2. Used for tests only. |
+--------------+-------------+---+-----------------------------------------+
| libconfig | | O | Used to parse libguestfs's own config |
View
@@ -219,14 +219,14 @@ main (int argc, char *argv[])
* below.
*/
if (drvs == NULL) {
-#if defined(HAVE_LIBVIRT) && defined(HAVE_LIBXML2)
+#if defined(HAVE_LIBVIRT)
get_all_libvirt_domains (libvirt_uri);
r = start_threads (max_threads, g, scan_work);
free_domains ();
if (r == -1)
exit (EXIT_FAILURE);
#else
- fprintf (stderr, _("%s: compiled without support for libvirt and/or libxml2.\n"),
+ fprintf (stderr, _("%s: compiled without support for libvirt.\n"),
program_name);
exit (EXIT_FAILURE);
#endif
View
@@ -850,18 +850,12 @@ AM_CONDITIONAL([HAVE_LIBVIRT],[test "x$LIBVIRT_LIBS" != "x"])
libvirt_ro_uri='qemu+unix:///system?socket=/var/run/libvirt/libvirt-sock-ro'
AC_SUBST([libvirt_ro_uri])
-dnl libxml2 (highly recommended)
-PKG_CHECK_MODULES([LIBXML2], [libxml-2.0],[
- AC_SUBST([LIBXML2_CFLAGS])
- AC_SUBST([LIBXML2_LIBS])
- AC_DEFINE([HAVE_LIBXML2],[1],[libxml2 found at compile time.])
- old_LIBS="$LIBS"
- LIBS="$LIBS $LIBXML2_LIBS"
- AC_CHECK_FUNCS([xmlBufferDetach])
- LIBS="$old_LIBS"
-],
- [AC_MSG_WARN([libxml2 not found, some core features will be disabled])])
-AM_CONDITIONAL([HAVE_LIBXML2],[test "x$LIBXML2_LIBS" != "x"])
+dnl libxml2 (required)
+PKG_CHECK_MODULES([LIBXML2], [libxml-2.0])
+old_LIBS="$LIBS"
+LIBS="$LIBS $LIBXML2_LIBS"
+AC_CHECK_FUNCS([xmlBufferDetach])
+LIBS="$old_LIBS"
dnl libconfig (highly recommended)
PKG_CHECK_MODULES([LIBCONFIG], [libconfig],[
View
@@ -30,9 +30,7 @@
#include <assert.h>
#include <libintl.h>
-#ifdef HAVE_LIBXML2
#include <libxml/uri.h>
-#endif
#ifdef HAVE_LIBVIRT
#include <libvirt/libvirt.h>
@@ -336,7 +334,6 @@ single_drive_display_name (struct drv *drvs)
exit (EXIT_FAILURE);
}
break;
-#ifdef HAVE_LIBXML2
case drv_uri: {
char *p;
@@ -361,7 +358,6 @@ single_drive_display_name (struct drv *drvs)
}
break;
}
-#endif /* HAVE_LIBXML2 */
case drv_d:
name = strdup (drvs->d.guest);
if (name == NULL) {
View
@@ -26,9 +26,7 @@
#include <libintl.h>
#include <getopt.h>
-#ifdef HAVE_LIBXML2
#include <libxml/uri.h>
-#endif
#include "c-ctype.h"
@@ -94,8 +92,6 @@ is_uri (const char *arg)
return 1;
}
-#ifdef HAVE_LIBXML2
-
static void
parse_uri (const char *arg, const char *format, struct drv *drv)
{
@@ -155,18 +151,6 @@ make_server (xmlURIPtr uri)
return ret;
}
-#else /* !HAVE_LIBXML2 */
-
-static void
-parse_uri (const char *arg, const char *format, struct drv *drv)
-{
- fprintf (stderr, _("%s: compiled without support for libxml2, so '-a URI' is not allowed\n"),
- program_name);
- exit (EXIT_FAILURE);
-}
-
-#endif /* !HAVE_LIBXML2 */
-
char
add_drives (struct drv *drv, char next_drive)
{
@@ -211,7 +195,6 @@ add_drives (struct drv *drv, char next_drive)
next_drive++;
break;
-#ifdef HAVE_LIBXML2
case drv_uri:
ad_optargs.bitmask = 0;
if (read_only) {
@@ -245,7 +228,6 @@ add_drives (struct drv *drv, char next_drive)
drv->nr_drives = 1;
next_drive++;
break;
-#endif /* HAVE_LIBXML2 */
case drv_d:
r = add_libvirt_drives (drv->d.guest);
@@ -351,11 +333,9 @@ free_drives (struct drv *drv)
case drv_a:
/* a.filename and a.format are optargs, don't free them */
break;
-#ifdef HAVE_LIBXML2
case drv_uri:
xmlFreeURI (drv->uri.uri);
break;
-#endif /* HAVE_LIBXML2 */
case drv_d:
/* d.filename is optarg, don't free it */
break;
View
@@ -21,9 +21,7 @@
#include <getopt.h>
-#ifdef HAVE_LIBXML2
#include <libxml/uri.h>
-#endif
#include "guestfs-internal-frontend.h"
@@ -54,9 +52,7 @@ struct drv {
enum {
drv_a, /* -a option (without URI) */
-#ifdef HAVE_LIBXML2
drv_uri, /* -a option (with URI) */
-#endif
drv_d, /* -d option */
#if COMPILING_GUESTFISH
drv_N, /* -N option (guestfish only) */
@@ -67,12 +63,10 @@ struct drv {
char *filename; /* disk filename */
const char *format; /* format (NULL == autodetect) */
} a;
-#ifdef HAVE_LIBXML2
struct {
xmlURIPtr uri; /* URI */
const char *format; /* format (NULL == autodetect) */
} uri;
-#endif
struct {
char *guest; /* guest name */
} d;
View
@@ -47,8 +47,6 @@ dist_doc_DATA = \
virt-inspector.rng \
$(EXAMPLE_XML)
-if HAVE_LIBXML2
-
bin_PROGRAMS = virt-inspector
SHARED_SOURCE_FILES = \
@@ -112,8 +110,6 @@ check-valgrind-local-guests:
$(top_builddir)/run --test @VG@ ./virt-inspector -c "$(libvirt_ro_uri)" -d "$$g" || exit $$?; \
done
-endif
-
# These rules require virt-inspector so there is no good time that we
# can run them. Instead you can run them by hand.
View
@@ -23,11 +23,9 @@
#include <unistd.h>
#include <string.h>
-#ifdef HAVE_LIBXML2
#include <libxml/tree.h>
#include <libxml/xpath.h>
#include <libxml/xmlwriter.h>
-#endif
#include "guestfs.h"
#include "guestfs-internal.h"
View
@@ -23,11 +23,9 @@
#include <unistd.h>
#include <string.h>
-#ifdef HAVE_LIBXML2
#include <libxml/tree.h>
#include <libxml/xpath.h>
#include <libxml/xmlwriter.h>
-#endif
#include "hash.h"
@@ -73,64 +71,44 @@ guestfs___cleanup_unlink_free (void *ptr)
void
guestfs___cleanup_xmlBufferFree (void *ptr)
{
-#ifdef HAVE_LIBXML2
xmlBufferPtr xb = * (xmlBufferPtr *) ptr;
if (xb)
xmlBufferFree (xb);
-#else
- abort ();
-#endif
}
void
guestfs___cleanup_xmlFreeDoc (void *ptr)
{
-#ifdef HAVE_LIBXML2
xmlDocPtr doc = * (xmlDocPtr *) ptr;
if (doc)
xmlFreeDoc (doc);
-#else
- abort ();
-#endif
}
void
guestfs___cleanup_xmlFreeTextWriter (void *ptr)
{
-#ifdef HAVE_LIBXML2
xmlTextWriterPtr xo = * (xmlTextWriterPtr *) ptr;
if (xo)
xmlFreeTextWriter (xo);
-#else
- abort ();
-#endif
}
void
guestfs___cleanup_xmlXPathFreeContext (void *ptr)
{
-#ifdef HAVE_LIBXML2
xmlXPathContextPtr ctx = * (xmlXPathContextPtr *) ptr;
if (ctx)
xmlXPathFreeContext (ctx);
-#else
- abort ();
-#endif
}
void
guestfs___cleanup_xmlXPathFreeObject (void *ptr)
{
-#ifdef HAVE_LIBXML2
xmlXPathObjectPtr obj = * (xmlXPathObjectPtr *) ptr;
if (obj)
xmlXPathFreeObject (obj);
-#else
- abort ();
-#endif
}
@@ -111,11 +111,9 @@ extern void guestfs___cleanup_xmlXPathFreeObject (void *ptr);
*/
#include "guestfs-internal-frontend-cleanups.h"
-#if defined(HAVE_LIBVIRT) && defined(HAVE_LIBXML2)
+#if defined(HAVE_LIBVIRT)
-#ifdef HAVE_LIBVIRT
#include <libvirt/libvirt.h>
-#endif
/* This was proposed as an external API, but there's a problem: the
* generator is unable to bind a virDomainPtr in any language other
@@ -138,7 +136,7 @@ struct guestfs___add_libvirt_dom_argv {
extern GUESTFS_DLL_PUBLIC int guestfs___add_libvirt_dom (guestfs_h *g, virDomainPtr dom, const struct guestfs___add_libvirt_dom_argv *optargs);
-#endif /* HAVE_LIBVIRT && HAVE_LIBXML2 */
+#endif /* HAVE_LIBVIRT */
/* Current program name. Note <errno.h> must be included in all files
* that want to use 'program_name'.
View
@@ -28,10 +28,8 @@
#include <libvirt/libvirt.h>
#endif
-#ifdef HAVE_LIBXML2
#include <libxml/parser.h>
#include <libxml/xmlversion.h>
-#endif
#include "glthread/lock.h"
#include "ignore-value.h"
@@ -61,19 +59,16 @@ static void init_libguestfs (void) __attribute__((constructor));
static void
init_libguestfs (void)
{
-#if defined(HAVE_LIBVIRT) || defined(HAVE_LIBXML2)
gl_lock_lock (init_lock);
-#endif
+
#ifdef HAVE_LIBVIRT
virInitialize ();
#endif
-#ifdef HAVE_LIBXML2
+
xmlInitParser ();
LIBXML_TEST_VERSION;
-#endif
-#if defined(HAVE_LIBVIRT) || defined(HAVE_LIBXML2)
+
gl_lock_unlock (init_lock);
-#endif
}
guestfs_h *
View
@@ -36,14 +36,12 @@
#include <libvirt/virterror.h>
#endif
-#ifdef HAVE_LIBXML2
#include <libxml/xmlIO.h>
#include <libxml/xmlwriter.h>
#include <libxml/xpath.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <libxml/xmlsave.h>
-#endif
#if HAVE_LIBSELINUX
#include <selinux/selinux.h>
@@ -73,8 +71,7 @@
MIN_LIBVIRT_MICRO)
#if defined(HAVE_LIBVIRT) && \
- LIBVIR_VERSION_NUMBER >= MIN_LIBVIRT_VERSION && \
- defined(HAVE_LIBXML2)
+ LIBVIR_VERSION_NUMBER >= MIN_LIBVIRT_VERSION
#ifndef HAVE_XMLBUFFERDETACH
/* Added in libxml2 2.8.0. This is mostly a copy of the function from
@@ -1810,12 +1807,12 @@ struct backend_ops backend_ops_libvirt = {
.hot_remove_drive = hot_remove_drive_libvirt,
};
-#else /* no libvirt or libxml2 at compile time */
+#else /* no libvirt at compile time */
#define NOT_IMPL(r) \
error (g, _("libvirt backend is not available because " \
"this version of libguestfs was compiled " \
- "without libvirt or libvirt < %d.%d.%d or without libxml2"), \
+ "without libvirt or libvirt < %d.%d.%d"), \
MIN_LIBVIRT_MAJOR, MIN_LIBVIRT_MINOR, MIN_LIBVIRT_MICRO); \
return r
@@ -1843,7 +1840,7 @@ struct backend_ops backend_ops_libvirt = {
.max_disks = max_disks_libvirt,
};
-#endif /* no libvirt or libxml2 at compile time */
+#endif /* no libvirt at compile time */
int
guestfs__internal_set_libvirt_selinux_label (guestfs_h *g, const char *label,
Oops, something went wrong.

0 comments on commit 2f0a4d7

Please sign in to comment.