[Libguestfs] [PATCH v4 1/7] v2v: require libvirt

Richard W.M. Jones rjones at redhat.com
Wed Apr 10 13:08:29 UTC 2019


On Mon, Apr 08, 2019 at 02:49:54PM +0200, Pino Toscano wrote:
> While there are input modes that do not use libvirt, making libvirt
> mandatory for virt-v2v slightly simplifies the code now, and allow for
> further improvements/integration with libvirt later on.

ACK

Rich.

>  Makefile.am           |  2 ++
>  v2v/Makefile.am       | 20 ++++++--------------
>  v2v/libvirt_utils-c.c | 22 ----------------------
>  v2v/v2v.ml            | 12 +++---------
>  4 files changed, 11 insertions(+), 45 deletions(-)
> 
> diff --git a/Makefile.am b/Makefile.am
> index 0067d7b7b..cf9ca512e 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -169,10 +169,12 @@ SUBDIRS += get-kernel
>  SUBDIRS += resize
>  SUBDIRS += sparsify
>  SUBDIRS += sysprep
> +if HAVE_LIBVIRT
>  SUBDIRS += v2v
>  if HAVE_OCAML_PKG_LIBVIRT
>  SUBDIRS += v2v/test-harness
>  endif
> +endif
>  if HAVE_FUSE
>  SUBDIRS += dib
>  endif
> diff --git a/v2v/Makefile.am b/v2v/Makefile.am
> index 39511022e..5999a6b50 100644
> --- a/v2v/Makefile.am
> +++ b/v2v/Makefile.am
> @@ -423,6 +423,7 @@ stamp-virt-v2v-support.pod: virt-v2v-support.pod
>  TESTS_ENVIRONMENT = $(top_builddir)/run --test
>  
>  TESTS = \
> +	test-v2v-copy-to-local.sh \
>  	test-v2v-docs.sh \
>  	test-v2v-python-syntax.sh \
>  	test-v2v-i-ova-bad-sha1.sh \
> @@ -442,29 +443,19 @@ TESTS = \
>  	test-v2v-o-vdsm-oo-query.sh \
>  	test-v2v-bad-networks-and-bridges.sh
>  
> -if HAVE_LIBVIRT
> -TESTS += \
> -	test-v2v-copy-to-local.sh
> -endif
> -
>  if HAVE_OCAML_PKG_OUNIT
>  TESTS += v2v_unit_tests var_expander_tests
>  endif
>  
>  if ENABLE_APPLIANCE
> -TESTS += \
> -	test-v2v-i-ova.sh \
> -	test-v2v-i-disk.sh \
> -	test-v2v-machine-readable.sh \
> -	test-v2v-virtio-win-iso.sh \
> -	test-v2v-windows-conversion.sh
> -
> -if HAVE_LIBVIRT
>  TESTS += \
>  	test-v2v-cdrom.sh \
>  	test-v2v-floppy.sh \
> +	test-v2v-i-disk.sh \
> +	test-v2v-i-ova.sh \
>  	test-v2v-in-place.sh \
>  	test-v2v-mac.sh \
> +	test-v2v-machine-readable.sh \
>  	test-v2v-networks-and-bridges.sh \
>  	test-v2v-no-copy.sh \
>  	test-v2v-o-glance.sh \
> @@ -481,9 +472,10 @@ TESTS += \
>  	test-v2v-print-estimate.sh \
>  	test-v2v-print-source.sh \
>  	test-v2v-sound.sh \
> +	test-v2v-virtio-win-iso.sh \
> +	test-v2v-windows-conversion.sh
>  	$(SLOW_TESTS) \
>  	$(ROOT_TESTS)
> -endif
>  endif ENABLE_APPLIANCE
>  
>  # The VMDK file is used for some -i ova tests.
> diff --git a/v2v/libvirt_utils-c.c b/v2v/libvirt_utils-c.c
> index 0e365eac7..5ca0d5363 100644
> --- a/v2v/libvirt_utils-c.c
> +++ b/v2v/libvirt_utils-c.c
> @@ -35,18 +35,14 @@
>  #include <caml/memory.h>
>  #include <caml/mlvalues.h>
>  
> -#ifdef HAVE_LIBVIRT
>  #include <libvirt/libvirt.h>
>  #include <libvirt/virterror.h>
> -#endif
>  
>  #include "guestfs.h"
>  #include "guestfs-utils.h"
>  
>  #pragma GCC diagnostic ignored "-Wmissing-prototypes"
>  
> -#ifdef HAVE_LIBVIRT
> -
>  #define ERROR_MESSAGE_LEN 512
>  
>  static void
> @@ -519,21 +515,3 @@ v2v_libvirt_get_version (value unitv)
>  
>    CAMLreturn (rv);
>  }
> -
> -#else /* !HAVE_LIBVIRT */
> -
> -#define NO_LIBVIRT(proto)                                               \
> -  proto __attribute__((noreturn));                                      \
> -  proto                                                                 \
> -  {                                                                     \
> -    caml_invalid_argument ("virt-v2v was compiled without libvirt support"); \
> -  }
> -
> -NO_LIBVIRT (value v2v_dumpxml (value connv, value domv))
> -NO_LIBVIRT (value v2v_pool_dumpxml (value connv, value poolv))
> -NO_LIBVIRT (value v2v_vol_dumpxml (value connv, value poolnamev, value volnamev))
> -NO_LIBVIRT (value v2v_capabilities (value connv, value unitv))
> -NO_LIBVIRT (value v2v_domain_exists (value connv, value domnamev))
> -NO_LIBVIRT (value v2v_libvirt_get_version (value unitv))
> -
> -#endif /* !HAVE_LIBVIRT */
> diff --git a/v2v/v2v.ml b/v2v/v2v.ml
> index 277d8f2c7..c056aa787 100644
> --- a/v2v/v2v.ml
> +++ b/v2v/v2v.ml
> @@ -59,16 +59,10 @@ let rec main () =
>          prog Guestfs_config.package_name Guestfs_config.package_version_full
>          Guestfs_config.host_cpu;
>  
> -  (* Print the libvirt version if debugging.  Note that if
> -   * we're configured --without-libvirt, then this will throw
> -   * an exception, but some conversions should still be possible,
> -   * hence the try block.
> -   *)
> +  (* Print the libvirt version if debugging. *)
>    if verbose () then (
> -    try
> -      let major, minor, release = Libvirt_utils.libvirt_get_version () in
> -      debug "libvirt version: %d.%d.%d" major minor release
> -    with _ -> ()
> +    let major, minor, release = Libvirt_utils.libvirt_get_version () in
> +    debug "libvirt version: %d.%d.%d" major minor release
>    );
>  
>    (* Perform pre-flight checks on the input and output objects. *)
> -- 
> 2.20.1
> 
> _______________________________________________
> Libguestfs mailing list
> Libguestfs at redhat.com
> https://www.redhat.com/mailman/listinfo/libguestfs

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/




More information about the Libguestfs mailing list