./PaxHeaders/virt-v2v-1.44.20000644000000000000000000000013214147746611012452 xustar0030 mtime=1637862793.056823965 30 atime=1637862793.119823266 30 ctime=1637862793.056823965 virt-v2v-1.44.2/0000755000175000017500000000000014147746611014176 5ustar00rjonesrjones00000000000000virt-v2v-1.44.2/PaxHeaders/subdir-rules.mk0000644000000000000000000000013213731075514015336 xustar0030 mtime=1600420684.696853953 30 atime=1637862732.880490653 30 ctime=1637862786.858892631 virt-v2v-1.44.2/subdir-rules.mk0000664000175000017500000001057313731075514017152 0ustar00rjonesrjones00000000000000# libguestfs # Copyright (C) 2009-2020 Red Hat Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # subdir-rules.mk should be included in every *subdirectory* Makefile.am. include $(top_srcdir)/common-rules.mk # Individual Makefile.am's should define generator_built if that # subdirectory contains any files which are built by the generator. # Set generator_built to the list of those files. $(generator_built): $(top_builddir)/generator/stamp-generator $(top_builddir)/generator/stamp-generator: $(top_builddir)/generator/generator @if test -f $(top_builddir)/generator/Makefile; then \ $(MAKE) -C $(top_builddir)/generator stamp-generator; \ else \ echo "warning: Run 'make' at the top level to build $(generator_built)"; \ fi # If this file doesn't exist, just print a warning and continue. # During 'make distclean' we can end up deleting this file. $(top_builddir)/generator/generator: @if test -f $(top_builddir)/generator/Makefile; then \ $(MAKE) -C $(top_builddir)/generator generator; \ else \ echo "warning: Run 'make' at the top level to build $@"; \ fi # Rules for building OCaml objects. # See also: # guestfs-hacking(1) section "HOW OCAML PROGRAMS ARE COMPILED AND LINKED" if !HAVE_OCAMLOPT MLARCHIVE = cma LINK_CUSTOM_OCAMLC_ONLY = -custom BEST = c else MLARCHIVE = cmxa BEST = opt endif # custom silent rules guestfs_am_v_ocamlc = $(guestfs_am_v_ocamlc_@AM_V@) guestfs_am_v_ocamlc_ = $(guestfs_am_v_ocamlc_@AM_DEFAULT_V@) guestfs_am_v_ocamlc_0 = @echo " OCAMLC " $@; guestfs_am_v_ocamlcmi= $(guestfs_am_v_ocamlcmi_@AM_V@) guestfs_am_v_ocamlcmi_ = $(guestfs_am_v_ocamlcmi_@AM_DEFAULT_V@) guestfs_am_v_ocamlcmi_0 = @echo " OCAMLCMI" $@; guestfs_am_v_ocamlopt = $(guestfs_am_v_ocamlopt_@AM_V@) guestfs_am_v_ocamlopt_ = $(guestfs_am_v_ocamlopt_@AM_DEFAULT_V@) guestfs_am_v_ocamlopt_0 = @echo " OCAMLOPT" $@; guestfs_am_v_javac = $(guestfs_am_v_javac_@AM_V@) guestfs_am_v_javac_ = $(guestfs_am_v_javac_@AM_DEFAULT_V@) guestfs_am_v_javac_0 = @echo " JAVAC " $@; guestfs_am_v_erlc = $(guestfs_am_v_erlc_@AM_V@) guestfs_am_v_erlc_ = $(guestfs_am_v_erlc_@AM_DEFAULT_V@) guestfs_am_v_erlc_0 = @echo " ERLC " $@; guestfs_am_v_podwrapper = $(guestfs_am_v_podwrapper_@AM_V@) guestfs_am_v_podwrapper_ = $(guestfs_am_v_podwrapper_@AM_DEFAULT_V@) guestfs_am_v_podwrapper_0 = @echo " POD " $@; guestfs_am_v_jar = $(guestfs_am_v_jar_@AM_V@) guestfs_am_v_jar_ = $(guestfs_am_v_jar_@AM_DEFAULT_V@) guestfs_am_v_jar_0 = @echo " JAR " $@; guestfs_am_v_po4a_translate = $(guestfs_am_v_po4a_translate_@AM_V@) guestfs_am_v_po4a_translate_ = $(guestfs_am_v_po4a_translate_@AM_DEFAULT_V@) guestfs_am_v_po4a_translate_0 = @echo " PO4A-T " $@; %.cmi: %.mli $(guestfs_am_v_ocamlcmi)$(OCAMLFIND) ocamlc -package guestfs $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@ %.cmo: %.ml $(guestfs_am_v_ocamlc)$(OCAMLFIND) ocamlc -package guestfs $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@ if HAVE_OCAMLOPT %.cmx: %.ml $(guestfs_am_v_ocamlopt)$(OCAMLFIND) ocamlopt -package guestfs $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@ endif # Test shell scripts should use '$TEST_FUNCTIONS' to get a predefined # set of helper functions for running tests (see # tests/test-functions.sh). # # Notes: # # (1) This is in fact a single command all on one line. The variables # are evaluated in test-functions.sh. # # (2) We use absolute paths here and in test-functions.sh so that the # test can change directory freely. But we also include the # non-absolute values so they can be used by the test script itself. export TEST_FUNCTIONS := \ source $(abs_top_srcdir)/tests/test-functions.sh \ abs_srcdir="$(abs_srcdir)" \ abs_builddir="$(abs_builddir)" \ top_srcdir="$(top_srcdir)" \ top_builddir="$(top_builddir)" \ abs_top_srcdir="$(abs_top_srcdir)" \ abs_top_builddir="$(abs_top_builddir)" virt-v2v-1.44.2/PaxHeaders/config.sh.in0000644000000000000000000000013113631710510014561 xustar0030 mtime=1583845704.129870988 30 atime=1637862729.884523844 29 ctime=1637862786.65589488 virt-v2v-1.44.2/config.sh.in0000664000175000017500000000170713631710510016375 0ustar00rjonesrjones00000000000000#!/bin/bash - # (C) Copyright 2019 Red Hat Inc. # @configure_input@ # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # This shell script contains the results of some configure checks, # mostly used in other shell scripts. export VIRT_V2V_NBDKIT_PYTHON_PLUGIN="@VIRT_V2V_NBDKIT_PYTHON_PLUGIN@" export PYCODESTYLE="@PYCODESTYLE@" virt-v2v-1.44.2/PaxHeaders/cfg.mk0000644000000000000000000000013213631710510013444 xustar0030 mtime=1583845704.128871002 30 atime=1637752334.902869347 30 ctime=1637862786.704894337 virt-v2v-1.44.2/cfg.mk0000664000175000017500000001310213631710510015247 0ustar00rjonesrjones00000000000000# Customize Makefile.maint. -*- makefile -*- # Copyright (C) 2003-2012 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # Use alpha.gnu.org for alpha and beta releases. # Use ftp.gnu.org for major releases. gnu_ftp_host-alpha = alpha.gnu.org gnu_ftp_host-beta = alpha.gnu.org gnu_ftp_host-major = ftp.gnu.org gnu_rel_host = $(gnu_ftp_host-$(RELEASE_TYPE)) url_dir_list = \ ftp://$(gnu_rel_host)/gnu/coreutils # Exclude some filenames. exclude_file_name_regexp--sc_bindtextdomain = ^(daemon|erlang|examples|tests)/|/test- exclude_file_name_regexp--sc_error_message_period = ^(generator|php|po-docs)/ exclude_file_name_regexp--sc_prohibit_always-defined_macros = ^examples/|^tests/xml/fake-libvirt-xml\.c|^daemon/guestfsd\.c exclude_file_name_regexp--sc_prohibit_doubled_word = ^po/ exclude_file_name_regexp--sc_prohibit_empty_lines_at_EOF = ^test-data/|\.patch$|\.png$ exclude_file_name_regexp--sc_prohibit_magic_number_exit = ^(po|po-docs)/|\.pod$|^fuse/guestunmount\.c exclude_file_name_regexp--sc_prohibit_strcmp = ^(examples|po-docs)/|\.pod$ exclude_file_name_regexp--sc_prohibit_strcmp_and_strncmp = ^(examples|po-docs)/|\.pod$ exclude_file_name_regexp--sc_prohibit_strncpy = ^lib/launch-.*\.c$ exclude_file_name_regexp--sc_require_config_h = ^examples/|^tests/c-api/test-just-header\.c$ exclude_file_name_regexp--sc_require_config_h_first = ^examples/|^tests/c-api/test-just-header\.c$|^python/guestfs-py-byhand\.c$ # Tests not to run as part of "make distcheck". local-checks-to-skip = \ sc_po_check \ sc_GPL_version \ sc_error_exit_success \ sc_file_system \ sc_makefile_path_separator_check \ sc_obsolete_symbols \ sc_prohibit_atoi_atof \ sc_prohibit_quote_without_use \ sc_prohibit_quotearg_without_use \ sc_prohibit_stat_st_blocks \ sc_space_tab \ sc_two_space_separator_in_usage \ sc_error_message_uppercase \ sc_program_name \ $(disable_temporarily) \ sc_useless_cpp_parens \ sc_cast_of_argument_to_free disable_temporarily = \ sc_makefile_check \ sc_unmarked_diagnostics \ sc_prohibit_ctype_h \ sc_prohibit_asprintf \ sc_avoid_write # Avoid uses of write(2). Either switch to streams (fwrite), or use # the safewrite wrapper. sc_avoid_write: @if $(VC_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then \ grep '\&2; exit 1; } || :; \ else :; \ fi # Use STREQ rather than comparing strcmp == 0, or != 0. # Similarly, use STREQLEN or STRPREFIX rather than strncmp. sc_prohibit_strcmp_and_strncmp: @grep -nE '! *strn?cmp *\(|\&2; exit 1; } || : # Use virAsprintf rather than a'sprintf since *strp is undefined on error. sc_prohibit_asprintf: @re='\<[a]sprintf\>' \ msg='use virAsprintf, not a'sprintf \ $(_prohibit_regexp) # Prohibit the inclusion of . sc_prohibit_ctype_h: @grep -E '^# *include *' $$($(VC_LIST_EXCEPT)) && \ { echo "$(ME): don't use ctype.h; instead, use c-ctype.h" \ 1>&2; exit 1; } || : ctype_re = isalnum|isalpha|isascii|isblank|iscntrl|isdigit|isgraph|islower\ |isprint|ispunct|isspace|isupper|isxdigit|tolower|toupper sc_avoid_ctype_macros: @grep -E '\b($(ctype_re)) *\(' /dev/null \ $$($(VC_LIST_EXCEPT)) && \ { echo "$(ME): don't use ctype macros (use c-ctype.h)" \ 1>&2; exit 1; } || : sc_prohibit_virBufferAdd_with_string_literal: @prohibit='\, 1995-2000. dnl Bruno Haible , 2000-2006, 2008-2010. dnl Macro to add for using GNU gettext. dnl Usage: AM_GNU_GETTEXT([INTLSYMBOL], [NEEDSYMBOL], [INTLDIR]). dnl INTLSYMBOL must be one of 'external', 'use-libtool'. dnl INTLSYMBOL should be 'external' for packages other than GNU gettext, and dnl 'use-libtool' for the packages 'gettext-runtime' and 'gettext-tools'. dnl If INTLSYMBOL is 'use-libtool', then a libtool library dnl $(top_builddir)/intl/libintl.la will be created (shared and/or static, dnl depending on --{enable,disable}-{shared,static} and on the presence of dnl AM-DISABLE-SHARED). dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext dnl implementations (in libc or libintl) without the ngettext() function dnl will be ignored. If NEEDSYMBOL is specified and is dnl 'need-formatstring-macros', then GNU gettext implementations that don't dnl support the ISO C 99 formatstring macros will be ignored. dnl INTLDIR is used to find the intl libraries. If empty, dnl the value '$(top_builddir)/intl/' is used. dnl dnl The result of the configuration is one of three cases: dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled dnl and used. dnl Catalog format: GNU --> install in $(datadir) dnl Catalog extension: .mo after installation, .gmo in source tree dnl 2) GNU gettext has been found in the system's C library. dnl Catalog format: GNU --> install in $(datadir) dnl Catalog extension: .mo after installation, .gmo in source tree dnl 3) No internationalization, always use English msgid. dnl Catalog format: none dnl Catalog extension: none dnl If INTLSYMBOL is 'external', only cases 2 and 3 can occur. dnl The use of .gmo is historical (it was needed to avoid overwriting the dnl GNU format catalogs when building on a platform with an X/Open gettext), dnl but we keep it in order not to force irrelevant filename changes on the dnl maintainers. dnl AC_DEFUN([AM_GNU_GETTEXT], [ dnl Argument checking. ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [use-libtool], , [errprint([ERROR: invalid first argument to AM_GNU_GETTEXT ])])])]) ifelse(ifelse([$1], [], [old])[]ifelse([$1], [no-libtool], [old]), [old], [errprint([ERROR: Use of AM_GNU_GETTEXT without [external] argument is no longer supported. ])]) ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], , [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT ])])])]) define([gt_included_intl], ifelse([$1], [external], [no], [yes])) gt_NEEDS_INIT AM_GNU_GETTEXT_NEED([$2]) AC_REQUIRE([AM_PO_SUBDIRS])dnl ifelse(gt_included_intl, yes, [ AC_REQUIRE([AM_INTL_SUBDIR])dnl ]) dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) AC_REQUIRE([AC_LIB_RPATH]) dnl Sometimes libintl requires libiconv, so first search for libiconv. dnl Ideally we would do this search only after the dnl if test "$USE_NLS" = "yes"; then dnl if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then dnl tests. But if configure.in invokes AM_ICONV after AM_GNU_GETTEXT dnl the configure script would need to contain the same shell code dnl again, outside any 'if'. There are two solutions: dnl - Invoke AM_ICONV_LINKFLAGS_BODY here, outside any 'if'. dnl - Control the expansions in more detail using AC_PROVIDE_IFELSE. dnl Since AC_PROVIDE_IFELSE is not documented, we avoid it. ifelse(gt_included_intl, yes, , [ AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) ]) dnl Sometimes, on Mac OS X, libintl requires linking with CoreFoundation. gt_INTL_MACOSX dnl Set USE_NLS. AC_REQUIRE([AM_NLS]) ifelse(gt_included_intl, yes, [ BUILD_INCLUDED_LIBINTL=no USE_INCLUDED_LIBINTL=no ]) LIBINTL= LTLIBINTL= POSUB= dnl Add a version number to the cache macros. case " $gt_needs " in *" need-formatstring-macros "*) gt_api_version=3 ;; *" need-ngettext "*) gt_api_version=2 ;; *) gt_api_version=1 ;; esac gt_func_gnugettext_libc="gt_cv_func_gnugettext${gt_api_version}_libc" gt_func_gnugettext_libintl="gt_cv_func_gnugettext${gt_api_version}_libintl" dnl If we use NLS figure out what method if test "$USE_NLS" = "yes"; then gt_use_preinstalled_gnugettext=no ifelse(gt_included_intl, yes, [ AC_MSG_CHECKING([whether included gettext is requested]) AC_ARG_WITH([included-gettext], [ --with-included-gettext use the GNU gettext library included here], nls_cv_force_use_gnu_gettext=$withval, nls_cv_force_use_gnu_gettext=no) AC_MSG_RESULT([$nls_cv_force_use_gnu_gettext]) nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext" if test "$nls_cv_force_use_gnu_gettext" != "yes"; then ]) dnl User does not insist on using GNU NLS library. Figure out what dnl to use. If GNU gettext is available we use this. Else we have dnl to fall back to GNU NLS library. if test $gt_api_version -ge 3; then gt_revision_test_code=' #ifndef __GNU_GETTEXT_SUPPORTED_REVISION #define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1) #endif changequote(,)dnl typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1]; changequote([,])dnl ' else gt_revision_test_code= fi if test $gt_api_version -ge 2; then gt_expression_test_code=' + * ngettext ("", "", 0)' else gt_expression_test_code= fi AC_CACHE_CHECK([for GNU gettext in libc], [$gt_func_gnugettext_libc], [AC_LINK_IFELSE( [AC_LANG_PROGRAM( [[ #include #ifndef __GNU_GETTEXT_SUPPORTED_REVISION extern int _nl_msg_cat_cntr; extern int *_nl_domain_bindings; #define __GNU_GETTEXT_SYMBOL_EXPRESSION (_nl_msg_cat_cntr + *_nl_domain_bindings) #else #define __GNU_GETTEXT_SYMBOL_EXPRESSION 0 #endif $gt_revision_test_code ]], [[ bindtextdomain ("", ""); return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION ]])], [eval "$gt_func_gnugettext_libc=yes"], [eval "$gt_func_gnugettext_libc=no"])]) if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then dnl Sometimes libintl requires libiconv, so first search for libiconv. ifelse(gt_included_intl, yes, , [ AM_ICONV_LINK ]) dnl Search for libintl and define LIBINTL, LTLIBINTL and INCINTL dnl accordingly. Don't use AC_LIB_LINKFLAGS_BODY([intl],[iconv]) dnl because that would add "-liconv" to LIBINTL and LTLIBINTL dnl even if libiconv doesn't exist. AC_LIB_LINKFLAGS_BODY([intl]) AC_CACHE_CHECK([for GNU gettext in libintl], [$gt_func_gnugettext_libintl], [gt_save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $INCINTL" gt_save_LIBS="$LIBS" LIBS="$LIBS $LIBINTL" dnl Now see whether libintl exists and does not depend on libiconv. AC_LINK_IFELSE( [AC_LANG_PROGRAM( [[ #include #ifndef __GNU_GETTEXT_SUPPORTED_REVISION extern int _nl_msg_cat_cntr; extern #ifdef __cplusplus "C" #endif const char *_nl_expand_alias (const char *); #define __GNU_GETTEXT_SYMBOL_EXPRESSION (_nl_msg_cat_cntr + *_nl_expand_alias ("")) #else #define __GNU_GETTEXT_SYMBOL_EXPRESSION 0 #endif $gt_revision_test_code ]], [[ bindtextdomain ("", ""); return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION ]])], [eval "$gt_func_gnugettext_libintl=yes"], [eval "$gt_func_gnugettext_libintl=no"]) dnl Now see whether libintl exists and depends on libiconv. if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" != yes; } && test -n "$LIBICONV"; then LIBS="$LIBS $LIBICONV" AC_LINK_IFELSE( [AC_LANG_PROGRAM( [[ #include #ifndef __GNU_GETTEXT_SUPPORTED_REVISION extern int _nl_msg_cat_cntr; extern #ifdef __cplusplus "C" #endif const char *_nl_expand_alias (const char *); #define __GNU_GETTEXT_SYMBOL_EXPRESSION (_nl_msg_cat_cntr + *_nl_expand_alias ("")) #else #define __GNU_GETTEXT_SYMBOL_EXPRESSION 0 #endif $gt_revision_test_code ]], [[ bindtextdomain ("", ""); return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION ]])], [LIBINTL="$LIBINTL $LIBICONV" LTLIBINTL="$LTLIBINTL $LTLIBICONV" eval "$gt_func_gnugettext_libintl=yes" ]) fi CPPFLAGS="$gt_save_CPPFLAGS" LIBS="$gt_save_LIBS"]) fi dnl If an already present or preinstalled GNU gettext() is found, dnl use it. But if this macro is used in GNU gettext, and GNU dnl gettext is already preinstalled in libintl, we update this dnl libintl. (Cf. the install rule in intl/Makefile.in.) if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" = "yes"; } \ || { { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; } \ && test "$PACKAGE" != gettext-runtime \ && test "$PACKAGE" != gettext-tools; }; then gt_use_preinstalled_gnugettext=yes else dnl Reset the values set by searching for libintl. LIBINTL= LTLIBINTL= INCINTL= fi ifelse(gt_included_intl, yes, [ if test "$gt_use_preinstalled_gnugettext" != "yes"; then dnl GNU gettext is not found in the C library. dnl Fall back on included GNU gettext library. nls_cv_use_gnu_gettext=yes fi fi if test "$nls_cv_use_gnu_gettext" = "yes"; then dnl Mark actions used to generate GNU NLS library. BUILD_INCLUDED_LIBINTL=yes USE_INCLUDED_LIBINTL=yes LIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.la $LIBICONV $LIBTHREAD" LTLIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.la $LTLIBICONV $LTLIBTHREAD" LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'` fi CATOBJEXT= if test "$gt_use_preinstalled_gnugettext" = "yes" \ || test "$nls_cv_use_gnu_gettext" = "yes"; then dnl Mark actions to use GNU gettext tools. CATOBJEXT=.gmo fi ]) if test -n "$INTL_MACOSX_LIBS"; then if test "$gt_use_preinstalled_gnugettext" = "yes" \ || test "$nls_cv_use_gnu_gettext" = "yes"; then dnl Some extra flags are needed during linking. LIBINTL="$LIBINTL $INTL_MACOSX_LIBS" LTLIBINTL="$LTLIBINTL $INTL_MACOSX_LIBS" fi fi if test "$gt_use_preinstalled_gnugettext" = "yes" \ || test "$nls_cv_use_gnu_gettext" = "yes"; then AC_DEFINE([ENABLE_NLS], [1], [Define to 1 if translation of program messages to the user's native language is requested.]) else USE_NLS=no fi fi AC_MSG_CHECKING([whether to use NLS]) AC_MSG_RESULT([$USE_NLS]) if test "$USE_NLS" = "yes"; then AC_MSG_CHECKING([where the gettext function comes from]) if test "$gt_use_preinstalled_gnugettext" = "yes"; then if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then gt_source="external libintl" else gt_source="libc" fi else gt_source="included intl directory" fi AC_MSG_RESULT([$gt_source]) fi if test "$USE_NLS" = "yes"; then if test "$gt_use_preinstalled_gnugettext" = "yes"; then if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then AC_MSG_CHECKING([how to link with libintl]) AC_MSG_RESULT([$LIBINTL]) AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCINTL]) fi dnl For backward compatibility. Some packages may be using this. AC_DEFINE([HAVE_GETTEXT], [1], [Define if the GNU gettext() function is already present or preinstalled.]) AC_DEFINE([HAVE_DCGETTEXT], [1], [Define if the GNU dcgettext() function is already present or preinstalled.]) fi dnl We need to process the po/ directory. POSUB=po fi ifelse(gt_included_intl, yes, [ dnl In GNU gettext we have to set BUILD_INCLUDED_LIBINTL to 'yes' dnl because some of the testsuite requires it. BUILD_INCLUDED_LIBINTL=yes dnl Make all variables we use known to autoconf. AC_SUBST([BUILD_INCLUDED_LIBINTL]) AC_SUBST([USE_INCLUDED_LIBINTL]) AC_SUBST([CATOBJEXT]) ]) dnl For backward compatibility. Some Makefiles may be using this. INTLLIBS="$LIBINTL" AC_SUBST([INTLLIBS]) dnl Make all documented variables known to autoconf. AC_SUBST([LIBINTL]) AC_SUBST([LTLIBINTL]) AC_SUBST([POSUB]) ]) dnl gt_NEEDS_INIT ensures that the gt_needs variable is initialized. m4_define([gt_NEEDS_INIT], [ m4_divert_text([DEFAULTS], [gt_needs=]) m4_define([gt_NEEDS_INIT], []) ]) dnl Usage: AM_GNU_GETTEXT_NEED([NEEDSYMBOL]) AC_DEFUN([AM_GNU_GETTEXT_NEED], [ m4_divert_text([INIT_PREPARE], [gt_needs="$gt_needs $1"]) ]) dnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version]) AC_DEFUN([AM_GNU_GETTEXT_VERSION], []) dnl Usage: AM_GNU_GETTEXT_REQUIRE_VERSION([gettext-version]) AC_DEFUN([AM_GNU_GETTEXT_REQUIRE_VERSION], []) # host-cpu-c-abi.m4 serial 13 dnl Copyright (C) 2002-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl From Bruno Haible and Sam Steingold. dnl Sets the HOST_CPU variable to the canonical name of the CPU. dnl Sets the HOST_CPU_C_ABI variable to the canonical name of the CPU with its dnl C language ABI (application binary interface). dnl Also defines __${HOST_CPU}__ and __${HOST_CPU_C_ABI}__ as C macros in dnl config.h. dnl dnl This canonical name can be used to select a particular assembly language dnl source file that will interoperate with C code on the given host. dnl dnl For example: dnl * 'i386' and 'sparc' are different canonical names, because code for i386 dnl will not run on SPARC CPUs and vice versa. They have different dnl instruction sets. dnl * 'sparc' and 'sparc64' are different canonical names, because code for dnl 'sparc' and code for 'sparc64' cannot be linked together: 'sparc' code dnl contains 32-bit instructions, whereas 'sparc64' code contains 64-bit dnl instructions. A process on a SPARC CPU can be in 32-bit mode or in 64-bit dnl mode, but not both. dnl * 'mips' and 'mipsn32' are different canonical names, because they use dnl different argument passing and return conventions for C functions, and dnl although the instruction set of 'mips' is a large subset of the dnl instruction set of 'mipsn32'. dnl * 'mipsn32' and 'mips64' are different canonical names, because they use dnl different sizes for the C types like 'int' and 'void *', and although dnl the instruction sets of 'mipsn32' and 'mips64' are the same. dnl * The same canonical name is used for different endiannesses. You can dnl determine the endianness through preprocessor symbols: dnl - 'arm': test __ARMEL__. dnl - 'mips', 'mipsn32', 'mips64': test _MIPSEB vs. _MIPSEL. dnl - 'powerpc64': test _BIG_ENDIAN vs. _LITTLE_ENDIAN. dnl * The same name 'i386' is used for CPUs of type i386, i486, i586 dnl (Pentium), AMD K7, Pentium II, Pentium IV, etc., because dnl - Instructions that do not exist on all of these CPUs (cmpxchg, dnl MMX, SSE, SSE2, 3DNow! etc.) are not frequently used. If your dnl assembly language source files use such instructions, you will dnl need to make the distinction. dnl - Speed of execution of the common instruction set is reasonable across dnl the entire family of CPUs. If you have assembly language source files dnl that are optimized for particular CPU types (like GNU gmp has), you dnl will need to make the distinction. dnl See . AC_DEFUN([gl_HOST_CPU_C_ABI], [ AC_REQUIRE([AC_CANONICAL_HOST]) AC_REQUIRE([gl_C_ASM]) AC_CACHE_CHECK([host CPU and C ABI], [gl_cv_host_cpu_c_abi], [case "$host_cpu" in changequote(,)dnl i[34567]86 ) changequote([,])dnl gl_cv_host_cpu_c_abi=i386 ;; x86_64 ) # On x86_64 systems, the C compiler may be generating code in one of # these ABIs: # - 64-bit instruction set, 64-bit pointers, 64-bit 'long': x86_64. # - 64-bit instruction set, 64-bit pointers, 32-bit 'long': x86_64 # with native Windows (mingw, MSVC). # - 64-bit instruction set, 32-bit pointers, 32-bit 'long': x86_64-x32. # - 32-bit instruction set, 32-bit pointers, 32-bit 'long': i386. AC_COMPILE_IFELSE( [AC_LANG_SOURCE( [[#if (defined __x86_64__ || defined __amd64__ \ || defined _M_X64 || defined _M_AMD64) int ok; #else error fail #endif ]])], [AC_COMPILE_IFELSE( [AC_LANG_SOURCE( [[#if defined __ILP32__ || defined _ILP32 int ok; #else error fail #endif ]])], [gl_cv_host_cpu_c_abi=x86_64-x32], [gl_cv_host_cpu_c_abi=x86_64])], [gl_cv_host_cpu_c_abi=i386]) ;; changequote(,)dnl alphaev[4-8] | alphaev56 | alphapca5[67] | alphaev6[78] ) changequote([,])dnl gl_cv_host_cpu_c_abi=alpha ;; arm* | aarch64 ) # Assume arm with EABI. # On arm64 systems, the C compiler may be generating code in one of # these ABIs: # - aarch64 instruction set, 64-bit pointers, 64-bit 'long': arm64. # - aarch64 instruction set, 32-bit pointers, 32-bit 'long': arm64-ilp32. # - 32-bit instruction set, 32-bit pointers, 32-bit 'long': arm or armhf. AC_COMPILE_IFELSE( [AC_LANG_SOURCE( [[#ifdef __aarch64__ int ok; #else error fail #endif ]])], [AC_COMPILE_IFELSE( [AC_LANG_SOURCE( [[#if defined __ILP32__ || defined _ILP32 int ok; #else error fail #endif ]])], [gl_cv_host_cpu_c_abi=arm64-ilp32], [gl_cv_host_cpu_c_abi=arm64])], [# Don't distinguish little-endian and big-endian arm, since they # don't require different machine code for simple operations and # since the user can distinguish them through the preprocessor # defines __ARMEL__ vs. __ARMEB__. # But distinguish arm which passes floating-point arguments and # return values in integer registers (r0, r1, ...) - this is # gcc -mfloat-abi=soft or gcc -mfloat-abi=softfp - from arm which # passes them in float registers (s0, s1, ...) and double registers # (d0, d1, ...) - this is gcc -mfloat-abi=hard. GCC 4.6 or newer # sets the preprocessor defines __ARM_PCS (for the first case) and # __ARM_PCS_VFP (for the second case), but older GCC does not. echo 'double ddd; void func (double dd) { ddd = dd; }' > conftest.c # Look for a reference to the register d0 in the .s file. AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS $gl_c_asm_opt conftest.c) >/dev/null 2>&1 if LC_ALL=C grep 'd0,' conftest.$gl_asmext >/dev/null; then gl_cv_host_cpu_c_abi=armhf else gl_cv_host_cpu_c_abi=arm fi rm -f conftest* ]) ;; hppa1.0 | hppa1.1 | hppa2.0* | hppa64 ) # On hppa, the C compiler may be generating 32-bit code or 64-bit # code. In the latter case, it defines _LP64 and __LP64__. AC_COMPILE_IFELSE( [AC_LANG_SOURCE( [[#ifdef __LP64__ int ok; #else error fail #endif ]])], [gl_cv_host_cpu_c_abi=hppa64], [gl_cv_host_cpu_c_abi=hppa]) ;; ia64* ) # On ia64 on HP-UX, the C compiler may be generating 64-bit code or # 32-bit code. In the latter case, it defines _ILP32. AC_COMPILE_IFELSE( [AC_LANG_SOURCE( [[#ifdef _ILP32 int ok; #else error fail #endif ]])], [gl_cv_host_cpu_c_abi=ia64-ilp32], [gl_cv_host_cpu_c_abi=ia64]) ;; mips* ) # We should also check for (_MIPS_SZPTR == 64), but gcc keeps this # at 32. AC_COMPILE_IFELSE( [AC_LANG_SOURCE( [[#if defined _MIPS_SZLONG && (_MIPS_SZLONG == 64) int ok; #else error fail #endif ]])], [gl_cv_host_cpu_c_abi=mips64], [# In the n32 ABI, _ABIN32 is defined, _ABIO32 is not defined (but # may later get defined by ), and _MIPS_SIM == _ABIN32. # In the 32 ABI, _ABIO32 is defined, _ABIN32 is not defined (but # may later get defined by ), and _MIPS_SIM == _ABIO32. AC_COMPILE_IFELSE( [AC_LANG_SOURCE( [[#if (_MIPS_SIM == _ABIN32) int ok; #else error fail #endif ]])], [gl_cv_host_cpu_c_abi=mipsn32], [gl_cv_host_cpu_c_abi=mips])]) ;; powerpc* ) # Different ABIs are in use on AIX vs. Mac OS X vs. Linux,*BSD. # No need to distinguish them here; the caller may distinguish # them based on the OS. # On powerpc64 systems, the C compiler may still be generating # 32-bit code. And on powerpc-ibm-aix systems, the C compiler may # be generating 64-bit code. AC_COMPILE_IFELSE( [AC_LANG_SOURCE( [[#if defined __powerpc64__ || defined _ARCH_PPC64 int ok; #else error fail #endif ]])], [# On powerpc64, there are two ABIs on Linux: The AIX compatible # one and the ELFv2 one. The latter defines _CALL_ELF=2. AC_COMPILE_IFELSE( [AC_LANG_SOURCE( [[#if defined _CALL_ELF && _CALL_ELF == 2 int ok; #else error fail #endif ]])], [gl_cv_host_cpu_c_abi=powerpc64-elfv2], [gl_cv_host_cpu_c_abi=powerpc64]) ], [gl_cv_host_cpu_c_abi=powerpc]) ;; rs6000 ) gl_cv_host_cpu_c_abi=powerpc ;; riscv32 | riscv64 ) # There are 2 architectures (with variants): rv32* and rv64*. AC_COMPILE_IFELSE( [AC_LANG_SOURCE( [[#if __riscv_xlen == 64 int ok; #else error fail #endif ]])], [cpu=riscv64], [cpu=riscv32]) # There are 6 ABIs: ilp32, ilp32f, ilp32d, lp64, lp64f, lp64d. # Size of 'long' and 'void *': AC_COMPILE_IFELSE( [AC_LANG_SOURCE( [[#if defined __LP64__ int ok; #else error fail #endif ]])], [main_abi=lp64], [main_abi=ilp32]) # Float ABIs: # __riscv_float_abi_double: # 'float' and 'double' are passed in floating-point registers. # __riscv_float_abi_single: # 'float' are passed in floating-point registers. # __riscv_float_abi_soft: # No values are passed in floating-point registers. AC_COMPILE_IFELSE( [AC_LANG_SOURCE( [[#if defined __riscv_float_abi_double int ok; #else error fail #endif ]])], [float_abi=d], [AC_COMPILE_IFELSE( [AC_LANG_SOURCE( [[#if defined __riscv_float_abi_single int ok; #else error fail #endif ]])], [float_abi=f], [float_abi='']) ]) gl_cv_host_cpu_c_abi="${cpu}-${main_abi}${float_abi}" ;; s390* ) # On s390x, the C compiler may be generating 64-bit (= s390x) code # or 31-bit (= s390) code. AC_COMPILE_IFELSE( [AC_LANG_SOURCE( [[#if defined __LP64__ || defined __s390x__ int ok; #else error fail #endif ]])], [gl_cv_host_cpu_c_abi=s390x], [gl_cv_host_cpu_c_abi=s390]) ;; sparc | sparc64 ) # UltraSPARCs running Linux have `uname -m` = "sparc64", but the # C compiler still generates 32-bit code. AC_COMPILE_IFELSE( [AC_LANG_SOURCE( [[#if defined __sparcv9 || defined __arch64__ int ok; #else error fail #endif ]])], [gl_cv_host_cpu_c_abi=sparc64], [gl_cv_host_cpu_c_abi=sparc]) ;; *) gl_cv_host_cpu_c_abi="$host_cpu" ;; esac ]) dnl In most cases, $HOST_CPU and $HOST_CPU_C_ABI are the same. HOST_CPU=`echo "$gl_cv_host_cpu_c_abi" | sed -e 's/-.*//'` HOST_CPU_C_ABI="$gl_cv_host_cpu_c_abi" AC_SUBST([HOST_CPU]) AC_SUBST([HOST_CPU_C_ABI]) # This was # AC_DEFINE_UNQUOTED([__${HOST_CPU}__]) # AC_DEFINE_UNQUOTED([__${HOST_CPU_C_ABI}__]) # earlier, but KAI C++ 3.2d doesn't like this. sed -e 's/-/_/g' >> confdefs.h < #include ]], [[iconv_t cd = iconv_open("",""); iconv(cd,NULL,NULL,NULL,NULL); iconv_close(cd);]])], [am_cv_func_iconv=yes]) if test "$am_cv_func_iconv" != yes; then am_save_LIBS="$LIBS" LIBS="$LIBS $LIBICONV" AC_LINK_IFELSE( [AC_LANG_PROGRAM( [[ #include #include ]], [[iconv_t cd = iconv_open("",""); iconv(cd,NULL,NULL,NULL,NULL); iconv_close(cd);]])], [am_cv_lib_iconv=yes] [am_cv_func_iconv=yes]) LIBS="$am_save_LIBS" fi ]) if test "$am_cv_func_iconv" = yes; then AC_CACHE_CHECK([for working iconv], [am_cv_func_iconv_works], [ dnl This tests against bugs in AIX 5.1, AIX 6.1..7.1, HP-UX 11.11, dnl Solaris 10. am_save_LIBS="$LIBS" if test $am_cv_lib_iconv = yes; then LIBS="$LIBS $LIBICONV" fi am_cv_func_iconv_works=no for ac_iconv_const in '' 'const'; do AC_RUN_IFELSE( [AC_LANG_PROGRAM( [[ #include #include #ifndef ICONV_CONST # define ICONV_CONST $ac_iconv_const #endif ]], [[int result = 0; /* Test against AIX 5.1 bug: Failures are not distinguishable from successful returns. */ { iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8"); if (cd_utf8_to_88591 != (iconv_t)(-1)) { static ICONV_CONST char input[] = "\342\202\254"; /* EURO SIGN */ char buf[10]; ICONV_CONST char *inptr = input; size_t inbytesleft = strlen (input); char *outptr = buf; size_t outbytesleft = sizeof (buf); size_t res = iconv (cd_utf8_to_88591, &inptr, &inbytesleft, &outptr, &outbytesleft); if (res == 0) result |= 1; iconv_close (cd_utf8_to_88591); } } /* Test against Solaris 10 bug: Failures are not distinguishable from successful returns. */ { iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646"); if (cd_ascii_to_88591 != (iconv_t)(-1)) { static ICONV_CONST char input[] = "\263"; char buf[10]; ICONV_CONST char *inptr = input; size_t inbytesleft = strlen (input); char *outptr = buf; size_t outbytesleft = sizeof (buf); size_t res = iconv (cd_ascii_to_88591, &inptr, &inbytesleft, &outptr, &outbytesleft); if (res == 0) result |= 2; iconv_close (cd_ascii_to_88591); } } /* Test against AIX 6.1..7.1 bug: Buffer overrun. */ { iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1"); if (cd_88591_to_utf8 != (iconv_t)(-1)) { static ICONV_CONST char input[] = "\304"; static char buf[2] = { (char)0xDE, (char)0xAD }; ICONV_CONST char *inptr = input; size_t inbytesleft = 1; char *outptr = buf; size_t outbytesleft = 1; size_t res = iconv (cd_88591_to_utf8, &inptr, &inbytesleft, &outptr, &outbytesleft); if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD) result |= 4; iconv_close (cd_88591_to_utf8); } } #if 0 /* This bug could be worked around by the caller. */ /* Test against HP-UX 11.11 bug: Positive return value instead of 0. */ { iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591"); if (cd_88591_to_utf8 != (iconv_t)(-1)) { static ICONV_CONST char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; char buf[50]; ICONV_CONST char *inptr = input; size_t inbytesleft = strlen (input); char *outptr = buf; size_t outbytesleft = sizeof (buf); size_t res = iconv (cd_88591_to_utf8, &inptr, &inbytesleft, &outptr, &outbytesleft); if ((int)res > 0) result |= 8; iconv_close (cd_88591_to_utf8); } } #endif /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is provided. */ { /* Try standardized names. */ iconv_t cd1 = iconv_open ("UTF-8", "EUC-JP"); /* Try IRIX, OSF/1 names. */ iconv_t cd2 = iconv_open ("UTF-8", "eucJP"); /* Try AIX names. */ iconv_t cd3 = iconv_open ("UTF-8", "IBM-eucJP"); /* Try HP-UX names. */ iconv_t cd4 = iconv_open ("utf8", "eucJP"); if (cd1 == (iconv_t)(-1) && cd2 == (iconv_t)(-1) && cd3 == (iconv_t)(-1) && cd4 == (iconv_t)(-1)) result |= 16; if (cd1 != (iconv_t)(-1)) iconv_close (cd1); if (cd2 != (iconv_t)(-1)) iconv_close (cd2); if (cd3 != (iconv_t)(-1)) iconv_close (cd3); if (cd4 != (iconv_t)(-1)) iconv_close (cd4); } return result; ]])], [am_cv_func_iconv_works=yes], , [case "$host_os" in aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; *) am_cv_func_iconv_works="guessing yes" ;; esac]) test "$am_cv_func_iconv_works" = no || break done LIBS="$am_save_LIBS" ]) case "$am_cv_func_iconv_works" in *no) am_func_iconv=no am_cv_lib_iconv=no ;; *) am_func_iconv=yes ;; esac else am_func_iconv=no am_cv_lib_iconv=no fi if test "$am_func_iconv" = yes; then AC_DEFINE([HAVE_ICONV], [1], [Define if you have the iconv() function and it works.]) fi if test "$am_cv_lib_iconv" = yes; then AC_MSG_CHECKING([how to link with libiconv]) AC_MSG_RESULT([$LIBICONV]) else dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV dnl either. CPPFLAGS="$am_save_CPPFLAGS" LIBICONV= LTLIBICONV= fi AC_SUBST([LIBICONV]) AC_SUBST([LTLIBICONV]) ]) dnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to dnl avoid warnings like dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required". dnl This is tricky because of the way 'aclocal' is implemented: dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN. dnl Otherwise aclocal's initial scan pass would miss the macro definition. dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions. dnl Otherwise aclocal would emit many "Use of uninitialized value $1" dnl warnings. m4_define([gl_iconv_AC_DEFUN], m4_version_prereq([2.64], [[AC_DEFUN_ONCE( [$1], [$2])]], [m4_ifdef([gl_00GNULIB], [[AC_DEFUN_ONCE( [$1], [$2])]], [[AC_DEFUN( [$1], [$2])]])])) gl_iconv_AC_DEFUN([AM_ICONV], [ AM_ICONV_LINK if test "$am_cv_func_iconv" = yes; then AC_MSG_CHECKING([for iconv declaration]) AC_CACHE_VAL([am_cv_proto_iconv], [ AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( [[ #include #include extern #ifdef __cplusplus "C" #endif #if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); #else size_t iconv(); #endif ]], [[]])], [am_cv_proto_iconv_arg1=""], [am_cv_proto_iconv_arg1="const"]) am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"]) am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` AC_MSG_RESULT([ $am_cv_proto_iconv]) else dnl When compiling GNU libiconv on a system that does not have iconv yet, dnl pick the POSIX compliant declaration without 'const'. am_cv_proto_iconv_arg1="" fi AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1], [Define as const if the declaration of iconv() needs const.]) dnl Also substitute ICONV_CONST in the gnulib generated . m4_ifdef([gl_ICONV_H_DEFAULTS], [AC_REQUIRE([gl_ICONV_H_DEFAULTS]) if test -n "$am_cv_proto_iconv_arg1"; then ICONV_CONST="const" fi ]) ]) # intlmacosx.m4 serial 8 (gettext-0.20.2) dnl Copyright (C) 2004-2014, 2016, 2019-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl dnl This file can be used in projects which are not available under dnl the GNU General Public License or the GNU Lesser General Public dnl License but which still want to provide support for the GNU gettext dnl functionality. dnl Please note that the actual code of the GNU gettext library is covered dnl by the GNU Lesser General Public License, and the rest of the GNU dnl gettext package is covered by the GNU General Public License. dnl They are *not* in the public domain. dnl Checks for special options needed on Mac OS X. dnl Defines INTL_MACOSX_LIBS. AC_DEFUN([gt_INTL_MACOSX], [ dnl Check for API introduced in Mac OS X 10.4. AC_CACHE_CHECK([for CFPreferencesCopyAppValue], [gt_cv_func_CFPreferencesCopyAppValue], [gt_save_LIBS="$LIBS" LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" AC_LINK_IFELSE( [AC_LANG_PROGRAM( [[#include ]], [[CFPreferencesCopyAppValue(NULL, NULL)]])], [gt_cv_func_CFPreferencesCopyAppValue=yes], [gt_cv_func_CFPreferencesCopyAppValue=no]) LIBS="$gt_save_LIBS"]) if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then AC_DEFINE([HAVE_CFPREFERENCESCOPYAPPVALUE], [1], [Define to 1 if you have the Mac OS X function CFPreferencesCopyAppValue in the CoreFoundation framework.]) fi dnl Don't check for the API introduced in Mac OS X 10.5, CFLocaleCopyCurrent, dnl because in macOS 10.13.4 it has the following behaviour: dnl When two or more languages are specified in the dnl "System Preferences > Language & Region > Preferred Languages" panel, dnl it returns en_CC where CC is the territory (even when English is not among dnl the preferred languages!). What we want instead is what dnl CFLocaleCopyCurrent returned in earlier macOS releases and what dnl CFPreferencesCopyAppValue still returns, namely ll_CC where ll is the dnl first among the preferred languages and CC is the territory. AC_CACHE_CHECK([for CFLocaleCopyPreferredLanguages], [gt_cv_func_CFLocaleCopyPreferredLanguages], [gt_save_LIBS="$LIBS" LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" AC_LINK_IFELSE( [AC_LANG_PROGRAM( [[#include ]], [[CFLocaleCopyPreferredLanguages();]])], [gt_cv_func_CFLocaleCopyPreferredLanguages=yes], [gt_cv_func_CFLocaleCopyPreferredLanguages=no]) LIBS="$gt_save_LIBS"]) if test $gt_cv_func_CFLocaleCopyPreferredLanguages = yes; then AC_DEFINE([HAVE_CFLOCALECOPYPREFERREDLANGUAGES], [1], [Define to 1 if you have the Mac OS X function CFLocaleCopyPreferredLanguages in the CoreFoundation framework.]) fi INTL_MACOSX_LIBS= if test $gt_cv_func_CFPreferencesCopyAppValue = yes \ || test $gt_cv_func_CFLocaleCopyPreferredLanguages = yes; then INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation" fi AC_SUBST([INTL_MACOSX_LIBS]) ]) # lib-ld.m4 serial 9 dnl Copyright (C) 1996-2003, 2009-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl Subroutines of libtool.m4, dnl with replacements s/_*LT_PATH/AC_LIB_PROG/ and s/lt_/acl_/ to avoid dnl collision with libtool.m4. dnl From libtool-2.4. Sets the variable with_gnu_ld to yes or no. AC_DEFUN([AC_LIB_PROG_LD_GNU], [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], [acl_cv_prog_gnu_ld], [# I'd rather use --version here, but apparently some GNU lds only accept -v. case `$LD -v 2>&1 /dev/null 2>&1 \ && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ || PATH_SEPARATOR=';' } fi if test -n "$LD"; then AC_MSG_CHECKING([for ld]) elif test "$GCC" = yes; then AC_MSG_CHECKING([for ld used by $CC]) elif test "$with_gnu_ld" = yes; then AC_MSG_CHECKING([for GNU ld]) else AC_MSG_CHECKING([for non-GNU ld]) fi if test -n "$LD"; then # Let the user override the test with a path. : else AC_CACHE_VAL([acl_cv_path_LD], [ acl_cv_path_LD= # Final result of this test ac_prog=ld # Program to search in $PATH if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw acl_output=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) acl_output=`($CC -print-prog-name=ld) 2>&5` ;; esac case $acl_output in # Accept absolute paths. [[\\/]]* | ?:[[\\/]]*) re_direlt='/[[^/]][[^/]]*/\.\./' # Canonicalize the pathname of ld acl_output=`echo "$acl_output" | sed 's%\\\\%/%g'` while echo "$acl_output" | grep "$re_direlt" > /dev/null 2>&1; do acl_output=`echo $acl_output | sed "s%$re_direlt%/%"` done # Got the pathname. No search in PATH is needed. acl_cv_path_LD="$acl_output" ac_prog= ;; "") # If it fails, then pretend we aren't using GCC. ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac fi if test -n "$ac_prog"; then # Search for $ac_prog in $PATH. acl_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$acl_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then acl_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$acl_cv_path_LD" -v 2>&1 conftest.sh . ./conftest.sh rm -f ./conftest.sh acl_cv_rpath=done ]) wl="$acl_cv_wl" acl_libext="$acl_cv_libext" acl_shlibext="$acl_cv_shlibext" acl_libname_spec="$acl_cv_libname_spec" acl_library_names_spec="$acl_cv_library_names_spec" acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" acl_hardcode_direct="$acl_cv_hardcode_direct" acl_hardcode_minus_L="$acl_cv_hardcode_minus_L" dnl Determine whether the user wants rpath handling at all. AC_ARG_ENABLE([rpath], [ --disable-rpath do not hardcode runtime library paths], :, enable_rpath=yes) ]) dnl AC_LIB_FROMPACKAGE(name, package) dnl declares that libname comes from the given package. The configure file dnl will then not have a --with-libname-prefix option but a dnl --with-package-prefix option. Several libraries can come from the same dnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar dnl macro call that searches for libname. AC_DEFUN([AC_LIB_FROMPACKAGE], [ pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) define([acl_frompackage_]NAME, [$2]) popdef([NAME]) pushdef([PACK],[$2]) pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-], [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) define([acl_libsinpackage_]PACKUP, m4_ifdef([acl_libsinpackage_]PACKUP, [m4_defn([acl_libsinpackage_]PACKUP)[, ]],)[lib$1]) popdef([PACKUP]) popdef([PACK]) ]) dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and dnl the libraries corresponding to explicit and implicit dependencies. dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables. dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem. AC_DEFUN([AC_LIB_LINKFLAGS_BODY], [ AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])]) pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-], [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])]) dnl By default, look in $includedir and $libdir. use_additional=yes AC_LIB_WITH_FINAL_PREFIX([ eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" eval additional_libdir2=\"$exec_prefix/$acl_libdirstem2\" eval additional_libdir3=\"$exec_prefix/$acl_libdirstem3\" ]) AC_ARG_WITH(PACK[-prefix], [[ --with-]]PACK[[-prefix[=DIR] search for ]PACKLIBS[ in DIR/include and DIR/lib --without-]]PACK[[-prefix don't search for ]PACKLIBS[ in includedir and libdir]], [ if test "X$withval" = "Xno"; then use_additional=no else if test "X$withval" = "X"; then AC_LIB_WITH_FINAL_PREFIX([ eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" eval additional_libdir2=\"$exec_prefix/$acl_libdirstem2\" eval additional_libdir3=\"$exec_prefix/$acl_libdirstem3\" ]) else additional_includedir="$withval/include" additional_libdir="$withval/$acl_libdirstem" additional_libdir2="$withval/$acl_libdirstem2" additional_libdir3="$withval/$acl_libdirstem3" fi fi ]) if test "X$additional_libdir2" = "X$additional_libdir"; then additional_libdir2= fi if test "X$additional_libdir3" = "X$additional_libdir"; then additional_libdir3= fi dnl Search the library and its dependencies in $additional_libdir and dnl $LDFLAGS. Using breadth-first-seach. LIB[]NAME= LTLIB[]NAME= INC[]NAME= LIB[]NAME[]_PREFIX= dnl HAVE_LIB${NAME} is an indicator that LIB${NAME}, LTLIB${NAME} have been dnl computed. So it has to be reset here. HAVE_LIB[]NAME= rpathdirs= ltrpathdirs= names_already_handled= names_next_round='$1 $2' while test -n "$names_next_round"; do names_this_round="$names_next_round" names_next_round= for name in $names_this_round; do already_handled= for n in $names_already_handled; do if test "$n" = "$name"; then already_handled=yes break fi done if test -z "$already_handled"; then names_already_handled="$names_already_handled $name" dnl See if it was already located by an earlier AC_LIB_LINKFLAGS dnl or AC_LIB_HAVE_LINKFLAGS call. uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'` eval value=\"\$HAVE_LIB$uppername\" if test -n "$value"; then if test "$value" = yes; then eval value=\"\$LIB$uppername\" test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value" eval value=\"\$LTLIB$uppername\" test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value" else dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined dnl that this library doesn't exist. So just drop it. : fi else dnl Search the library lib$name in $additional_libdir and $LDFLAGS dnl and the already constructed $LIBNAME/$LTLIBNAME. found_dir= found_la= found_so= found_a= eval libname=\"$acl_libname_spec\" # typically: libname=lib$name if test -n "$acl_shlibext"; then shrext=".$acl_shlibext" # typically: shrext=.so else shrext= fi if test $use_additional = yes; then for additional_libdir_variable in additional_libdir additional_libdir2 additional_libdir3; do if test "X$found_dir" = "X"; then eval dir=\$$additional_libdir_variable if test -n "$dir"; then dnl The same code as in the loop below: dnl First look for a shared library. if test -n "$acl_shlibext"; then if test -f "$dir/$libname$shrext" && acl_is_expected_elfclass < "$dir/$libname$shrext"; then found_dir="$dir" found_so="$dir/$libname$shrext" else if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then ver=`(cd "$dir" && \ for f in "$libname$shrext".*; do echo "$f"; done \ | sed -e "s,^$libname$shrext\\\\.,," \ | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ | sed 1q ) 2>/dev/null` if test -n "$ver" && test -f "$dir/$libname$shrext.$ver" && acl_is_expected_elfclass < "$dir/$libname$shrext.$ver"; then found_dir="$dir" found_so="$dir/$libname$shrext.$ver" fi else eval library_names=\"$acl_library_names_spec\" for f in $library_names; do if test -f "$dir/$f" && acl_is_expected_elfclass < "$dir/$f"; then found_dir="$dir" found_so="$dir/$f" break fi done fi fi fi dnl Then look for a static library. if test "X$found_dir" = "X"; then if test -f "$dir/$libname.$acl_libext" && ${AR-ar} -p "$dir/$libname.$acl_libext" | acl_is_expected_elfclass; then found_dir="$dir" found_a="$dir/$libname.$acl_libext" fi fi if test "X$found_dir" != "X"; then if test -f "$dir/$libname.la"; then found_la="$dir/$libname.la" fi fi fi fi done fi if test "X$found_dir" = "X"; then for x in $LDFLAGS $LTLIB[]NAME; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) case "$x" in -L*) dir=`echo "X$x" | sed -e 's/^X-L//'` dnl First look for a shared library. if test -n "$acl_shlibext"; then if test -f "$dir/$libname$shrext" && acl_is_expected_elfclass < "$dir/$libname$shrext"; then found_dir="$dir" found_so="$dir/$libname$shrext" else if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then ver=`(cd "$dir" && \ for f in "$libname$shrext".*; do echo "$f"; done \ | sed -e "s,^$libname$shrext\\\\.,," \ | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ | sed 1q ) 2>/dev/null` if test -n "$ver" && test -f "$dir/$libname$shrext.$ver" && acl_is_expected_elfclass < "$dir/$libname$shrext.$ver"; then found_dir="$dir" found_so="$dir/$libname$shrext.$ver" fi else eval library_names=\"$acl_library_names_spec\" for f in $library_names; do if test -f "$dir/$f" && acl_is_expected_elfclass < "$dir/$f"; then found_dir="$dir" found_so="$dir/$f" break fi done fi fi fi dnl Then look for a static library. if test "X$found_dir" = "X"; then if test -f "$dir/$libname.$acl_libext" && ${AR-ar} -p "$dir/$libname.$acl_libext" | acl_is_expected_elfclass; then found_dir="$dir" found_a="$dir/$libname.$acl_libext" fi fi if test "X$found_dir" != "X"; then if test -f "$dir/$libname.la"; then found_la="$dir/$libname.la" fi fi ;; esac if test "X$found_dir" != "X"; then break fi done fi if test "X$found_dir" != "X"; then dnl Found the library. LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name" if test "X$found_so" != "X"; then dnl Linking with a shared library. We attempt to hardcode its dnl directory into the executable's runpath, unless it's the dnl standard /usr/lib. if test "$enable_rpath" = no \ || test "X$found_dir" = "X/usr/$acl_libdirstem" \ || test "X$found_dir" = "X/usr/$acl_libdirstem2" \ || test "X$found_dir" = "X/usr/$acl_libdirstem3"; then dnl No hardcoding is needed. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" else dnl Use an explicit option to hardcode DIR into the resulting dnl binary. dnl Potentially add DIR to ltrpathdirs. dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. haveit= for x in $ltrpathdirs; do if test "X$x" = "X$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then ltrpathdirs="$ltrpathdirs $found_dir" fi dnl The hardcoding into $LIBNAME is system dependent. if test "$acl_hardcode_direct" = yes; then dnl Using DIR/libNAME.so during linking hardcodes DIR into the dnl resulting binary. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" else if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then dnl Use an explicit option to hardcode DIR into the resulting dnl binary. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" dnl Potentially add DIR to rpathdirs. dnl The rpathdirs will be appended to $LIBNAME at the end. haveit= for x in $rpathdirs; do if test "X$x" = "X$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then rpathdirs="$rpathdirs $found_dir" fi else dnl Rely on "-L$found_dir". dnl But don't add it if it's already contained in the LDFLAGS dnl or the already constructed $LIBNAME haveit= for x in $LDFLAGS $LIB[]NAME; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-L$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir" fi if test "$acl_hardcode_minus_L" != no; then dnl FIXME: Not sure whether we should use dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" dnl here. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" else dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH dnl here, because this doesn't fit in flags passed to the dnl compiler. So give up. No hardcoding. This affects only dnl very old systems. dnl FIXME: Not sure whether we should use dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" dnl here. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" fi fi fi fi else if test "X$found_a" != "X"; then dnl Linking with a static library. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a" else dnl We shouldn't come here, but anyway it's good to have a dnl fallback. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name" fi fi dnl Assume the include files are nearby. additional_includedir= case "$found_dir" in */$acl_libdirstem | */$acl_libdirstem/) basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` if test "$name" = '$1'; then LIB[]NAME[]_PREFIX="$basedir" fi additional_includedir="$basedir/include" ;; */$acl_libdirstem2 | */$acl_libdirstem2/) basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'` if test "$name" = '$1'; then LIB[]NAME[]_PREFIX="$basedir" fi additional_includedir="$basedir/include" ;; */$acl_libdirstem3 | */$acl_libdirstem3/) basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem3/"'*$,,'` if test "$name" = '$1'; then LIB[]NAME[]_PREFIX="$basedir" fi additional_includedir="$basedir/include" ;; esac if test "X$additional_includedir" != "X"; then dnl Potentially add $additional_includedir to $INCNAME. dnl But don't add it dnl 1. if it's the standard /usr/include, dnl 2. if it's /usr/local/include and we are using GCC on Linux, dnl 3. if it's already present in $CPPFLAGS or the already dnl constructed $INCNAME, dnl 4. if it doesn't exist as a directory. if test "X$additional_includedir" != "X/usr/include"; then haveit= if test "X$additional_includedir" = "X/usr/local/include"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then for x in $CPPFLAGS $INC[]NAME; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-I$additional_includedir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_includedir"; then dnl Really add $additional_includedir to $INCNAME. INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir" fi fi fi fi fi dnl Look for dependencies. if test -n "$found_la"; then dnl Read the .la file. It defines the variables dnl dlname, library_names, old_library, dependency_libs, current, dnl age, revision, installed, dlopen, dlpreopen, libdir. save_libdir="$libdir" case "$found_la" in */* | *\\*) . "$found_la" ;; *) . "./$found_la" ;; esac libdir="$save_libdir" dnl We use only dependency_libs. for dep in $dependency_libs; do case "$dep" in -L*) dependency_libdir=`echo "X$dep" | sed -e 's/^X-L//'` dnl Potentially add $dependency_libdir to $LIBNAME and $LTLIBNAME. dnl But don't add it dnl 1. if it's the standard /usr/lib, dnl 2. if it's /usr/local/lib and we are using GCC on Linux, dnl 3. if it's already present in $LDFLAGS or the already dnl constructed $LIBNAME, dnl 4. if it doesn't exist as a directory. if test "X$dependency_libdir" != "X/usr/$acl_libdirstem" \ && test "X$dependency_libdir" != "X/usr/$acl_libdirstem2" \ && test "X$dependency_libdir" != "X/usr/$acl_libdirstem3"; then haveit= if test "X$dependency_libdir" = "X/usr/local/$acl_libdirstem" \ || test "X$dependency_libdir" = "X/usr/local/$acl_libdirstem2" \ || test "X$dependency_libdir" = "X/usr/local/$acl_libdirstem3"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then haveit= for x in $LDFLAGS $LIB[]NAME; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-L$dependency_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$dependency_libdir"; then dnl Really add $dependency_libdir to $LIBNAME. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$dependency_libdir" fi fi haveit= for x in $LDFLAGS $LTLIB[]NAME; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-L$dependency_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$dependency_libdir"; then dnl Really add $dependency_libdir to $LTLIBNAME. LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$dependency_libdir" fi fi fi fi ;; -R*) dir=`echo "X$dep" | sed -e 's/^X-R//'` if test "$enable_rpath" != no; then dnl Potentially add DIR to rpathdirs. dnl The rpathdirs will be appended to $LIBNAME at the end. haveit= for x in $rpathdirs; do if test "X$x" = "X$dir"; then haveit=yes break fi done if test -z "$haveit"; then rpathdirs="$rpathdirs $dir" fi dnl Potentially add DIR to ltrpathdirs. dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. haveit= for x in $ltrpathdirs; do if test "X$x" = "X$dir"; then haveit=yes break fi done if test -z "$haveit"; then ltrpathdirs="$ltrpathdirs $dir" fi fi ;; -l*) dnl Handle this in the next round. names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` ;; *.la) dnl Handle this in the next round. Throw away the .la's dnl directory; it is already contained in a preceding -L dnl option. names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` ;; *) dnl Most likely an immediate library name. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep" LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep" ;; esac done fi else dnl Didn't find the library; assume it is in the system directories dnl known to the linker and runtime loader. (All the system dnl directories known to the linker should also be known to the dnl runtime loader, otherwise the system is severely misconfigured.) LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name" fi fi fi done done if test "X$rpathdirs" != "X"; then if test -n "$acl_hardcode_libdir_separator"; then dnl Weird platform: only the last -rpath option counts, the user must dnl pass all path elements in one option. We can arrange that for a dnl single library, but not when more than one $LIBNAMEs are used. alldirs= for found_dir in $rpathdirs; do alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir" done dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl. acl_save_libdir="$libdir" libdir="$alldirs" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" else dnl The -rpath options are cumulative. for found_dir in $rpathdirs; do acl_save_libdir="$libdir" libdir="$found_dir" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" done fi fi if test "X$ltrpathdirs" != "X"; then dnl When using libtool, the option that works for both libraries and dnl executables is -R. The -R options are cumulative. for found_dir in $ltrpathdirs; do LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir" done fi popdef([PACKLIBS]) popdef([PACKUP]) popdef([PACK]) popdef([NAME]) ]) dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR, dnl unless already present in VAR. dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes dnl contains two or three consecutive elements that belong together. AC_DEFUN([AC_LIB_APPENDTOVAR], [ for element in [$2]; do haveit= for x in $[$1]; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X$element"; then haveit=yes break fi done if test -z "$haveit"; then [$1]="${[$1]}${[$1]:+ }$element" fi done ]) dnl For those cases where a variable contains several -L and -l options dnl referring to unknown libraries and directories, this macro determines the dnl necessary additional linker options for the runtime path. dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL]) dnl sets LDADDVAR to linker options needed together with LIBSVALUE. dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed, dnl otherwise linking without libtool is assumed. AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS], [ AC_REQUIRE([AC_LIB_RPATH]) AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) $1= if test "$enable_rpath" != no; then if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then dnl Use an explicit option to hardcode directories into the resulting dnl binary. rpathdirs= next= for opt in $2; do if test -n "$next"; then dir="$next" dnl No need to hardcode the standard /usr/lib. if test "X$dir" != "X/usr/$acl_libdirstem" \ && test "X$dir" != "X/usr/$acl_libdirstem2" \ && test "X$dir" != "X/usr/$acl_libdirstem3"; then rpathdirs="$rpathdirs $dir" fi next= else case $opt in -L) next=yes ;; -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'` dnl No need to hardcode the standard /usr/lib. if test "X$dir" != "X/usr/$acl_libdirstem" \ && test "X$dir" != "X/usr/$acl_libdirstem2" \ && test "X$dir" != "X/usr/$acl_libdirstem3"; then rpathdirs="$rpathdirs $dir" fi next= ;; *) next= ;; esac fi done if test "X$rpathdirs" != "X"; then if test -n ""$3""; then dnl libtool is used for linking. Use -R options. for dir in $rpathdirs; do $1="${$1}${$1:+ }-R$dir" done else dnl The linker is used for linking directly. if test -n "$acl_hardcode_libdir_separator"; then dnl Weird platform: only the last -rpath option counts, the user dnl must pass all path elements in one option. alldirs= for dir in $rpathdirs; do alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir" done acl_save_libdir="$libdir" libdir="$alldirs" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" $1="$flag" else dnl The -rpath options are cumulative. for dir in $rpathdirs; do acl_save_libdir="$libdir" libdir="$dir" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" $1="${$1}${$1:+ }$flag" done fi fi fi fi fi AC_SUBST([$1]) ]) # lib-prefix.m4 serial 17 dnl Copyright (C) 2001-2005, 2008-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl From Bruno Haible. dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed dnl to access previously installed libraries. The basic assumption is that dnl a user will want packages to use other packages he previously installed dnl with the same --prefix option. dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate dnl libraries, but is otherwise very convenient. AC_DEFUN([AC_LIB_PREFIX], [ AC_BEFORE([$0], [AC_LIB_LINKFLAGS]) AC_REQUIRE([AC_PROG_CC]) AC_REQUIRE([AC_CANONICAL_HOST]) AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) dnl By default, look in $includedir and $libdir. use_additional=yes AC_LIB_WITH_FINAL_PREFIX([ eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" ]) AC_ARG_WITH([lib-prefix], [[ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib --without-lib-prefix don't search for libraries in includedir and libdir]], [ if test "X$withval" = "Xno"; then use_additional=no else if test "X$withval" = "X"; then AC_LIB_WITH_FINAL_PREFIX([ eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" ]) else additional_includedir="$withval/include" additional_libdir="$withval/$acl_libdirstem" fi fi ]) if test $use_additional = yes; then dnl Potentially add $additional_includedir to $CPPFLAGS. dnl But don't add it dnl 1. if it's the standard /usr/include, dnl 2. if it's already present in $CPPFLAGS, dnl 3. if it's /usr/local/include and we are using GCC on Linux, dnl 4. if it doesn't exist as a directory. if test "X$additional_includedir" != "X/usr/include"; then haveit= for x in $CPPFLAGS; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-I$additional_includedir"; then haveit=yes break fi done if test -z "$haveit"; then if test "X$additional_includedir" = "X/usr/local/include"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then if test -d "$additional_includedir"; then dnl Really add $additional_includedir to $CPPFLAGS. CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir" fi fi fi fi dnl Potentially add $additional_libdir to $LDFLAGS. dnl But don't add it dnl 1. if it's the standard /usr/lib, dnl 2. if it's already present in $LDFLAGS, dnl 3. if it's /usr/local/lib and we are using GCC on Linux, dnl 4. if it doesn't exist as a directory. if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then haveit= for x in $LDFLAGS; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-L$additional_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then if test -n "$GCC"; then case $host_os in linux*) haveit=yes;; esac fi fi if test -z "$haveit"; then if test -d "$additional_libdir"; then dnl Really add $additional_libdir to $LDFLAGS. LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir" fi fi fi fi fi ]) dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix, dnl acl_final_exec_prefix, containing the values to which $prefix and dnl $exec_prefix will expand at the end of the configure script. AC_DEFUN([AC_LIB_PREPARE_PREFIX], [ dnl Unfortunately, prefix and exec_prefix get only finally determined dnl at the end of configure. if test "X$prefix" = "XNONE"; then acl_final_prefix="$ac_default_prefix" else acl_final_prefix="$prefix" fi if test "X$exec_prefix" = "XNONE"; then acl_final_exec_prefix='${prefix}' else acl_final_exec_prefix="$exec_prefix" fi acl_save_prefix="$prefix" prefix="$acl_final_prefix" eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" prefix="$acl_save_prefix" ]) dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the dnl variables prefix and exec_prefix bound to the values they will have dnl at the end of the configure script. AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX], [ acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" $1 exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" ]) dnl AC_LIB_PREPARE_MULTILIB creates dnl - a function acl_is_expected_elfclass, that tests whether standard input dn; has a 32-bit or 64-bit ELF header, depending on the host CPU ABI, dnl - 3 variables acl_libdirstem, acl_libdirstem2, acl_libdirstem3, containing dnl the basename of the libdir to try in turn, either "lib" or "lib64" or dnl "lib/64" or "lib32" or "lib/sparcv9" or "lib/amd64" or similar. AC_DEFUN([AC_LIB_PREPARE_MULTILIB], [ dnl There is no formal standard regarding lib, lib32, and lib64. dnl On most glibc systems, the current practice is that on a system supporting dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under dnl $prefix/lib64 and 32-bit libraries go under $prefix/lib. However, on dnl Arch Linux based distributions, it's the opposite: 32-bit libraries go dnl under $prefix/lib32 and 64-bit libraries go under $prefix/lib. dnl We determine the compiler's default mode by looking at the compiler's dnl library search path. If at least one of its elements ends in /lib64 or dnl points to a directory whose absolute pathname ends in /lib64, we use that dnl for 64-bit ABIs. Similarly for 32-bit ABIs. Otherwise we use the default, dnl namely "lib". dnl On Solaris systems, the current practice is that on a system supporting dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under dnl $prefix/lib/64 (which is a symlink to either $prefix/lib/sparcv9 or dnl $prefix/lib/amd64) and 32-bit libraries go under $prefix/lib. AC_REQUIRE([AC_CANONICAL_HOST]) AC_REQUIRE([gl_HOST_CPU_C_ABI_32BIT]) AC_CACHE_CHECK([for ELF binary format], [gl_cv_elf], [AC_EGREP_CPP([Extensible Linking Format], [#ifdef __ELF__ Extensible Linking Format #endif ], [gl_cv_elf=yes], [gl_cv_elf=no]) ]) if test $gl_cv_elf; then # Extract the ELF class of a file (5th byte) in decimal. # Cf. https://en.wikipedia.org/wiki/Executable_and_Linkable_Format#File_header if od -A x < /dev/null >/dev/null 2>/dev/null; then # Use POSIX od. func_elfclass () { od -A n -t d1 -j 4 -N 1 } else # Use BSD hexdump. func_elfclass () { dd bs=1 count=1 skip=4 2>/dev/null | hexdump -e '1/1 "%3d "' echo } fi changequote(,)dnl case $HOST_CPU_C_ABI_32BIT in yes) # 32-bit ABI. acl_is_expected_elfclass () { test "`func_elfclass | sed -e 's/[ ]//g'`" = 1 } ;; no) # 64-bit ABI. acl_is_expected_elfclass () { test "`func_elfclass | sed -e 's/[ ]//g'`" = 2 } ;; *) # Unknown. acl_is_expected_elfclass () { : } ;; esac changequote([,])dnl else acl_is_expected_elfclass () { : } fi dnl Allow the user to override the result by setting acl_cv_libdirstems. AC_CACHE_CHECK([for the common suffixes of directories in the library search path], [acl_cv_libdirstems], [dnl Try 'lib' first, because that's the default for libdir in GNU, see dnl . acl_libdirstem=lib acl_libdirstem2= acl_libdirstem3= case "$host_os" in solaris*) dnl See Solaris 10 Software Developer Collection > Solaris 64-bit Developer's Guide > The Development Environment dnl . dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link." dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the dnl symlink is missing, so we set acl_libdirstem2 too. if test $HOST_CPU_C_ABI_32BIT = no; then acl_libdirstem2=lib/64 case "$host_cpu" in sparc*) acl_libdirstem3=lib/sparcv9 ;; i*86 | x86_64) acl_libdirstem3=lib/amd64 ;; esac fi ;; *) dnl If $CC generates code for a 32-bit ABI, the libraries are dnl surely under $prefix/lib or $prefix/lib32, not $prefix/lib64. dnl Similarly, if $CC generates code for a 64-bit ABI, the libraries dnl are surely under $prefix/lib or $prefix/lib64, not $prefix/lib32. dnl Find the compiler's search path. However, non-system compilers dnl sometimes have odd library search paths. But we can't simply invoke dnl '/usr/bin/gcc -print-search-dirs' because that would not take into dnl account the -m32/-m31 or -m64 options from the $CC or $CFLAGS. searchpath=`(LC_ALL=C $CC $CPPFLAGS $CFLAGS -print-search-dirs) 2>/dev/null \ | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` if test $HOST_CPU_C_ABI_32BIT != no; then # 32-bit or unknown ABI. if test -d /usr/lib32; then acl_libdirstem2=lib32 fi fi if test $HOST_CPU_C_ABI_32BIT != yes; then # 64-bit or unknown ABI. if test -d /usr/lib64; then acl_libdirstem3=lib64 fi fi if test -n "$searchpath"; then acl_save_IFS="${IFS= }"; IFS=":" for searchdir in $searchpath; do if test -d "$searchdir"; then case "$searchdir" in */lib32/ | */lib32 ) acl_libdirstem2=lib32 ;; */lib64/ | */lib64 ) acl_libdirstem3=lib64 ;; */../ | */.. ) # Better ignore directories of this form. They are misleading. ;; *) searchdir=`cd "$searchdir" && pwd` case "$searchdir" in */lib32 ) acl_libdirstem2=lib32 ;; */lib64 ) acl_libdirstem3=lib64 ;; esac ;; esac fi done IFS="$acl_save_IFS" if test $HOST_CPU_C_ABI_32BIT = yes; then # 32-bit ABI. acl_libdirstem3= fi if test $HOST_CPU_C_ABI_32BIT = no; then # 64-bit ABI. acl_libdirstem2= fi fi ;; esac test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem" test -n "$acl_libdirstem3" || acl_libdirstem3="$acl_libdirstem" acl_cv_libdirstems="$acl_libdirstem,$acl_libdirstem2,$acl_libdirstem3" ]) dnl Decompose acl_cv_libdirstems into acl_libdirstem, acl_libdirstem2, and dnl acl_libdirstem3. changequote(,)dnl acl_libdirstem=`echo "$acl_cv_libdirstems" | sed -e 's/,.*//'` acl_libdirstem2=`echo "$acl_cv_libdirstems" | sed -e 's/^[^,]*,//' -e 's/,.*//'` acl_libdirstem3=`echo "$acl_cv_libdirstems" | sed -e 's/^[^,]*,[^,]*,//' -e 's/,.*//'` changequote([,])dnl ]) # nls.m4 serial 6 (gettext-0.20.2) dnl Copyright (C) 1995-2003, 2005-2006, 2008-2014, 2016, 2019-2020 Free dnl Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl dnl This file can be used in projects which are not available under dnl the GNU General Public License or the GNU Lesser General Public dnl License but which still want to provide support for the GNU gettext dnl functionality. dnl Please note that the actual code of the GNU gettext library is covered dnl by the GNU Lesser General Public License, and the rest of the GNU dnl gettext package is covered by the GNU General Public License. dnl They are *not* in the public domain. dnl Authors: dnl Ulrich Drepper , 1995-2000. dnl Bruno Haible , 2000-2003. AC_PREREQ([2.50]) AC_DEFUN([AM_NLS], [ AC_MSG_CHECKING([whether NLS is requested]) dnl Default is enabled NLS AC_ARG_ENABLE([nls], [ --disable-nls do not use Native Language Support], USE_NLS=$enableval, USE_NLS=yes) AC_MSG_RESULT([$USE_NLS]) AC_SUBST([USE_NLS]) ]) # pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- # serial 11 (pkg-config-0.29.1) dnl Copyright © 2004 Scott James Remnant . dnl Copyright © 2012-2015 Dan Nicholson dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, but dnl WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU dnl General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA dnl 02111-1307, USA. dnl dnl As a special exception to the GNU General Public License, if you dnl distribute this file as part of a program that contains a dnl configuration script generated by Autoconf, you may include it under dnl the same distribution terms that you use for the rest of that dnl program. dnl PKG_PREREQ(MIN-VERSION) dnl ----------------------- dnl Since: 0.29 dnl dnl Verify that the version of the pkg-config macros are at least dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's dnl installed version of pkg-config, this checks the developer's version dnl of pkg.m4 when generating configure. dnl dnl To ensure that this macro is defined, also add: dnl m4_ifndef([PKG_PREREQ], dnl [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])]) dnl dnl See the "Since" comment for each macro you use to see what version dnl of the macros you require. m4_defun([PKG_PREREQ], [m4_define([PKG_MACROS_VERSION], [0.29.1]) m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1, [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])]) ])dnl PKG_PREREQ dnl PKG_PROG_PKG_CONFIG([MIN-VERSION]) dnl ---------------------------------- dnl Since: 0.16 dnl dnl Search for the pkg-config tool and set the PKG_CONFIG variable to dnl first found in the path. Checks that the version of pkg-config found dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is dnl used since that's the first version where most current features of dnl pkg-config existed. AC_DEFUN([PKG_PROG_PKG_CONFIG], [m4_pattern_forbid([^_?PKG_[A-Z_]+$]) m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) fi if test -n "$PKG_CONFIG"; then _pkg_min_version=m4_default([$1], [0.9.0]) AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) PKG_CONFIG="" fi fi[]dnl ])dnl PKG_PROG_PKG_CONFIG dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) dnl ------------------------------------------------------------------- dnl Since: 0.18 dnl dnl Check to see whether a particular set of modules exists. Similar to dnl PKG_CHECK_MODULES(), but does not set variables or print errors. dnl dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) dnl only at the first occurence in configure.ac, so if the first place dnl it's called might be skipped (such as if it is within an "if", you dnl have to call PKG_CHECK_EXISTS manually AC_DEFUN([PKG_CHECK_EXISTS], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl if test -n "$PKG_CONFIG" && \ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then m4_default([$2], [:]) m4_ifvaln([$3], [else $3])dnl fi]) dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) dnl --------------------------------------------- dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting dnl pkg_failed based on the result. m4_define([_PKG_CONFIG], [if test -n "$$1"; then pkg_cv_[]$1="$$1" elif test -n "$PKG_CONFIG"; then PKG_CHECK_EXISTS([$3], [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes ], [pkg_failed=yes]) else pkg_failed=untried fi[]dnl ])dnl _PKG_CONFIG dnl _PKG_SHORT_ERRORS_SUPPORTED dnl --------------------------- dnl Internal check to see if pkg-config supports short errors. AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], [AC_REQUIRE([PKG_PROG_PKG_CONFIG]) if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi[]dnl ])dnl _PKG_SHORT_ERRORS_SUPPORTED dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], dnl [ACTION-IF-NOT-FOUND]) dnl -------------------------------------------------------------- dnl Since: 0.4.0 dnl dnl Note that if there is a possibility the first call to dnl PKG_CHECK_MODULES might not happen, you should be sure to include an dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac AC_DEFUN([PKG_CHECK_MODULES], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl pkg_failed=no AC_MSG_CHECKING([for $1]) _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) _PKG_CONFIG([$1][_LIBS], [libs], [$2]) m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS and $1[]_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.]) if test $pkg_failed = yes; then AC_MSG_RESULT([no]) _PKG_SHORT_ERRORS_SUPPORTED if test $_pkg_short_errors_supported = yes; then $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` else $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD m4_default([$4], [AC_MSG_ERROR( [Package requirements ($2) were not met: $$1_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. _PKG_TEXT])[]dnl ]) elif test $pkg_failed = untried; then AC_MSG_RESULT([no]) m4_default([$4], [AC_MSG_FAILURE( [The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. _PKG_TEXT To get pkg-config, see .])[]dnl ]) else $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS $1[]_LIBS=$pkg_cv_[]$1[]_LIBS AC_MSG_RESULT([yes]) $3 fi[]dnl ])dnl PKG_CHECK_MODULES dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], dnl [ACTION-IF-NOT-FOUND]) dnl --------------------------------------------------------------------- dnl Since: 0.29 dnl dnl Checks for existence of MODULES and gathers its build flags with dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags dnl and VARIABLE-PREFIX_LIBS from --libs. dnl dnl Note that if there is a possibility the first call to dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to dnl include an explicit call to PKG_PROG_PKG_CONFIG in your dnl configure.ac. AC_DEFUN([PKG_CHECK_MODULES_STATIC], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl _save_PKG_CONFIG=$PKG_CONFIG PKG_CONFIG="$PKG_CONFIG --static" PKG_CHECK_MODULES($@) PKG_CONFIG=$_save_PKG_CONFIG[]dnl ])dnl PKG_CHECK_MODULES_STATIC dnl PKG_INSTALLDIR([DIRECTORY]) dnl ------------------------- dnl Since: 0.27 dnl dnl Substitutes the variable pkgconfigdir as the location where a module dnl should install pkg-config .pc files. By default the directory is dnl $libdir/pkgconfig, but the default can be changed by passing dnl DIRECTORY. The user can override through the --with-pkgconfigdir dnl parameter. AC_DEFUN([PKG_INSTALLDIR], [m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])]) m4_pushdef([pkg_description], [pkg-config installation directory @<:@]pkg_default[@:>@]) AC_ARG_WITH([pkgconfigdir], [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],, [with_pkgconfigdir=]pkg_default) AC_SUBST([pkgconfigdir], [$with_pkgconfigdir]) m4_popdef([pkg_default]) m4_popdef([pkg_description]) ])dnl PKG_INSTALLDIR dnl PKG_NOARCH_INSTALLDIR([DIRECTORY]) dnl -------------------------------- dnl Since: 0.27 dnl dnl Substitutes the variable noarch_pkgconfigdir as the location where a dnl module should install arch-independent pkg-config .pc files. By dnl default the directory is $datadir/pkgconfig, but the default can be dnl changed by passing DIRECTORY. The user can override through the dnl --with-noarch-pkgconfigdir parameter. AC_DEFUN([PKG_NOARCH_INSTALLDIR], [m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])]) m4_pushdef([pkg_description], [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@]) AC_ARG_WITH([noarch-pkgconfigdir], [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],, [with_noarch_pkgconfigdir=]pkg_default) AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir]) m4_popdef([pkg_default]) m4_popdef([pkg_description]) ])dnl PKG_NOARCH_INSTALLDIR dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) dnl ------------------------------------------- dnl Since: 0.28 dnl dnl Retrieves the value of the pkg-config variable for the given module. AC_DEFUN([PKG_CHECK_VAR], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl _PKG_CONFIG([$1], [variable="][$3]["], [$2]) AS_VAR_COPY([$1], [pkg_cv_][$1]) AS_VAR_IF([$1], [""], [$5], [$4])dnl ])dnl PKG_CHECK_VAR dnl PKG_WITH_MODULES(VARIABLE-PREFIX, MODULES, dnl [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND], dnl [DESCRIPTION], [DEFAULT]) dnl ------------------------------------------ dnl dnl Prepare a "--with-" configure option using the lowercase dnl [VARIABLE-PREFIX] name, merging the behaviour of AC_ARG_WITH and dnl PKG_CHECK_MODULES in a single macro. AC_DEFUN([PKG_WITH_MODULES], [ m4_pushdef([with_arg], m4_tolower([$1])) m4_pushdef([description], [m4_default([$5], [build with ]with_arg[ support])]) m4_pushdef([def_arg], [m4_default([$6], [auto])]) m4_pushdef([def_action_if_found], [AS_TR_SH([with_]with_arg)=yes]) m4_pushdef([def_action_if_not_found], [AS_TR_SH([with_]with_arg)=no]) m4_case(def_arg, [yes],[m4_pushdef([with_without], [--without-]with_arg)], [m4_pushdef([with_without],[--with-]with_arg)]) AC_ARG_WITH(with_arg, AS_HELP_STRING(with_without, description[ @<:@default=]def_arg[@:>@]),, [AS_TR_SH([with_]with_arg)=def_arg]) AS_CASE([$AS_TR_SH([with_]with_arg)], [yes],[PKG_CHECK_MODULES([$1],[$2],$3,$4)], [auto],[PKG_CHECK_MODULES([$1],[$2], [m4_n([def_action_if_found]) $3], [m4_n([def_action_if_not_found]) $4])]) m4_popdef([with_arg]) m4_popdef([description]) m4_popdef([def_arg]) ])dnl PKG_WITH_MODULES dnl PKG_HAVE_WITH_MODULES(VARIABLE-PREFIX, MODULES, dnl [DESCRIPTION], [DEFAULT]) dnl ----------------------------------------------- dnl dnl Convenience macro to trigger AM_CONDITIONAL after PKG_WITH_MODULES dnl check._[VARIABLE-PREFIX] is exported as make variable. AC_DEFUN([PKG_HAVE_WITH_MODULES], [ PKG_WITH_MODULES([$1],[$2],,,[$3],[$4]) AM_CONDITIONAL([HAVE_][$1], [test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"]) ])dnl PKG_HAVE_WITH_MODULES dnl PKG_HAVE_DEFINE_WITH_MODULES(VARIABLE-PREFIX, MODULES, dnl [DESCRIPTION], [DEFAULT]) dnl ------------------------------------------------------ dnl dnl Convenience macro to run AM_CONDITIONAL and AC_DEFINE after dnl PKG_WITH_MODULES check. HAVE_[VARIABLE-PREFIX] is exported as make dnl and preprocessor variable. AC_DEFUN([PKG_HAVE_DEFINE_WITH_MODULES], [ PKG_HAVE_WITH_MODULES([$1],[$2],[$3],[$4]) AS_IF([test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"], [AC_DEFINE([HAVE_][$1], 1, [Enable ]m4_tolower([$1])[ support])]) ])dnl PKG_HAVE_DEFINE_WITH_MODULES # po.m4 serial 31 (gettext-0.20.2) dnl Copyright (C) 1995-2014, 2016, 2018-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl dnl This file can be used in projects which are not available under dnl the GNU General Public License or the GNU Lesser General Public dnl License but which still want to provide support for the GNU gettext dnl functionality. dnl Please note that the actual code of the GNU gettext library is covered dnl by the GNU Lesser General Public License, and the rest of the GNU dnl gettext package is covered by the GNU General Public License. dnl They are *not* in the public domain. dnl Authors: dnl Ulrich Drepper , 1995-2000. dnl Bruno Haible , 2000-2003. AC_PREREQ([2.60]) dnl Checks for all prerequisites of the po subdirectory. AC_DEFUN([AM_PO_SUBDIRS], [ AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl AC_REQUIRE([AC_PROG_SED])dnl AC_REQUIRE([AM_NLS])dnl dnl Release version of the gettext macros. This is used to ensure that dnl the gettext macros and po/Makefile.in.in are in sync. AC_SUBST([GETTEXT_MACRO_VERSION], [0.20]) dnl Perform the following tests also if --disable-nls has been given, dnl because they are needed for "make dist" to work. dnl Search for GNU msgfmt in the PATH. dnl The first test excludes Solaris msgfmt and early GNU msgfmt versions. dnl The second test excludes FreeBSD msgfmt. AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt, [$ac_dir/$ac_word --statistics /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 && (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)], :) AC_PATH_PROG([GMSGFMT], [gmsgfmt], [$MSGFMT]) dnl Test whether it is GNU msgfmt >= 0.15. changequote(,)dnl case `$GMSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) GMSGFMT_015=: ;; *) GMSGFMT_015=$GMSGFMT ;; esac changequote([,])dnl AC_SUBST([GMSGFMT_015]) dnl Search for GNU xgettext 0.12 or newer in the PATH. dnl The first test excludes Solaris xgettext and early GNU xgettext versions. dnl The second test excludes FreeBSD xgettext. AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext, [$ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 && (if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)], :) dnl Remove leftover from FreeBSD xgettext call. rm -f messages.po dnl Test whether it is GNU xgettext >= 0.15. changequote(,)dnl case `$XGETTEXT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) XGETTEXT_015=: ;; *) XGETTEXT_015=$XGETTEXT ;; esac changequote([,])dnl AC_SUBST([XGETTEXT_015]) dnl Search for GNU msgmerge 0.11 or newer in the PATH. AM_PATH_PROG_WITH_TEST(MSGMERGE, msgmerge, [$ac_dir/$ac_word --update -q /dev/null /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1], :) dnl Test whether it is GNU msgmerge >= 0.20. if LC_ALL=C $MSGMERGE --help | grep ' --for-msgfmt ' >/dev/null; then MSGMERGE_FOR_MSGFMT_OPTION='--for-msgfmt' else dnl Test whether it is GNU msgmerge >= 0.12. if LC_ALL=C $MSGMERGE --help | grep ' --no-fuzzy-matching ' >/dev/null; then MSGMERGE_FOR_MSGFMT_OPTION='--no-fuzzy-matching --no-location --quiet' else dnl With these old versions, $(MSGMERGE) $(MSGMERGE_FOR_MSGFMT_OPTION) is dnl slow. But this is not a big problem, as such old gettext versions are dnl hardly in use any more. MSGMERGE_FOR_MSGFMT_OPTION='--no-location --quiet' fi fi AC_SUBST([MSGMERGE_FOR_MSGFMT_OPTION]) dnl Support for AM_XGETTEXT_OPTION. test -n "${XGETTEXT_EXTRA_OPTIONS+set}" || XGETTEXT_EXTRA_OPTIONS= AC_SUBST([XGETTEXT_EXTRA_OPTIONS]) AC_CONFIG_COMMANDS([po-directories], [[ for ac_file in $CONFIG_FILES; do # Support "outfile[:infile[:infile...]]" case "$ac_file" in *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; esac # PO directories have a Makefile.in generated from Makefile.in.in. case "$ac_file" in */Makefile.in) # Adjust a relative srcdir. ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'` ac_dir_suffix=/`echo "$ac_dir"|sed 's%^\./%%'` ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'` # In autoconf-2.13 it is called $ac_given_srcdir. # In autoconf-2.50 it is called $srcdir. test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir" case "$ac_given_srcdir" in .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;; /*) top_srcdir="$ac_given_srcdir" ;; *) top_srcdir="$ac_dots$ac_given_srcdir" ;; esac # Treat a directory as a PO directory if and only if it has a # POTFILES.in file. This allows packages to have multiple PO # directories under different names or in different locations. if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then rm -f "$ac_dir/POTFILES" test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES" gt_tab=`printf '\t'` cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[ ${gt_tab}]*\$/d" -e "s,.*, $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES" POMAKEFILEDEPS="POTFILES.in" # ALL_LINGUAS, POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES depend # on $ac_dir but don't depend on user-specified configuration # parameters. if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then # The LINGUAS file contains the set of available languages. if test -n "$OBSOLETE_ALL_LINGUAS"; then test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete" fi ALL_LINGUAS=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"` POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS" else # The set of available languages was given in configure.in. ALL_LINGUAS=$OBSOLETE_ALL_LINGUAS fi # Compute POFILES # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po) # Compute UPDATEPOFILES # as $(foreach lang, $(ALL_LINGUAS), $(lang).po-update) # Compute DUMMYPOFILES # as $(foreach lang, $(ALL_LINGUAS), $(lang).nop) # Compute GMOFILES # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).gmo) case "$ac_given_srcdir" in .) srcdirpre= ;; *) srcdirpre='$(srcdir)/' ;; esac POFILES= UPDATEPOFILES= DUMMYPOFILES= GMOFILES= for lang in $ALL_LINGUAS; do POFILES="$POFILES $srcdirpre$lang.po" UPDATEPOFILES="$UPDATEPOFILES $lang.po-update" DUMMYPOFILES="$DUMMYPOFILES $lang.nop" GMOFILES="$GMOFILES $srcdirpre$lang.gmo" done # CATALOGS depends on both $ac_dir and the user's LINGUAS # environment variable. INST_LINGUAS= if test -n "$ALL_LINGUAS"; then for presentlang in $ALL_LINGUAS; do useit=no if test "%UNSET%" != "$LINGUAS"; then desiredlanguages="$LINGUAS" else desiredlanguages="$ALL_LINGUAS" fi for desiredlang in $desiredlanguages; do # Use the presentlang catalog if desiredlang is # a. equal to presentlang, or # b. a variant of presentlang (because in this case, # presentlang can be used as a fallback for messages # which are not translated in the desiredlang catalog). case "$desiredlang" in "$presentlang"*) useit=yes;; esac done if test $useit = yes; then INST_LINGUAS="$INST_LINGUAS $presentlang" fi done fi CATALOGS= if test -n "$INST_LINGUAS"; then for lang in $INST_LINGUAS; do CATALOGS="$CATALOGS $lang.gmo" done fi test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile" sed -e "/^POTFILES =/r $ac_dir/POTFILES" -e "/^# Makevars/r $ac_given_srcdir/$ac_dir/Makevars" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@POMAKEFILEDEPS@|$POMAKEFILEDEPS|g" "$ac_dir/Makefile.in" > "$ac_dir/Makefile" for f in "$ac_given_srcdir/$ac_dir"/Rules-*; do if test -f "$f"; then case "$f" in *.orig | *.bak | *~) ;; *) cat "$f" >> "$ac_dir/Makefile" ;; esac fi done fi ;; esac done]], [# Capture the value of obsolete ALL_LINGUAS because we need it to compute # POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES, CATALOGS. OBSOLETE_ALL_LINGUAS="$ALL_LINGUAS" # Capture the value of LINGUAS because we need it to compute CATALOGS. LINGUAS="${LINGUAS-%UNSET%}" ]) ]) dnl Postprocesses a Makefile in a directory containing PO files. AC_DEFUN([AM_POSTPROCESS_PO_MAKEFILE], [ # When this code is run, in config.status, two variables have already been # set: # - OBSOLETE_ALL_LINGUAS is the value of LINGUAS set in configure.in, # - LINGUAS is the value of the environment variable LINGUAS at configure # time. changequote(,)dnl # Adjust a relative srcdir. ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'` ac_dir_suffix=/`echo "$ac_dir"|sed 's%^\./%%'` ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'` # In autoconf-2.13 it is called $ac_given_srcdir. # In autoconf-2.50 it is called $srcdir. test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir" case "$ac_given_srcdir" in .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;; /*) top_srcdir="$ac_given_srcdir" ;; *) top_srcdir="$ac_dots$ac_given_srcdir" ;; esac # Find a way to echo strings without interpreting backslash. if test "X`(echo '\t') 2>/dev/null`" = 'X\t'; then gt_echo='echo' else if test "X`(printf '%s\n' '\t') 2>/dev/null`" = 'X\t'; then gt_echo='printf %s\n' else echo_func () { cat < "$ac_file.tmp" tab=`printf '\t'` if grep -l '@TCLCATALOGS@' "$ac_file" > /dev/null; then # Add dependencies that cannot be formulated as a simple suffix rule. for lang in $ALL_LINGUAS; do frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` cat >> "$ac_file.tmp" < /dev/null; then # Add dependencies that cannot be formulated as a simple suffix rule. for lang in $ALL_LINGUAS; do frobbedlang=`echo $lang | sed -e 's/_/-/g' -e 's/^sr-CS/sr-SP/' -e 's/@latin$/-Latn/' -e 's/@cyrillic$/-Cyrl/' -e 's/^sr-SP$/sr-SP-Latn/' -e 's/^uz-UZ$/uz-UZ-Latn/'` cat >> "$ac_file.tmp" <> "$ac_file.tmp" <, 1996. AC_PREREQ([2.50]) # Search path for a program which passes the given test. dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR, dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]]) AC_DEFUN([AM_PATH_PROG_WITH_TEST], [ # Prepare PATH_SEPARATOR. # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which # contains only /bin. Note that ksh looks also at the FPATH variable, # so we have to set that as well for the test. PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ || PATH_SEPARATOR=';' } fi # Find out how to test for executable files. Don't use a zero-byte file, # as systems may use methods other than mode bits to determine executability. cat >conf$$.file <<_ASEOF #! /bin/sh exit 0 _ASEOF chmod +x conf$$.file if test -x conf$$.file >/dev/null 2>&1; then ac_executable_p="test -x" else ac_executable_p="test -f" fi rm -f conf$$.file # Extract the first word of "$2", so it can be a program name with args. set dummy $2; ac_word=[$]2 AC_MSG_CHECKING([for $ac_word]) AC_CACHE_VAL([ac_cv_path_$1], [case "[$]$1" in [[\\/]]* | ?:[[\\/]]*) ac_cv_path_$1="[$]$1" # Let the user override the test with a path. ;; *) ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in ifelse([$5], , $PATH, [$5]); do IFS="$ac_save_IFS" test -z "$ac_dir" && ac_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then echo "$as_me: trying $ac_dir/$ac_word..." >&AS_MESSAGE_LOG_FD if [$3]; then ac_cv_path_$1="$ac_dir/$ac_word$ac_exec_ext" break 2 fi fi done done IFS="$ac_save_IFS" dnl If no 4th arg is given, leave the cache variable unset, dnl so AC_PATH_PROGS will keep looking. ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4" ])dnl ;; esac])dnl $1="$ac_cv_path_$1" if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then AC_MSG_RESULT([$][$1]) else AC_MSG_RESULT([no]) fi AC_SUBST([$1])dnl ]) # Copyright (C) 2002-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.16' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. m4_if([$1], [1.16.2], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) # _AM_AUTOCONF_VERSION(VERSION) # ----------------------------- # aclocal traces this macro to find the Autoconf version. # This is a private macro too. Using m4_define simplifies # the logic in aclocal, which can simply ignore this definition. m4_define([_AM_AUTOCONF_VERSION], []) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.16.2])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- # Copyright (C) 2001-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets # $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to # '$srcdir', '$srcdir/..', or '$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and # therefore $ac_aux_dir as well) can be either absolute or relative, # depending on how configure is run. This is pretty annoying, since # it makes $ac_aux_dir quite unusable in subdirectories: in the top # source directory, any form will work fine, but in subdirectories a # relative path needs to be adjusted first. # # $ac_aux_dir/missing # fails when called from a subdirectory if $ac_aux_dir is relative # $top_srcdir/$ac_aux_dir/missing # fails if $ac_aux_dir is absolute, # fails when called from a subdirectory in a VPATH build with # a relative $ac_aux_dir # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually # harmless because $srcdir is '.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, # iff we strip the leading $srcdir from $ac_aux_dir. That would be: # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` # and then we would define $MISSING as # MISSING="\${SHELL} $am_aux_dir/missing" # This will work as long as MISSING is not called from configure, because # unfortunately $(top_srcdir) has no meaning in configure. # However there are other variables, like CC, which are often used in # configure, and could therefore not use this "fixed" $ac_aux_dir. # # Another solution, used here, is to always expand $ac_aux_dir to an # absolute PATH. The drawback is that using absolute paths prevent a # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl # Expand $ac_aux_dir to an absolute path. am_aux_dir=`cd "$ac_aux_dir" && pwd` ]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [AC_PREREQ([2.52])dnl m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE])dnl AC_SUBST([$1_FALSE])dnl _AM_SUBST_NOTMAKE([$1_TRUE])dnl _AM_SUBST_NOTMAKE([$1_FALSE])dnl m4_define([_AM_COND_VALUE_$1], [$2])dnl if $2; then $1_TRUE= $1_FALSE='#' else $1_TRUE='#' $1_FALSE= fi AC_CONFIG_COMMANDS_PRE( [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then AC_MSG_ERROR([[conditional "$1" was never defined. Usually this means the macro was only invoked conditionally.]]) fi])]) # Copyright (C) 1999-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing # CC etc. in the Makefile, will ask for an AC_PROG_CC use... # _AM_DEPENDENCIES(NAME) # ---------------------- # See how the compiler implements dependency checking. # NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC". # We try a few techniques and use that to set a single cache variable. # # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular # dependency, and given that the user is not expected to run this macro, # just rely on AC_PROG_CC. AC_DEFUN([_AM_DEPENDENCIES], [AC_REQUIRE([AM_SET_DEPDIR])dnl AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl m4_if([$1], [CC], [depcc="$CC" am_compiler_list=], [$1], [CXX], [depcc="$CXX" am_compiler_list=], [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'], [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'], [$1], [UPC], [depcc="$UPC" am_compiler_list=], [$1], [GCJ], [depcc="$GCJ" am_compiler_list='gcc3 gcc'], [depcc="$$1" am_compiler_list=]) AC_CACHE_CHECK([dependency style of $depcc], [am_cv_$1_dependencies_compiler_type], [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_$1_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` fi am__universal=false m4_case([$1], [CC], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac], [CXX], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac]) for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_$1_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_$1_dependencies_compiler_type=none fi ]) AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) AM_CONDITIONAL([am__fastdep$1], [ test "x$enable_dependency_tracking" != xno \ && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) ]) # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. # This macro is AC_REQUIREd in _AM_DEPENDENCIES. AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl ]) # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], [AC_ARG_ENABLE([dependency-tracking], [dnl AS_HELP_STRING( [--enable-dependency-tracking], [do not reject slow dependency extractors]) AS_HELP_STRING( [--disable-dependency-tracking], [speeds up one-time build])]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl AC_SUBST([am__nodep])dnl _AM_SUBST_NOTMAKE([am__nodep])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- # Copyright (C) 1999-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [{ # Older Autoconf quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. # TODO: see whether this extra hack can be removed once we start # requiring Autoconf 2.70 or later. AS_CASE([$CONFIG_FILES], [*\'*], [eval set x "$CONFIG_FILES"], [*], [set x $CONFIG_FILES]) shift # Used to flag and report bootstrapping failures. am_rc=0 for am_mf do # Strip MF so we end up with the name of the file. am_mf=`AS_ECHO(["$am_mf"]) | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile which includes # dependency-tracking related rules and includes. # Grep'ing the whole file directly is not great: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. sed -n 's,^am--depfiles:.*,X,p' "$am_mf" | grep X >/dev/null 2>&1 \ || continue am_dirpart=`AS_DIRNAME(["$am_mf"])` am_filepart=`AS_BASENAME(["$am_mf"])` AM_RUN_LOG([cd "$am_dirpart" \ && sed -e '/# am--include-marker/d' "$am_filepart" \ | $MAKE -f - am--depfiles]) || am_rc=$? done if test $am_rc -ne 0; then AC_MSG_FAILURE([Something went wrong bootstrapping makefile fragments for automatic dependency tracking. If GNU make was not used, consider re-running the configure script with MAKE="gmake" (or whatever is necessary). You can also try re-running configure with the '--disable-dependency-tracking' option to at least be able to build the package (albeit without support for automatic dependency tracking).]) fi AS_UNSET([am_dirpart]) AS_UNSET([am_filepart]) AS_UNSET([am_mf]) AS_UNSET([am_rc]) rm -f conftest-deps.mk } ])# _AM_OUTPUT_DEPENDENCY_COMMANDS # AM_OUTPUT_DEPENDENCY_COMMANDS # ----------------------------- # This macro should only be invoked once -- use via AC_REQUIRE. # # This code is only required when automatic dependency tracking is enabled. # This creates each '.Po' and '.Plo' makefile fragment that we'll need in # order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], [AMDEP_TRUE="$AMDEP_TRUE" MAKE="${MAKE-make}"])]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O. m4_define([AC_PROG_CC], m4_defn([AC_PROG_CC]) [_AM_PROG_CC_C_O ]) # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- # The call with PACKAGE and VERSION arguments is the old style # call (pre autoconf-2.50), which is being phased out. PACKAGE # and VERSION should now be passed to AC_INIT and removed from # the call to AM_INIT_AUTOMAKE. # We support both call styles for the transition. After # the next Automake release, Autoconf can make the AC_INIT # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.65])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl # test to see if srcdir already configured if test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], [AC_DIAGNOSE([obsolete], [$0: two- and three-arguments forms are deprecated.]) m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. m4_if( m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]), [ok:ok],, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, [AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package]) AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}]) AM_MISSING_PROG([AUTOCONF], [autoconf]) AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}]) AM_MISSING_PROG([AUTOHEADER], [autoheader]) AM_MISSING_PROG([MAKEINFO], [makeinfo]) AC_REQUIRE([AM_PROG_INSTALL_SH])dnl AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: # # AC_SUBST([mkdir_p], ['$(MKDIR_P)']) # We need awk for the "check" target (and possibly the TAP driver). The # system "awk" is bad on some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], [_AM_DEPENDENCIES([CC])], [m4_define([AC_PROG_CC], m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES([CXX])], [m4_define([AC_PROG_CXX], m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], [_AM_DEPENDENCIES([OBJC])], [m4_define([AC_PROG_OBJC], m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], [_AM_DEPENDENCIES([OBJCXX])], [m4_define([AC_PROG_OBJCXX], m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl ]) AC_REQUIRE([AM_SILENT_RULES])dnl dnl The testsuite driver may need to know about EXEEXT, so add the dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl # POSIX will say in a future version that running "rm -f" with no argument # is OK; and we want to be able to make that assumption in our Makefile # recipes. So use an aggressive probe to check that the usage we want is # actually supported "in the wild" to an acceptable degree. # See automake bug#10828. # To make any issue more visible, cause the running configure to be aborted # by default if the 'rm' program in use doesn't match our expectations; the # user can still override this though. if rm -f && rm -fr && rm -rf; then : OK; else cat >&2 <<'END' Oops! Your 'rm' program seems unable to run without file operands specified on the command line, even when the '-f' option is present. This is contrary to the behaviour of most rm programs out there, and not conforming with the upcoming POSIX standard: Please tell bug-automake@gnu.org about your system, including the value of your $PATH and any error possibly output before this message. This can help us improve future automake versions. END if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then echo 'Configuration will proceed anyway, since you have set the' >&2 echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 echo >&2 else cat >&2 <<'END' Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation that behaves properly: . If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM to "yes", and re-run configure. END AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) fi fi dnl The trailing newline in this macro's definition is deliberate, for dnl backward compatibility and to allow trailing 'dnl'-style comments dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841. ]) dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the # loop where config.status creates the headers, so we can generate # our stamp files there. AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], [# Compute $1's index in $config_headers. _am_arg=$1 _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) # Copyright (C) 2001-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl if test x"${install_sh+set}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi AC_SUBST([install_sh])]) # Copyright (C) 2003-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], [rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) # Check to see how 'make' treats includes. -*- Autoconf -*- # Copyright (C) 2001-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_MAKE_INCLUDE() # ----------------- # Check whether make has an 'include' directive that can support all # the idioms we need for our automatic dependency tracking code. AC_DEFUN([AM_MAKE_INCLUDE], [AC_MSG_CHECKING([whether ${MAKE-make} supports the include directive]) cat > confinc.mk << 'END' am__doit: @echo this is the am__doit target >confinc.out .PHONY: am__doit END am__include="#" am__quote= # BSD make does it like this. echo '.include "confinc.mk" # ignored' > confmf.BSD # Other make implementations (GNU, Solaris 10, AIX) do it like this. echo 'include confinc.mk # ignored' > confmf.GNU _am_result=no for s in GNU BSD; do AM_RUN_LOG([${MAKE-make} -f confmf.$s && cat confinc.out]) AS_CASE([$?:`cat confinc.out 2>/dev/null`], ['0:this is the am__doit target'], [AS_CASE([$s], [BSD], [am__include='.include' am__quote='"'], [am__include='include' am__quote=''])]) if test "$am__include" != "#"; then _am_result="yes ($s style)" break fi done rm -f confinc.* confmf.* AC_MSG_RESULT([${_am_result}]) AC_SUBST([am__include])]) AC_SUBST([am__quote])]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], [AC_REQUIRE([AM_MISSING_HAS_RUN]) $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) # AM_MISSING_HAS_RUN # ------------------ # Define MISSING if not defined so far and test if it is modern enough. # If it is, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --is-lightweight"; then am_missing_run="$MISSING " else am_missing_run= AC_MSG_WARN(['missing' script is too old or missing]) fi ]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) # -------------------- # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], [m4_define(_AM_MANGLE_OPTION([$1]), [1])]) # _AM_SET_OPTIONS(OPTIONS) # ------------------------ # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) # ------------------------------------------- # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) # Copyright (C) 1999-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_PROG_CC_C_O # --------------- # Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC # to automatically call this. AC_DEFUN([_AM_PROG_CC_C_O], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([compile])dnl AC_LANG_PUSH([C])dnl AC_CACHE_CHECK( [whether $CC understands -c and -o together], [am_cv_prog_cc_c_o], [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])]) # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i]) if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi AC_LANG_POP([C])]) # For backward compatibility. AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) # Copyright (C) 2001-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_RUN_LOG(COMMAND) # ------------------- # Run COMMAND, save the exit status in ac_status, and log it. # (This has been adapted from Autoconf's _AC_RUN_LOG macro.) AC_DEFUN([AM_RUN_LOG], [{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD (exit $ac_status); }]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[[\\\"\#\$\&\'\`$am_lf]]*) AC_MSG_ERROR([unsafe absolute working directory name]);; esac case $srcdir in *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);; esac # Do 'set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( am_has_slept=no for am_try in 1 2; do echo "timestamp, slept: $am_has_slept" > conftest.file set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$[*]" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi if test "$[*]" != "X $srcdir/configure conftest.file" \ && test "$[*]" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi if test "$[2]" = conftest.file || test $am_try -eq 2; then break fi # Just in case. sleep 1 am_has_slept=yes done test "$[2]" = conftest.file ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi AC_MSG_RESULT([yes]) # If we didn't sleep, we still need to ensure time stamps of config.status and # generated files are strictly newer. am_sleep_pid= if grep 'slept: no' conftest.file >/dev/null 2>&1; then ( sleep 1 ) & am_sleep_pid=$! fi AC_CONFIG_COMMANDS_PRE( [AC_MSG_CHECKING([that generated files are newer than configure]) if test -n "$am_sleep_pid"; then # Hide warnings about reused PIDs. wait $am_sleep_pid 2>/dev/null fi AC_MSG_RESULT([done])]) rm -f conftest.file ]) # Copyright (C) 2009-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_SILENT_RULES([DEFAULT]) # -------------------------- # Enable less verbose build rules; with the default set to DEFAULT # ("yes" being less verbose, "no" or empty being verbose). AC_DEFUN([AM_SILENT_RULES], [AC_ARG_ENABLE([silent-rules], [dnl AS_HELP_STRING( [--enable-silent-rules], [less verbose build output (undo: "make V=1")]) AS_HELP_STRING( [--disable-silent-rules], [verbose build output (undo: "make V=0")])dnl ]) case $enable_silent_rules in @%:@ ((( yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; esac dnl dnl A few 'make' implementations (e.g., NonStop OS and NextStep) dnl do not support nested variable expansions. dnl See automake bug#9928 and bug#10237. am_make=${MAKE-make} AC_CACHE_CHECK([whether $am_make supports nested variables], [am_cv_make_support_nested_variables], [if AS_ECHO([['TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi]) if test $am_cv_make_support_nested_variables = yes; then dnl Using '$V' instead of '$(V)' breaks IRIX make. AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AC_SUBST([AM_V])dnl AM_SUBST_NOTMAKE([AM_V])dnl AC_SUBST([AM_DEFAULT_V])dnl AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl AC_SUBST([AM_DEFAULT_VERBOSITY])dnl AM_BACKSLASH='\' AC_SUBST([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) # Copyright (C) 2001-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_STRIP # --------------------- # One issue with vendor 'install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we # always use install-sh in "make install-strip", and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl # Installed binaries are usually stripped using 'strip' when the user # run "make install-strip". However 'strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the 'STRIP' environment variable to overrule this program. dnl Don't test for $cross_compiling = yes, because it might be 'maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) # Copyright (C) 2006-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. # This macro is traced by Automake. AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) # -------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- # Copyright (C) 2004-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. # FORMAT should be one of 'v7', 'ustar', or 'pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory # $tardir. # tardir=directory && $(am__tar) > result.tar # # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar # AC_DEFUN([_AM_PROG_TAR], [# Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AC_SUBST([AMTAR], ['$${TAR-tar}']) # We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' m4_if([$1], [v7], [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], [m4_case([$1], [ustar], [# The POSIX 1988 'ustar' format is defined with fixed-size fields. # There is notably a 21 bits limit for the UID and the GID. In fact, # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343 # and bug#13588). am_max_uid=2097151 # 2^21 - 1 am_max_gid=$am_max_uid # The $UID and $GID variables are not portable, so we need to resort # to the POSIX-mandated id(1) utility. Errors in the 'id' calls # below are definitely unexpected, so allow the users to see them # (that is, avoid stderr redirection). am_uid=`id -u || echo unknown` am_gid=`id -g || echo unknown` AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format]) if test $am_uid -le $am_max_uid; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none fi AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format]) if test $am_gid -le $am_max_gid; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none fi], [pax], [], [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) # Go ahead even if we have the value already cached. We do so because we # need to set the values for the 'am__tar' and 'am__untar' variables. _am_tools=${am_cv_prog_tar_$1-$_am_tools} for _am_tool in $_am_tools; do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do AM_RUN_LOG([$_am_tar --version]) && break done am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x $1 -w "$$tardir"' am__tar_='pax -L -x $1 -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H $1 -L' am__tar_='find "$tardir" -print | cpio -o -H $1 -L' am__untar='cpio -i -H $1 -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_$1}" && break # tar/untar a dummy directory, and stop if the command works. rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) rm -rf conftest.dir if test -s conftest.tar; then AM_RUN_LOG([$am__untar /dev/null 2>&1 && break fi done rm -rf conftest.dir AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) AC_MSG_RESULT([$am_cv_prog_tar_$1])]) AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR m4_include([m4/guestfs-ocaml-gettext.m4]) m4_include([m4/libtool.m4]) m4_include([m4/ltoptions.m4]) m4_include([m4/ltsugar.m4]) m4_include([m4/ltversion.m4]) m4_include([m4/lt~obsolete.m4]) m4_include([m4/ocaml.m4]) virt-v2v-1.44.2/PaxHeaders/Makefile.am0000644000000000000000000000013114035551123014411 xustar0030 mtime=1618399827.663070982 29 atime=1637862732.85449094 30 ctime=1637862786.606895423 virt-v2v-1.44.2/Makefile.am0000644000175000017500000001277514035551123016232 0ustar00rjonesrjones00000000000000# libguestfs # Copyright (C) 2009-2020 Red Hat Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. include $(top_srcdir)/common-rules.mk ACLOCAL_AMFLAGS = -I m4 SUBDIRS = common/mlstdutils # Files and other test data used by the tests. Must be before any # tests run, except tests/qemu. SUBDIRS += test-data SUBDIRS += gnulib/lib SUBDIRS += common/qemuopts SUBDIRS += common/utils SUBDIRS += common/mlutils SUBDIRS += common/mlpcre SUBDIRS += common/options SUBDIRS += common/mlgettext SUBDIRS += common/mlxml SUBDIRS += common/mltools SUBDIRS += common/mlcustomize SUBDIRS += common/mlv2v SUBDIRS += bundled/libvirt-ocaml SUBDIRS += v2v SUBDIRS += test-harness SUBDIRS += tests # bash-completion SUBDIRS += bash # Documentation SUBDIRS += docs # After all source files were used we can generate the translation strings SUBDIRS += po # po-docs must come after tools, inspector. if HAVE_PO4A SUBDIRS += po-docs endif # lib/guestfs-internal-all.h is a hack, remove it XXX EXTRA_DIST = \ .gitignore \ bugs-in-changelog.sh \ build-aux/config.rpath \ cfg.mk \ check-mli.sh \ common/.gitignore \ common/README \ COPYING \ lib/guestfs-internal-all.h \ ocaml-link.sh \ podcheck.pl \ tmp/.gitignore \ valgrind-suppressions \ website/bugs.png \ website/communicate.png \ website/documentation.png \ website/download.png \ website/draft.png \ website/draft.svg \ website/easytoread.css \ website/feed.css \ website/fish-5yrs.svg \ website/fish.png \ website/git.png \ website/index.css \ website/index.html.in \ website/pod.css \ website/standard.css # When doing 'make dist' update a few files automatically. # # po/POTFILES - files with ordinary extensions, but not OCaml files # po/POTFILES-ml - OCaml files, which need a special tool to translate dist-hook: po/POTFILES po/POTFILES-ml # For more information about translations, see po/Makefile.am. po/POTFILES: configure.ac rm -f $@ $@-t cd $(srcdir); \ find $(DIST_SUBDIRS) -name '*.c' | \ grep -v -E '^(po-docs|tests|test-data|bundled)/' | \ grep -v -E '/(dummy\.c)$$' | \ grep -v -E '.*-(tests)\.c$$' | \ LC_ALL=C sort -u > $@-t mv $@-t $@ po/POTFILES-ml: configure.ac rm -f $@ $@-t cd $(srcdir); \ find common/ml* v2v -name '*.ml' | \ grep -v '^common/mlprogress/' | \ grep -v '^common/mlvisit/' | \ grep -v '^v2v/config.ml$$' | \ grep -v -E '.*_tests\.ml$$' | \ LC_ALL=C sort > $@-t mv $@-t $@ # NB. podwrapper is an internal tool, so the man page mustn't be installed. # It should be noinst_MANS but that doesn't work. noinst_DATA = podwrapper.1 podwrapper.1: podwrapper.pl $(PODWRAPPER) \ --section 1 \ --man $@-t \ --license GPLv2+ \ --warning safe \ $< mv $@-t $@ # Make clean. CLEANFILES += \ pod2htm?.tmp \ tmp/disk* \ tmp/run-* \ tmp/valgrind-*.log clean-local: -rm -rf tmp/libguestfs?????? -rm -rf tmp/guestfs.* -rm -rf tmp/.guestfs-* -rm -rf tmp/null.* -find tmp -type s -delete -find . -name '*~' -delete check-valgrind: build-test-guests @errors=0; \ for f in `grep -l '^$@:' $(SUBDIRS:%=%/Makefile.am)`; do \ echo $(MAKE) -C `dirname $$f` $@; \ $(MAKE) -C `dirname $$f` $@ || (( errors++ )); \ done; \ exit $$(( $$errors ? 1 : 0 )) check-slow: build-test-guests @errors=0; \ for f in `grep -l '^$@:' $(SUBDIRS:%=%/Makefile.am)`; do \ echo $(MAKE) -C `dirname $$f` $@; \ $(MAKE) -C `dirname $$f` $@ || (( errors++ )); \ done; \ exit $$(( $$errors ? 1 : 0 )) build-test-guests: $(MAKE) -C test-data/phony-guests check # Some tests which run at the top level. TESTS = check-mli.sh # Commit everything in current directory to HEAD, and set commit # message to current version (only for maintainer). maintainer-commit: git commit -a -m "Version $(VERSION)." # Tag HEAD with current version (only for maintainer). maintainer-tag: git tag -a "v$(VERSION)" -m "Version $(VERSION) ($(BRANCH_TYPE))" -f # Maintainer only: check no files are missing from EXTRA_DIST rules, # and that all generated files have been included in the tarball. # (Note you must have done 'make dist') maintainer-check-extra-dist: zcat $(PACKAGE_NAME)-$(VERSION).tar.gz | tar tf - | sort | \ sed 's,^$(PACKAGE_NAME)-$(VERSION)/,,' > tmp/tarfiles ( git ls-files ; \ cd common; git ls-files | sed 's,^,common/,' ) | \ grep -v '^common$$' | \ grep -v '^common/edit/' | \ grep -v '^common/errnostring/' | \ grep -v '^common/mlprogress/' | \ grep -v '^common/mlvisit/' | \ grep -v '^common/parallel/' | \ grep -v '^common/progress/' | \ grep -v '^common/protocol/' | \ grep -v '^common/structs/' | \ grep -v '^common/visit/' | \ grep -v '^common/windows/' | \ grep -v '^intltool-.*\.in' | \ grep -v '^\.gitmodules' | \ sort > tmp/gitfiles comm -13 tmp/tarfiles tmp/gitfiles > tmp/comm-out @echo Checking for differences between EXTRA_DIST and git ... cat tmp/comm-out [ ! -s tmp/comm-out ] rm tmp/tarfiles tmp/gitfiles tmp/comm-out @echo PASS: EXTRA_DIST tests virt-v2v-1.44.2/PaxHeaders/bundled0000644000000000000000000000013214147746606013736 xustar0030 mtime=1637862790.478852525 30 atime=1637862793.119823266 30 ctime=1637862790.478852525 virt-v2v-1.44.2/bundled/0000755000175000017500000000000014147746606015617 5ustar00rjonesrjones00000000000000virt-v2v-1.44.2/bundled/PaxHeaders/libvirt-ocaml0000644000000000000000000000013214147746606016502 xustar0030 mtime=1637862790.586851329 30 atime=1637862793.119823266 30 ctime=1637862790.586851329 virt-v2v-1.44.2/bundled/libvirt-ocaml/0000755000175000017500000000000014147746606020363 5ustar00rjonesrjones00000000000000virt-v2v-1.44.2/bundled/libvirt-ocaml/PaxHeaders/libvirt.ml0000644000000000000000000000013113631710510020541 xustar0029 mtime=1583845704.12687103 30 atime=1637862772.146055633 30 ctime=1637862790.581851385 virt-v2v-1.44.2/bundled/libvirt-ocaml/libvirt.ml0000664000175000017500000016230713631710510022361 0ustar00rjonesrjones00000000000000(* OCaml bindings for libvirt. (C) Copyright 2007-2015 Richard W.M. Jones, Red Hat Inc. https://libvirt.org/ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version, with the OCaml linking exception described in ../COPYING.LIB. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *) type uuid = string type xml = string type filename = string external get_version : ?driver:string -> unit -> int * int = "ocaml_libvirt_get_version" let uuid_length = 16 let uuid_string_length = 36 (* https://caml.inria.fr/pub/ml-archives/caml-list/2004/07/80683af867cce6bf8fff273973f70c95.en.html *) type rw = [`R|`W] type ro = [`R] module Connect = struct type 'rw t type node_info = { model : string; memory : int64; cpus : int; mhz : int; nodes : int; sockets : int; cores : int; threads : int; } type credential_type = | CredentialUsername | CredentialAuthname | CredentialLanguage | CredentialCnonce | CredentialPassphrase | CredentialEchoprompt | CredentialNoechoprompt | CredentialRealm | CredentialExternal type credential = { typ : credential_type; prompt : string; challenge : string option; defresult : string option; } type auth = { credtype : credential_type list; cb : (credential list -> string option list); } type list_flag = | ListNoState | ListRunning | ListBlocked | ListPaused | ListShutdown | ListShutoff | ListCrashed | ListActive | ListInactive | ListAll external connect : ?name:string -> unit -> rw t = "ocaml_libvirt_connect_open" external connect_readonly : ?name:string -> unit -> ro t = "ocaml_libvirt_connect_open_readonly" external connect_auth : ?name:string -> auth -> rw t = "ocaml_libvirt_connect_open_auth" external connect_auth_readonly : ?name:string -> auth -> ro t = "ocaml_libvirt_connect_open_auth_readonly" external close : [>`R] t -> unit = "ocaml_libvirt_connect_close" external get_type : [>`R] t -> string = "ocaml_libvirt_connect_get_type" external get_version : [>`R] t -> int = "ocaml_libvirt_connect_get_version" external get_hostname : [>`R] t -> string = "ocaml_libvirt_connect_get_hostname" external get_uri : [>`R] t -> string = "ocaml_libvirt_connect_get_uri" external get_max_vcpus : [>`R] t -> ?type_:string -> unit -> int = "ocaml_libvirt_connect_get_max_vcpus" external list_domains : [>`R] t -> int -> int array = "ocaml_libvirt_connect_list_domains" external num_of_domains : [>`R] t -> int = "ocaml_libvirt_connect_num_of_domains" external get_capabilities : [>`R] t -> xml = "ocaml_libvirt_connect_get_capabilities" external num_of_defined_domains : [>`R] t -> int = "ocaml_libvirt_connect_num_of_defined_domains" external list_defined_domains : [>`R] t -> int -> string array = "ocaml_libvirt_connect_list_defined_domains" external num_of_networks : [>`R] t -> int = "ocaml_libvirt_connect_num_of_networks" external list_networks : [>`R] t -> int -> string array = "ocaml_libvirt_connect_list_networks" external num_of_defined_networks : [>`R] t -> int = "ocaml_libvirt_connect_num_of_defined_networks" external list_defined_networks : [>`R] t -> int -> string array = "ocaml_libvirt_connect_list_defined_networks" external num_of_pools : [>`R] t -> int = "ocaml_libvirt_connect_num_of_storage_pools" external list_pools : [>`R] t -> int -> string array = "ocaml_libvirt_connect_list_storage_pools" external num_of_defined_pools : [>`R] t -> int = "ocaml_libvirt_connect_num_of_defined_storage_pools" external list_defined_pools : [>`R] t -> int -> string array = "ocaml_libvirt_connect_list_defined_storage_pools" external num_of_secrets : [>`R] t -> int = "ocaml_libvirt_connect_num_of_secrets" external list_secrets : [>`R] t -> int -> string array = "ocaml_libvirt_connect_list_secrets" external get_node_info : [>`R] t -> node_info = "ocaml_libvirt_connect_get_node_info" external node_get_free_memory : [> `R] t -> int64 = "ocaml_libvirt_connect_node_get_free_memory" external node_get_cells_free_memory : [> `R] t -> int -> int -> int64 array = "ocaml_libvirt_connect_node_get_cells_free_memory" (* See VIR_NODEINFO_MAXCPUS macro defined in . *) let maxcpus_of_node_info { nodes = nodes; sockets = sockets; cores = cores; threads = threads } = nodes * sockets * cores * threads (* See VIR_CPU_MAPLEN macro defined in . *) let cpumaplen nr_cpus = (nr_cpus + 7) / 8 (* See VIR_USE_CPU, VIR_UNUSE_CPU, VIR_CPU_USABLE macros defined in . *) let use_cpu cpumap cpu = Bytes.set cpumap (cpu/8) (Char.chr (Char.code (Bytes.get cpumap (cpu/8)) lor (1 lsl (cpu mod 8)))) let unuse_cpu cpumap cpu = Bytes.set cpumap (cpu/8) (Char.chr (Char.code (Bytes.get cpumap (cpu/8)) land (lnot (1 lsl (cpu mod 8))))) let cpu_usable cpumaps maplen vcpu cpu = Char.code (Bytes.get cpumaps (vcpu*maplen + cpu/8)) land (1 lsl (cpu mod 8)) <> 0 external set_keep_alive : [>`R] t -> int -> int -> unit = "ocaml_libvirt_connect_set_keep_alive" (* Internal API needed for get_auth_default. *) external _credtypes_from_auth_default : unit -> credential_type list = "ocaml_libvirt_connect_credtypes_from_auth_default" external _call_auth_default_callback : credential list -> string option list = "ocaml_libvirt_connect_call_auth_default_callback" let get_auth_default () = { credtype = _credtypes_from_auth_default (); cb = _call_auth_default_callback; } external get_domain_capabilities : ?emulatorbin:string -> ?arch:string -> ?machine:string -> ?virttype:string -> [>`R] t -> string = "ocaml_libvirt_connect_get_domain_capabilities" external const : [>`R] t -> ro t = "%identity" end module Virterror = struct type code = | VIR_ERR_OK | VIR_ERR_INTERNAL_ERROR | VIR_ERR_NO_MEMORY | VIR_ERR_NO_SUPPORT | VIR_ERR_UNKNOWN_HOST | VIR_ERR_NO_CONNECT | VIR_ERR_INVALID_CONN | VIR_ERR_INVALID_DOMAIN | VIR_ERR_INVALID_ARG | VIR_ERR_OPERATION_FAILED | VIR_ERR_GET_FAILED | VIR_ERR_POST_FAILED | VIR_ERR_HTTP_ERROR | VIR_ERR_SEXPR_SERIAL | VIR_ERR_NO_XEN | VIR_ERR_XEN_CALL | VIR_ERR_OS_TYPE | VIR_ERR_NO_KERNEL | VIR_ERR_NO_ROOT | VIR_ERR_NO_SOURCE | VIR_ERR_NO_TARGET | VIR_ERR_NO_NAME | VIR_ERR_NO_OS | VIR_ERR_NO_DEVICE | VIR_ERR_NO_XENSTORE | VIR_ERR_DRIVER_FULL | VIR_ERR_CALL_FAILED | VIR_ERR_XML_ERROR | VIR_ERR_DOM_EXIST | VIR_ERR_OPERATION_DENIED | VIR_ERR_OPEN_FAILED | VIR_ERR_READ_FAILED | VIR_ERR_PARSE_FAILED | VIR_ERR_CONF_SYNTAX | VIR_ERR_WRITE_FAILED | VIR_ERR_XML_DETAIL | VIR_ERR_INVALID_NETWORK | VIR_ERR_NETWORK_EXIST | VIR_ERR_SYSTEM_ERROR | VIR_ERR_RPC | VIR_ERR_GNUTLS_ERROR | VIR_WAR_NO_NETWORK | VIR_ERR_NO_DOMAIN | VIR_ERR_NO_NETWORK | VIR_ERR_INVALID_MAC | VIR_ERR_AUTH_FAILED | VIR_ERR_INVALID_STORAGE_POOL | VIR_ERR_INVALID_STORAGE_VOL | VIR_WAR_NO_STORAGE | VIR_ERR_NO_STORAGE_POOL | VIR_ERR_NO_STORAGE_VOL | VIR_WAR_NO_NODE | VIR_ERR_INVALID_NODE_DEVICE | VIR_ERR_NO_NODE_DEVICE | VIR_ERR_NO_SECURITY_MODEL | VIR_ERR_OPERATION_INVALID | VIR_WAR_NO_INTERFACE | VIR_ERR_NO_INTERFACE | VIR_ERR_INVALID_INTERFACE | VIR_ERR_MULTIPLE_INTERFACES | VIR_WAR_NO_NWFILTER | VIR_ERR_INVALID_NWFILTER | VIR_ERR_NO_NWFILTER | VIR_ERR_BUILD_FIREWALL | VIR_WAR_NO_SECRET | VIR_ERR_INVALID_SECRET | VIR_ERR_NO_SECRET | VIR_ERR_CONFIG_UNSUPPORTED | VIR_ERR_OPERATION_TIMEOUT | VIR_ERR_MIGRATE_PERSIST_FAILED | VIR_ERR_HOOK_SCRIPT_FAILED | VIR_ERR_INVALID_DOMAIN_SNAPSHOT | VIR_ERR_NO_DOMAIN_SNAPSHOT | VIR_ERR_INVALID_STREAM | VIR_ERR_ARGUMENT_UNSUPPORTED | VIR_ERR_STORAGE_PROBE_FAILED | VIR_ERR_STORAGE_POOL_BUILT | VIR_ERR_SNAPSHOT_REVERT_RISKY | VIR_ERR_OPERATION_ABORTED | VIR_ERR_AUTH_CANCELLED | VIR_ERR_NO_DOMAIN_METADATA | VIR_ERR_MIGRATE_UNSAFE | VIR_ERR_OVERFLOW | VIR_ERR_BLOCK_COPY_ACTIVE | VIR_ERR_OPERATION_UNSUPPORTED | VIR_ERR_SSH | VIR_ERR_AGENT_UNRESPONSIVE | VIR_ERR_RESOURCE_BUSY | VIR_ERR_ACCESS_DENIED | VIR_ERR_DBUS_SERVICE | VIR_ERR_STORAGE_VOL_EXIST | VIR_ERR_CPU_INCOMPATIBLE | VIR_ERR_XML_INVALID_SCHEMA | VIR_ERR_MIGRATE_FINISH_OK | VIR_ERR_AUTH_UNAVAILABLE | VIR_ERR_NO_SERVER | VIR_ERR_NO_CLIENT | VIR_ERR_AGENT_UNSYNCED | VIR_ERR_LIBSSH | VIR_ERR_DEVICE_MISSING | VIR_ERR_INVALID_NWFILTER_BINDING | VIR_ERR_NO_NWFILTER_BINDING | VIR_ERR_INVALID_DOMAIN_CHECKPOINT | VIR_ERR_NO_DOMAIN_CHECKPOINT | VIR_ERR_NO_DOMAIN_BACKUP | VIR_ERR_INVALID_NETWORK_PORT | VIR_ERR_NETWORK_PORT_EXIST | VIR_ERR_NO_NETWORK_PORT | VIR_ERR_UNKNOWN of int let string_of_code = function | VIR_ERR_OK -> "VIR_ERR_OK" | VIR_ERR_INTERNAL_ERROR -> "VIR_ERR_INTERNAL_ERROR" | VIR_ERR_NO_MEMORY -> "VIR_ERR_NO_MEMORY" | VIR_ERR_NO_SUPPORT -> "VIR_ERR_NO_SUPPORT" | VIR_ERR_UNKNOWN_HOST -> "VIR_ERR_UNKNOWN_HOST" | VIR_ERR_NO_CONNECT -> "VIR_ERR_NO_CONNECT" | VIR_ERR_INVALID_CONN -> "VIR_ERR_INVALID_CONN" | VIR_ERR_INVALID_DOMAIN -> "VIR_ERR_INVALID_DOMAIN" | VIR_ERR_INVALID_ARG -> "VIR_ERR_INVALID_ARG" | VIR_ERR_OPERATION_FAILED -> "VIR_ERR_OPERATION_FAILED" | VIR_ERR_GET_FAILED -> "VIR_ERR_GET_FAILED" | VIR_ERR_POST_FAILED -> "VIR_ERR_POST_FAILED" | VIR_ERR_HTTP_ERROR -> "VIR_ERR_HTTP_ERROR" | VIR_ERR_SEXPR_SERIAL -> "VIR_ERR_SEXPR_SERIAL" | VIR_ERR_NO_XEN -> "VIR_ERR_NO_XEN" | VIR_ERR_XEN_CALL -> "VIR_ERR_XEN_CALL" | VIR_ERR_OS_TYPE -> "VIR_ERR_OS_TYPE" | VIR_ERR_NO_KERNEL -> "VIR_ERR_NO_KERNEL" | VIR_ERR_NO_ROOT -> "VIR_ERR_NO_ROOT" | VIR_ERR_NO_SOURCE -> "VIR_ERR_NO_SOURCE" | VIR_ERR_NO_TARGET -> "VIR_ERR_NO_TARGET" | VIR_ERR_NO_NAME -> "VIR_ERR_NO_NAME" | VIR_ERR_NO_OS -> "VIR_ERR_NO_OS" | VIR_ERR_NO_DEVICE -> "VIR_ERR_NO_DEVICE" | VIR_ERR_NO_XENSTORE -> "VIR_ERR_NO_XENSTORE" | VIR_ERR_DRIVER_FULL -> "VIR_ERR_DRIVER_FULL" | VIR_ERR_CALL_FAILED -> "VIR_ERR_CALL_FAILED" | VIR_ERR_XML_ERROR -> "VIR_ERR_XML_ERROR" | VIR_ERR_DOM_EXIST -> "VIR_ERR_DOM_EXIST" | VIR_ERR_OPERATION_DENIED -> "VIR_ERR_OPERATION_DENIED" | VIR_ERR_OPEN_FAILED -> "VIR_ERR_OPEN_FAILED" | VIR_ERR_READ_FAILED -> "VIR_ERR_READ_FAILED" | VIR_ERR_PARSE_FAILED -> "VIR_ERR_PARSE_FAILED" | VIR_ERR_CONF_SYNTAX -> "VIR_ERR_CONF_SYNTAX" | VIR_ERR_WRITE_FAILED -> "VIR_ERR_WRITE_FAILED" | VIR_ERR_XML_DETAIL -> "VIR_ERR_XML_DETAIL" | VIR_ERR_INVALID_NETWORK -> "VIR_ERR_INVALID_NETWORK" | VIR_ERR_NETWORK_EXIST -> "VIR_ERR_NETWORK_EXIST" | VIR_ERR_SYSTEM_ERROR -> "VIR_ERR_SYSTEM_ERROR" | VIR_ERR_RPC -> "VIR_ERR_RPC" | VIR_ERR_GNUTLS_ERROR -> "VIR_ERR_GNUTLS_ERROR" | VIR_WAR_NO_NETWORK -> "VIR_WAR_NO_NETWORK" | VIR_ERR_NO_DOMAIN -> "VIR_ERR_NO_DOMAIN" | VIR_ERR_NO_NETWORK -> "VIR_ERR_NO_NETWORK" | VIR_ERR_INVALID_MAC -> "VIR_ERR_INVALID_MAC" | VIR_ERR_AUTH_FAILED -> "VIR_ERR_AUTH_FAILED" | VIR_ERR_INVALID_STORAGE_POOL -> "VIR_ERR_INVALID_STORAGE_POOL" | VIR_ERR_INVALID_STORAGE_VOL -> "VIR_ERR_INVALID_STORAGE_VOL" | VIR_WAR_NO_STORAGE -> "VIR_WAR_NO_STORAGE" | VIR_ERR_NO_STORAGE_POOL -> "VIR_ERR_NO_STORAGE_POOL" | VIR_ERR_NO_STORAGE_VOL -> "VIR_ERR_NO_STORAGE_VOL" | VIR_WAR_NO_NODE -> "VIR_WAR_NO_NODE" | VIR_ERR_INVALID_NODE_DEVICE -> "VIR_ERR_INVALID_NODE_DEVICE" | VIR_ERR_NO_NODE_DEVICE -> "VIR_ERR_NO_NODE_DEVICE" | VIR_ERR_NO_SECURITY_MODEL -> "VIR_ERR_NO_SECURITY_MODEL" | VIR_ERR_OPERATION_INVALID -> "VIR_ERR_OPERATION_INVALID" | VIR_WAR_NO_INTERFACE -> "VIR_WAR_NO_INTERFACE" | VIR_ERR_NO_INTERFACE -> "VIR_ERR_NO_INTERFACE" | VIR_ERR_INVALID_INTERFACE -> "VIR_ERR_INVALID_INTERFACE" | VIR_ERR_MULTIPLE_INTERFACES -> "VIR_ERR_MULTIPLE_INTERFACES" | VIR_WAR_NO_NWFILTER -> "VIR_WAR_NO_NWFILTER" | VIR_ERR_INVALID_NWFILTER -> "VIR_ERR_INVALID_NWFILTER" | VIR_ERR_NO_NWFILTER -> "VIR_ERR_NO_NWFILTER" | VIR_ERR_BUILD_FIREWALL -> "VIR_ERR_BUILD_FIREWALL" | VIR_WAR_NO_SECRET -> "VIR_WAR_NO_SECRET" | VIR_ERR_INVALID_SECRET -> "VIR_ERR_INVALID_SECRET" | VIR_ERR_NO_SECRET -> "VIR_ERR_NO_SECRET" | VIR_ERR_CONFIG_UNSUPPORTED -> "VIR_ERR_CONFIG_UNSUPPORTED" | VIR_ERR_OPERATION_TIMEOUT -> "VIR_ERR_OPERATION_TIMEOUT" | VIR_ERR_MIGRATE_PERSIST_FAILED -> "VIR_ERR_MIGRATE_PERSIST_FAILED" | VIR_ERR_HOOK_SCRIPT_FAILED -> "VIR_ERR_HOOK_SCRIPT_FAILED" | VIR_ERR_INVALID_DOMAIN_SNAPSHOT -> "VIR_ERR_INVALID_DOMAIN_SNAPSHOT" | VIR_ERR_NO_DOMAIN_SNAPSHOT -> "VIR_ERR_NO_DOMAIN_SNAPSHOT" | VIR_ERR_INVALID_STREAM -> "VIR_ERR_INVALID_STREAM" | VIR_ERR_ARGUMENT_UNSUPPORTED -> "VIR_ERR_ARGUMENT_UNSUPPORTED" | VIR_ERR_STORAGE_PROBE_FAILED -> "VIR_ERR_STORAGE_PROBE_FAILED" | VIR_ERR_STORAGE_POOL_BUILT -> "VIR_ERR_STORAGE_POOL_BUILT" | VIR_ERR_SNAPSHOT_REVERT_RISKY -> "VIR_ERR_SNAPSHOT_REVERT_RISKY" | VIR_ERR_OPERATION_ABORTED -> "VIR_ERR_OPERATION_ABORTED" | VIR_ERR_AUTH_CANCELLED -> "VIR_ERR_AUTH_CANCELLED" | VIR_ERR_NO_DOMAIN_METADATA -> "VIR_ERR_NO_DOMAIN_METADATA" | VIR_ERR_MIGRATE_UNSAFE -> "VIR_ERR_MIGRATE_UNSAFE" | VIR_ERR_OVERFLOW -> "VIR_ERR_OVERFLOW" | VIR_ERR_BLOCK_COPY_ACTIVE -> "VIR_ERR_BLOCK_COPY_ACTIVE" | VIR_ERR_OPERATION_UNSUPPORTED -> "VIR_ERR_OPERATION_UNSUPPORTED" | VIR_ERR_SSH -> "VIR_ERR_SSH" | VIR_ERR_AGENT_UNRESPONSIVE -> "VIR_ERR_AGENT_UNRESPONSIVE" | VIR_ERR_RESOURCE_BUSY -> "VIR_ERR_RESOURCE_BUSY" | VIR_ERR_ACCESS_DENIED -> "VIR_ERR_ACCESS_DENIED" | VIR_ERR_DBUS_SERVICE -> "VIR_ERR_DBUS_SERVICE" | VIR_ERR_STORAGE_VOL_EXIST -> "VIR_ERR_STORAGE_VOL_EXIST" | VIR_ERR_CPU_INCOMPATIBLE -> "VIR_ERR_CPU_INCOMPATIBLE" | VIR_ERR_XML_INVALID_SCHEMA -> "VIR_ERR_XML_INVALID_SCHEMA" | VIR_ERR_MIGRATE_FINISH_OK -> "VIR_ERR_MIGRATE_FINISH_OK" | VIR_ERR_AUTH_UNAVAILABLE -> "VIR_ERR_AUTH_UNAVAILABLE" | VIR_ERR_NO_SERVER -> "VIR_ERR_NO_SERVER" | VIR_ERR_NO_CLIENT -> "VIR_ERR_NO_CLIENT" | VIR_ERR_AGENT_UNSYNCED -> "VIR_ERR_AGENT_UNSYNCED" | VIR_ERR_LIBSSH -> "VIR_ERR_LIBSSH" | VIR_ERR_DEVICE_MISSING -> "VIR_ERR_DEVICE_MISSING" | VIR_ERR_INVALID_NWFILTER_BINDING -> "VIR_ERR_INVALID_NWFILTER_BINDING" | VIR_ERR_NO_NWFILTER_BINDING -> "VIR_ERR_NO_NWFILTER_BINDING" | VIR_ERR_INVALID_DOMAIN_CHECKPOINT -> "VIR_ERR_INVALID_DOMAIN_CHECKPOINT" | VIR_ERR_NO_DOMAIN_CHECKPOINT -> "VIR_ERR_NO_DOMAIN_CHECKPOINT" | VIR_ERR_NO_DOMAIN_BACKUP -> "VIR_ERR_NO_DOMAIN_BACKUP" | VIR_ERR_INVALID_NETWORK_PORT -> "VIR_ERR_INVALID_NETWORK_PORT" | VIR_ERR_NETWORK_PORT_EXIST -> "VIR_ERR_NETWORK_PORT_EXIST" | VIR_ERR_NO_NETWORK_PORT -> "VIR_ERR_NO_NETWORK_PORT" | VIR_ERR_UNKNOWN i -> "VIR_ERR_" ^ string_of_int i type domain = | VIR_FROM_NONE | VIR_FROM_XEN | VIR_FROM_XEND | VIR_FROM_XENSTORE | VIR_FROM_SEXPR | VIR_FROM_XML | VIR_FROM_DOM | VIR_FROM_RPC | VIR_FROM_PROXY | VIR_FROM_CONF | VIR_FROM_QEMU | VIR_FROM_NET | VIR_FROM_TEST | VIR_FROM_REMOTE | VIR_FROM_OPENVZ | VIR_FROM_XENXM | VIR_FROM_STATS_LINUX | VIR_FROM_LXC | VIR_FROM_STORAGE | VIR_FROM_NETWORK | VIR_FROM_DOMAIN | VIR_FROM_UML | VIR_FROM_NODEDEV | VIR_FROM_XEN_INOTIFY | VIR_FROM_SECURITY | VIR_FROM_VBOX | VIR_FROM_INTERFACE | VIR_FROM_ONE | VIR_FROM_ESX | VIR_FROM_PHYP | VIR_FROM_SECRET | VIR_FROM_CPU | VIR_FROM_XENAPI | VIR_FROM_NWFILTER | VIR_FROM_HOOK | VIR_FROM_DOMAIN_SNAPSHOT | VIR_FROM_AUDIT | VIR_FROM_SYSINFO | VIR_FROM_STREAMS | VIR_FROM_VMWARE | VIR_FROM_EVENT | VIR_FROM_LIBXL | VIR_FROM_LOCKING | VIR_FROM_HYPERV | VIR_FROM_CAPABILITIES | VIR_FROM_URI | VIR_FROM_AUTH | VIR_FROM_DBUS | VIR_FROM_PARALLELS | VIR_FROM_DEVICE | VIR_FROM_SSH | VIR_FROM_LOCKSPACE | VIR_FROM_INITCTL | VIR_FROM_IDENTITY | VIR_FROM_CGROUP | VIR_FROM_ACCESS | VIR_FROM_SYSTEMD | VIR_FROM_BHYVE | VIR_FROM_CRYPTO | VIR_FROM_FIREWALL | VIR_FROM_POLKIT | VIR_FROM_THREAD | VIR_FROM_ADMIN | VIR_FROM_LOGGING | VIR_FROM_XENXL | VIR_FROM_PERF | VIR_FROM_LIBSSH | VIR_FROM_RESCTRL | VIR_FROM_FIREWALLD | VIR_FROM_DOMAIN_CHECKPOINT | VIR_FROM_TPM | VIR_FROM_BPF | VIR_FROM_UNKNOWN of int let string_of_domain = function | VIR_FROM_NONE -> "VIR_FROM_NONE" | VIR_FROM_XEN -> "VIR_FROM_XEN" | VIR_FROM_XEND -> "VIR_FROM_XEND" | VIR_FROM_XENSTORE -> "VIR_FROM_XENSTORE" | VIR_FROM_SEXPR -> "VIR_FROM_SEXPR" | VIR_FROM_XML -> "VIR_FROM_XML" | VIR_FROM_DOM -> "VIR_FROM_DOM" | VIR_FROM_RPC -> "VIR_FROM_RPC" | VIR_FROM_PROXY -> "VIR_FROM_PROXY" | VIR_FROM_CONF -> "VIR_FROM_CONF" | VIR_FROM_QEMU -> "VIR_FROM_QEMU" | VIR_FROM_NET -> "VIR_FROM_NET" | VIR_FROM_TEST -> "VIR_FROM_TEST" | VIR_FROM_REMOTE -> "VIR_FROM_REMOTE" | VIR_FROM_OPENVZ -> "VIR_FROM_OPENVZ" | VIR_FROM_XENXM -> "VIR_FROM_XENXM" | VIR_FROM_STATS_LINUX -> "VIR_FROM_STATS_LINUX" | VIR_FROM_LXC -> "VIR_FROM_LXC" | VIR_FROM_STORAGE -> "VIR_FROM_STORAGE" | VIR_FROM_NETWORK -> "VIR_FROM_NETWORK" | VIR_FROM_DOMAIN -> "VIR_FROM_DOMAIN" | VIR_FROM_UML -> "VIR_FROM_UML" | VIR_FROM_NODEDEV -> "VIR_FROM_NODEDEV" | VIR_FROM_XEN_INOTIFY -> "VIR_FROM_XEN_INOTIFY" | VIR_FROM_SECURITY -> "VIR_FROM_SECURITY" | VIR_FROM_VBOX -> "VIR_FROM_VBOX" | VIR_FROM_INTERFACE -> "VIR_FROM_INTERFACE" | VIR_FROM_ONE -> "VIR_FROM_ONE" | VIR_FROM_ESX -> "VIR_FROM_ESX" | VIR_FROM_PHYP -> "VIR_FROM_PHYP" | VIR_FROM_SECRET -> "VIR_FROM_SECRET" | VIR_FROM_CPU -> "VIR_FROM_CPU" | VIR_FROM_XENAPI -> "VIR_FROM_XENAPI" | VIR_FROM_NWFILTER -> "VIR_FROM_NWFILTER" | VIR_FROM_HOOK -> "VIR_FROM_HOOK" | VIR_FROM_DOMAIN_SNAPSHOT -> "VIR_FROM_DOMAIN_SNAPSHOT" | VIR_FROM_AUDIT -> "VIR_FROM_AUDIT" | VIR_FROM_SYSINFO -> "VIR_FROM_SYSINFO" | VIR_FROM_STREAMS -> "VIR_FROM_STREAMS" | VIR_FROM_VMWARE -> "VIR_FROM_VMWARE" | VIR_FROM_EVENT -> "VIR_FROM_EVENT" | VIR_FROM_LIBXL -> "VIR_FROM_LIBXL" | VIR_FROM_LOCKING -> "VIR_FROM_LOCKING" | VIR_FROM_HYPERV -> "VIR_FROM_HYPERV" | VIR_FROM_CAPABILITIES -> "VIR_FROM_CAPABILITIES" | VIR_FROM_URI -> "VIR_FROM_URI" | VIR_FROM_AUTH -> "VIR_FROM_AUTH" | VIR_FROM_DBUS -> "VIR_FROM_DBUS" | VIR_FROM_PARALLELS -> "VIR_FROM_PARALLELS" | VIR_FROM_DEVICE -> "VIR_FROM_DEVICE" | VIR_FROM_SSH -> "VIR_FROM_SSH" | VIR_FROM_LOCKSPACE -> "VIR_FROM_LOCKSPACE" | VIR_FROM_INITCTL -> "VIR_FROM_INITCTL" | VIR_FROM_IDENTITY -> "VIR_FROM_IDENTITY" | VIR_FROM_CGROUP -> "VIR_FROM_CGROUP" | VIR_FROM_ACCESS -> "VIR_FROM_ACCESS" | VIR_FROM_SYSTEMD -> "VIR_FROM_SYSTEMD" | VIR_FROM_BHYVE -> "VIR_FROM_BHYVE" | VIR_FROM_CRYPTO -> "VIR_FROM_CRYPTO" | VIR_FROM_FIREWALL -> "VIR_FROM_FIREWALL" | VIR_FROM_POLKIT -> "VIR_FROM_POLKIT" | VIR_FROM_THREAD -> "VIR_FROM_THREAD" | VIR_FROM_ADMIN -> "VIR_FROM_ADMIN" | VIR_FROM_LOGGING -> "VIR_FROM_LOGGING" | VIR_FROM_XENXL -> "VIR_FROM_XENXL" | VIR_FROM_PERF -> "VIR_FROM_PERF" | VIR_FROM_LIBSSH -> "VIR_FROM_LIBSSH" | VIR_FROM_RESCTRL -> "VIR_FROM_RESCTRL" | VIR_FROM_FIREWALLD -> "VIR_FROM_FIREWALLD" | VIR_FROM_DOMAIN_CHECKPOINT -> "VIR_FROM_DOMAIN_CHECKPOINT" | VIR_FROM_TPM -> "VIR_FROM_TPM" | VIR_FROM_BPF -> "VIR_FROM_BPF" | VIR_FROM_UNKNOWN i -> "VIR_FROM_" ^ string_of_int i type level = | VIR_ERR_NONE | VIR_ERR_WARNING | VIR_ERR_ERROR | VIR_ERR_UNKNOWN_LEVEL of int let string_of_level = function | VIR_ERR_NONE -> "VIR_ERR_NONE" | VIR_ERR_WARNING -> "VIR_ERR_WARNING" | VIR_ERR_ERROR -> "VIR_ERR_ERROR" | VIR_ERR_UNKNOWN_LEVEL i -> "VIR_ERR_LEVEL_" ^ string_of_int i type t = { code : code; domain : domain; message : string option; level : level; str1 : string option; str2 : string option; str3 : string option; int1 : int32; int2 : int32; } let to_string { code = code; domain = domain; message = message } = let buf = Buffer.create 128 in Buffer.add_string buf "libvirt: "; Buffer.add_string buf (string_of_code code); Buffer.add_string buf ": "; Buffer.add_string buf (string_of_domain domain); Buffer.add_string buf ": "; (match message with Some msg -> Buffer.add_string buf msg | None -> ()); Buffer.contents buf external get_last_error : unit -> t option = "ocaml_libvirt_virterror_get_last_error" external get_last_conn_error : [>`R] Connect.t -> t option = "ocaml_libvirt_virterror_get_last_conn_error" external reset_last_error : unit -> unit = "ocaml_libvirt_virterror_reset_last_error" external reset_last_conn_error : [>`R] Connect.t -> unit = "ocaml_libvirt_virterror_reset_last_conn_error" let no_error () = { code = VIR_ERR_OK; domain = VIR_FROM_NONE; message = None; level = VIR_ERR_NONE; str1 = None; str2 = None; str3 = None; int1 = 0_l; int2 = 0_l } end exception Virterror of Virterror.t exception Not_supported of string let rec map_ignore_errors f = function | [] -> [] | x :: xs -> try f x :: map_ignore_errors f xs with Virterror _ -> map_ignore_errors f xs module Domain = struct type 'rw t type state = | InfoNoState | InfoRunning | InfoBlocked | InfoPaused | InfoShutdown | InfoShutoff | InfoCrashed | InfoPMSuspended type info = { state : state; max_mem : int64; memory : int64; nr_virt_cpu : int; cpu_time : int64; } type vcpu_state = VcpuOffline | VcpuRunning | VcpuBlocked type vcpu_info = { number : int; vcpu_state : vcpu_state; vcpu_time : int64; cpu : int; } type domain_create_flag = | START_PAUSED | START_AUTODESTROY | START_BYPASS_CACHE | START_FORCE_BOOT | START_VALIDATE let rec int_of_domain_create_flags = function | [] -> 0 | START_PAUSED :: flags -> 1 lor int_of_domain_create_flags flags | START_AUTODESTROY :: flags -> 2 lor int_of_domain_create_flags flags | START_BYPASS_CACHE :: flags -> 4 lor int_of_domain_create_flags flags | START_FORCE_BOOT :: flags -> 8 lor int_of_domain_create_flags flags | START_VALIDATE :: flags -> 16 lor int_of_domain_create_flags flags type sched_param = string * sched_param_value and sched_param_value = | SchedFieldInt32 of int32 | SchedFieldUInt32 of int32 | SchedFieldInt64 of int64 | SchedFieldUInt64 of int64 | SchedFieldFloat of float | SchedFieldBool of bool type typed_param = string * typed_param_value and typed_param_value = | TypedFieldInt32 of int32 | TypedFieldUInt32 of int32 | TypedFieldInt64 of int64 | TypedFieldUInt64 of int64 | TypedFieldFloat of float | TypedFieldBool of bool | TypedFieldString of string type migrate_flag = Live type memory_flag = Virtual type list_flag = | ListActive | ListInactive | ListAll type block_stats = { rd_req : int64; rd_bytes : int64; wr_req : int64; wr_bytes : int64; errs : int64; } type interface_stats = { rx_bytes : int64; rx_packets : int64; rx_errs : int64; rx_drop : int64; tx_bytes : int64; tx_packets : int64; tx_errs : int64; tx_drop : int64; } type get_all_domain_stats_flag = | GetAllDomainsStatsActive | GetAllDomainsStatsInactive | GetAllDomainsStatsOther | GetAllDomainsStatsPaused | GetAllDomainsStatsPersistent | GetAllDomainsStatsRunning | GetAllDomainsStatsShutoff | GetAllDomainsStatsTransient | GetAllDomainsStatsBacking | GetAllDomainsStatsEnforceStats type stats_type = | StatsState | StatsCpuTotal | StatsBalloon | StatsVcpu | StatsInterface | StatsBlock | StatsPerf type domain_stats_record = { dom_uuid : uuid; params : typed_param array; } type xml_desc_flag = | XmlSecure | XmlInactive | XmlUpdateCPU | XmlMigratable (* The maximum size for Domain.memory_peek and Domain.block_peek * supported by libvirt. This may change with different versions * of libvirt in the future, hence it's a function. *) let max_peek _ = 65536 external create_linux : [>`W] Connect.t -> xml -> rw t = "ocaml_libvirt_domain_create_linux" external _create_xml : [>`W] Connect.t -> xml -> int -> rw t = "ocaml_libvirt_domain_create_xml" let create_xml conn xml flags = _create_xml conn xml (int_of_domain_create_flags flags) external lookup_by_id : 'a Connect.t -> int -> 'a t = "ocaml_libvirt_domain_lookup_by_id" external lookup_by_uuid : 'a Connect.t -> uuid -> 'a t = "ocaml_libvirt_domain_lookup_by_uuid" external lookup_by_uuid_string : 'a Connect.t -> string -> 'a t = "ocaml_libvirt_domain_lookup_by_uuid_string" external lookup_by_name : 'a Connect.t -> string -> 'a t = "ocaml_libvirt_domain_lookup_by_name" external destroy : [>`W] t -> unit = "ocaml_libvirt_domain_destroy" external free : [>`R] t -> unit = "ocaml_libvirt_domain_free" external suspend : [>`W] t -> unit = "ocaml_libvirt_domain_suspend" external resume : [>`W] t -> unit = "ocaml_libvirt_domain_resume" external save : [>`W] t -> filename -> unit = "ocaml_libvirt_domain_save" external restore : [>`W] Connect.t -> filename -> unit = "ocaml_libvirt_domain_restore" external core_dump : [>`W] t -> filename -> unit = "ocaml_libvirt_domain_core_dump" external shutdown : [>`W] t -> unit = "ocaml_libvirt_domain_shutdown" external reboot : [>`W] t -> unit = "ocaml_libvirt_domain_reboot" external get_name : [>`R] t -> string = "ocaml_libvirt_domain_get_name" external get_uuid : [>`R] t -> uuid = "ocaml_libvirt_domain_get_uuid" external get_uuid_string : [>`R] t -> string = "ocaml_libvirt_domain_get_uuid_string" external get_id : [>`R] t -> int = "ocaml_libvirt_domain_get_id" external get_os_type : [>`R] t -> string = "ocaml_libvirt_domain_get_os_type" external get_max_memory : [>`R] t -> int64 = "ocaml_libvirt_domain_get_max_memory" external set_max_memory : [>`W] t -> int64 -> unit = "ocaml_libvirt_domain_set_max_memory" external set_memory : [>`W] t -> int64 -> unit = "ocaml_libvirt_domain_set_memory" external get_info : [>`R] t -> info = "ocaml_libvirt_domain_get_info" external get_xml_desc : [>`R] t -> xml = "ocaml_libvirt_domain_get_xml_desc" external get_xml_desc_flags : [>`W] t -> xml_desc_flag list -> xml = "ocaml_libvirt_domain_get_xml_desc_flags" external get_scheduler_type : [>`R] t -> string * int = "ocaml_libvirt_domain_get_scheduler_type" external get_scheduler_parameters : [>`R] t -> int -> sched_param array = "ocaml_libvirt_domain_get_scheduler_parameters" external set_scheduler_parameters : [>`W] t -> sched_param array -> unit = "ocaml_libvirt_domain_set_scheduler_parameters" external define_xml : [>`W] Connect.t -> xml -> rw t = "ocaml_libvirt_domain_define_xml" external undefine : [>`W] t -> unit = "ocaml_libvirt_domain_undefine" external create : [>`W] t -> unit = "ocaml_libvirt_domain_create" external get_autostart : [>`R] t -> bool = "ocaml_libvirt_domain_get_autostart" external set_autostart : [>`W] t -> bool -> unit = "ocaml_libvirt_domain_set_autostart" external set_vcpus : [>`W] t -> int -> unit = "ocaml_libvirt_domain_set_vcpus" external pin_vcpu : [>`W] t -> int -> string -> unit = "ocaml_libvirt_domain_pin_vcpu" external get_vcpus : [>`R] t -> int -> int -> int * vcpu_info array * string = "ocaml_libvirt_domain_get_vcpus" external get_cpu_stats : [>`R] t -> typed_param list array = "ocaml_libvirt_domain_get_cpu_stats" external get_max_vcpus : [>`R] t -> int = "ocaml_libvirt_domain_get_max_vcpus" external attach_device : [>`W] t -> xml -> unit = "ocaml_libvirt_domain_attach_device" external detach_device : [>`W] t -> xml -> unit = "ocaml_libvirt_domain_detach_device" external migrate : [>`W] t -> [>`W] Connect.t -> migrate_flag list -> ?dname:string -> ?uri:string -> ?bandwidth:int -> unit -> rw t = "ocaml_libvirt_domain_migrate_bytecode" "ocaml_libvirt_domain_migrate_native" external block_stats : [>`R] t -> string -> block_stats = "ocaml_libvirt_domain_block_stats" external interface_stats : [>`R] t -> string -> interface_stats = "ocaml_libvirt_domain_interface_stats" external block_peek : [>`W] t -> string -> int64 -> int -> bytes -> int -> unit = "ocaml_libvirt_domain_block_peek_bytecode" "ocaml_libvirt_domain_block_peek_native" external memory_peek : [>`W] t -> memory_flag list -> int64 -> int -> bytes -> int -> unit = "ocaml_libvirt_domain_memory_peek_bytecode" "ocaml_libvirt_domain_memory_peek_native" external get_all_domain_stats : [>`R] Connect.t -> stats_type list -> get_all_domain_stats_flag list -> domain_stats_record array = "ocaml_libvirt_domain_get_all_domain_stats" external const : [>`R] t -> ro t = "%identity" let get_domains conn flags = (* Old/slow/inefficient method. *) let get_active, get_inactive = if List.mem ListAll flags then (true, true) else (List.mem ListActive flags, List.mem ListInactive flags) in let active_doms = if get_active then ( let n = Connect.num_of_domains conn in let ids = Connect.list_domains conn n in let ids = Array.to_list ids in map_ignore_errors (lookup_by_id conn) ids ) else [] in let inactive_doms = if get_inactive then ( let n = Connect.num_of_defined_domains conn in let names = Connect.list_defined_domains conn n in let names = Array.to_list names in map_ignore_errors (lookup_by_name conn) names ) else [] in active_doms @ inactive_doms let get_domains_and_infos conn flags = (* Old/slow/inefficient method. *) let get_active, get_inactive = if List.mem ListAll flags then (true, true) else (List.mem ListActive flags, List.mem ListInactive flags) in let active_doms = if get_active then ( let n = Connect.num_of_domains conn in let ids = Connect.list_domains conn n in let ids = Array.to_list ids in map_ignore_errors (lookup_by_id conn) ids ) else [] in let inactive_doms = if get_inactive then ( let n = Connect.num_of_defined_domains conn in let names = Connect.list_defined_domains conn n in let names = Array.to_list names in map_ignore_errors (lookup_by_name conn) names ) else [] in let doms = active_doms @ inactive_doms in map_ignore_errors (fun dom -> (dom, get_info dom)) doms end module Event = struct module Defined = struct type t = [ | `Added | `Updated | `Unknown of int ] let to_string = function | `Added -> "Added" | `Updated -> "Updated" | `Unknown x -> Printf.sprintf "Unknown Defined.detail: %d" x let make = function | 0 -> `Added | 1 -> `Updated | x -> `Unknown x (* newer libvirt *) end module Undefined = struct type t = [ | `Removed | `Unknown of int ] let to_string = function | `Removed -> "UndefinedRemoved" | `Unknown x -> Printf.sprintf "Unknown Undefined.detail: %d" x let make = function | 0 -> `Removed | x -> `Unknown x (* newer libvirt *) end module Started = struct type t = [ | `Booted | `Migrated | `Restored | `FromSnapshot | `Wakeup | `Unknown of int ] let to_string = function | `Booted -> "Booted" | `Migrated -> "Migrated" | `Restored -> "Restored" | `FromSnapshot -> "FromSnapshot" | `Wakeup -> "Wakeup" | `Unknown x -> Printf.sprintf "Unknown Started.detail: %d" x let make = function | 0 -> `Booted | 1 -> `Migrated | 2 -> `Restored | 3 -> `FromSnapshot | 4 -> `Wakeup | x -> `Unknown x (* newer libvirt *) end module Suspended = struct type t = [ | `Paused | `Migrated | `IOError | `Watchdog | `Restored | `FromSnapshot | `APIError | `Unknown of int (* newer libvirt *) ] let to_string = function | `Paused -> "Paused" | `Migrated -> "Migrated" | `IOError -> "IOError" | `Watchdog -> "Watchdog" | `Restored -> "Restored" | `FromSnapshot -> "FromSnapshot" | `APIError -> "APIError" | `Unknown x -> Printf.sprintf "Unknown Suspended.detail: %d" x let make = function | 0 -> `Paused | 1 -> `Migrated | 2 -> `IOError | 3 -> `Watchdog | 4 -> `Restored | 5 -> `FromSnapshot | 6 -> `APIError | x -> `Unknown x (* newer libvirt *) end module Resumed = struct type t = [ | `Unpaused | `Migrated | `FromSnapshot | `Unknown of int (* newer libvirt *) ] let to_string = function | `Unpaused -> "Unpaused" | `Migrated -> "Migrated" | `FromSnapshot -> "FromSnapshot" | `Unknown x -> Printf.sprintf "Unknown Resumed.detail: %d" x let make = function | 0 -> `Unpaused | 1 -> `Migrated | 2 -> `FromSnapshot | x -> `Unknown x (* newer libvirt *) end module Stopped = struct type t = [ | `Shutdown | `Destroyed | `Crashed | `Migrated | `Saved | `Failed | `FromSnapshot | `Unknown of int ] let to_string = function | `Shutdown -> "Shutdown" | `Destroyed -> "Destroyed" | `Crashed -> "Crashed" | `Migrated -> "Migrated" | `Saved -> "Saved" | `Failed -> "Failed" | `FromSnapshot -> "FromSnapshot" | `Unknown x -> Printf.sprintf "Unknown Stopped.detail: %d" x let make = function | 0 -> `Shutdown | 1 -> `Destroyed | 2 -> `Crashed | 3 -> `Migrated | 4 -> `Saved | 5 -> `Failed | 6 -> `FromSnapshot | x -> `Unknown x (* newer libvirt *) end module PM_suspended = struct type t = [ | `Memory | `Disk | `Unknown of int (* newer libvirt *) ] let to_string = function | `Memory -> "Memory" | `Disk -> "Disk" | `Unknown x -> Printf.sprintf "Unknown PM_suspended.detail: %d" x let make = function | 0 -> `Memory | 1 -> `Disk | x -> `Unknown x (* newer libvirt *) end let string_option x = match x with | None -> "None" | Some x' -> "Some " ^ x' module Lifecycle = struct type t = [ | `Defined of Defined.t | `Undefined of Undefined.t | `Started of Started.t | `Suspended of Suspended.t | `Resumed of Resumed.t | `Stopped of Stopped.t | `Shutdown (* no detail defined yet *) | `PMSuspended of PM_suspended.t | `Unknown of int (* newer libvirt *) ] let to_string = function | `Defined x -> "Defined " ^ (Defined.to_string x) | `Undefined x -> "Undefined " ^ (Undefined.to_string x) | `Started x -> "Started " ^ (Started.to_string x) | `Suspended x -> "Suspended " ^ (Suspended.to_string x) | `Resumed x -> "Resumed " ^ (Resumed.to_string x) | `Stopped x -> "Stopped " ^ (Stopped.to_string x) | `Shutdown -> "Shutdown" | `PMSuspended x -> "PMSuspended " ^ (PM_suspended.to_string x) | `Unknown x -> Printf.sprintf "Unknown Lifecycle event: %d" x let make (ty, detail) = match ty with | 0 -> `Defined (Defined.make detail) | 1 -> `Undefined (Undefined.make detail) | 2 -> `Started (Started.make detail) | 3 -> `Suspended (Suspended.make detail) | 4 -> `Resumed (Resumed.make detail) | 5 -> `Stopped (Stopped.make detail) | 6 -> `Shutdown | 7 -> `PMSuspended (PM_suspended.make detail) | x -> `Unknown x end module Reboot = struct type t = unit let to_string _ = "()" let make () = () end module Rtc_change = struct type t = int64 let to_string = Int64.to_string let make x = x end module Watchdog = struct type t = [ | `None | `Pause | `Reset | `Poweroff | `Shutdown | `Debug | `Unknown of int ] let to_string = function | `None -> "None" | `Pause -> "Pause" | `Reset -> "Reset" | `Poweroff -> "Poweroff" | `Shutdown -> "Shutdown" | `Debug -> "Debug" | `Unknown x -> Printf.sprintf "Unknown watchdog_action: %d" x let make = function | 0 -> `None | 1 -> `Pause | 2 -> `Reset | 3 -> `Poweroff | 4 -> `Shutdown | 5 -> `Debug | x -> `Unknown x (* newer libvirt *) end module Io_error = struct type action = [ | `None | `Pause | `Report | `Unknown of int (* newer libvirt *) ] let string_of_action = function | `None -> "None" | `Pause -> "Pause" | `Report -> "Report" | `Unknown x -> Printf.sprintf "Unknown Io_error.action: %d" x let action_of_int = function | 0 -> `None | 1 -> `Pause | 2 -> `Report | x -> `Unknown x type t = { src_path: string option; dev_alias: string option; action: action; reason: string option; } let to_string t = Printf.sprintf "{ Io_error.src_path = %s; dev_alias = %s; action = %s; reason = %s }" (string_option t.src_path) (string_option t.dev_alias) (string_of_action t.action) (string_option t.reason) let make (src_path, dev_alias, action, reason) = { src_path = src_path; dev_alias = dev_alias; action = action_of_int action; reason = reason; } let make_noreason (src_path, dev_alias, action) = make (src_path, dev_alias, action, None) end module Graphics_address = struct type family = [ | `Ipv4 | `Ipv6 | `Unix | `Unknown of int (* newer libvirt *) ] let string_of_family = function | `Ipv4 -> "IPv4" | `Ipv6 -> "IPv6" | `Unix -> "UNIX" | `Unknown x -> Printf.sprintf "Unknown Graphics_address.family: %d" x let family_of_int = function (* no zero *) | 1 -> `Ipv4 | 2 -> `Ipv6 | 3 -> `Unix | x -> `Unknown x type t = { family: family; (** Address family *) node: string option; (** Address of node (eg IP address, or UNIX path *) service: string option; (** Service name/number (eg TCP port, or NULL) *) } let to_string t = Printf.sprintf "{ family = %s; node = %s; service = %s }" (string_of_family t.family) (string_option t.node) (string_option t.service) let make (family, node, service) = { family = family_of_int family; node = node; service = service; } end module Graphics_subject = struct type identity = { ty: string option; name: string option; } let string_of_identity t = Printf.sprintf "{ ty = %s; name = %s }" (string_option t.ty) (string_option t.name) type t = identity list let to_string ts = "[ " ^ (String.concat "; " (List.map string_of_identity ts)) ^ " ]" let make xs = List.map (fun (ty, name) -> { ty = ty; name = name }) (Array.to_list xs) end module Graphics = struct type phase = [ | `Connect | `Initialize | `Disconnect | `Unknown of int (** newer libvirt *) ] let string_of_phase = function | `Connect -> "Connect" | `Initialize -> "Initialize" | `Disconnect -> "Disconnect" | `Unknown x -> Printf.sprintf "Unknown Graphics.phase: %d" x let phase_of_int = function | 0 -> `Connect | 1 -> `Initialize | 2 -> `Disconnect | x -> `Unknown x type t = { phase: phase; (** the phase of the connection *) local: Graphics_address.t; (** the local server address *) remote: Graphics_address.t; (** the remote client address *) auth_scheme: string option; (** the authentication scheme activated *) subject: Graphics_subject.t; (** the authenticated subject (user) *) } let to_string t = let phase = Printf.sprintf "phase = %s" (string_of_phase t.phase) in let local = Printf.sprintf "local = %s" (Graphics_address.to_string t.local) in let remote = Printf.sprintf "remote = %s" (Graphics_address.to_string t.remote) in let auth_scheme = Printf.sprintf "auth_scheme = %s" (string_option t.auth_scheme) in let subject = Printf.sprintf "subject = %s" (Graphics_subject.to_string t.subject) in "{ " ^ (String.concat "; " [ phase; local; remote; auth_scheme; subject ]) ^ " }" let make (phase, local, remote, auth_scheme, subject) = { phase = phase_of_int phase; local = Graphics_address.make local; remote = Graphics_address.make remote; auth_scheme = auth_scheme; subject = Graphics_subject.make subject; } end module Control_error = struct type t = unit let to_string () = "()" let make () = () end module Block_job = struct type ty = [ | `KnownUnknown (* explicitly named UNKNOWN in the spec *) | `Pull | `Copy | `Commit | `Unknown of int (* newer libvirt *) ] let string_of_ty = function | `KnownUnknown -> "KnownUnknown" | `Pull -> "Pull" | `Copy -> "Copy" | `Commit -> "Commit" | `Unknown x -> Printf.sprintf "Unknown Block_job.ty: %d" x let ty_of_int = function | 0 -> `KnownUnknown | 1 -> `Pull | 2 -> `Copy | 3 -> `Commit | x -> `Unknown x (* newer libvirt *) type status = [ | `Completed | `Failed | `Cancelled | `Ready | `Unknown of int ] let string_of_status = function | `Completed -> "Completed" | `Failed -> "Failed" | `Cancelled -> "Cancelled" | `Ready -> "Ready" | `Unknown x -> Printf.sprintf "Unknown Block_job.status: %d" x let status_of_int = function | 0 -> `Completed | 1 -> `Failed | 2 -> `Cancelled | 3 -> `Ready | x -> `Unknown x type t = { disk: string option; ty: ty; status: status; } let to_string t = Printf.sprintf "{ disk = %s; ty = %s; status = %s }" (string_option t.disk) (string_of_ty t.ty) (string_of_status t.status) let make (disk, ty, status) = { disk = disk; ty = ty_of_int ty; status = status_of_int ty; } end module Disk_change = struct type reason = [ | `MissingOnStart | `Unknown of int ] let string_of_reason = function | `MissingOnStart -> "MissingOnStart" | `Unknown x -> Printf.sprintf "Unknown Disk_change.reason: %d" x let reason_of_int = function | 0 -> `MissingOnStart | x -> `Unknown x type t = { old_src_path: string option; new_src_path: string option; dev_alias: string option; reason: reason; } let to_string t = let o = Printf.sprintf "old_src_path = %s" (string_option t.old_src_path) in let n = Printf.sprintf "new_src_path = %s" (string_option t.new_src_path) in let d = Printf.sprintf "dev_alias = %s" (string_option t.dev_alias) in let r = string_of_reason t.reason in "{ " ^ (String.concat "; " [ o; n; d; r ]) ^ " }" let make (o, n, d, r) = { old_src_path = o; new_src_path = n; dev_alias = d; reason = reason_of_int r; } end module Tray_change = struct type reason = [ | `Open | `Close | `Unknown of int ] let string_of_reason = function | `Open -> "Open" | `Close -> "Close" | `Unknown x -> Printf.sprintf "Unknown Tray_change.reason: %d" x let reason_of_int = function | 0 -> `Open | 1 -> `Close | x -> `Unknown x type t = { dev_alias: string option; reason: reason; } let to_string t = Printf.sprintf "{ dev_alias = %s; reason = %s }" (string_option t.dev_alias) (string_of_reason t.reason) let make (dev_alias, reason) = { dev_alias = dev_alias; reason = reason_of_int reason; } end module PM_wakeup = struct type reason = [ | `Unknown of int ] type t = reason let to_string = function | `Unknown x -> Printf.sprintf "Unknown PM_wakeup.reason: %d" x let make x = `Unknown x end module PM_suspend = struct type reason = [ | `Unknown of int ] type t = reason let to_string = function | `Unknown x -> Printf.sprintf "Unknown PM_suspend.reason: %d" x let make x = `Unknown x end module Balloon_change = struct type t = int64 let to_string = Int64.to_string let make x = x end module PM_suspend_disk = struct type reason = [ | `Unknown of int ] type t = reason let to_string = function | `Unknown x -> Printf.sprintf "Unknown PM_suspend_disk.reason: %d" x let make x = `Unknown x end type callback = | Lifecycle of ([`R] Domain.t -> Lifecycle.t -> unit) | Reboot of ([`R] Domain.t -> Reboot.t -> unit) | RtcChange of ([`R] Domain.t -> Rtc_change.t -> unit) | Watchdog of ([`R] Domain.t -> Watchdog.t -> unit) | IOError of ([`R] Domain.t -> Io_error.t -> unit) | Graphics of ([`R] Domain.t -> Graphics.t -> unit) | IOErrorReason of ([`R] Domain.t -> Io_error.t -> unit) | ControlError of ([`R] Domain.t -> Control_error.t -> unit) | BlockJob of ([`R] Domain.t -> Block_job.t -> unit) | DiskChange of ([`R] Domain.t -> Disk_change.t -> unit) | TrayChange of ([`R] Domain.t -> Tray_change.t -> unit) | PMWakeUp of ([`R] Domain.t -> PM_wakeup.t -> unit) | PMSuspend of ([`R] Domain.t -> PM_suspend.t -> unit) | BalloonChange of ([`R] Domain.t -> Balloon_change.t -> unit) | PMSuspendDisk of ([`R] Domain.t -> PM_suspend_disk.t -> unit) type callback_id = int64 let fresh_callback_id = let next = ref 0L in fun () -> let result = !next in next := Int64.succ !next; result let make_table value_name = let table = Hashtbl.create 16 in let callback callback_id generic x = if Hashtbl.mem table callback_id then Hashtbl.find table callback_id generic x in let _ = Callback.register value_name callback in table let u_table = make_table "Libvirt.u_callback" let i_table = make_table "Libvirt.i_callback" let i64_table = make_table "Libvirt.i64_callback" let i_i_table = make_table "Libvirt.i_i_callback" let s_i_table = make_table "Libvirt.s_i_callback" let s_i_i_table = make_table "Libvirt.s_i_i_callback" let s_s_i_table = make_table "Libvirt.s_s_i_callback" let s_s_i_s_table = make_table "Libvirt.s_s_i_s_callback" let s_s_s_i_table = make_table "Libvirt.s_s_s_i_callback" let i_ga_ga_s_gs_table = make_table "Libvirt.i_ga_ga_s_gs_callback" external register_default_impl : unit -> unit = "ocaml_libvirt_event_register_default_impl" external run_default_impl : unit -> unit = "ocaml_libvirt_event_run_default_impl" external register_any' : 'a Connect.t -> 'a Domain.t option -> callback -> callback_id -> int = "ocaml_libvirt_connect_domain_event_register_any" external deregister_any' : 'a Connect.t -> int -> unit = "ocaml_libvirt_connect_domain_event_deregister_any" let our_id_to_libvirt_id = Hashtbl.create 16 let register_any conn ?dom callback = let id = fresh_callback_id () in begin match callback with | Lifecycle f -> Hashtbl.add i_i_table id (fun dom x -> f dom (Lifecycle.make x) ) | Reboot f -> Hashtbl.add u_table id (fun dom x -> f dom (Reboot.make x) ) | RtcChange f -> Hashtbl.add i64_table id (fun dom x -> f dom (Rtc_change.make x) ) | Watchdog f -> Hashtbl.add i_table id (fun dom x -> f dom (Watchdog.make x) ) | IOError f -> Hashtbl.add s_s_i_table id (fun dom x -> f dom (Io_error.make_noreason x) ) | Graphics f -> Hashtbl.add i_ga_ga_s_gs_table id (fun dom x -> f dom (Graphics.make x) ) | IOErrorReason f -> Hashtbl.add s_s_i_s_table id (fun dom x -> f dom (Io_error.make x) ) | ControlError f -> Hashtbl.add u_table id (fun dom x -> f dom (Control_error.make x) ) | BlockJob f -> Hashtbl.add s_i_i_table id (fun dom x -> f dom (Block_job.make x) ) | DiskChange f -> Hashtbl.add s_s_s_i_table id (fun dom x -> f dom (Disk_change.make x) ) | TrayChange f -> Hashtbl.add s_i_table id (fun dom x -> f dom (Tray_change.make x) ) | PMWakeUp f -> Hashtbl.add i_table id (fun dom x -> f dom (PM_wakeup.make x) ) | PMSuspend f -> Hashtbl.add i_table id (fun dom x -> f dom (PM_suspend.make x) ) | BalloonChange f -> Hashtbl.add i64_table id (fun dom x -> f dom (Balloon_change.make x) ) | PMSuspendDisk f -> Hashtbl.add i_table id (fun dom x -> f dom (PM_suspend_disk.make x) ) end; let libvirt_id = register_any' conn dom callback id in Hashtbl.replace our_id_to_libvirt_id id libvirt_id; id let deregister_any conn id = if Hashtbl.mem our_id_to_libvirt_id id then begin let libvirt_id = Hashtbl.find our_id_to_libvirt_id id in deregister_any' conn libvirt_id end; Hashtbl.remove our_id_to_libvirt_id id; Hashtbl.remove u_table id; Hashtbl.remove i_table id; Hashtbl.remove i64_table id; Hashtbl.remove i_i_table id; Hashtbl.remove s_i_table id; Hashtbl.remove s_i_i_table id; Hashtbl.remove s_s_i_table id; Hashtbl.remove s_s_i_s_table id; Hashtbl.remove s_s_s_i_table id; Hashtbl.remove i_ga_ga_s_gs_table id let timeout_table = Hashtbl.create 16 let _ = let callback x = if Hashtbl.mem timeout_table x then Hashtbl.find timeout_table x () in Callback.register "Libvirt.timeout_callback" callback type timer_id = int64 external add_timeout' : 'a Connect.t -> int -> int64 -> int = "ocaml_libvirt_event_add_timeout" external remove_timeout' : 'a Connect.t -> int -> unit = "ocaml_libvirt_event_remove_timeout" let our_id_to_timer_id = Hashtbl.create 16 let add_timeout conn ms fn = let id = fresh_callback_id () in Hashtbl.add timeout_table id fn; let timer_id = add_timeout' conn ms id in Hashtbl.add our_id_to_timer_id id timer_id; id let remove_timeout conn id = if Hashtbl.mem our_id_to_timer_id id then begin let timer_id = Hashtbl.find our_id_to_timer_id id in remove_timeout' conn timer_id end; Hashtbl.remove our_id_to_timer_id id; Hashtbl.remove timeout_table id end module Network = struct type 'rw t external lookup_by_name : 'a Connect.t -> string -> 'a t = "ocaml_libvirt_network_lookup_by_name" external lookup_by_uuid : 'a Connect.t -> uuid -> 'a t = "ocaml_libvirt_network_lookup_by_uuid" external lookup_by_uuid_string : 'a Connect.t -> string -> 'a t = "ocaml_libvirt_network_lookup_by_uuid_string" external create_xml : [>`W] Connect.t -> xml -> rw t = "ocaml_libvirt_network_create_xml" external define_xml : [>`W] Connect.t -> xml -> rw t = "ocaml_libvirt_network_define_xml" external undefine : [>`W] t -> unit = "ocaml_libvirt_network_undefine" external create : [>`W] t -> unit = "ocaml_libvirt_network_create" external destroy : [>`W] t -> unit = "ocaml_libvirt_network_destroy" external free : [>`R] t -> unit = "ocaml_libvirt_network_free" external get_name : [>`R] t -> string = "ocaml_libvirt_network_get_name" external get_uuid : [>`R] t -> uuid = "ocaml_libvirt_network_get_uuid" external get_uuid_string : [>`R] t -> string = "ocaml_libvirt_network_get_uuid_string" external get_xml_desc : [>`R] t -> xml = "ocaml_libvirt_network_get_xml_desc" external get_bridge_name : [>`R] t -> string = "ocaml_libvirt_network_get_bridge_name" external get_autostart : [>`R] t -> bool = "ocaml_libvirt_network_get_autostart" external set_autostart : [>`W] t -> bool -> unit = "ocaml_libvirt_network_set_autostart" external const : [>`R] t -> ro t = "%identity" end module Pool = struct type 'rw t type pool_state = Inactive | Building | Running | Degraded | Inaccessible type pool_build_flags = New | Repair | Resize type pool_delete_flags = Normal | Zeroed type pool_info = { state : pool_state; capacity : int64; allocation : int64; available : int64; } external lookup_by_name : 'a Connect.t -> string -> 'a t = "ocaml_libvirt_storage_pool_lookup_by_name" external lookup_by_uuid : 'a Connect.t -> uuid -> 'a t = "ocaml_libvirt_storage_pool_lookup_by_uuid" external lookup_by_uuid_string : 'a Connect.t -> string -> 'a t = "ocaml_libvirt_storage_pool_lookup_by_uuid_string" external create_xml : [>`W] Connect.t -> xml -> rw t = "ocaml_libvirt_storage_pool_create_xml" external define_xml : [>`W] Connect.t -> xml -> rw t = "ocaml_libvirt_storage_pool_define_xml" external build : [>`W] t -> pool_build_flags -> unit = "ocaml_libvirt_storage_pool_build" external undefine : [>`W] t -> unit = "ocaml_libvirt_storage_pool_undefine" external create : [>`W] t -> unit = "ocaml_libvirt_storage_pool_create" external destroy : [>`W] t -> unit = "ocaml_libvirt_storage_pool_destroy" external delete : [>`W] t -> unit = "ocaml_libvirt_storage_pool_delete" external free : [>`R] t -> unit = "ocaml_libvirt_storage_pool_free" external refresh : [`R] t -> unit = "ocaml_libvirt_storage_pool_refresh" external get_name : [`R] t -> string = "ocaml_libvirt_storage_pool_get_name" external get_uuid : [`R] t -> uuid = "ocaml_libvirt_storage_pool_get_uuid" external get_uuid_string : [`R] t -> string = "ocaml_libvirt_storage_pool_get_uuid_string" external get_info : [`R] t -> pool_info = "ocaml_libvirt_storage_pool_get_info" external get_xml_desc : [`R] t -> xml = "ocaml_libvirt_storage_pool_get_xml_desc" external get_autostart : [`R] t -> bool = "ocaml_libvirt_storage_pool_get_autostart" external set_autostart : [>`W] t -> bool -> unit = "ocaml_libvirt_storage_pool_set_autostart" external num_of_volumes : [`R] t -> int = "ocaml_libvirt_storage_pool_num_of_volumes" external list_volumes : [`R] t -> int -> string array = "ocaml_libvirt_storage_pool_list_volumes" external const : [>`R] t -> ro t = "%identity" end module Volume = struct type 'rw t type vol_type = File | Block | Dir | Network | NetDir | Ploop type vol_delete_flags = Normal | Zeroed type vol_info = { typ : vol_type; capacity : int64; allocation : int64; } external lookup_by_name : 'a Pool.t -> string -> 'a t = "ocaml_libvirt_storage_vol_lookup_by_name" external lookup_by_key : 'a Connect.t -> string -> 'a t = "ocaml_libvirt_storage_vol_lookup_by_key" external lookup_by_path : 'a Connect.t -> string -> 'a t = "ocaml_libvirt_storage_vol_lookup_by_path" external pool_of_volume : 'a t -> 'a Pool.t = "ocaml_libvirt_storage_pool_lookup_by_volume" external get_name : [`R] t -> string = "ocaml_libvirt_storage_vol_get_name" external get_key : [`R] t -> string = "ocaml_libvirt_storage_vol_get_key" external get_path : [`R] t -> string = "ocaml_libvirt_storage_vol_get_path" external get_info : [`R] t -> vol_info = "ocaml_libvirt_storage_vol_get_info" external get_xml_desc : [`R] t -> xml = "ocaml_libvirt_storage_vol_get_xml_desc" external create_xml : [>`W] Pool.t -> xml -> unit = "ocaml_libvirt_storage_vol_create_xml" external delete : [>`W] t -> vol_delete_flags -> unit = "ocaml_libvirt_storage_vol_delete" external free : [>`R] t -> unit = "ocaml_libvirt_storage_vol_free" external const : [>`R] t -> ro t = "%identity" end module Secret = struct type 'rw t type secret_usage_type = | NoType | Volume | Ceph | ISCSI | TLS external lookup_by_uuid : 'a Connect.t -> uuid -> 'a t = "ocaml_libvirt_secret_lookup_by_uuid" external lookup_by_uuid_string : 'a Connect.t -> string -> 'a t = "ocaml_libvirt_secret_lookup_by_uuid_string" external lookup_by_usage : 'a Connect.t -> secret_usage_type -> string -> 'a t = "ocaml_libvirt_secret_lookup_by_usage" external define_xml : [>`W] Connect.t -> xml -> rw t = "ocaml_libvirt_secret_define_xml" external get_uuid : [>`R] t -> uuid = "ocaml_libvirt_secret_get_uuid" external get_uuid_string : [>`R] t -> string = "ocaml_libvirt_secret_get_uuid_string" external get_usage_type : [>`R] t -> secret_usage_type = "ocaml_libvirt_secret_get_usage_type" external get_usage_id : [>`R] t -> string = "ocaml_libvirt_secret_get_usage_id" external get_xml_desc : [>`R] t -> xml = "ocaml_libvirt_secret_get_xml_desc" external set_value : [>`W] t -> bytes -> unit = "ocaml_libvirt_secret_set_value" external get_value : [>`R] t -> bytes = "ocaml_libvirt_secret_get_value" external undefine : [>`W] t -> unit = "ocaml_libvirt_secret_undefine" external free : [>`R] t -> unit = "ocaml_libvirt_secret_free" external const : [>`R] t -> ro t = "%identity" end (* Initialization. *) external c_init : unit -> unit = "ocaml_libvirt_init" let () = Callback.register_exception "ocaml_libvirt_virterror" (Virterror (Virterror.no_error ())); Callback.register_exception "ocaml_libvirt_not_supported" (Not_supported ""); c_init (); Printexc.register_printer ( function | Virterror e -> Some (Virterror.to_string e) | _ -> None ) virt-v2v-1.44.2/bundled/libvirt-ocaml/PaxHeaders/libvirt.mli0000644000000000000000000000013213631710510020713 xustar0030 mtime=1583845704.127871016 30 atime=1637862772.141055689 30 ctime=1637862790.579851407 virt-v2v-1.44.2/bundled/libvirt-ocaml/libvirt.mli0000664000175000017500000015013313631710510022524 0ustar00rjonesrjones00000000000000(** OCaml bindings for libvirt. *) (* (C) Copyright 2007-2015 Richard W.M. Jones, Red Hat Inc. https://libvirt.org/ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version, with the OCaml linking exception described in ../COPYING.LIB. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *) (** {2 Introduction and examples} This is a set of bindings for writing OCaml programs to manage virtual machines through {{:https://libvirt.org/}libvirt}. {3 Using libvirt interactively} Using the interactive toplevel: {v $ ocaml -I +libvirt Objective Caml version 3.10.0 # #load "unix.cma";; # #load "mllibvirt.cma";; # let name = "test:///default";; val name : string = "test:///default" # let conn = Libvirt.Connect.connect_readonly ~name () ;; val conn : Libvirt.ro Libvirt.Connect.t = # Libvirt.Connect.get_node_info conn;; : Libvirt.Connect.node_info = {Libvirt.Connect.model = "i686"; Libvirt.Connect.memory = 3145728L; Libvirt.Connect.cpus = 16; Libvirt.Connect.mhz = 1400; Libvirt.Connect.nodes = 2; Libvirt.Connect.sockets = 2; Libvirt.Connect.cores = 2; Libvirt.Connect.threads = 2} v} {3 Compiling libvirt programs} This command compiles a program to native code: {v ocamlopt -I +libvirt mllibvirt.cmxa list_domains.ml -o list_domains v} {3 Example: Connect to the hypervisor} The main modules are {!Libvirt.Connect}, {!Libvirt.Domain} and {!Libvirt.Network} corresponding respectively to the {{:https://libvirt.org/html/libvirt-libvirt-host.html}virConnect*}, {{:https://libvirt.org/html/libvirt-libvirt-domain.html}virDomain*}, and {{:https://libvirt.org/html/libvirt-libvirt-network.html}virNetwork*} functions from libvirt. For brevity I usually rename these modules like this: {[ module C = Libvirt.Connect module D = Libvirt.Domain module N = Libvirt.Network ]} To get a connection handle, assuming a Xen hypervisor: {[ let name = "xen:///" let conn = C.connect_readonly ~name () ]} {3 Example: List running domains} {[ open Printf let domains = D.get_domains conn [D.ListActive] in List.iter ( fun dom -> printf "%8d %s\n%!" (D.get_id dom) (D.get_name dom) ) domains; ]} {3 Example: List inactive domains} {[ let domains = D.get_domains conn [D.ListInactive] in List.iter ( fun dom -> printf "inactive %s\n%!" (D.get_name dom) ) domains; ]} {3 Example: Print node info} {[ let node_info = C.get_node_info conn in printf "model = %s\n" node_info.C.model; printf "memory = %Ld K\n" node_info.C.memory; printf "cpus = %d\n" node_info.C.cpus; printf "mhz = %d\n" node_info.C.mhz; printf "nodes = %d\n" node_info.C.nodes; printf "sockets = %d\n" node_info.C.sockets; printf "cores = %d\n" node_info.C.cores; printf "threads = %d\n%!" node_info.C.threads; let hostname = C.get_hostname conn in printf "hostname = %s\n%!" hostname; let uri = C.get_uri conn in printf "uri = %s\n%!" uri ]} *) (** {2 Programming issues} {3 General safety issues} Memory allocation / automatic garbage collection of all libvirt objects should be completely safe. If you find any safety issues or if your pure OCaml program ever segfaults, please contact the author. You can force a libvirt object to be freed early by calling the {!Libvirt.Connect.close} function on the object. This shouldn't affect the safety of garbage collection and should only be used when you want to explicitly free memory. Note that explicitly closing a connection object does nothing if there are still unclosed domain or network objects referencing it. Note that even though you hold open (eg) a domain object, that doesn't mean that the domain (virtual machine) actually exists. The domain could have been shut down or deleted by another user. Thus domain objects can raise odd exceptions at any time. This is just the nature of virtualisation. {3 Backwards and forwards compatibility} OCaml-libvirt requires libvirt version 1.2.8 or later. Future releases of OCaml-libvirt will use newer features of libvirt and therefore will require later versions of libvirt. It is always possible to dynamically link your application against a newer libvirt than OCaml-libvirt was originally compiled against. {3 Get list of domains and domain infos} This is a very common operation, and libvirt supports various different methods to do it. We have hidden the complexity in a flexible {!Libvirt.Domain.get_domains} and {!Libvirt.Domain.get_domains_and_infos} calls which is easy to use and automatically chooses the most efficient method depending on the version of libvirt in use. {3 Threads} You can issue multiple concurrent libvirt requests in different threads. However you must follow this rule: Each thread must have its own separate libvirt connection, {i or} you must implement your own mutex scheme to ensure that no two threads can ever make concurrent calls using the same libvirt connection. (Note that multithreaded code is not well tested. If you find bugs please report them.) {3 Initialisation} Libvirt requires all callers to call virInitialize before using the library. This is done automatically for you by these bindings when the program starts up, and we believe that the way this is done is safe. {2 Reference} *) type uuid = string (** This is a "raw" UUID, ie. a packed string of bytes. *) type xml = string (** Type of XML (an uninterpreted string of bytes). Use PXP, expat, xml-light, etc. if you want to do anything useful with the XML. *) type filename = string (** A filename. *) val get_version : ?driver:string -> unit -> int * int (** [get_version ()] returns the library version in the first part of the tuple, and [0] in the second part. [get_version ~driver ()] returns the library version in the first part of the tuple, and the version of the driver called [driver] in the second part. The version numbers are encoded as [major * 1_000_000 + minor * 1000 + release]. *) val uuid_length : int (** Length of packed UUIDs. *) val uuid_string_length : int (** Length of UUID strings. *) type rw = [`R|`W] type ro = [`R] (** These {{:https://caml.inria.fr/pub/ml-archives/caml-list/2004/07/80683af867cce6bf8fff273973f70c95.en.html}phantom types} are used to ensure the type-safety of read-only versus read-write connections. All connection/domain/etc. objects are marked with a phantom read-write or read-only type, and trying to pass a read-only object into a function which could mutate the object will cause a compile time error. Each module provides a function like {!Libvirt.Connect.const} to demote a read-write object into a read-only object. The opposite operation is, of course, not allowed. If you want to handle both read-write and read-only connections at runtime, use a variant similar to this: {[ type conn_t = | No_connection | Read_only of Libvirt.ro Libvirt.Connect.t | Read_write of Libvirt.rw Libvirt.Connect.t ]} *) (** {3 Forward definitions} These definitions are placed here to avoid the need to use recursive module dependencies. *) (** {3 Connections} *) module Connect : sig type 'rw t (** Connection. Read-only connections have type [ro Connect.t] and read-write connections have type [rw Connect.t]. *) type node_info = { model : string; (** CPU model *) memory : int64; (** memory size in kilobytes *) cpus : int; (** number of active CPUs *) mhz : int; (** expected CPU frequency *) nodes : int; (** number of NUMA nodes (1 = UMA) *) sockets : int; (** number of CPU sockets per node *) cores : int; (** number of cores per socket *) threads : int; (** number of threads per core *) } type credential_type = | CredentialUsername (** Identity to act as *) | CredentialAuthname (** Identify to authorize as *) | CredentialLanguage (** RFC 1766 languages, comma separated *) | CredentialCnonce (** client supplies a nonce *) | CredentialPassphrase (** Passphrase secret *) | CredentialEchoprompt (** Challenge response *) | CredentialNoechoprompt (** Challenge response *) | CredentialRealm (** Authentication realm *) | CredentialExternal (** Externally managed credential *) type credential = { typ : credential_type; (** The type of credential *) prompt : string; (** Prompt to show to user *) challenge : string option; (** Additional challenge to show *) defresult : string option; (** Optional default result *) } type auth = { credtype : credential_type list; (** List of supported credential_type values *) cb : (credential list -> string option list); (** Callback used to collect credentials. The input is a list of all the requested credentials. The function returns a list of all the results from the requested credentials, so the number of results {e must} match the number of input credentials. Each result is optional, and in case it is [None] it means there was no result. *) } val connect : ?name:string -> unit -> rw t (** [connect ~name ()] connects to the hypervisor with URI [name]. [connect ()] connects to the default hypervisor. *) val connect_readonly : ?name:string -> unit -> ro t (** [connect_readonly ~name ()] connects in read-only mode to the hypervisor with URI [name]. [connect_readonly ()] connects in read-only mode to the default hypervisor. *) val connect_auth : ?name:string -> auth -> rw t (** [connect_auth ~name auth] connects to the hypervisor with URI [name], using [auth] as authentication handler. [connect_auth auth] connects to the default hypervisor, using [auth] as authentication handler. *) val connect_auth_readonly : ?name:string -> auth -> ro t (** [connect_auth_readonly ~name auth] connects in read-only mode to the hypervisor with URI [name], using [auth] as authentication handler. [connect_auth_readonly auth] connects in read-only mode to the default hypervisor, using [auth] as authentication handler. *) val close : [>`R] t -> unit (** [close conn] closes and frees the connection object in memory. The connection is automatically closed if it is garbage collected. This function just forces it to be closed and freed right away. *) val get_type : [>`R] t -> string (** Returns the name of the driver (hypervisor). *) val get_version : [>`R] t -> int (** Returns the driver version [major * 1_000_000 + minor * 1000 + release] *) val get_hostname : [>`R] t -> string (** Returns the hostname of the physical server. *) val get_uri : [>`R] t -> string (** Returns the canonical connection URI. *) val get_max_vcpus : [>`R] t -> ?type_:string -> unit -> int (** Returns the maximum number of virtual CPUs supported by a guest VM of a particular type. *) val list_domains : [>`R] t -> int -> int array (** [list_domains conn max] returns the running domain IDs, up to a maximum of [max] entries. Call {!num_of_domains} first to get a value for [max]. See also: {!Libvirt.Domain.get_domains}, {!Libvirt.Domain.get_domains_and_infos}. *) val num_of_domains : [>`R] t -> int (** Returns the number of running domains. *) val get_capabilities : [>`R] t -> xml (** Returns the hypervisor capabilities (as XML). *) val num_of_defined_domains : [>`R] t -> int (** Returns the number of inactive (shutdown) domains. *) val list_defined_domains : [>`R] t -> int -> string array (** [list_defined_domains conn max] returns the names of the inactive domains, up to a maximum of [max] entries. Call {!num_of_defined_domains} first to get a value for [max]. See also: {!Libvirt.Domain.get_domains}, {!Libvirt.Domain.get_domains_and_infos}. *) val num_of_networks : [>`R] t -> int (** Returns the number of networks. *) val list_networks : [>`R] t -> int -> string array (** [list_networks conn max] returns the names of the networks, up to a maximum of [max] entries. Call {!num_of_networks} first to get a value for [max]. *) val num_of_defined_networks : [>`R] t -> int (** Returns the number of inactive networks. *) val list_defined_networks : [>`R] t -> int -> string array (** [list_defined_networks conn max] returns the names of the inactive networks, up to a maximum of [max] entries. Call {!num_of_defined_networks} first to get a value for [max]. *) val num_of_pools : [>`R] t -> int (** Returns the number of storage pools. *) val list_pools : [>`R] t -> int -> string array (** Return list of storage pools. *) val num_of_defined_pools : [>`R] t -> int (** Returns the number of storage pools. *) val list_defined_pools : [>`R] t -> int -> string array (** Return list of storage pools. *) (* The name of this function is inconsistent, but the inconsistency * is really in libvirt itself. *) val num_of_secrets : [>`R] t -> int (** Returns the number of secrets. *) val list_secrets : [>`R] t -> int -> string array (** Returns the list of secrets. *) val get_node_info : [>`R] t -> node_info (** Return information about the physical server. *) val node_get_free_memory : [> `R] t -> int64 (** [node_get_free_memory conn] returns the amount of free memory (not allocated to any guest) in the machine. *) val node_get_cells_free_memory : [> `R] t -> int -> int -> int64 array (** [node_get_cells_free_memory conn start max] returns the amount of free memory on each NUMA cell in kilobytes. [start] is the first cell for which we return free memory. [max] is the maximum number of cells for which we return free memory. Returns an array of up to [max] entries in length. *) val maxcpus_of_node_info : node_info -> int (** Calculate the total number of CPUs supported (but not necessarily active) in the host. *) val cpumaplen : int -> int (** Calculate the length (in bytes) required to store the complete CPU map between a single virtual and all physical CPUs of a domain. *) val use_cpu : bytes -> int -> unit (** [use_cpu cpumap cpu] marks [cpu] as usable in [cpumap]. *) val unuse_cpu : bytes -> int -> unit (** [unuse_cpu cpumap cpu] marks [cpu] as not usable in [cpumap]. *) val cpu_usable : bytes -> int -> int -> int -> bool (** [cpu_usable cpumaps maplen vcpu cpu] checks returns true iff the [cpu] is usable by [vcpu]. *) val set_keep_alive : [>`R] t -> int -> int -> unit (** [set_keep_alive conn interval count] starts sending keepalive messages after [interval] seconds of inactivity and consider the connection to be broken when no response is received after [count] keepalive messages. Note: the client has to implement and run an event loop to be able to use keep-alive messages. *) val get_auth_default : unit -> auth (** [get_auth_default ()] returns the default authentication handler of libvirt. *) val get_domain_capabilities : ?emulatorbin:string -> ?arch:string -> ?machine:string -> ?virttype:string -> [>`R] t -> string (** [get_domain_capabilities ()] returns the XML with the available capabilities of the emulator or libvirt for domains. The optional flag [?emulatorbin] is used to specify a different emulator. The optional flag [?arch] is used to specify a different architecture. The optional flag [?machine] is used to specify a different machine type. The optional flag [?virttype] is used to specify a different type of virtualization. *) external const : [>`R] t -> ro t = "%identity" (** [const conn] turns a read/write connection into a read-only connection. Note that the opposite operation is impossible. *) end (** Module dealing with connections. [Connect.t] is the connection object. *) (** {3 Domains} *) module Domain : sig type 'rw t (** Domain handle. Read-only handles have type [ro Domain.t] and read-write handles have type [rw Domain.t]. *) type state = | InfoNoState | InfoRunning | InfoBlocked | InfoPaused | InfoShutdown | InfoShutoff | InfoCrashed | InfoPMSuspended type info = { state : state; (** running state *) max_mem : int64; (** maximum memory in kilobytes *) memory : int64; (** memory used in kilobytes *) nr_virt_cpu : int; (** number of virtual CPUs *) cpu_time : int64; (** CPU time used in nanoseconds *) } type vcpu_state = VcpuOffline | VcpuRunning | VcpuBlocked type vcpu_info = { number : int; (** virtual CPU number *) vcpu_state : vcpu_state; (** state *) vcpu_time : int64; (** CPU time used in nanoseconds *) cpu : int; (** real CPU number, -1 if offline *) } type domain_create_flag = | START_PAUSED (** Launch guest in paused state *) | START_AUTODESTROY (** Automatically kill guest on close *) | START_BYPASS_CACHE (** Avoid filesystem cache pollution *) | START_FORCE_BOOT (** Discard any managed save *) | START_VALIDATE (** Validate XML against schema *) type sched_param = string * sched_param_value and sched_param_value = | SchedFieldInt32 of int32 | SchedFieldUInt32 of int32 | SchedFieldInt64 of int64 | SchedFieldUInt64 of int64 | SchedFieldFloat of float | SchedFieldBool of bool type typed_param = string * typed_param_value and typed_param_value = | TypedFieldInt32 of int32 | TypedFieldUInt32 of int32 | TypedFieldInt64 of int64 | TypedFieldUInt64 of int64 | TypedFieldFloat of float | TypedFieldBool of bool | TypedFieldString of string type migrate_flag = Live type memory_flag = Virtual type list_flag = | ListActive | ListInactive | ListAll type block_stats = { rd_req : int64; rd_bytes : int64; wr_req : int64; wr_bytes : int64; errs : int64; } type interface_stats = { rx_bytes : int64; rx_packets : int64; rx_errs : int64; rx_drop : int64; tx_bytes : int64; tx_packets : int64; tx_errs : int64; tx_drop : int64; } type get_all_domain_stats_flag = | GetAllDomainsStatsActive | GetAllDomainsStatsInactive | GetAllDomainsStatsOther | GetAllDomainsStatsPaused | GetAllDomainsStatsPersistent | GetAllDomainsStatsRunning | GetAllDomainsStatsShutoff | GetAllDomainsStatsTransient | GetAllDomainsStatsBacking | GetAllDomainsStatsEnforceStats type stats_type = | StatsState | StatsCpuTotal | StatsBalloon | StatsVcpu | StatsInterface | StatsBlock | StatsPerf type domain_stats_record = { dom_uuid : uuid; params : typed_param array; } type xml_desc_flag = | XmlSecure (** dump security sensitive information too *) | XmlInactive (** dump inactive domain information *) | XmlUpdateCPU (** update guest CPU requirements according to host CPU *) | XmlMigratable (** dump XML suitable for migration *) val max_peek : [>`R] t -> int (** Maximum size supported by the {!block_peek} and {!memory_peek} functions. If you want to peek more than this then you must break your request into chunks. *) val create_linux : [>`W] Connect.t -> xml -> rw t (** Create a new guest domain (not necessarily a Linux one) from the given XML. @deprecated Use {!create_xml} instead. *) val create_xml : [>`W] Connect.t -> xml -> domain_create_flag list -> rw t (** Create a new guest domain from the given XML. *) val lookup_by_id : 'a Connect.t -> int -> 'a t (** Lookup a domain by ID. *) val lookup_by_uuid : 'a Connect.t -> uuid -> 'a t (** Lookup a domain by UUID. This uses the packed byte array UUID. *) val lookup_by_uuid_string : 'a Connect.t -> string -> 'a t (** Lookup a domain by (string) UUID. *) val lookup_by_name : 'a Connect.t -> string -> 'a t (** Lookup a domain by name. *) val destroy : [>`W] t -> unit (** Abruptly destroy a domain. *) val free : [>`R] t -> unit (** [free domain] frees the domain object in memory. The domain object is automatically freed if it is garbage collected. This function just forces it to be freed right away. *) val suspend : [>`W] t -> unit (** Suspend a domain. *) val resume : [>`W] t -> unit (** Resume a domain. *) val save : [>`W] t -> filename -> unit (** Suspend a domain, then save it to the file. *) val restore : [>`W] Connect.t -> filename -> unit (** Restore a domain from a file. *) val core_dump : [>`W] t -> filename -> unit (** Force a domain to core dump to the named file. *) val shutdown : [>`W] t -> unit (** Shutdown a domain. *) val reboot : [>`W] t -> unit (** Reboot a domain. *) val get_name : [>`R] t -> string (** Get the domain name. *) val get_uuid : [>`R] t -> uuid (** Get the domain UUID (as a packed byte array). *) val get_uuid_string : [>`R] t -> string (** Get the domain UUID (as a printable string). *) val get_id : [>`R] t -> int (** [get_id dom] returns the ID of the domain. In most cases this returns [-1] if the domain is not running. *) val get_os_type : [>`R] t -> string (** Get the operating system type. *) val get_max_memory : [>`R] t -> int64 (** Get the maximum memory allocation. *) val set_max_memory : [>`W] t -> int64 -> unit (** Set the maximum memory allocation. *) val set_memory : [>`W] t -> int64 -> unit (** Set the normal memory allocation. *) val get_info : [>`R] t -> info (** Get information about a domain. *) val get_xml_desc : [>`R] t -> xml (** Get the XML description of a domain. *) val get_xml_desc_flags : [>`W] t -> xml_desc_flag list -> xml (** Get the XML description of a domain, with the possibility to specify flags. *) val get_scheduler_type : [>`R] t -> string * int (** Get the scheduler type. *) val get_scheduler_parameters : [>`R] t -> int -> sched_param array (** Get the array of scheduler parameters. *) val set_scheduler_parameters : [>`W] t -> sched_param array -> unit (** Set the array of scheduler parameters. *) val define_xml : [>`W] Connect.t -> xml -> rw t (** Define a new domain (but don't start it up) from the XML. *) val undefine : [>`W] t -> unit (** Undefine a domain - removes its configuration. *) val create : [>`W] t -> unit (** Launch a defined (inactive) domain. *) val get_autostart : [>`R] t -> bool (** Get the autostart flag for a domain. *) val set_autostart : [>`W] t -> bool -> unit (** Set the autostart flag for a domain. *) val set_vcpus : [>`W] t -> int -> unit (** Change the number of vCPUs available to a domain. *) val pin_vcpu : [>`W] t -> int -> string -> unit (** [pin_vcpu dom vcpu bitmap] pins a domain vCPU to a bitmap of physical CPUs. See the libvirt documentation for details of the layout of the bitmap. *) val get_vcpus : [>`R] t -> int -> int -> int * vcpu_info array * string (** [get_vcpus dom maxinfo maplen] returns the pinning information for a domain. See the libvirt documentation for details of the array and bitmap returned from this function. *) val get_cpu_stats : [>`R] t -> typed_param list array (** [get_pcpu_stats dom] returns the physical CPU stats for a domain. See the libvirt documentation for details. *) val get_max_vcpus : [>`R] t -> int (** Returns the maximum number of vCPUs supported for this domain. *) val attach_device : [>`W] t -> xml -> unit (** Attach a device (described by the device XML) to a domain. *) val detach_device : [>`W] t -> xml -> unit (** Detach a device (described by the device XML) from a domain. *) val migrate : [>`W] t -> [>`W] Connect.t -> migrate_flag list -> ?dname:string -> ?uri:string -> ?bandwidth:int -> unit -> rw t (** [migrate dom dconn flags ()] migrates a domain to a destination host described by [dconn]. The optional flag [?dname] is used to rename the domain. The optional flag [?uri] is used to route the migration. The optional flag [?bandwidth] is used to limit the bandwidth used for migration (in Mbps). *) val block_stats : [>`R] t -> string -> block_stats (** Returns block device stats. *) val interface_stats : [>`R] t -> string -> interface_stats (** Returns network interface stats. *) val block_peek : [>`W] t -> string -> int64 -> int -> bytes -> int -> unit (** [block_peek dom path offset size buf boff] reads [size] bytes at [offset] in the domain's [path] block device. If successful then the data is written into [buf] starting at offset [boff], for [size] bytes. See also {!max_peek}. *) val memory_peek : [>`W] t -> memory_flag list -> int64 -> int -> bytes -> int -> unit (** [memory_peek dom Virtual offset size] reads [size] bytes at [offset] in the domain's virtual memory. If successful then the data is written into [buf] starting at offset [boff], for [size] bytes. See also {!max_peek}. *) external get_all_domain_stats : [>`R] Connect.t -> stats_type list -> get_all_domain_stats_flag list -> domain_stats_record array = "ocaml_libvirt_domain_get_all_domain_stats" (** [get_all_domain_stats conn stats flags] allows you to read all stats across multiple/all domains in a single call. See the libvirt documentation for [virConnectGetAllDomainStats]. *) external const : [>`R] t -> ro t = "%identity" (** [const dom] turns a read/write domain handle into a read-only domain handle. Note that the opposite operation is impossible. *) val get_domains : ([>`R] as 'a) Connect.t -> list_flag list -> 'a t list (** Get the active and/or inactive domains using the most efficient method available. See also: {!get_domains_and_infos}, {!Connect.list_domains}, {!Connect.list_defined_domains}. *) val get_domains_and_infos : ([>`R] as 'a) Connect.t -> list_flag list -> ('a t * info) list (** This gets the active and/or inactive domains and the domain info for each one using the most efficient method available. See also: {!get_domains}, {!Connect.list_domains}, {!Connect.list_defined_domains}, {!get_info}. *) end (** Module dealing with domains. [Domain.t] is the domain object. *) module Event : sig module Defined : sig type t = [ | `Added (** Newly created config file *) | `Updated (** Changed config file *) | `Unknown of int ] val to_string: t -> string end module Undefined : sig type t = [ | `Removed (** Deleted the config file *) | `Unknown of int ] val to_string: t -> string end module Started : sig type t = [ | `Booted (** Normal startup from boot *) | `Migrated (** Incoming migration from another host *) | `Restored (** Restored from a state file *) | `FromSnapshot (** Restored from snapshot *) | `Wakeup (** Started due to wakeup event *) | `Unknown of int ] val to_string: t -> string end module Suspended : sig type t = [ | `Paused (** Normal suspend due to admin pause *) | `Migrated (** Suspended for offline migration *) | `IOError (** Suspended due to a disk I/O error *) | `Watchdog (** Suspended due to a watchdog firing *) | `Restored (** Restored from paused state file *) | `FromSnapshot (** Restored from paused snapshot *) | `APIError (** suspended after failure during libvirt API call *) | `Unknown of int ] val to_string: t -> string end module Resumed : sig type t = [ | `Unpaused (** Normal resume due to admin unpause *) | `Migrated (** Resumed for completion of migration *) | `FromSnapshot (** Resumed from snapshot *) | `Unknown of int ] val to_string: t -> string end module Stopped : sig type t = [ | `Shutdown (** Normal shutdown *) | `Destroyed (** Forced poweroff from host *) | `Crashed (** Guest crashed *) | `Migrated (** Migrated off to another host *) | `Saved (** Saved to a state file *) | `Failed (** Host emulator/mgmt failed *) | `FromSnapshot (** offline snapshot loaded *) | `Unknown of int ] val to_string: t -> string end module PM_suspended : sig type t = [ | `Memory (** Guest was PM suspended to memory *) | `Disk (** Guest was PM suspended to disk *) | `Unknown of int ] val to_string: t -> string end module Lifecycle : sig type t = [ | `Defined of Defined.t | `Undefined of Undefined.t | `Started of Started.t | `Suspended of Suspended.t | `Resumed of Resumed.t | `Stopped of Stopped.t | `Shutdown (* no detail defined yet *) | `PMSuspended of PM_suspended.t | `Unknown of int ] val to_string: t -> string end module Reboot : sig type t = unit val to_string: t -> string end module Rtc_change : sig type t = int64 val to_string: t -> string end module Watchdog : sig type t = [ | `None (** No action, watchdog ignored *) | `Pause (** Guest CPUs are paused *) | `Reset (** Guest CPUs are reset *) | `Poweroff (** Guest is forcably powered off *) | `Shutdown (** Guest is requested to gracefully shutdown *) | `Debug (** No action, a debug message logged *) | `Unknown of int (** newer libvirt *) ] val to_string: t -> string end module Io_error : sig (** Represents both IOError and IOErrorReason *) type action = [ | `None (** No action, IO error ignored *) | `Pause (** Guest CPUs are paused *) | `Report (** IO error reported to guest OS *) | `Unknown of int (** newer libvirt *) ] type t = { src_path: string option; (** The host file on which the I/O error occurred *) dev_alias: string option; (** The guest device alias associated with the path *) action: action; (** The action that is to be taken due to the IO error *) reason: string option; (** The cause of the IO error *) } val to_string: t -> string end module Graphics_address : sig type family = [ | `Ipv4 (** IPv4 address *) | `Ipv6 (** IPv6 address *) | `Unix (** UNIX socket path *) | `Unknown of int (** newer libvirt *) ] type t = { family: family; (** Address family *) node: string option; (** Address of node (eg IP address, or UNIX path *) service: string option; (** Service name/number (eg TCP port, or NULL) *) } val to_string: t -> string end module Graphics_subject : sig type identity = { ty: string option; (** Type of identity *) name: string option; (** Identity value *) } type t = identity list val to_string: t -> string end module Graphics : sig type phase = [ | `Connect (** Initial socket connection established *) | `Initialize (** Authentication & setup completed *) | `Disconnect (** Final socket disconnection *) | `Unknown of int (** newer libvirt *) ] type t = { phase: phase; (** the phase of the connection *) local: Graphics_address.t; (** the local server address *) remote: Graphics_address.t; (** the remote client address *) auth_scheme: string option; (** the authentication scheme activated *) subject: Graphics_subject.t; (** the authenticated subject (user) *) } val to_string: t -> string end module Control_error : sig type t = unit val to_string: t -> string end module Block_job : sig type ty = [ | `KnownUnknown (** explicitly named UNKNOWN in the spec *) | `Pull | `Copy | `Commit | `Unknown of int ] type status = [ | `Completed | `Failed | `Cancelled | `Ready | `Unknown of int ] type t = { disk: string option; (** fully-qualified name of the affected disk *) ty: ty; (** type of block job *) status: status; (** final status of the operation *) } val to_string: t -> string end module Disk_change : sig type reason = [ | `MissingOnStart | `Unknown of int ] type t = { old_src_path: string option; (** old source path *) new_src_path: string option; (** new source path *) dev_alias: string option; (** device alias name *) reason: reason; (** reason why this callback was called *) } val to_string: t -> string end module Tray_change : sig type reason = [ | `Open | `Close | `Unknown of int ] type t = { dev_alias: string option; (** device alias *) reason: reason; (** why the tray status was changed *) } val to_string: t -> string end module PM_wakeup : sig type reason = [ | `Unknown of int ] type t = reason val to_string: t -> string end module PM_suspend : sig type reason = [ | `Unknown of int ] type t = reason val to_string: t -> string end module Balloon_change : sig type t = int64 val to_string: t -> string end module PM_suspend_disk : sig type reason = [ | `Unknown of int ] type t = reason val to_string: t -> string end type callback = | Lifecycle of ([`R] Domain.t -> Lifecycle.t -> unit) | Reboot of ([`R] Domain.t -> Reboot.t -> unit) | RtcChange of ([`R] Domain.t -> Rtc_change.t -> unit) | Watchdog of ([`R] Domain.t -> Watchdog.t -> unit) | IOError of ([`R] Domain.t -> Io_error.t -> unit) | Graphics of ([`R] Domain.t -> Graphics.t -> unit) | IOErrorReason of ([`R] Domain.t -> Io_error.t -> unit) | ControlError of ([`R] Domain.t -> Control_error.t -> unit) | BlockJob of ([`R] Domain.t -> Block_job.t -> unit) | DiskChange of ([`R] Domain.t -> Disk_change.t -> unit) | TrayChange of ([`R] Domain.t -> Tray_change.t -> unit) | PMWakeUp of ([`R] Domain.t -> PM_wakeup.t -> unit) | PMSuspend of ([`R] Domain.t -> PM_suspend.t -> unit) | BalloonChange of ([`R] Domain.t -> Balloon_change.t -> unit) | PMSuspendDisk of ([`R] Domain.t -> PM_suspend_disk.t -> unit) (** type of a registered call back function *) val register_default_impl : unit -> unit (** Registers the default event loop based on poll(). This must be done before connections are opened. Once registered call run_default_impl in a loop. *) val run_default_impl : unit -> unit (** Runs one iteration of the event loop. Applications will generally want to have a thread which invokes this in an infinite loop. *) type callback_id (** an individual event registration *) val register_any : 'a Connect.t -> ?dom:'a Domain.t -> callback -> callback_id (** [register_any con ?dom callback] registers [callback] to receive notification of arbitrary domain events. Return a registration id which can be used in [deregister_any]. If [?dom] is [None] then register for this kind of event on all domains. If [dom] is [Some d] then register for this kind of event only on [d]. *) val deregister_any : 'a Connect.t -> callback_id -> unit (** [deregister_any con id] deregisters the previously registered callback with id [id]. *) type timer_id (** an individual timer event *) val add_timeout : 'a Connect.t -> int -> (unit -> unit) -> timer_id (** [add_timeout con ms cb] registers [cb] as a timeout callback which will be called every [ms] milliseconds *) val remove_timeout : 'a Connect.t -> timer_id -> unit (** [remove_timeout con t] deregisters timeout callback [t]. *) end (** Module dealing with events generated by domain state changes. *) (** {3 Networks} *) module Network : sig type 'rw t (** Network handle. Read-only handles have type [ro Network.t] and read-write handles have type [rw Network.t]. *) val lookup_by_name : 'a Connect.t -> string -> 'a t (** Lookup a network by name. *) val lookup_by_uuid : 'a Connect.t -> uuid -> 'a t (** Lookup a network by (packed) UUID. *) val lookup_by_uuid_string : 'a Connect.t -> string -> 'a t (** Lookup a network by UUID string. *) val create_xml : [>`W] Connect.t -> xml -> rw t (** Create a network. *) val define_xml : [>`W] Connect.t -> xml -> rw t (** Define but don't activate a network. *) val undefine : [>`W] t -> unit (** Undefine configuration of a network. *) val create : [>`W] t -> unit (** Start up a defined (inactive) network. *) val destroy : [>`W] t -> unit (** Destroy a network. *) val free : [>`R] t -> unit (** [free network] frees the network object in memory. The network object is automatically freed if it is garbage collected. This function just forces it to be freed right away. *) val get_name : [>`R] t -> string (** Get network name. *) val get_uuid : [>`R] t -> uuid (** Get network packed UUID. *) val get_uuid_string : [>`R] t -> string (** Get network UUID as a printable string. *) val get_xml_desc : [>`R] t -> xml (** Get XML description of a network. *) val get_bridge_name : [>`R] t -> string (** Get bridge device name of a network. *) val get_autostart : [>`R] t -> bool (** Get the autostart flag for a network. *) val set_autostart : [>`W] t -> bool -> unit (** Set the autostart flag for a network. *) external const : [>`R] t -> ro t = "%identity" (** [const network] turns a read/write network handle into a read-only network handle. Note that the opposite operation is impossible. *) end (** Module dealing with networks. [Network.t] is the network object. *) (** {3 Storage pools} *) module Pool : sig type 'rw t (** Storage pool handle. *) type pool_state = Inactive | Building | Running | Degraded | Inaccessible (** State of the storage pool. *) type pool_build_flags = New | Repair | Resize (** Flags for creating a storage pool. *) type pool_delete_flags = Normal | Zeroed (** Flags for deleting a storage pool. *) type pool_info = { state : pool_state; (** Pool state. *) capacity : int64; (** Logical size in bytes. *) allocation : int64; (** Currently allocated in bytes. *) available : int64; (** Remaining free space bytes. *) } val lookup_by_name : 'a Connect.t -> string -> 'a t val lookup_by_uuid : 'a Connect.t -> uuid -> 'a t val lookup_by_uuid_string : 'a Connect.t -> string -> 'a t (** Look up a storage pool by name, UUID or UUID string. *) val create_xml : [>`W] Connect.t -> xml -> rw t (** Create a storage pool. *) val define_xml : [>`W] Connect.t -> xml -> rw t (** Define but don't activate a storage pool. *) val build : [>`W] t -> pool_build_flags -> unit (** Build a storage pool. *) val undefine : [>`W] t -> unit (** Undefine configuration of a storage pool. *) val create : [>`W] t -> unit (** Start up a defined (inactive) storage pool. *) val destroy : [>`W] t -> unit (** Destroy a storage pool. *) val delete : [>`W] t -> unit (** Delete a storage pool. *) val free : [>`R] t -> unit (** Free a storage pool object in memory. The storage pool object is automatically freed if it is garbage collected. This function just forces it to be freed right away. *) val refresh : [`R] t -> unit (** Refresh the list of volumes in the storage pool. *) val get_name : [`R] t -> string (** Name of the pool. *) val get_uuid : [`R] t -> uuid (** Get the UUID (as a packed byte array). *) val get_uuid_string : [`R] t -> string (** Get the UUID (as a printable string). *) val get_info : [`R] t -> pool_info (** Get information about the pool. *) val get_xml_desc : [`R] t -> xml (** Get the XML description. *) val get_autostart : [`R] t -> bool (** Get the autostart flag for the storage pool. *) val set_autostart : [>`W] t -> bool -> unit (** Set the autostart flag for the storage pool. *) val num_of_volumes : [`R] t -> int (** Returns the number of storage volumes within the storage pool. *) val list_volumes : [`R] t -> int -> string array (** Return list of storage volumes. *) external const : [>`R] t -> ro t = "%identity" (** [const conn] turns a read/write storage pool into a read-only pool. Note that the opposite operation is impossible. *) end (** Module dealing with storage pools. *) (** {3 Storage volumes} *) module Volume : sig type 'rw t (** Storage volume handle. *) type vol_type = File | Block | Dir | Network | NetDir | Ploop (** Type of a storage volume. *) type vol_delete_flags = Normal | Zeroed (** Flags for deleting a storage volume. *) type vol_info = { typ : vol_type; (** Type of storage volume. *) capacity : int64; (** Logical size in bytes. *) allocation : int64; (** Currently allocated in bytes. *) } val lookup_by_name : 'a Pool.t -> string -> 'a t val lookup_by_key : 'a Connect.t -> string -> 'a t val lookup_by_path : 'a Connect.t -> string -> 'a t (** Look up a storage volume by name, key or path volume. *) val pool_of_volume : 'a t -> 'a Pool.t (** Get the storage pool containing this volume. *) val get_name : [`R] t -> string (** Name of the volume. *) val get_key : [`R] t -> string (** Key of the volume. *) val get_path : [`R] t -> string (** Path of the volume. *) val get_info : [`R] t -> vol_info (** Get information about the storage volume. *) val get_xml_desc : [`R] t -> xml (** Get the XML description. *) val create_xml : [>`W] Pool.t -> xml -> unit (** Create a storage volume. *) val delete : [>`W] t -> vol_delete_flags -> unit (** Delete a storage volume. *) val free : [>`R] t -> unit (** Free a storage volume object in memory. The storage volume object is automatically freed if it is garbage collected. This function just forces it to be freed right away. *) external const : [>`R] t -> ro t = "%identity" (** [const conn] turns a read/write storage volume into a read-only volume. Note that the opposite operation is impossible. *) end (** Module dealing with storage volumes. *) (** {3 Secrets} *) module Secret : sig type 'rw t (** Secret handle. *) type secret_usage_type = | NoType | Volume | Ceph | ISCSI | TLS (** Usage type of a secret. *) val lookup_by_uuid : 'a Connect.t -> uuid -> 'a t (** Lookup a secret by UUID. This uses the packed byte array UUID. *) val lookup_by_uuid_string : 'a Connect.t -> string -> 'a t (** Lookup a secret by (string) UUID. *) val lookup_by_usage : 'a Connect.t -> secret_usage_type -> string -> 'a t (** Lookup a secret by usage type, and usage ID. *) val define_xml : [>`W] Connect.t -> xml -> rw t (** Define a secret. *) val get_uuid : [>`R] t -> uuid (** Get the UUID (as a packed byte array) of the secret. *) val get_uuid_string : [>`R] t -> string (** Get the UUID (as a printable string) of the secret. *) val get_usage_type : [>`R] t -> secret_usage_type (** Get the usage type of the secret. *) val get_usage_id : [>`R] t -> string (** Get the usage ID of the secret. *) val get_xml_desc : [>`R] t -> xml (** Get the XML description. *) val set_value : [>`W] t -> bytes -> unit (** Set a new value for the secret. *) val get_value : [>`R] t -> bytes (** Get the value of the secret. *) val undefine : [>`W] t -> unit (** Undefine a secret. *) val free : [>`R] t -> unit (** Free a secret object in memory. The secret object is automatically freed if it is garbage collected. This function just forces it to be freed right away. *) external const : [>`R] t -> ro t = "%identity" (** [const conn] turns a read/write secret into a read-only secret. Note that the opposite operation is impossible. *) end (** Module dealing with secrets. *) (** {3 Error handling and exceptions} *) module Virterror : sig type code = | VIR_ERR_OK | VIR_ERR_INTERNAL_ERROR | VIR_ERR_NO_MEMORY | VIR_ERR_NO_SUPPORT | VIR_ERR_UNKNOWN_HOST | VIR_ERR_NO_CONNECT | VIR_ERR_INVALID_CONN | VIR_ERR_INVALID_DOMAIN | VIR_ERR_INVALID_ARG | VIR_ERR_OPERATION_FAILED | VIR_ERR_GET_FAILED | VIR_ERR_POST_FAILED | VIR_ERR_HTTP_ERROR | VIR_ERR_SEXPR_SERIAL | VIR_ERR_NO_XEN | VIR_ERR_XEN_CALL | VIR_ERR_OS_TYPE | VIR_ERR_NO_KERNEL | VIR_ERR_NO_ROOT | VIR_ERR_NO_SOURCE | VIR_ERR_NO_TARGET | VIR_ERR_NO_NAME | VIR_ERR_NO_OS | VIR_ERR_NO_DEVICE | VIR_ERR_NO_XENSTORE | VIR_ERR_DRIVER_FULL | VIR_ERR_CALL_FAILED | VIR_ERR_XML_ERROR | VIR_ERR_DOM_EXIST | VIR_ERR_OPERATION_DENIED | VIR_ERR_OPEN_FAILED | VIR_ERR_READ_FAILED | VIR_ERR_PARSE_FAILED | VIR_ERR_CONF_SYNTAX | VIR_ERR_WRITE_FAILED | VIR_ERR_XML_DETAIL | VIR_ERR_INVALID_NETWORK | VIR_ERR_NETWORK_EXIST | VIR_ERR_SYSTEM_ERROR | VIR_ERR_RPC | VIR_ERR_GNUTLS_ERROR | VIR_WAR_NO_NETWORK | VIR_ERR_NO_DOMAIN | VIR_ERR_NO_NETWORK | VIR_ERR_INVALID_MAC | VIR_ERR_AUTH_FAILED | VIR_ERR_INVALID_STORAGE_POOL | VIR_ERR_INVALID_STORAGE_VOL | VIR_WAR_NO_STORAGE | VIR_ERR_NO_STORAGE_POOL | VIR_ERR_NO_STORAGE_VOL | VIR_WAR_NO_NODE | VIR_ERR_INVALID_NODE_DEVICE | VIR_ERR_NO_NODE_DEVICE | VIR_ERR_NO_SECURITY_MODEL | VIR_ERR_OPERATION_INVALID | VIR_WAR_NO_INTERFACE | VIR_ERR_NO_INTERFACE | VIR_ERR_INVALID_INTERFACE | VIR_ERR_MULTIPLE_INTERFACES | VIR_WAR_NO_NWFILTER | VIR_ERR_INVALID_NWFILTER | VIR_ERR_NO_NWFILTER | VIR_ERR_BUILD_FIREWALL | VIR_WAR_NO_SECRET | VIR_ERR_INVALID_SECRET | VIR_ERR_NO_SECRET | VIR_ERR_CONFIG_UNSUPPORTED | VIR_ERR_OPERATION_TIMEOUT | VIR_ERR_MIGRATE_PERSIST_FAILED | VIR_ERR_HOOK_SCRIPT_FAILED | VIR_ERR_INVALID_DOMAIN_SNAPSHOT | VIR_ERR_NO_DOMAIN_SNAPSHOT | VIR_ERR_INVALID_STREAM | VIR_ERR_ARGUMENT_UNSUPPORTED | VIR_ERR_STORAGE_PROBE_FAILED | VIR_ERR_STORAGE_POOL_BUILT | VIR_ERR_SNAPSHOT_REVERT_RISKY | VIR_ERR_OPERATION_ABORTED | VIR_ERR_AUTH_CANCELLED | VIR_ERR_NO_DOMAIN_METADATA | VIR_ERR_MIGRATE_UNSAFE | VIR_ERR_OVERFLOW | VIR_ERR_BLOCK_COPY_ACTIVE | VIR_ERR_OPERATION_UNSUPPORTED | VIR_ERR_SSH | VIR_ERR_AGENT_UNRESPONSIVE | VIR_ERR_RESOURCE_BUSY | VIR_ERR_ACCESS_DENIED | VIR_ERR_DBUS_SERVICE | VIR_ERR_STORAGE_VOL_EXIST | VIR_ERR_CPU_INCOMPATIBLE | VIR_ERR_XML_INVALID_SCHEMA | VIR_ERR_MIGRATE_FINISH_OK | VIR_ERR_AUTH_UNAVAILABLE | VIR_ERR_NO_SERVER | VIR_ERR_NO_CLIENT | VIR_ERR_AGENT_UNSYNCED | VIR_ERR_LIBSSH | VIR_ERR_DEVICE_MISSING | VIR_ERR_INVALID_NWFILTER_BINDING | VIR_ERR_NO_NWFILTER_BINDING | VIR_ERR_INVALID_DOMAIN_CHECKPOINT | VIR_ERR_NO_DOMAIN_CHECKPOINT | VIR_ERR_NO_DOMAIN_BACKUP | VIR_ERR_INVALID_NETWORK_PORT | VIR_ERR_NETWORK_PORT_EXIST | VIR_ERR_NO_NETWORK_PORT (* ^^ NB: If you add a variant you MUST edit libvirt_c_common.c:MAX_VIR_* *) | VIR_ERR_UNKNOWN of int (** Other error, not handled with existing values. *) (** See [] for meaning of these codes. *) val string_of_code : code -> string type domain = | VIR_FROM_NONE | VIR_FROM_XEN | VIR_FROM_XEND | VIR_FROM_XENSTORE | VIR_FROM_SEXPR | VIR_FROM_XML | VIR_FROM_DOM | VIR_FROM_RPC | VIR_FROM_PROXY | VIR_FROM_CONF | VIR_FROM_QEMU | VIR_FROM_NET | VIR_FROM_TEST | VIR_FROM_REMOTE | VIR_FROM_OPENVZ | VIR_FROM_XENXM | VIR_FROM_STATS_LINUX | VIR_FROM_LXC | VIR_FROM_STORAGE | VIR_FROM_NETWORK | VIR_FROM_DOMAIN | VIR_FROM_UML | VIR_FROM_NODEDEV | VIR_FROM_XEN_INOTIFY | VIR_FROM_SECURITY | VIR_FROM_VBOX | VIR_FROM_INTERFACE | VIR_FROM_ONE | VIR_FROM_ESX | VIR_FROM_PHYP | VIR_FROM_SECRET | VIR_FROM_CPU | VIR_FROM_XENAPI | VIR_FROM_NWFILTER | VIR_FROM_HOOK | VIR_FROM_DOMAIN_SNAPSHOT | VIR_FROM_AUDIT | VIR_FROM_SYSINFO | VIR_FROM_STREAMS | VIR_FROM_VMWARE | VIR_FROM_EVENT | VIR_FROM_LIBXL | VIR_FROM_LOCKING | VIR_FROM_HYPERV | VIR_FROM_CAPABILITIES | VIR_FROM_URI | VIR_FROM_AUTH | VIR_FROM_DBUS | VIR_FROM_PARALLELS | VIR_FROM_DEVICE | VIR_FROM_SSH | VIR_FROM_LOCKSPACE | VIR_FROM_INITCTL | VIR_FROM_IDENTITY | VIR_FROM_CGROUP | VIR_FROM_ACCESS | VIR_FROM_SYSTEMD | VIR_FROM_BHYVE | VIR_FROM_CRYPTO | VIR_FROM_FIREWALL | VIR_FROM_POLKIT | VIR_FROM_THREAD | VIR_FROM_ADMIN | VIR_FROM_LOGGING | VIR_FROM_XENXL | VIR_FROM_PERF | VIR_FROM_LIBSSH | VIR_FROM_RESCTRL | VIR_FROM_FIREWALLD | VIR_FROM_DOMAIN_CHECKPOINT | VIR_FROM_TPM | VIR_FROM_BPF (* ^^ NB: If you add a variant you MUST edit libvirt_c_common.c: MAX_VIR_* *) | VIR_FROM_UNKNOWN of int (** Other domain, not handled with existing values. *) (** Subsystem / driver which produced the error. *) val string_of_domain : domain -> string type level = | VIR_ERR_NONE | VIR_ERR_WARNING | VIR_ERR_ERROR (* ^^ NB: If you add a variant you MUST edit libvirt_generated.c: MAX_VIR_* *) | VIR_ERR_UNKNOWN_LEVEL of int (** Other level, not handled with existing values. *) (** No error, a warning or an error. *) val string_of_level : level -> string type t = { code : code; (** Error code. *) domain : domain; (** Origin of the error. *) message : string option; (** Human-readable message. *) level : level; (** Error or warning. *) str1 : string option; (** Informational string. *) str2 : string option; (** Informational string. *) str3 : string option; (** Informational string. *) int1 : int32; (** Informational integer. *) int2 : int32; (** Informational integer. *) } (** An error object. *) val to_string : t -> string (** Turn the exception into a printable string. *) val get_last_error : unit -> t option val get_last_conn_error : [>`R] Connect.t -> t option (** Get the last error at a global or connection level. Normally you do not need to use these functions because the library automatically turns errors into exceptions. *) val reset_last_error : unit -> unit val reset_last_conn_error : [>`R] Connect.t -> unit (** Reset the error at a global or connection level. Normally you do not need to use these functions. *) val no_error : unit -> t (** Creates an empty error message. Normally you do not need to use this function. *) end (** Module dealing with errors. *) exception Virterror of Virterror.t (** This exception can be raised by any library function that detects an error. To get a printable error message, call {!Virterror.to_string} on the content of this exception. *) exception Not_supported of string (** Functions may raise [Not_supported "virFoo"] (where [virFoo] is the libvirt function name) if a function is not supported at either compile or run time. This applies to any libvirt function added after version 0.2.1. See also {{:https://libvirt.org/hvsupport.html}https://libvirt.org/hvsupport.html} *) (** {3 Utility functions} *) val map_ignore_errors : ('a -> 'b) -> 'a list -> 'b list (** [map_ignore_errors f xs] calls function [f] for each element of [xs]. This is just like [List.map] except that if [f x] throws a {!Virterror.t} exception, the error is ignored and [f x] is not returned in the final list. This function is primarily useful when dealing with domains which might 'disappear' asynchronously from the currently running program. *) virt-v2v-1.44.2/bundled/libvirt-ocaml/PaxHeaders/libvirt.README0000644000000000000000000000013213631710510021067 xustar0030 mtime=1583845704.125871044 30 atime=1637752334.902869347 30 ctime=1637862790.586851329 virt-v2v-1.44.2/bundled/libvirt-ocaml/libvirt.README0000664000175000017500000000072113631710510022675 0ustar00rjonesrjones00000000000000The files generator.pl, libvirt_c.h, libvirt_c_oneoffs.c, libvirt_c_common.c, libvirt.ml, and libvirt.mli come from the libvirt-ocaml library: https://libvirt.org/git/?p=libvirt-ocaml.git which is released under a compatible license. We want to keep them identical, so changes to these files must be submitted to libvirt-ocaml first. Before virt-v2v 1.42 is released we hope to have unbundled this library and will require that libvirt-ocaml is used instead. virt-v2v-1.44.2/bundled/libvirt-ocaml/PaxHeaders/libvirt_generated.c0000644000000000000000000000013214147746573022417 xustar0030 mtime=1637862779.602973019 30 atime=1637862779.622972797 30 ctime=1637862790.574851462 virt-v2v-1.44.2/bundled/libvirt-ocaml/libvirt_generated.c0000644000175000017500000015467414147746573024244 0ustar00rjonesrjones00000000000000/* !!! WARNING WARNING WARNING WARNING WARNING WARNING WARNING !!! * * THIS FILE IS AUTOMATICALLY GENERATED BY 'generator.pl'. * * Any changes you make to this file may be overwritten. */ /* OCaml bindings for libvirt. * (C) Copyright 2007-2015 Richard W.M. Jones, Red Hat Inc. * https://libvirt.org/ * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version, * with the OCaml linking exception described in ../COPYING.LIB. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "libvirt_c.h" #ifdef __GNUC__ #pragma GCC diagnostic ignored "-Wmissing-prototypes" #endif /* Automatically generated binding for virConnectClose. * In generator.pl this function has signature "conn : free". */ CAMLprim value ocaml_libvirt_connect_close (value connv) { CAMLparam1 (connv); virConnectPtr conn = Connect_val (connv); int r; NONBLOCKING (r = virConnectClose (conn)); CHECK_ERROR (r == -1, "virConnectClose"); /* So that we don't double-free in the finalizer: */ Connect_val (connv) = NULL; CAMLreturn (Val_unit); } /* Automatically generated binding for virConnectGetHostname. * In generator.pl this function has signature "conn : string". */ CAMLprim value ocaml_libvirt_connect_get_hostname (value connv) { CAMLparam1 (connv); CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); char *r; NONBLOCKING (r = virConnectGetHostname (conn)); CHECK_ERROR (!r, "virConnectGetHostname"); rv = caml_copy_string (r); free (r); CAMLreturn (rv); } /* Automatically generated binding for virConnectGetURI. * In generator.pl this function has signature "conn : string". */ CAMLprim value ocaml_libvirt_connect_get_uri (value connv) { CAMLparam1 (connv); CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); char *r; NONBLOCKING (r = virConnectGetURI (conn)); CHECK_ERROR (!r, "virConnectGetURI"); rv = caml_copy_string (r); free (r); CAMLreturn (rv); } /* Automatically generated binding for virConnectGetType. * In generator.pl this function has signature "conn : static string". */ CAMLprim value ocaml_libvirt_connect_get_type (value connv) { CAMLparam1 (connv); CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); const char *r; NONBLOCKING (r = virConnectGetType (conn)); CHECK_ERROR (!r, "virConnectGetType"); rv = caml_copy_string (r); CAMLreturn (rv); } /* Automatically generated binding for virConnectNumOfDomains. * In generator.pl this function has signature "conn : int". */ CAMLprim value ocaml_libvirt_connect_num_of_domains (value connv) { CAMLparam1 (connv); virConnectPtr conn = Connect_val (connv); int r; NONBLOCKING (r = virConnectNumOfDomains (conn)); CHECK_ERROR (r == -1, "virConnectNumOfDomains"); CAMLreturn (Val_int (r)); } /* Automatically generated binding for virConnectListDomains. * In generator.pl this function has signature "conn, int : int array". */ CAMLprim value ocaml_libvirt_connect_list_domains (value connv, value iv) { CAMLparam2 (connv, iv); CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); int i = Int_val (iv); int *ids, r; /* Some libvirt List* functions still throw exceptions if i == 0, * so catch that and return an empty array directly. This changes * the semantics slightly (masking other failures) but it's * unlikely anyone will care. RWMJ 2008/06/10 */ if (i == 0) { rv = caml_alloc (0, 0); CAMLreturn (rv); } ids = malloc (sizeof (*ids) * i); if (ids == NULL) caml_raise_out_of_memory (); NONBLOCKING (r = virConnectListDomains (conn, ids, i)); CHECK_ERROR_CLEANUP (r == -1, free (ids), "virConnectListDomains"); rv = caml_alloc (r, 0); for (i = 0; i < r; ++i) Store_field (rv, i, Val_int (ids[i])); free (ids); CAMLreturn (rv); } /* Automatically generated binding for virConnectNumOfDefinedDomains. * In generator.pl this function has signature "conn : int". */ CAMLprim value ocaml_libvirt_connect_num_of_defined_domains (value connv) { CAMLparam1 (connv); virConnectPtr conn = Connect_val (connv); int r; NONBLOCKING (r = virConnectNumOfDefinedDomains (conn)); CHECK_ERROR (r == -1, "virConnectNumOfDefinedDomains"); CAMLreturn (Val_int (r)); } /* Automatically generated binding for virConnectListDefinedDomains. * In generator.pl this function has signature "conn, int : string array". */ CAMLprim value ocaml_libvirt_connect_list_defined_domains (value connv, value iv) { CAMLparam2 (connv, iv); CAMLlocal2 (rv, strv); virConnectPtr conn = Connect_val (connv); int i = Int_val (iv); char **names; int r; /* Some libvirt List* functions still throw exceptions if i == 0, * so catch that and return an empty array directly. This changes * the semantics slightly (masking other failures) but it's * unlikely anyone will care. RWMJ 2008/06/10 */ if (i == 0) { rv = caml_alloc (0, 0); CAMLreturn (rv); } names = malloc (sizeof (*names) * i); if (names == NULL) caml_raise_out_of_memory (); NONBLOCKING (r = virConnectListDefinedDomains (conn, names, i)); CHECK_ERROR_CLEANUP (r == -1, free (names), "virConnectListDefinedDomains"); rv = caml_alloc (r, 0); for (i = 0; i < r; ++i) { strv = caml_copy_string (names[i]); Store_field (rv, i, strv); free (names[i]); } free (names); CAMLreturn (rv); } /* Automatically generated binding for virConnectNumOfNetworks. * In generator.pl this function has signature "conn : int". */ CAMLprim value ocaml_libvirt_connect_num_of_networks (value connv) { CAMLparam1 (connv); virConnectPtr conn = Connect_val (connv); int r; NONBLOCKING (r = virConnectNumOfNetworks (conn)); CHECK_ERROR (r == -1, "virConnectNumOfNetworks"); CAMLreturn (Val_int (r)); } /* Automatically generated binding for virConnectListNetworks. * In generator.pl this function has signature "conn, int : string array". */ CAMLprim value ocaml_libvirt_connect_list_networks (value connv, value iv) { CAMLparam2 (connv, iv); CAMLlocal2 (rv, strv); virConnectPtr conn = Connect_val (connv); int i = Int_val (iv); char **names; int r; /* Some libvirt List* functions still throw exceptions if i == 0, * so catch that and return an empty array directly. This changes * the semantics slightly (masking other failures) but it's * unlikely anyone will care. RWMJ 2008/06/10 */ if (i == 0) { rv = caml_alloc (0, 0); CAMLreturn (rv); } names = malloc (sizeof (*names) * i); if (names == NULL) caml_raise_out_of_memory (); NONBLOCKING (r = virConnectListNetworks (conn, names, i)); CHECK_ERROR_CLEANUP (r == -1, free (names), "virConnectListNetworks"); rv = caml_alloc (r, 0); for (i = 0; i < r; ++i) { strv = caml_copy_string (names[i]); Store_field (rv, i, strv); free (names[i]); } free (names); CAMLreturn (rv); } /* Automatically generated binding for virConnectNumOfDefinedNetworks. * In generator.pl this function has signature "conn : int". */ CAMLprim value ocaml_libvirt_connect_num_of_defined_networks (value connv) { CAMLparam1 (connv); virConnectPtr conn = Connect_val (connv); int r; NONBLOCKING (r = virConnectNumOfDefinedNetworks (conn)); CHECK_ERROR (r == -1, "virConnectNumOfDefinedNetworks"); CAMLreturn (Val_int (r)); } /* Automatically generated binding for virConnectListDefinedNetworks. * In generator.pl this function has signature "conn, int : string array". */ CAMLprim value ocaml_libvirt_connect_list_defined_networks (value connv, value iv) { CAMLparam2 (connv, iv); CAMLlocal2 (rv, strv); virConnectPtr conn = Connect_val (connv); int i = Int_val (iv); char **names; int r; /* Some libvirt List* functions still throw exceptions if i == 0, * so catch that and return an empty array directly. This changes * the semantics slightly (masking other failures) but it's * unlikely anyone will care. RWMJ 2008/06/10 */ if (i == 0) { rv = caml_alloc (0, 0); CAMLreturn (rv); } names = malloc (sizeof (*names) * i); if (names == NULL) caml_raise_out_of_memory (); NONBLOCKING (r = virConnectListDefinedNetworks (conn, names, i)); CHECK_ERROR_CLEANUP (r == -1, free (names), "virConnectListDefinedNetworks"); rv = caml_alloc (r, 0); for (i = 0; i < r; ++i) { strv = caml_copy_string (names[i]); Store_field (rv, i, strv); free (names[i]); } free (names); CAMLreturn (rv); } /* Automatically generated binding for virConnectNumOfStoragePools. * In generator.pl this function has signature "conn : int". */ CAMLprim value ocaml_libvirt_connect_num_of_storage_pools (value connv) { CAMLparam1 (connv); virConnectPtr conn = Connect_val (connv); int r; NONBLOCKING (r = virConnectNumOfStoragePools (conn)); CHECK_ERROR (r == -1, "virConnectNumOfStoragePools"); CAMLreturn (Val_int (r)); } /* Automatically generated binding for virConnectListStoragePools. * In generator.pl this function has signature "conn, int : string array". */ CAMLprim value ocaml_libvirt_connect_list_storage_pools (value connv, value iv) { CAMLparam2 (connv, iv); CAMLlocal2 (rv, strv); virConnectPtr conn = Connect_val (connv); int i = Int_val (iv); char **names; int r; /* Some libvirt List* functions still throw exceptions if i == 0, * so catch that and return an empty array directly. This changes * the semantics slightly (masking other failures) but it's * unlikely anyone will care. RWMJ 2008/06/10 */ if (i == 0) { rv = caml_alloc (0, 0); CAMLreturn (rv); } names = malloc (sizeof (*names) * i); if (names == NULL) caml_raise_out_of_memory (); NONBLOCKING (r = virConnectListStoragePools (conn, names, i)); CHECK_ERROR_CLEANUP (r == -1, free (names), "virConnectListStoragePools"); rv = caml_alloc (r, 0); for (i = 0; i < r; ++i) { strv = caml_copy_string (names[i]); Store_field (rv, i, strv); free (names[i]); } free (names); CAMLreturn (rv); } /* Automatically generated binding for virConnectNumOfDefinedStoragePools. * In generator.pl this function has signature "conn : int". */ CAMLprim value ocaml_libvirt_connect_num_of_defined_storage_pools (value connv) { CAMLparam1 (connv); virConnectPtr conn = Connect_val (connv); int r; NONBLOCKING (r = virConnectNumOfDefinedStoragePools (conn)); CHECK_ERROR (r == -1, "virConnectNumOfDefinedStoragePools"); CAMLreturn (Val_int (r)); } /* Automatically generated binding for virConnectListDefinedStoragePools. * In generator.pl this function has signature "conn, int : string array". */ CAMLprim value ocaml_libvirt_connect_list_defined_storage_pools (value connv, value iv) { CAMLparam2 (connv, iv); CAMLlocal2 (rv, strv); virConnectPtr conn = Connect_val (connv); int i = Int_val (iv); char **names; int r; /* Some libvirt List* functions still throw exceptions if i == 0, * so catch that and return an empty array directly. This changes * the semantics slightly (masking other failures) but it's * unlikely anyone will care. RWMJ 2008/06/10 */ if (i == 0) { rv = caml_alloc (0, 0); CAMLreturn (rv); } names = malloc (sizeof (*names) * i); if (names == NULL) caml_raise_out_of_memory (); NONBLOCKING (r = virConnectListDefinedStoragePools (conn, names, i)); CHECK_ERROR_CLEANUP (r == -1, free (names), "virConnectListDefinedStoragePools"); rv = caml_alloc (r, 0); for (i = 0; i < r; ++i) { strv = caml_copy_string (names[i]); Store_field (rv, i, strv); free (names[i]); } free (names); CAMLreturn (rv); } /* Automatically generated binding for virConnectNumOfSecrets. * In generator.pl this function has signature "conn : int". */ CAMLprim value ocaml_libvirt_connect_num_of_secrets (value connv) { CAMLparam1 (connv); virConnectPtr conn = Connect_val (connv); int r; NONBLOCKING (r = virConnectNumOfSecrets (conn)); CHECK_ERROR (r == -1, "virConnectNumOfSecrets"); CAMLreturn (Val_int (r)); } /* Automatically generated binding for virConnectListSecrets. * In generator.pl this function has signature "conn, int : string array". */ CAMLprim value ocaml_libvirt_connect_list_secrets (value connv, value iv) { CAMLparam2 (connv, iv); CAMLlocal2 (rv, strv); virConnectPtr conn = Connect_val (connv); int i = Int_val (iv); char **names; int r; /* Some libvirt List* functions still throw exceptions if i == 0, * so catch that and return an empty array directly. This changes * the semantics slightly (masking other failures) but it's * unlikely anyone will care. RWMJ 2008/06/10 */ if (i == 0) { rv = caml_alloc (0, 0); CAMLreturn (rv); } names = malloc (sizeof (*names) * i); if (names == NULL) caml_raise_out_of_memory (); NONBLOCKING (r = virConnectListSecrets (conn, names, i)); CHECK_ERROR_CLEANUP (r == -1, free (names), "virConnectListSecrets"); rv = caml_alloc (r, 0); for (i = 0; i < r; ++i) { strv = caml_copy_string (names[i]); Store_field (rv, i, strv); free (names[i]); } free (names); CAMLreturn (rv); } /* Automatically generated binding for virConnectGetCapabilities. * In generator.pl this function has signature "conn : string". */ CAMLprim value ocaml_libvirt_connect_get_capabilities (value connv) { CAMLparam1 (connv); CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); char *r; NONBLOCKING (r = virConnectGetCapabilities (conn)); CHECK_ERROR (!r, "virConnectGetCapabilities"); rv = caml_copy_string (r); free (r); CAMLreturn (rv); } /* Automatically generated binding for virConnectDomainEventDeregisterAny. * In generator.pl this function has signature "conn, int : unit". */ CAMLprim value ocaml_libvirt_connect_domain_event_deregister_any (value connv, value iv) { CAMLparam2 (connv, iv); virConnectPtr conn = Connect_val (connv); int i = Int_val (iv); int r; NONBLOCKING (r = virConnectDomainEventDeregisterAny (conn, i)); CHECK_ERROR (r == -1, "virConnectDomainEventDeregisterAny"); CAMLreturn (Val_unit); } /* Automatically generated binding for virDomainCreateLinux. * In generator.pl this function has signature "conn, string, 0U : dom". */ CAMLprim value ocaml_libvirt_domain_create_linux (value connv, value strv) { CAMLparam2 (connv, strv); CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); const char *str = String_val (strv); virDomainPtr r; NONBLOCKING (r = virDomainCreateLinux (conn, str, 0)); CHECK_ERROR (!r, "virDomainCreateLinux"); rv = Val_domain (r, connv); CAMLreturn (rv); } /* Automatically generated binding for virDomainCreateXML. * In generator.pl this function has signature "conn, string, unsigned : dom". */ CAMLprim value ocaml_libvirt_domain_create_xml (value connv, value strv, value uv) { CAMLparam3 (connv, strv, uv); CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); const char *str = String_val (strv); unsigned int u = Int_val (uv); virDomainPtr r; NONBLOCKING (r = virDomainCreateXML (conn, str, u)); CHECK_ERROR (!r, "virDomainCreateXML"); rv = Val_domain (r, connv); CAMLreturn (rv); } /* Automatically generated binding for virDomainFree. * In generator.pl this function has signature "dom : free". */ CAMLprim value ocaml_libvirt_domain_free (value domv) { CAMLparam1 (domv); virDomainPtr dom = Domain_val (domv); int r; NONBLOCKING (r = virDomainFree (dom)); CHECK_ERROR (r == -1, "virDomainFree"); /* So that we don't double-free in the finalizer: */ Domain_val (domv) = NULL; CAMLreturn (Val_unit); } /* Automatically generated binding for virDomainDestroy. * In generator.pl this function has signature "dom : free". */ CAMLprim value ocaml_libvirt_domain_destroy (value domv) { CAMLparam1 (domv); virDomainPtr dom = Domain_val (domv); int r; NONBLOCKING (r = virDomainDestroy (dom)); CHECK_ERROR (r == -1, "virDomainDestroy"); /* So that we don't double-free in the finalizer: */ Domain_val (domv) = NULL; CAMLreturn (Val_unit); } /* Automatically generated binding for virDomainLookupByName. * In generator.pl this function has signature "conn, string : dom". */ CAMLprim value ocaml_libvirt_domain_lookup_by_name (value connv, value strv) { CAMLparam2 (connv, strv); CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); const char *str = String_val (strv); virDomainPtr r; NONBLOCKING (r = virDomainLookupByName (conn, str)); CHECK_ERROR (!r, "virDomainLookupByName"); rv = Val_domain (r, connv); CAMLreturn (rv); } /* Automatically generated binding for virDomainLookupByID. * In generator.pl this function has signature "conn, int : dom". */ CAMLprim value ocaml_libvirt_domain_lookup_by_id (value connv, value iv) { CAMLparam2 (connv, iv); CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); int i = Int_val (iv); virDomainPtr r; NONBLOCKING (r = virDomainLookupByID (conn, i)); CHECK_ERROR (!r, "virDomainLookupByID"); rv = Val_domain (r, connv); CAMLreturn (rv); } /* Automatically generated binding for virDomainLookupByUUID. * In generator.pl this function has signature "conn, uuid : dom". */ CAMLprim value ocaml_libvirt_domain_lookup_by_uuid (value connv, value uuidv) { CAMLparam2 (connv, uuidv); CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); unsigned char *uuid = (unsigned char *) String_val (uuidv); virDomainPtr r; NONBLOCKING (r = virDomainLookupByUUID (conn, uuid)); CHECK_ERROR (!r, "virDomainLookupByUUID"); rv = Val_domain (r, connv); CAMLreturn (rv); } /* Automatically generated binding for virDomainLookupByUUIDString. * In generator.pl this function has signature "conn, string : dom". */ CAMLprim value ocaml_libvirt_domain_lookup_by_uuid_string (value connv, value strv) { CAMLparam2 (connv, strv); CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); const char *str = String_val (strv); virDomainPtr r; NONBLOCKING (r = virDomainLookupByUUIDString (conn, str)); CHECK_ERROR (!r, "virDomainLookupByUUIDString"); rv = Val_domain (r, connv); CAMLreturn (rv); } /* Automatically generated binding for virDomainGetName. * In generator.pl this function has signature "dom : static string". */ CAMLprim value ocaml_libvirt_domain_get_name (value domv) { CAMLparam1 (domv); CAMLlocal1 (rv); virDomainPtr dom = Domain_val (domv); const char *r; NONBLOCKING (r = virDomainGetName (dom)); CHECK_ERROR (!r, "virDomainGetName"); rv = caml_copy_string (r); CAMLreturn (rv); } /* Automatically generated binding for virDomainGetOSType. * In generator.pl this function has signature "dom : string". */ CAMLprim value ocaml_libvirt_domain_get_os_type (value domv) { CAMLparam1 (domv); CAMLlocal1 (rv); virDomainPtr dom = Domain_val (domv); char *r; NONBLOCKING (r = virDomainGetOSType (dom)); CHECK_ERROR (!r, "virDomainGetOSType"); rv = caml_copy_string (r); free (r); CAMLreturn (rv); } /* Automatically generated binding for virDomainGetXMLDesc. * In generator.pl this function has signature "dom, 0 : string". */ CAMLprim value ocaml_libvirt_domain_get_xml_desc (value domv) { CAMLparam1 (domv); CAMLlocal1 (rv); virDomainPtr dom = Domain_val (domv); char *r; NONBLOCKING (r = virDomainGetXMLDesc (dom, 0)); CHECK_ERROR (!r, "virDomainGetXMLDesc"); rv = caml_copy_string (r); free (r); CAMLreturn (rv); } /* Automatically generated binding for virDomainGetUUID. * In generator.pl this function has signature "dom : uuid". */ CAMLprim value ocaml_libvirt_domain_get_uuid (value domv) { CAMLparam1 (domv); CAMLlocal1 (rv); virDomainPtr dom = Domain_val (domv); unsigned char uuid[VIR_UUID_BUFLEN]; int r; NONBLOCKING (r = virDomainGetUUID (dom, uuid)); CHECK_ERROR (r == -1, "virDomainGetUUID"); /* UUIDs are byte arrays with a fixed length. */ rv = caml_alloc_string (VIR_UUID_BUFLEN); memcpy (Bytes_val (rv), uuid, VIR_UUID_BUFLEN); CAMLreturn (rv); } /* Automatically generated binding for virDomainGetUUIDString. * In generator.pl this function has signature "dom : uuid string". */ CAMLprim value ocaml_libvirt_domain_get_uuid_string (value domv) { CAMLparam1 (domv); CAMLlocal1 (rv); virDomainPtr dom = Domain_val (domv); char uuid[VIR_UUID_STRING_BUFLEN]; int r; NONBLOCKING (r = virDomainGetUUIDString (dom, uuid)); CHECK_ERROR (r == -1, "virDomainGetUUIDString"); rv = caml_copy_string (uuid); CAMLreturn (rv); } /* Automatically generated binding for virDomainGetMaxVcpus. * In generator.pl this function has signature "dom : int". */ CAMLprim value ocaml_libvirt_domain_get_max_vcpus (value domv) { CAMLparam1 (domv); virDomainPtr dom = Domain_val (domv); int r; NONBLOCKING (r = virDomainGetMaxVcpus (dom)); CHECK_ERROR (r == -1, "virDomainGetMaxVcpus"); CAMLreturn (Val_int (r)); } /* Automatically generated binding for virDomainSave. * In generator.pl this function has signature "dom, string : unit". */ CAMLprim value ocaml_libvirt_domain_save (value domv, value strv) { CAMLparam2 (domv, strv); virDomainPtr dom = Domain_val (domv); const char *str = String_val (strv); int r; NONBLOCKING (r = virDomainSave (dom, str)); CHECK_ERROR (r == -1, "virDomainSave"); CAMLreturn (Val_unit); } /* Automatically generated binding for virDomainRestore. * In generator.pl this function has signature "conn, string : unit". */ CAMLprim value ocaml_libvirt_domain_restore (value connv, value strv) { CAMLparam2 (connv, strv); virConnectPtr conn = Connect_val (connv); const char *str = String_val (strv); int r; NONBLOCKING (r = virDomainRestore (conn, str)); CHECK_ERROR (r == -1, "virDomainRestore"); CAMLreturn (Val_unit); } /* Automatically generated binding for virDomainCoreDump. * In generator.pl this function has signature "dom, string, 0 : unit". */ CAMLprim value ocaml_libvirt_domain_core_dump (value domv, value strv) { CAMLparam2 (domv, strv); CAMLlocal1 (rv); virDomainPtr dom = Domain_val (domv); const char *str = String_val (strv); int r; NONBLOCKING (r = virDomainCoreDump (dom, str, 0)); CHECK_ERROR (!r, "virDomainCoreDump"); CAMLreturn (Val_unit); } /* Automatically generated binding for virDomainSuspend. * In generator.pl this function has signature "dom : unit". */ CAMLprim value ocaml_libvirt_domain_suspend (value domv) { CAMLparam1 (domv); virDomainPtr dom = Domain_val (domv); int r; NONBLOCKING (r = virDomainSuspend (dom)); CHECK_ERROR (r == -1, "virDomainSuspend"); CAMLreturn (Val_unit); } /* Automatically generated binding for virDomainResume. * In generator.pl this function has signature "dom : unit". */ CAMLprim value ocaml_libvirt_domain_resume (value domv) { CAMLparam1 (domv); virDomainPtr dom = Domain_val (domv); int r; NONBLOCKING (r = virDomainResume (dom)); CHECK_ERROR (r == -1, "virDomainResume"); CAMLreturn (Val_unit); } /* Automatically generated binding for virDomainShutdown. * In generator.pl this function has signature "dom : unit". */ CAMLprim value ocaml_libvirt_domain_shutdown (value domv) { CAMLparam1 (domv); virDomainPtr dom = Domain_val (domv); int r; NONBLOCKING (r = virDomainShutdown (dom)); CHECK_ERROR (r == -1, "virDomainShutdown"); CAMLreturn (Val_unit); } /* Automatically generated binding for virDomainReboot. * In generator.pl this function has signature "dom, 0 : unit". */ CAMLprim value ocaml_libvirt_domain_reboot (value domv) { CAMLparam1 (domv); virDomainPtr dom = Domain_val (domv); int r; NONBLOCKING (r = virDomainReboot (dom, 0)); CHECK_ERROR (r == -1, "virDomainReboot"); CAMLreturn (Val_unit); } /* Automatically generated binding for virDomainDefineXML. * In generator.pl this function has signature "conn, string : dom". */ CAMLprim value ocaml_libvirt_domain_define_xml (value connv, value strv) { CAMLparam2 (connv, strv); CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); const char *str = String_val (strv); virDomainPtr r; NONBLOCKING (r = virDomainDefineXML (conn, str)); CHECK_ERROR (!r, "virDomainDefineXML"); rv = Val_domain (r, connv); CAMLreturn (rv); } /* Automatically generated binding for virDomainUndefine. * In generator.pl this function has signature "dom : unit". */ CAMLprim value ocaml_libvirt_domain_undefine (value domv) { CAMLparam1 (domv); virDomainPtr dom = Domain_val (domv); int r; NONBLOCKING (r = virDomainUndefine (dom)); CHECK_ERROR (r == -1, "virDomainUndefine"); CAMLreturn (Val_unit); } /* Automatically generated binding for virDomainCreate. * In generator.pl this function has signature "dom : unit". */ CAMLprim value ocaml_libvirt_domain_create (value domv) { CAMLparam1 (domv); virDomainPtr dom = Domain_val (domv); int r; NONBLOCKING (r = virDomainCreate (dom)); CHECK_ERROR (r == -1, "virDomainCreate"); CAMLreturn (Val_unit); } /* Automatically generated binding for virDomainAttachDevice. * In generator.pl this function has signature "dom, string : unit". */ CAMLprim value ocaml_libvirt_domain_attach_device (value domv, value strv) { CAMLparam2 (domv, strv); virDomainPtr dom = Domain_val (domv); const char *str = String_val (strv); int r; NONBLOCKING (r = virDomainAttachDevice (dom, str)); CHECK_ERROR (r == -1, "virDomainAttachDevice"); CAMLreturn (Val_unit); } /* Automatically generated binding for virDomainDetachDevice. * In generator.pl this function has signature "dom, string : unit". */ CAMLprim value ocaml_libvirt_domain_detach_device (value domv, value strv) { CAMLparam2 (domv, strv); virDomainPtr dom = Domain_val (domv); const char *str = String_val (strv); int r; NONBLOCKING (r = virDomainDetachDevice (dom, str)); CHECK_ERROR (r == -1, "virDomainDetachDevice"); CAMLreturn (Val_unit); } /* Automatically generated binding for virDomainGetAutostart. * In generator.pl this function has signature "dom : bool". */ CAMLprim value ocaml_libvirt_domain_get_autostart (value domv) { CAMLparam1 (domv); virDomainPtr dom = Domain_val (domv); int r, b; NONBLOCKING (r = virDomainGetAutostart (dom, &b)); CHECK_ERROR (r == -1, "virDomainGetAutostart"); CAMLreturn (b ? Val_true : Val_false); } /* Automatically generated binding for virDomainSetAutostart. * In generator.pl this function has signature "dom, bool : unit". */ CAMLprim value ocaml_libvirt_domain_set_autostart (value domv, value bv) { CAMLparam2 (domv, bv); virDomainPtr dom = Domain_val (domv); int r, b; b = bv == Val_true ? 1 : 0; NONBLOCKING (r = virDomainSetAutostart (dom, b)); CHECK_ERROR (r == -1, "virDomainSetAutostart"); CAMLreturn (Val_unit); } /* Automatically generated binding for virNetworkFree. * In generator.pl this function has signature "net : free". */ CAMLprim value ocaml_libvirt_network_free (value netv) { CAMLparam1 (netv); virNetworkPtr net = Network_val (netv); int r; NONBLOCKING (r = virNetworkFree (net)); CHECK_ERROR (r == -1, "virNetworkFree"); /* So that we don't double-free in the finalizer: */ Network_val (netv) = NULL; CAMLreturn (Val_unit); } /* Automatically generated binding for virNetworkDestroy. * In generator.pl this function has signature "net : free". */ CAMLprim value ocaml_libvirt_network_destroy (value netv) { CAMLparam1 (netv); virNetworkPtr net = Network_val (netv); int r; NONBLOCKING (r = virNetworkDestroy (net)); CHECK_ERROR (r == -1, "virNetworkDestroy"); /* So that we don't double-free in the finalizer: */ Network_val (netv) = NULL; CAMLreturn (Val_unit); } /* Automatically generated binding for virNetworkLookupByName. * In generator.pl this function has signature "conn, string : net". */ CAMLprim value ocaml_libvirt_network_lookup_by_name (value connv, value strv) { CAMLparam2 (connv, strv); CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); const char *str = String_val (strv); virNetworkPtr r; NONBLOCKING (r = virNetworkLookupByName (conn, str)); CHECK_ERROR (!r, "virNetworkLookupByName"); rv = Val_network (r, connv); CAMLreturn (rv); } /* Automatically generated binding for virNetworkLookupByUUID. * In generator.pl this function has signature "conn, uuid : net". */ CAMLprim value ocaml_libvirt_network_lookup_by_uuid (value connv, value uuidv) { CAMLparam2 (connv, uuidv); CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); unsigned char *uuid = (unsigned char *) String_val (uuidv); virNetworkPtr r; NONBLOCKING (r = virNetworkLookupByUUID (conn, uuid)); CHECK_ERROR (!r, "virNetworkLookupByUUID"); rv = Val_network (r, connv); CAMLreturn (rv); } /* Automatically generated binding for virNetworkLookupByUUIDString. * In generator.pl this function has signature "conn, string : net". */ CAMLprim value ocaml_libvirt_network_lookup_by_uuid_string (value connv, value strv) { CAMLparam2 (connv, strv); CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); const char *str = String_val (strv); virNetworkPtr r; NONBLOCKING (r = virNetworkLookupByUUIDString (conn, str)); CHECK_ERROR (!r, "virNetworkLookupByUUIDString"); rv = Val_network (r, connv); CAMLreturn (rv); } /* Automatically generated binding for virNetworkGetName. * In generator.pl this function has signature "net : static string". */ CAMLprim value ocaml_libvirt_network_get_name (value netv) { CAMLparam1 (netv); CAMLlocal1 (rv); virNetworkPtr net = Network_val (netv); const char *r; NONBLOCKING (r = virNetworkGetName (net)); CHECK_ERROR (!r, "virNetworkGetName"); rv = caml_copy_string (r); CAMLreturn (rv); } /* Automatically generated binding for virNetworkGetXMLDesc. * In generator.pl this function has signature "net, 0 : string". */ CAMLprim value ocaml_libvirt_network_get_xml_desc (value netv) { CAMLparam1 (netv); CAMLlocal1 (rv); virNetworkPtr net = Network_val (netv); char *r; NONBLOCKING (r = virNetworkGetXMLDesc (net, 0)); CHECK_ERROR (!r, "virNetworkGetXMLDesc"); rv = caml_copy_string (r); free (r); CAMLreturn (rv); } /* Automatically generated binding for virNetworkGetBridgeName. * In generator.pl this function has signature "net : string". */ CAMLprim value ocaml_libvirt_network_get_bridge_name (value netv) { CAMLparam1 (netv); CAMLlocal1 (rv); virNetworkPtr net = Network_val (netv); char *r; NONBLOCKING (r = virNetworkGetBridgeName (net)); CHECK_ERROR (!r, "virNetworkGetBridgeName"); rv = caml_copy_string (r); free (r); CAMLreturn (rv); } /* Automatically generated binding for virNetworkGetUUID. * In generator.pl this function has signature "net : uuid". */ CAMLprim value ocaml_libvirt_network_get_uuid (value netv) { CAMLparam1 (netv); CAMLlocal1 (rv); virNetworkPtr net = Network_val (netv); unsigned char uuid[VIR_UUID_BUFLEN]; int r; NONBLOCKING (r = virNetworkGetUUID (net, uuid)); CHECK_ERROR (r == -1, "virNetworkGetUUID"); /* UUIDs are byte arrays with a fixed length. */ rv = caml_alloc_string (VIR_UUID_BUFLEN); memcpy (Bytes_val (rv), uuid, VIR_UUID_BUFLEN); CAMLreturn (rv); } /* Automatically generated binding for virNetworkGetUUIDString. * In generator.pl this function has signature "net : uuid string". */ CAMLprim value ocaml_libvirt_network_get_uuid_string (value netv) { CAMLparam1 (netv); CAMLlocal1 (rv); virNetworkPtr net = Network_val (netv); char uuid[VIR_UUID_STRING_BUFLEN]; int r; NONBLOCKING (r = virNetworkGetUUIDString (net, uuid)); CHECK_ERROR (r == -1, "virNetworkGetUUIDString"); rv = caml_copy_string (uuid); CAMLreturn (rv); } /* Automatically generated binding for virNetworkUndefine. * In generator.pl this function has signature "net : unit". */ CAMLprim value ocaml_libvirt_network_undefine (value netv) { CAMLparam1 (netv); virNetworkPtr net = Network_val (netv); int r; NONBLOCKING (r = virNetworkUndefine (net)); CHECK_ERROR (r == -1, "virNetworkUndefine"); CAMLreturn (Val_unit); } /* Automatically generated binding for virNetworkCreateXML. * In generator.pl this function has signature "conn, string : net". */ CAMLprim value ocaml_libvirt_network_create_xml (value connv, value strv) { CAMLparam2 (connv, strv); CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); const char *str = String_val (strv); virNetworkPtr r; NONBLOCKING (r = virNetworkCreateXML (conn, str)); CHECK_ERROR (!r, "virNetworkCreateXML"); rv = Val_network (r, connv); CAMLreturn (rv); } /* Automatically generated binding for virNetworkDefineXML. * In generator.pl this function has signature "conn, string : net". */ CAMLprim value ocaml_libvirt_network_define_xml (value connv, value strv) { CAMLparam2 (connv, strv); CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); const char *str = String_val (strv); virNetworkPtr r; NONBLOCKING (r = virNetworkDefineXML (conn, str)); CHECK_ERROR (!r, "virNetworkDefineXML"); rv = Val_network (r, connv); CAMLreturn (rv); } /* Automatically generated binding for virNetworkCreate. * In generator.pl this function has signature "net : unit". */ CAMLprim value ocaml_libvirt_network_create (value netv) { CAMLparam1 (netv); virNetworkPtr net = Network_val (netv); int r; NONBLOCKING (r = virNetworkCreate (net)); CHECK_ERROR (r == -1, "virNetworkCreate"); CAMLreturn (Val_unit); } /* Automatically generated binding for virNetworkGetAutostart. * In generator.pl this function has signature "net : bool". */ CAMLprim value ocaml_libvirt_network_get_autostart (value netv) { CAMLparam1 (netv); virNetworkPtr net = Network_val (netv); int r, b; NONBLOCKING (r = virNetworkGetAutostart (net, &b)); CHECK_ERROR (r == -1, "virNetworkGetAutostart"); CAMLreturn (b ? Val_true : Val_false); } /* Automatically generated binding for virNetworkSetAutostart. * In generator.pl this function has signature "net, bool : unit". */ CAMLprim value ocaml_libvirt_network_set_autostart (value netv, value bv) { CAMLparam2 (netv, bv); virNetworkPtr net = Network_val (netv); int r, b; b = bv == Val_true ? 1 : 0; NONBLOCKING (r = virNetworkSetAutostart (net, b)); CHECK_ERROR (r == -1, "virNetworkSetAutostart"); CAMLreturn (Val_unit); } /* Automatically generated binding for virStoragePoolFree. * In generator.pl this function has signature "pool : free". */ CAMLprim value ocaml_libvirt_storage_pool_free (value poolv) { CAMLparam1 (poolv); virStoragePoolPtr pool = Pool_val (poolv); int r; NONBLOCKING (r = virStoragePoolFree (pool)); CHECK_ERROR (r == -1, "virStoragePoolFree"); /* So that we don't double-free in the finalizer: */ Pool_val (poolv) = NULL; CAMLreturn (Val_unit); } /* Automatically generated binding for virStoragePoolDestroy. * In generator.pl this function has signature "pool : free". */ CAMLprim value ocaml_libvirt_storage_pool_destroy (value poolv) { CAMLparam1 (poolv); virStoragePoolPtr pool = Pool_val (poolv); int r; NONBLOCKING (r = virStoragePoolDestroy (pool)); CHECK_ERROR (r == -1, "virStoragePoolDestroy"); /* So that we don't double-free in the finalizer: */ Pool_val (poolv) = NULL; CAMLreturn (Val_unit); } /* Automatically generated binding for virStoragePoolLookupByName. * In generator.pl this function has signature "conn, string : pool". */ CAMLprim value ocaml_libvirt_storage_pool_lookup_by_name (value connv, value strv) { CAMLparam2 (connv, strv); CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); const char *str = String_val (strv); virStoragePoolPtr r; NONBLOCKING (r = virStoragePoolLookupByName (conn, str)); CHECK_ERROR (!r, "virStoragePoolLookupByName"); rv = Val_pool (r, connv); CAMLreturn (rv); } /* Automatically generated binding for virStoragePoolLookupByUUID. * In generator.pl this function has signature "conn, uuid : pool". */ CAMLprim value ocaml_libvirt_storage_pool_lookup_by_uuid (value connv, value uuidv) { CAMLparam2 (connv, uuidv); CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); unsigned char *uuid = (unsigned char *) String_val (uuidv); virStoragePoolPtr r; NONBLOCKING (r = virStoragePoolLookupByUUID (conn, uuid)); CHECK_ERROR (!r, "virStoragePoolLookupByUUID"); rv = Val_pool (r, connv); CAMLreturn (rv); } /* Automatically generated binding for virStoragePoolLookupByUUIDString. * In generator.pl this function has signature "conn, string : pool". */ CAMLprim value ocaml_libvirt_storage_pool_lookup_by_uuid_string (value connv, value strv) { CAMLparam2 (connv, strv); CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); const char *str = String_val (strv); virStoragePoolPtr r; NONBLOCKING (r = virStoragePoolLookupByUUIDString (conn, str)); CHECK_ERROR (!r, "virStoragePoolLookupByUUIDString"); rv = Val_pool (r, connv); CAMLreturn (rv); } /* Automatically generated binding for virStoragePoolGetName. * In generator.pl this function has signature "pool : static string". */ CAMLprim value ocaml_libvirt_storage_pool_get_name (value poolv) { CAMLparam1 (poolv); CAMLlocal1 (rv); virStoragePoolPtr pool = Pool_val (poolv); const char *r; NONBLOCKING (r = virStoragePoolGetName (pool)); CHECK_ERROR (!r, "virStoragePoolGetName"); rv = caml_copy_string (r); CAMLreturn (rv); } /* Automatically generated binding for virStoragePoolGetXMLDesc. * In generator.pl this function has signature "pool, 0U : string". */ CAMLprim value ocaml_libvirt_storage_pool_get_xml_desc (value poolv) { CAMLparam1 (poolv); CAMLlocal1 (rv); virStoragePoolPtr pool = Pool_val (poolv); char *r; NONBLOCKING (r = virStoragePoolGetXMLDesc (pool, 0)); CHECK_ERROR (!r, "virStoragePoolGetXMLDesc"); rv = caml_copy_string (r); free (r); CAMLreturn (rv); } /* Automatically generated binding for virStoragePoolGetUUID. * In generator.pl this function has signature "pool : uuid". */ CAMLprim value ocaml_libvirt_storage_pool_get_uuid (value poolv) { CAMLparam1 (poolv); CAMLlocal1 (rv); virStoragePoolPtr pool = Pool_val (poolv); unsigned char uuid[VIR_UUID_BUFLEN]; int r; NONBLOCKING (r = virStoragePoolGetUUID (pool, uuid)); CHECK_ERROR (r == -1, "virStoragePoolGetUUID"); /* UUIDs are byte arrays with a fixed length. */ rv = caml_alloc_string (VIR_UUID_BUFLEN); memcpy (Bytes_val (rv), uuid, VIR_UUID_BUFLEN); CAMLreturn (rv); } /* Automatically generated binding for virStoragePoolGetUUIDString. * In generator.pl this function has signature "pool : uuid string". */ CAMLprim value ocaml_libvirt_storage_pool_get_uuid_string (value poolv) { CAMLparam1 (poolv); CAMLlocal1 (rv); virStoragePoolPtr pool = Pool_val (poolv); char uuid[VIR_UUID_STRING_BUFLEN]; int r; NONBLOCKING (r = virStoragePoolGetUUIDString (pool, uuid)); CHECK_ERROR (r == -1, "virStoragePoolGetUUIDString"); rv = caml_copy_string (uuid); CAMLreturn (rv); } /* Automatically generated binding for virStoragePoolCreateXML. * In generator.pl this function has signature "conn, string, 0U : pool". */ CAMLprim value ocaml_libvirt_storage_pool_create_xml (value connv, value strv) { CAMLparam2 (connv, strv); CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); const char *str = String_val (strv); virStoragePoolPtr r; NONBLOCKING (r = virStoragePoolCreateXML (conn, str, 0)); CHECK_ERROR (!r, "virStoragePoolCreateXML"); rv = Val_pool (r, connv); CAMLreturn (rv); } /* Automatically generated binding for virStoragePoolDefineXML. * In generator.pl this function has signature "conn, string, 0U : pool". */ CAMLprim value ocaml_libvirt_storage_pool_define_xml (value connv, value strv) { CAMLparam2 (connv, strv); CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); const char *str = String_val (strv); virStoragePoolPtr r; NONBLOCKING (r = virStoragePoolDefineXML (conn, str, 0)); CHECK_ERROR (!r, "virStoragePoolDefineXML"); rv = Val_pool (r, connv); CAMLreturn (rv); } /* Automatically generated binding for virStoragePoolBuild. * In generator.pl this function has signature "pool, uint : unit". */ CAMLprim value ocaml_libvirt_storage_pool_build (value poolv, value iv) { CAMLparam2 (poolv, iv); virStoragePoolPtr pool = Pool_val (poolv); unsigned int i = Int_val (iv); int r; NONBLOCKING (r = virStoragePoolBuild (pool, i)); CHECK_ERROR (r == -1, "virStoragePoolBuild"); CAMLreturn (Val_unit); } /* Automatically generated binding for virStoragePoolUndefine. * In generator.pl this function has signature "pool : unit". */ CAMLprim value ocaml_libvirt_storage_pool_undefine (value poolv) { CAMLparam1 (poolv); virStoragePoolPtr pool = Pool_val (poolv); int r; NONBLOCKING (r = virStoragePoolUndefine (pool)); CHECK_ERROR (r == -1, "virStoragePoolUndefine"); CAMLreturn (Val_unit); } /* Automatically generated binding for virStoragePoolCreate. * In generator.pl this function has signature "pool, 0U : unit". */ CAMLprim value ocaml_libvirt_storage_pool_create (value poolv) { CAMLparam1 (poolv); virStoragePoolPtr pool = Pool_val (poolv); int r; NONBLOCKING (r = virStoragePoolCreate (pool, 0)); CHECK_ERROR (r == -1, "virStoragePoolCreate"); CAMLreturn (Val_unit); } /* Automatically generated binding for virStoragePoolDelete. * In generator.pl this function has signature "pool, uint : unit". */ CAMLprim value ocaml_libvirt_storage_pool_delete (value poolv, value iv) { CAMLparam2 (poolv, iv); virStoragePoolPtr pool = Pool_val (poolv); unsigned int i = Int_val (iv); int r; NONBLOCKING (r = virStoragePoolDelete (pool, i)); CHECK_ERROR (r == -1, "virStoragePoolDelete"); CAMLreturn (Val_unit); } /* Automatically generated binding for virStoragePoolRefresh. * In generator.pl this function has signature "pool, 0U : unit". */ CAMLprim value ocaml_libvirt_storage_pool_refresh (value poolv) { CAMLparam1 (poolv); virStoragePoolPtr pool = Pool_val (poolv); int r; NONBLOCKING (r = virStoragePoolRefresh (pool, 0)); CHECK_ERROR (r == -1, "virStoragePoolRefresh"); CAMLreturn (Val_unit); } /* Automatically generated binding for virStoragePoolGetAutostart. * In generator.pl this function has signature "pool : bool". */ CAMLprim value ocaml_libvirt_storage_pool_get_autostart (value poolv) { CAMLparam1 (poolv); virStoragePoolPtr pool = Pool_val (poolv); int r, b; NONBLOCKING (r = virStoragePoolGetAutostart (pool, &b)); CHECK_ERROR (r == -1, "virStoragePoolGetAutostart"); CAMLreturn (b ? Val_true : Val_false); } /* Automatically generated binding for virStoragePoolSetAutostart. * In generator.pl this function has signature "pool, bool : unit". */ CAMLprim value ocaml_libvirt_storage_pool_set_autostart (value poolv, value bv) { CAMLparam2 (poolv, bv); virStoragePoolPtr pool = Pool_val (poolv); int r, b; b = bv == Val_true ? 1 : 0; NONBLOCKING (r = virStoragePoolSetAutostart (pool, b)); CHECK_ERROR (r == -1, "virStoragePoolSetAutostart"); CAMLreturn (Val_unit); } /* Automatically generated binding for virStoragePoolNumOfVolumes. * In generator.pl this function has signature "pool : int". */ CAMLprim value ocaml_libvirt_storage_pool_num_of_volumes (value poolv) { CAMLparam1 (poolv); virStoragePoolPtr pool = Pool_val (poolv); int r; NONBLOCKING (r = virStoragePoolNumOfVolumes (pool)); CHECK_ERROR (r == -1, "virStoragePoolNumOfVolumes"); CAMLreturn (Val_int (r)); } /* Automatically generated binding for virStoragePoolListVolumes. * In generator.pl this function has signature "pool, int : string array". */ CAMLprim value ocaml_libvirt_storage_pool_list_volumes (value poolv, value iv) { CAMLparam2 (poolv, iv); CAMLlocal2 (rv, strv); virStoragePoolPtr pool = Pool_val (poolv); int i = Int_val (iv); char **names; int r; /* Some libvirt List* functions still throw exceptions if i == 0, * so catch that and return an empty array directly. This changes * the semantics slightly (masking other failures) but it's * unlikely anyone will care. RWMJ 2008/06/10 */ if (i == 0) { rv = caml_alloc (0, 0); CAMLreturn (rv); } names = malloc (sizeof (*names) * i); if (names == NULL) caml_raise_out_of_memory (); NONBLOCKING (r = virStoragePoolListVolumes (pool, names, i)); CHECK_ERROR_CLEANUP (r == -1, free (names), "virStoragePoolListVolumes"); rv = caml_alloc (r, 0); for (i = 0; i < r; ++i) { strv = caml_copy_string (names[i]); Store_field (rv, i, strv); free (names[i]); } free (names); CAMLreturn (rv); } /* Automatically generated binding for virStorageVolFree. * In generator.pl this function has signature "vol : free". */ CAMLprim value ocaml_libvirt_storage_vol_free (value volv) { CAMLparam1 (volv); virStorageVolPtr vol = Volume_val (volv); int r; NONBLOCKING (r = virStorageVolFree (vol)); CHECK_ERROR (r == -1, "virStorageVolFree"); /* So that we don't double-free in the finalizer: */ Volume_val (volv) = NULL; CAMLreturn (Val_unit); } /* Automatically generated binding for virStorageVolDelete. * In generator.pl this function has signature "vol, uint : unit". */ CAMLprim value ocaml_libvirt_storage_vol_delete (value volv, value iv) { CAMLparam2 (volv, iv); virStorageVolPtr vol = Volume_val (volv); unsigned int i = Int_val (iv); int r; NONBLOCKING (r = virStorageVolDelete (vol, i)); CHECK_ERROR (r == -1, "virStorageVolDelete"); CAMLreturn (Val_unit); } /* Automatically generated binding for virStorageVolLookupByName. * In generator.pl this function has signature "pool, string : vol from pool". */ CAMLprim value ocaml_libvirt_storage_vol_lookup_by_name (value poolv, value strv) { CAMLparam2 (poolv, strv); CAMLlocal2 (rv, connv); virStoragePoolPtr pool = Pool_val (poolv); const char *str = String_val (strv); virStorageVolPtr r; NONBLOCKING (r = virStorageVolLookupByName (pool, str)); CHECK_ERROR (!r, "virStorageVolLookupByName"); connv = Field (poolv, 1); rv = Val_volume (r, connv); CAMLreturn (rv); } /* Automatically generated binding for virStorageVolLookupByKey. * In generator.pl this function has signature "conn, string : vol". */ CAMLprim value ocaml_libvirt_storage_vol_lookup_by_key (value connv, value strv) { CAMLparam2 (connv, strv); CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); const char *str = String_val (strv); virStorageVolPtr r; NONBLOCKING (r = virStorageVolLookupByKey (conn, str)); CHECK_ERROR (!r, "virStorageVolLookupByKey"); rv = Val_volume (r, connv); CAMLreturn (rv); } /* Automatically generated binding for virStorageVolLookupByPath. * In generator.pl this function has signature "conn, string : vol". */ CAMLprim value ocaml_libvirt_storage_vol_lookup_by_path (value connv, value strv) { CAMLparam2 (connv, strv); CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); const char *str = String_val (strv); virStorageVolPtr r; NONBLOCKING (r = virStorageVolLookupByPath (conn, str)); CHECK_ERROR (!r, "virStorageVolLookupByPath"); rv = Val_volume (r, connv); CAMLreturn (rv); } /* Automatically generated binding for virStorageVolCreateXML. * In generator.pl this function has signature "pool, string, 0U : vol from pool". */ CAMLprim value ocaml_libvirt_storage_vol_create_xml (value poolv, value strv) { CAMLparam2 (poolv, strv); CAMLlocal2 (rv, connv); virStoragePoolPtr pool = Pool_val (poolv); const char *str = String_val (strv); virStorageVolPtr r; NONBLOCKING (r = virStorageVolCreateXML (pool, str, 0)); CHECK_ERROR (!r, "virStorageVolCreateXML"); connv = Field (poolv, 1); rv = Val_volume (r, connv); CAMLreturn (rv); } /* Automatically generated binding for virStorageVolGetXMLDesc. * In generator.pl this function has signature "vol, 0U : string". */ CAMLprim value ocaml_libvirt_storage_vol_get_xml_desc (value volv) { CAMLparam1 (volv); CAMLlocal1 (rv); virStorageVolPtr vol = Volume_val (volv); char *r; NONBLOCKING (r = virStorageVolGetXMLDesc (vol, 0)); CHECK_ERROR (!r, "virStorageVolGetXMLDesc"); rv = caml_copy_string (r); free (r); CAMLreturn (rv); } /* Automatically generated binding for virStorageVolGetPath. * In generator.pl this function has signature "vol : string". */ CAMLprim value ocaml_libvirt_storage_vol_get_path (value volv) { CAMLparam1 (volv); CAMLlocal1 (rv); virStorageVolPtr vol = Volume_val (volv); char *r; NONBLOCKING (r = virStorageVolGetPath (vol)); CHECK_ERROR (!r, "virStorageVolGetPath"); rv = caml_copy_string (r); free (r); CAMLreturn (rv); } /* Automatically generated binding for virStorageVolGetKey. * In generator.pl this function has signature "vol : static string". */ CAMLprim value ocaml_libvirt_storage_vol_get_key (value volv) { CAMLparam1 (volv); CAMLlocal1 (rv); virStorageVolPtr vol = Volume_val (volv); const char *r; NONBLOCKING (r = virStorageVolGetKey (vol)); CHECK_ERROR (!r, "virStorageVolGetKey"); rv = caml_copy_string (r); CAMLreturn (rv); } /* Automatically generated binding for virStorageVolGetName. * In generator.pl this function has signature "vol : static string". */ CAMLprim value ocaml_libvirt_storage_vol_get_name (value volv) { CAMLparam1 (volv); CAMLlocal1 (rv); virStorageVolPtr vol = Volume_val (volv); const char *r; NONBLOCKING (r = virStorageVolGetName (vol)); CHECK_ERROR (!r, "virStorageVolGetName"); rv = caml_copy_string (r); CAMLreturn (rv); } /* Automatically generated binding for virStoragePoolLookupByVolume. * In generator.pl this function has signature "vol : pool from vol". */ CAMLprim value ocaml_libvirt_storage_pool_lookup_by_volume (value volv) { CAMLparam1 (volv); CAMLlocal2 (rv, connv); virStorageVolPtr vol = Volume_val (volv); virStoragePoolPtr r; NONBLOCKING (r = virStoragePoolLookupByVolume (vol)); CHECK_ERROR (!r, "virStoragePoolLookupByVolume"); connv = Field (volv, 1); rv = Val_pool (r, connv); CAMLreturn (rv); } /* Automatically generated binding for virSecretFree. * In generator.pl this function has signature "sec : free". */ CAMLprim value ocaml_libvirt_secret_free (value secv) { CAMLparam1 (secv); virSecretPtr sec = Secret_val (secv); int r; NONBLOCKING (r = virSecretFree (sec)); CHECK_ERROR (r == -1, "virSecretFree"); /* So that we don't double-free in the finalizer: */ Secret_val (secv) = NULL; CAMLreturn (Val_unit); } /* Automatically generated binding for virSecretUndefine. * In generator.pl this function has signature "sec : unit". */ CAMLprim value ocaml_libvirt_secret_undefine (value secv) { CAMLparam1 (secv); virSecretPtr sec = Secret_val (secv); int r; NONBLOCKING (r = virSecretUndefine (sec)); CHECK_ERROR (r == -1, "virSecretUndefine"); CAMLreturn (Val_unit); } /* Automatically generated binding for virSecretLookupByUUID. * In generator.pl this function has signature "conn, uuid : sec". */ CAMLprim value ocaml_libvirt_secret_lookup_by_uuid (value connv, value uuidv) { CAMLparam2 (connv, uuidv); CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); unsigned char *uuid = (unsigned char *) String_val (uuidv); virSecretPtr r; NONBLOCKING (r = virSecretLookupByUUID (conn, uuid)); CHECK_ERROR (!r, "virSecretLookupByUUID"); rv = Val_secret (r, connv); CAMLreturn (rv); } /* Automatically generated binding for virSecretLookupByUUIDString. * In generator.pl this function has signature "conn, string : sec". */ CAMLprim value ocaml_libvirt_secret_lookup_by_uuid_string (value connv, value strv) { CAMLparam2 (connv, strv); CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); const char *str = String_val (strv); virSecretPtr r; NONBLOCKING (r = virSecretLookupByUUIDString (conn, str)); CHECK_ERROR (!r, "virSecretLookupByUUIDString"); rv = Val_secret (r, connv); CAMLreturn (rv); } /* Automatically generated binding for virSecretDefineXML. * In generator.pl this function has signature "conn, string, 0 : sec". */ CAMLprim value ocaml_libvirt_secret_define_xml (value connv, value strv) { CAMLparam2 (connv, strv); CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); const char *str = String_val (strv); virSecretPtr r; NONBLOCKING (r = virSecretDefineXML (conn, str, 0)); CHECK_ERROR (!r, "virSecretDefineXML"); rv = Val_secret (r, connv); CAMLreturn (rv); } /* Automatically generated binding for virSecretGetUUID. * In generator.pl this function has signature "sec : uuid". */ CAMLprim value ocaml_libvirt_secret_get_uuid (value secv) { CAMLparam1 (secv); CAMLlocal1 (rv); virSecretPtr sec = Secret_val (secv); unsigned char uuid[VIR_UUID_BUFLEN]; int r; NONBLOCKING (r = virSecretGetUUID (sec, uuid)); CHECK_ERROR (r == -1, "virSecretGetUUID"); /* UUIDs are byte arrays with a fixed length. */ rv = caml_alloc_string (VIR_UUID_BUFLEN); memcpy (Bytes_val (rv), uuid, VIR_UUID_BUFLEN); CAMLreturn (rv); } /* Automatically generated binding for virSecretGetUUIDString. * In generator.pl this function has signature "sec : uuid string". */ CAMLprim value ocaml_libvirt_secret_get_uuid_string (value secv) { CAMLparam1 (secv); CAMLlocal1 (rv); virSecretPtr sec = Secret_val (secv); char uuid[VIR_UUID_STRING_BUFLEN]; int r; NONBLOCKING (r = virSecretGetUUIDString (sec, uuid)); CHECK_ERROR (r == -1, "virSecretGetUUIDString"); rv = caml_copy_string (uuid); CAMLreturn (rv); } /* Automatically generated binding for virSecretGetUsageType. * In generator.pl this function has signature "sec : int". */ CAMLprim value ocaml_libvirt_secret_get_usage_type (value secv) { CAMLparam1 (secv); virSecretPtr sec = Secret_val (secv); int r; NONBLOCKING (r = virSecretGetUsageType (sec)); CHECK_ERROR (r == -1, "virSecretGetUsageType"); CAMLreturn (Val_int (r)); } /* Automatically generated binding for virSecretGetUsageID. * In generator.pl this function has signature "sec : static string". */ CAMLprim value ocaml_libvirt_secret_get_usage_id (value secv) { CAMLparam1 (secv); CAMLlocal1 (rv); virSecretPtr sec = Secret_val (secv); const char *r; NONBLOCKING (r = virSecretGetUsageID (sec)); CHECK_ERROR (!r, "virSecretGetUsageID"); rv = caml_copy_string (r); CAMLreturn (rv); } /* Automatically generated binding for virSecretGetXMLDesc. * In generator.pl this function has signature "sec, 0 : string". */ CAMLprim value ocaml_libvirt_secret_get_xml_desc (value secv) { CAMLparam1 (secv); CAMLlocal1 (rv); virSecretPtr sec = Secret_val (secv); char *r; NONBLOCKING (r = virSecretGetXMLDesc (sec, 0)); CHECK_ERROR (!r, "virSecretGetXMLDesc"); rv = caml_copy_string (r); free (r); CAMLreturn (rv); } /* EOF */ virt-v2v-1.44.2/bundled/libvirt-ocaml/PaxHeaders/Makefile.am0000644000000000000000000000013213631710510020571 xustar0030 mtime=1583845704.125871044 30 atime=1637862732.898490453 30 ctime=1637862790.564851573 virt-v2v-1.44.2/bundled/libvirt-ocaml/Makefile.am0000664000175000017500000000451013631710510022377 0ustar00rjonesrjones00000000000000# libguestfs OCaml tools common code # Copyright (C) 2018 Red Hat Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. include $(top_srcdir)/subdir-rules.mk EXTRA_DIST = \ $(SOURCES_MLI) \ $(SOURCES_ML) \ generator.pl \ libvirt.README SOURCES_MLI = \ libvirt.mli SOURCES_ML = \ libvirt.ml SOURCES_C = \ libvirt_c.h \ libvirt_c_common.c \ libvirt_generated.c \ libvirt_c_oneoffs.c # Automatically generate the C code from a Perl script 'generator.pl'. libvirt_generated.c: $(srcdir)/generator.pl $(PERL) -w $< CLEANFILES += \ libvirt_generated.c # We pretend that we're building a C library. automake handles the # compilation of the C sources for us. At the end we take the C # objects and OCaml objects and link them into the OCaml library. # This C library is never used. noinst_LIBRARIES = libmllibvirt.a if !HAVE_OCAMLOPT MLLIBVIRT_CMA = mllibvirt.cma else MLLIBVIRT_CMA = mllibvirt.cmxa endif noinst_DATA = $(MLLIBVIRT_CMA) libmllibvirt_a_SOURCES = $(SOURCES_C) libmllibvirt_a_CPPFLAGS = \ -DCAML_NAME_SPACE \ -I. \ -I$(top_builddir) \ -I$(shell $(OCAMLC) -where) libmllibvirt_a_CFLAGS = \ $(WARN_CFLAGS) $(WERROR_CFLAGS) \ $(LIBVIRT_CFLAGS) \ -fPIC BOBJECTS = $(SOURCES_ML:.ml=.cmo) XOBJECTS = $(BOBJECTS:.cmo=.cmx) OCAMLPACKAGES = OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR) if !HAVE_OCAMLOPT OBJECTS = $(BOBJECTS) else OBJECTS = $(XOBJECTS) endif libmllibvirt_a_DEPENDENCIES = $(OBJECTS) $(MLLIBVIRT_CMA): $(OBJECTS) libmllibvirt.a $(OCAMLFIND) mklib $(OCAMLPACKAGES) \ $(OBJECTS) $(libmllibvirt_a_OBJECTS) -cclib -lvirt -o mllibvirt # Dependencies. .depend: $(srcdir)/*.mli $(srcdir)/*.ml $(top_builddir)/ocaml-dep.sh $^ -include .depend .PHONY: depend docs virt-v2v-1.44.2/bundled/libvirt-ocaml/PaxHeaders/libvirt_c_common.c0000644000000000000000000000013213631710510022226 xustar0030 mtime=1583845704.127871016 30 atime=1637862779.599973052 30 ctime=1637862790.571851495 virt-v2v-1.44.2/bundled/libvirt-ocaml/libvirt_c_common.c0000664000175000017500000002444413631710510024044 0ustar00rjonesrjones00000000000000/* OCaml bindings for libvirt. * (C) Copyright 2007 Richard W.M. Jones, Red Hat Inc. * https://libvirt.org/ * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version, * with the OCaml linking exception described in ../COPYING.LIB. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* Please read libvirt/README file. */ #include "libvirt_c.h" const char * Optstring_val (value strv) { if (strv == Val_int (0)) /* None */ return NULL; else /* Some string */ return String_val (Field (strv, 0)); } value Val_opt (void *ptr, Val_ptr_t Val_ptr) { CAMLparam0 (); CAMLlocal2 (optv, ptrv); if (ptr) { /* Some ptr */ optv = caml_alloc (1, 0); ptrv = Val_ptr (ptr); Store_field (optv, 0, ptrv); } else /* None */ optv = Val_int (0); CAMLreturn (optv); } value Val_opt_const (const void *ptr, Val_const_ptr_t Val_ptr) { CAMLparam0 (); CAMLlocal2 (optv, ptrv); if (ptr) { /* Some ptr */ optv = caml_alloc (1, 0); ptrv = Val_ptr (ptr); Store_field (optv, 0, ptrv); } else /* None */ optv = Val_int (0); CAMLreturn (optv); } #if 0 value option_default (value option, value deflt) { if (option == Val_int (0)) /* "None" */ return deflt; else /* "Some 'a" */ return Field (option, 0); } #endif void _raise_virterror (const char *fn) { CAMLparam0 (); CAMLlocal1 (rv); virErrorPtr errp; struct _virError err; errp = virGetLastError (); if (!errp) { /* Fake a _virError structure. */ memset (&err, 0, sizeof err); err.code = VIR_ERR_INTERNAL_ERROR; err.domain = VIR_FROM_NONE; err.level = VIR_ERR_ERROR; err.message = (char *) fn; errp = &err; } rv = Val_virterror (errp); caml_raise_with_arg (*caml_named_value ("ocaml_libvirt_virterror"), rv); /*NOTREACHED*/ /* Suppresses a compiler warning. */ (void) caml__frame; } int _list_length (value listv) { CAMLparam1 (listv); int len = 0; for (; listv != Val_emptylist; listv = Field (listv, 1), ++len) {} CAMLreturnT (int, len); } value Val_virconnectcredential (const virConnectCredentialPtr cred) { CAMLparam0 (); CAMLlocal1 (rv); rv = caml_alloc (4, 0); Store_field (rv, 0, Val_int (cred->type - 1)); Store_field (rv, 1, caml_copy_string (cred->prompt)); Store_field (rv, 2, Val_opt_const (cred->challenge, (Val_const_ptr_t) caml_copy_string)); Store_field (rv, 3, Val_opt_const (cred->defresult, (Val_const_ptr_t) caml_copy_string)); CAMLreturn (rv); } /* Convert the virErrorNumber, virErrorDomain and virErrorLevel enums * into values (longs because they are variants in OCaml). * * The enum values are part of the libvirt ABI so they cannot change, * which means that we can convert these numbers directly into * OCaml variants (which use the same ordering) very fast. * * The tricky part here is when we are linked to a newer version of * libvirt than the one we were compiled against. If the newer libvirt * generates an error code which we don't know about then we need * to convert it into VIR_*_UNKNOWN (code). */ #define MAX_VIR_CODE 107 /* VIR_ERR_NO_NETWORK_PORT */ #define MAX_VIR_DOMAIN 71 /* VIR_FROM_BPF */ #define MAX_VIR_LEVEL VIR_ERR_ERROR static inline value Val_err_number (virErrorNumber code) { CAMLparam0 (); CAMLlocal1 (rv); if (0 <= (int) code && code <= MAX_VIR_CODE) rv = Val_int (code); else { rv = caml_alloc (1, 0); /* VIR_ERR_UNKNOWN (code) */ Store_field (rv, 0, Val_int (code)); } CAMLreturn (rv); } static inline value Val_err_domain (virErrorDomain code) { CAMLparam0 (); CAMLlocal1 (rv); if (0 <= (int) code && code <= MAX_VIR_DOMAIN) rv = Val_int (code); else { rv = caml_alloc (1, 0); /* VIR_FROM_UNKNOWN (code) */ Store_field (rv, 0, Val_int (code)); } CAMLreturn (rv); } static inline value Val_err_level (virErrorLevel code) { CAMLparam0 (); CAMLlocal1 (rv); if (0 <= (int) code && code <= MAX_VIR_LEVEL) rv = Val_int (code); else { rv = caml_alloc (1, 0); /* VIR_ERR_UNKNOWN_LEVEL (code) */ Store_field (rv, 0, Val_int (code)); } CAMLreturn (rv); } /* Convert a virterror to a value. */ value Val_virterror (virErrorPtr err) { CAMLparam0 (); CAMLlocal3 (rv, connv, optv); rv = caml_alloc (9, 0); Store_field (rv, 0, Val_err_number (err->code)); Store_field (rv, 1, Val_err_domain (err->domain)); Store_field (rv, 2, Val_opt (err->message, (Val_ptr_t) caml_copy_string)); Store_field (rv, 3, Val_err_level (err->level)); Store_field (rv, 4, Val_opt (err->str1, (Val_ptr_t) caml_copy_string)); Store_field (rv, 5, Val_opt (err->str2, (Val_ptr_t) caml_copy_string)); Store_field (rv, 6, Val_opt (err->str3, (Val_ptr_t) caml_copy_string)); Store_field (rv, 7, caml_copy_int32 (err->int1)); Store_field (rv, 8, caml_copy_int32 (err->int2)); CAMLreturn (rv); } static void conn_finalize (value); static void dom_finalize (value); static void net_finalize (value); static void pol_finalize (value); static void vol_finalize (value); static void sec_finalize (value); static struct custom_operations conn_custom_operations = { (char *) "conn_custom_operations", conn_finalize, custom_compare_default, custom_hash_default, custom_serialize_default, custom_deserialize_default }; static struct custom_operations dom_custom_operations = { (char *) "dom_custom_operations", dom_finalize, custom_compare_default, custom_hash_default, custom_serialize_default, custom_deserialize_default }; static struct custom_operations net_custom_operations = { (char *) "net_custom_operations", net_finalize, custom_compare_default, custom_hash_default, custom_serialize_default, custom_deserialize_default }; static struct custom_operations pol_custom_operations = { (char *) "pol_custom_operations", pol_finalize, custom_compare_default, custom_hash_default, custom_serialize_default, custom_deserialize_default }; static struct custom_operations vol_custom_operations = { (char *) "vol_custom_operations", vol_finalize, custom_compare_default, custom_hash_default, custom_serialize_default, custom_deserialize_default }; static struct custom_operations sec_custom_operations = { (char *) "sec_custom_operations", sec_finalize, custom_compare_default, custom_hash_default, custom_serialize_default, custom_deserialize_default }; value Val_connect (virConnectPtr conn) { CAMLparam0 (); CAMLlocal1 (rv); rv = caml_alloc_custom (&conn_custom_operations, sizeof (virConnectPtr), 0, 1); Connect_val (rv) = conn; CAMLreturn (rv); } value Val_dom (virDomainPtr dom) { CAMLparam0 (); CAMLlocal1 (rv); rv = caml_alloc_custom (&dom_custom_operations, sizeof (virDomainPtr), 0, 1); Dom_val (rv) = dom; CAMLreturn (rv); } value Val_net (virNetworkPtr net) { CAMLparam0 (); CAMLlocal1 (rv); rv = caml_alloc_custom (&net_custom_operations, sizeof (virNetworkPtr), 0, 1); Net_val (rv) = net; CAMLreturn (rv); } value Val_pol (virStoragePoolPtr pol) { CAMLparam0 (); CAMLlocal1 (rv); rv = caml_alloc_custom (&pol_custom_operations, sizeof (virStoragePoolPtr), 0, 1); Pol_val (rv) = pol; CAMLreturn (rv); } value Val_vol (virStorageVolPtr vol) { CAMLparam0 (); CAMLlocal1 (rv); rv = caml_alloc_custom (&vol_custom_operations, sizeof (virStorageVolPtr), 0, 1); Vol_val (rv) = vol; CAMLreturn (rv); } value Val_sec (virSecretPtr sec) { CAMLparam0 (); CAMLlocal1 (rv); rv = caml_alloc_custom (&sec_custom_operations, sizeof (virSecretPtr), 0, 1); Sec_val (rv) = sec; CAMLreturn (rv); } /* This wraps up the (dom, conn) pair (Domain.t). */ value Val_domain (virDomainPtr dom, value connv) { CAMLparam1 (connv); CAMLlocal2 (rv, v); rv = caml_alloc_tuple (2); v = Val_dom (dom); Store_field (rv, 0, v); Store_field (rv, 1, connv); CAMLreturn (rv); } /* This wraps up the (net, conn) pair (Network.t). */ value Val_network (virNetworkPtr net, value connv) { CAMLparam1 (connv); CAMLlocal2 (rv, v); rv = caml_alloc_tuple (2); v = Val_net (net); Store_field (rv, 0, v); Store_field (rv, 1, connv); CAMLreturn (rv); } /* This wraps up the (pol, conn) pair (Pool.t). */ value Val_pool (virStoragePoolPtr pol, value connv) { CAMLparam1 (connv); CAMLlocal2 (rv, v); rv = caml_alloc_tuple (2); v = Val_pol (pol); Store_field (rv, 0, v); Store_field (rv, 1, connv); CAMLreturn (rv); } /* This wraps up the (vol, conn) pair (Volume.t). */ value Val_volume (virStorageVolPtr vol, value connv) { CAMLparam1 (connv); CAMLlocal2 (rv, v); rv = caml_alloc_tuple (2); v = Val_vol (vol); Store_field (rv, 0, v); Store_field (rv, 1, connv); CAMLreturn (rv); } /* This wraps up the (sec, conn) pair (Secret.t). */ value Val_secret (virSecretPtr sec, value connv) { CAMLparam1 (connv); CAMLlocal2 (rv, v); rv = caml_alloc_tuple (2); v = Val_sec (sec); Store_field (rv, 0, v); Store_field (rv, 1, connv); CAMLreturn (rv); } static void conn_finalize (value connv) { virConnectPtr conn = Connect_val (connv); if (conn) (void) virConnectClose (conn); } static void dom_finalize (value domv) { virDomainPtr dom = Dom_val (domv); if (dom) (void) virDomainFree (dom); } static void net_finalize (value netv) { virNetworkPtr net = Net_val (netv); if (net) (void) virNetworkFree (net); } static void pol_finalize (value polv) { virStoragePoolPtr pol = Pol_val (polv); if (pol) (void) virStoragePoolFree (pol); } static void vol_finalize (value volv) { virStorageVolPtr vol = Vol_val (volv); if (vol) (void) virStorageVolFree (vol); } static void sec_finalize (value secv) { virSecretPtr sec = Sec_val (secv); if (sec) (void) virSecretFree (sec); } virt-v2v-1.44.2/bundled/libvirt-ocaml/PaxHeaders/libvirt_c_oneoffs.c0000644000000000000000000000013013631710510022373 xustar0030 mtime=1583845704.128871002 29 atime=1637862779.61097293 29 ctime=1637862790.57685144 virt-v2v-1.44.2/bundled/libvirt-ocaml/libvirt_c_oneoffs.c0000664000175000017500000014133013631710510024205 0ustar00rjonesrjones00000000000000/* OCaml bindings for libvirt. * (C) Copyright 2007-2017 Richard W.M. Jones, Red Hat Inc. * https://libvirt.org/ * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* Please read libvirt/README file. */ #include "libvirt_c.h" #ifdef __GNUC__ #pragma GCC diagnostic ignored "-Wmissing-prototypes" #endif /*----------------------------------------------------------------------*/ CAMLprim value ocaml_libvirt_get_version (value driverv, value unit) { CAMLparam2 (driverv, unit); CAMLlocal1 (rv); const char *driver = Optstring_val (driverv); unsigned long libVer, typeVer = 0, *typeVer_ptr; int r; typeVer_ptr = driver ? &typeVer : NULL; NONBLOCKING (r = virGetVersion (&libVer, driver, typeVer_ptr)); CHECK_ERROR (r == -1, "virGetVersion"); rv = caml_alloc_tuple (2); Store_field (rv, 0, Val_int (libVer)); Store_field (rv, 1, Val_int (typeVer)); CAMLreturn (rv); } /*----------------------------------------------------------------------*/ /* Connection object. */ CAMLprim value ocaml_libvirt_connect_open (value namev, value unit) { CAMLparam2 (namev, unit); CAMLlocal1 (rv); const char *name = Optstring_val (namev); virConnectPtr conn; NONBLOCKING (conn = virConnectOpen (name)); CHECK_ERROR (!conn, "virConnectOpen"); rv = Val_connect (conn); CAMLreturn (rv); } CAMLprim value ocaml_libvirt_connect_open_readonly (value namev, value unit) { CAMLparam2 (namev, unit); CAMLlocal1 (rv); const char *name = Optstring_val (namev); virConnectPtr conn; NONBLOCKING (conn = virConnectOpenReadOnly (name)); CHECK_ERROR (!conn, "virConnectOpen"); rv = Val_connect (conn); CAMLreturn (rv); } /* Helper struct holding data needed for the helper C authentication * callback (which will call the actual OCaml callback). */ struct ocaml_auth_callback_data { value *fvp; /* The OCaml auth callback. */ }; static int _ocaml_auth_callback (virConnectCredentialPtr cred, unsigned int ncred, void *cbdata) { CAMLparam0 (); CAMLlocal4 (listv, elemv, rv, v); struct ocaml_auth_callback_data *s = cbdata; int i, len; listv = Val_emptylist; for (i = ncred - 1; i >= 0; --i) { elemv = caml_alloc (2, 0); Store_field (elemv, 0, Val_virconnectcredential (&cred[i])); Store_field (elemv, 1, listv); listv = elemv; } /* Call the auth callback. */ rv = caml_callback_exn (*s->fvp, listv); if (Is_exception_result (rv)) { /* The callback raised an exception, so return an error. */ CAMLreturnT (int, -1); } len = _list_length (rv); if (len != (int) ncred) { /* The callback did not return the same number of results as the * credentials. */ CAMLreturnT (int, -1); } for (i = 0; rv != Val_emptylist; rv = Field (rv, 1), ++i) { virConnectCredentialPtr c = &cred[i]; elemv = Field (rv, 0); if (elemv == Val_int (0)) { c->result = NULL; c->resultlen = 0; } else { v = Field (elemv, 0); len = caml_string_length (v); c->result = malloc (len + 1); if (c->result == NULL) CAMLreturnT (int, -1); memcpy (c->result, String_val (v), len); c->result[len] = '\0'; c->resultlen = len; } } CAMLreturnT (int, 0); } static virConnectPtr _ocaml_libvirt_connect_open_auth_common (value namev, value authv, int flags) { CAMLparam2 (namev, authv); CAMLlocal2 (listv, fv); virConnectPtr conn; virConnectAuth auth; struct ocaml_auth_callback_data data; int i; char *name = NULL; /* Keep a copy of the 'namev' string, as its value could move around * when calling other OCaml code that allocates memory. */ if (namev != Val_int (0)) { /* Some string */ name = strdup (String_val (Field (namev, 0))); if (name == NULL) caml_raise_out_of_memory (); } fv = Field (authv, 1); data.fvp = &fv; listv = Field (authv, 0); auth.ncredtype = _list_length (listv); auth.credtype = malloc (sizeof (int) * auth.ncredtype); if (auth.credtype == NULL) caml_raise_out_of_memory (); for (i = 0; listv != Val_emptylist; listv = Field (listv, 1), ++i) { auth.credtype[i] = Int_val (Field (listv, 0)) + 1; } auth.cb = &_ocaml_auth_callback; auth.cbdata = &data; /* Call virConnectOpenAuth directly, without using the NONBLOCKING * macro, as this will indeed call ocaml_* APIs, and run OCaml code. */ conn = virConnectOpenAuth (name, &auth, flags); free (auth.credtype); free (name); CHECK_ERROR (!conn, "virConnectOpenAuth"); CAMLreturnT (virConnectPtr, conn); } CAMLprim value ocaml_libvirt_connect_open_auth (value namev, value authv) { CAMLparam2 (namev, authv); CAMLlocal1 (rv); virConnectPtr conn; conn = _ocaml_libvirt_connect_open_auth_common (namev, authv, 0); rv = Val_connect (conn); CAMLreturn (rv); } CAMLprim value ocaml_libvirt_connect_open_auth_readonly (value namev, value authv) { CAMLparam2 (namev, authv); CAMLlocal1 (rv); virConnectPtr conn; conn = _ocaml_libvirt_connect_open_auth_common (namev, authv, VIR_CONNECT_RO); rv = Val_connect (conn); CAMLreturn (rv); } CAMLprim value ocaml_libvirt_connect_get_version (value connv) { CAMLparam1 (connv); virConnectPtr conn = Connect_val (connv); unsigned long hvVer; int r; NONBLOCKING (r = virConnectGetVersion (conn, &hvVer)); CHECK_ERROR (r == -1, "virConnectGetVersion"); CAMLreturn (Val_int (hvVer)); } CAMLprim value ocaml_libvirt_connect_get_max_vcpus (value connv, value typev) { CAMLparam2 (connv, typev); virConnectPtr conn = Connect_val (connv); const char *type = Optstring_val (typev); int r; NONBLOCKING (r = virConnectGetMaxVcpus (conn, type)); CHECK_ERROR (r == -1, "virConnectGetMaxVcpus"); CAMLreturn (Val_int (r)); } CAMLprim value ocaml_libvirt_connect_get_node_info (value connv) { CAMLparam1 (connv); CAMLlocal2 (rv, v); virConnectPtr conn = Connect_val (connv); virNodeInfo info; int r; NONBLOCKING (r = virNodeGetInfo (conn, &info)); CHECK_ERROR (r == -1, "virNodeGetInfo"); rv = caml_alloc (8, 0); v = caml_copy_string (info.model); Store_field (rv, 0, v); v = caml_copy_int64 (info.memory); Store_field (rv, 1, v); Store_field (rv, 2, Val_int (info.cpus)); Store_field (rv, 3, Val_int (info.mhz)); Store_field (rv, 4, Val_int (info.nodes)); Store_field (rv, 5, Val_int (info.sockets)); Store_field (rv, 6, Val_int (info.cores)); Store_field (rv, 7, Val_int (info.threads)); CAMLreturn (rv); } CAMLprim value ocaml_libvirt_connect_node_get_free_memory (value connv) { CAMLparam1 (connv); CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); unsigned long long r; NONBLOCKING (r = virNodeGetFreeMemory (conn)); CHECK_ERROR (r == 0, "virNodeGetFreeMemory"); rv = caml_copy_int64 ((int64_t) r); CAMLreturn (rv); } CAMLprim value ocaml_libvirt_connect_node_get_cells_free_memory (value connv, value startv, value maxv) { CAMLparam3 (connv, startv, maxv); CAMLlocal2 (rv, iv); virConnectPtr conn = Connect_val (connv); int start = Int_val (startv); int max = Int_val (maxv); int r, i; unsigned long long *freemems; freemems = malloc(sizeof (*freemems) * max); if (freemems == NULL) caml_raise_out_of_memory (); NONBLOCKING (r = virNodeGetCellsFreeMemory (conn, freemems, start, max)); CHECK_ERROR_CLEANUP (r == -1, free (freemems), "virNodeGetCellsFreeMemory"); rv = caml_alloc (r, 0); for (i = 0; i < r; ++i) { iv = caml_copy_int64 ((int64_t) freemems[i]); Store_field (rv, i, iv); } free (freemems); CAMLreturn (rv); } CAMLprim value ocaml_libvirt_connect_set_keep_alive(value connv, value intervalv, value countv) { CAMLparam3 (connv, intervalv, countv); virConnectPtr conn = Connect_val(connv); int interval = Int_val(intervalv); unsigned int count = Int_val(countv); int r; NONBLOCKING(r = virConnectSetKeepAlive(conn, interval, count)); CHECK_ERROR (r == -1, "virConnectSetKeepAlive"); CAMLreturn(Val_unit); } CAMLprim value ocaml_libvirt_connect_credtypes_from_auth_default (value unitv) { CAMLparam1 (unitv); CAMLlocal2 (listv, itemv); int i; listv = Val_emptylist; if (virConnectAuthPtrDefault) { for (i = virConnectAuthPtrDefault->ncredtype; i >= 0; --i) { const int type = virConnectAuthPtrDefault->credtype[i]; itemv = caml_alloc (2, 0); Store_field (itemv, 0, Val_int (type - 1)); Store_field (itemv, 1, listv); listv = itemv; } } CAMLreturn (listv); } CAMLprim value ocaml_libvirt_connect_call_auth_default_callback (value listv) { CAMLparam1 (listv); CAMLlocal5 (credv, retv, elemv, optv, v); int i, len, ret; const char *str; virConnectCredentialPtr creds; if (virConnectAuthPtrDefault == NULL || virConnectAuthPtrDefault->cb == NULL) CAMLreturn (Val_unit); len = _list_length (listv); creds = calloc (len, sizeof (*creds)); if (creds == NULL) caml_raise_out_of_memory (); for (i = 0; listv != Val_emptylist; listv = Field (listv, 1), ++i) { virConnectCredentialPtr cred = &creds[i]; credv = Field (listv, 0); cred->type = Int_val (Field (credv, 0)) + 1; cred->prompt = strdup (String_val (Field (credv, 1))); if (cred->prompt == NULL) caml_raise_out_of_memory (); str = Optstring_val (Field (credv, 2)); if (str) { cred->challenge = strdup (str); if (cred->challenge == NULL) caml_raise_out_of_memory (); } str = Optstring_val (Field (credv, 3)); if (str) { cred->defresult = strdup (str); if (cred->defresult == NULL) caml_raise_out_of_memory (); } } ret = virConnectAuthPtrDefault->cb (creds, len, virConnectAuthPtrDefault->cbdata); if (ret >= 0) { retv = Val_emptylist; for (i = len - 1; i >= 0; --i) { virConnectCredentialPtr cred = &creds[i]; elemv = caml_alloc (2, 0); if (cred->result != NULL && cred->resultlen > 0) { v = caml_alloc_string (cred->resultlen); memcpy (Bytes_val (v), cred->result, cred->resultlen); optv = caml_alloc (1, 0); Store_field (optv, 0, v); } else optv = Val_int (0); Store_field (elemv, 0, optv); Store_field (elemv, 1, retv); retv = elemv; } } for (i = 0; i < len; ++i) { virConnectCredentialPtr cred = &creds[i]; /* Cast to char *, as the virConnectCredential structs we fill have * const char * qualifiers. */ free ((char *) cred->prompt); free ((char *) cred->challenge); free ((char *) cred->defresult); } free (creds); if (ret < 0) caml_failwith ("virConnectAuthPtrDefault callback failed"); CAMLreturn (retv); } CAMLprim value ocaml_libvirt_connect_get_domain_capabilities (value emulatorbinv, value archv, value machinev, value virttypev, value connv) { CAMLparam5 (emulatorbinv, archv, machinev, virttypev, connv); CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); char *r; NONBLOCKING (r = virConnectGetDomainCapabilities (conn, Optstring_val (emulatorbinv), Optstring_val (archv), Optstring_val (machinev), Optstring_val (virttypev), 0)); CHECK_ERROR (r == NULL, "virConnectGetDomainCapabilities"); rv = caml_copy_string (r); free (r); CAMLreturn (rv); } CAMLprim value ocaml_libvirt_domain_get_id (value domv) { CAMLparam1 (domv); virDomainPtr dom = Domain_val (domv); unsigned int r; NONBLOCKING (r = virDomainGetID (dom)); /* In theory this could return -1 on error, but in practice * libvirt never does this unless you call it with a corrupted * or NULL dom object. So ignore errors here. */ CAMLreturn (Val_int ((int) r)); } CAMLprim value ocaml_libvirt_domain_get_max_memory (value domv) { CAMLparam1 (domv); CAMLlocal1 (rv); virDomainPtr dom = Domain_val (domv); unsigned long r; NONBLOCKING (r = virDomainGetMaxMemory (dom)); CHECK_ERROR (r == 0 /* [sic] */, "virDomainGetMaxMemory"); rv = caml_copy_int64 (r); CAMLreturn (rv); } CAMLprim value ocaml_libvirt_domain_set_max_memory (value domv, value memv) { CAMLparam2 (domv, memv); virDomainPtr dom = Domain_val (domv); unsigned long mem = Int64_val (memv); int r; NONBLOCKING (r = virDomainSetMaxMemory (dom, mem)); CHECK_ERROR (r == -1, "virDomainSetMaxMemory"); CAMLreturn (Val_unit); } CAMLprim value ocaml_libvirt_domain_set_memory (value domv, value memv) { CAMLparam2 (domv, memv); virDomainPtr dom = Domain_val (domv); unsigned long mem = Int64_val (memv); int r; NONBLOCKING (r = virDomainSetMemory (dom, mem)); CHECK_ERROR (r == -1, "virDomainSetMemory"); CAMLreturn (Val_unit); } CAMLprim value ocaml_libvirt_domain_get_info (value domv) { CAMLparam1 (domv); CAMLlocal2 (rv, v); virDomainPtr dom = Domain_val (domv); virDomainInfo info; int r; NONBLOCKING (r = virDomainGetInfo (dom, &info)); CHECK_ERROR (r == -1, "virDomainGetInfo"); rv = caml_alloc (5, 0); Store_field (rv, 0, Val_int (info.state)); // These flags are compatible. v = caml_copy_int64 (info.maxMem); Store_field (rv, 1, v); v = caml_copy_int64 (info.memory); Store_field (rv, 2, v); Store_field (rv, 3, Val_int (info.nrVirtCpu)); v = caml_copy_int64 (info.cpuTime); Store_field (rv, 4, v); CAMLreturn (rv); } CAMLprim value ocaml_libvirt_domain_get_scheduler_type (value domv) { CAMLparam1 (domv); CAMLlocal2 (rv, strv); virDomainPtr dom = Domain_val (domv); char *r; int nparams; NONBLOCKING (r = virDomainGetSchedulerType (dom, &nparams)); CHECK_ERROR (!r, "virDomainGetSchedulerType"); rv = caml_alloc_tuple (2); strv = caml_copy_string (r); Store_field (rv, 0, strv); free (r); Store_field (rv, 1, nparams); CAMLreturn (rv); } CAMLprim value ocaml_libvirt_domain_get_scheduler_parameters (value domv, value nparamsv) { CAMLparam2 (domv, nparamsv); CAMLlocal4 (rv, v, v2, v3); virDomainPtr dom = Domain_val (domv); int nparams = Int_val (nparamsv); virSchedParameterPtr params; int r, i; params = malloc (sizeof (*params) * nparams); if (params == NULL) caml_raise_out_of_memory (); NONBLOCKING (r = virDomainGetSchedulerParameters (dom, params, &nparams)); CHECK_ERROR_CLEANUP (r == -1, free (params), "virDomainGetSchedulerParameters"); rv = caml_alloc (nparams, 0); for (i = 0; i < nparams; ++i) { v = caml_alloc_tuple (2); Store_field (rv, i, v); v2 = caml_copy_string (params[i].field); Store_field (v, 0, v2); switch (params[i].type) { case VIR_DOMAIN_SCHED_FIELD_INT: v2 = caml_alloc (1, 0); v3 = caml_copy_int32 (params[i].value.i); Store_field (v2, 0, v3); break; case VIR_DOMAIN_SCHED_FIELD_UINT: v2 = caml_alloc (1, 1); v3 = caml_copy_int32 (params[i].value.ui); Store_field (v2, 0, v3); break; case VIR_DOMAIN_SCHED_FIELD_LLONG: v2 = caml_alloc (1, 2); v3 = caml_copy_int64 (params[i].value.l); Store_field (v2, 0, v3); break; case VIR_DOMAIN_SCHED_FIELD_ULLONG: v2 = caml_alloc (1, 3); v3 = caml_copy_int64 (params[i].value.ul); Store_field (v2, 0, v3); break; case VIR_DOMAIN_SCHED_FIELD_DOUBLE: v2 = caml_alloc (1, 4); v3 = caml_copy_double (params[i].value.d); Store_field (v2, 0, v3); break; case VIR_DOMAIN_SCHED_FIELD_BOOLEAN: v2 = caml_alloc (1, 5); Store_field (v2, 0, Val_int (params[i].value.b)); break; default: caml_failwith ((char *)__FUNCTION__); } Store_field (v, 1, v2); } free (params); CAMLreturn (rv); } CAMLprim value ocaml_libvirt_domain_set_scheduler_parameters (value domv, value paramsv) { CAMLparam2 (domv, paramsv); CAMLlocal1 (v); virDomainPtr dom = Domain_val (domv); int nparams = Wosize_val (paramsv); virSchedParameterPtr params; int r, i; const char *name; params = malloc (sizeof (*params) * nparams); if (params == NULL) caml_raise_out_of_memory (); for (i = 0; i < nparams; ++i) { v = Field (paramsv, i); /* Points to the two-element tuple. */ name = String_val (Field (v, 0)); strncpy (params[i].field, name, VIR_DOMAIN_SCHED_FIELD_LENGTH); params[i].field[VIR_DOMAIN_SCHED_FIELD_LENGTH-1] = '\0'; v = Field (v, 1); /* Points to the sched_param_value block. */ switch (Tag_val (v)) { case 0: params[i].type = VIR_DOMAIN_SCHED_FIELD_INT; params[i].value.i = Int32_val (Field (v, 0)); break; case 1: params[i].type = VIR_DOMAIN_SCHED_FIELD_UINT; params[i].value.ui = Int32_val (Field (v, 0)); break; case 2: params[i].type = VIR_DOMAIN_SCHED_FIELD_LLONG; params[i].value.l = Int64_val (Field (v, 0)); break; case 3: params[i].type = VIR_DOMAIN_SCHED_FIELD_ULLONG; params[i].value.ul = Int64_val (Field (v, 0)); break; case 4: params[i].type = VIR_DOMAIN_SCHED_FIELD_DOUBLE; params[i].value.d = Double_val (Field (v, 0)); break; case 5: params[i].type = VIR_DOMAIN_SCHED_FIELD_BOOLEAN; params[i].value.b = Int_val (Field (v, 0)); break; default: caml_failwith ((char *)__FUNCTION__); } } NONBLOCKING (r = virDomainSetSchedulerParameters (dom, params, nparams)); free (params); CHECK_ERROR (r == -1, "virDomainSetSchedulerParameters"); CAMLreturn (Val_unit); } CAMLprim value ocaml_libvirt_domain_set_vcpus (value domv, value nvcpusv) { CAMLparam2 (domv, nvcpusv); virDomainPtr dom = Domain_val (domv); int r, nvcpus = Int_val (nvcpusv); NONBLOCKING (r = virDomainSetVcpus (dom, nvcpus)); CHECK_ERROR (r == -1, "virDomainSetVcpus"); CAMLreturn (Val_unit); } CAMLprim value ocaml_libvirt_domain_pin_vcpu (value domv, value vcpuv, value cpumapv) { CAMLparam3 (domv, vcpuv, cpumapv); virDomainPtr dom = Domain_val (domv); int maplen = caml_string_length (cpumapv); unsigned char *cpumap = (unsigned char *) String_val (cpumapv); int vcpu = Int_val (vcpuv); int r; NONBLOCKING (r = virDomainPinVcpu (dom, vcpu, cpumap, maplen)); CHECK_ERROR (r == -1, "virDomainPinVcpu"); CAMLreturn (Val_unit); } CAMLprim value ocaml_libvirt_domain_get_vcpus (value domv, value maxinfov, value maplenv) { CAMLparam3 (domv, maxinfov, maplenv); CAMLlocal5 (rv, infov, strv, v, v2); virDomainPtr dom = Domain_val (domv); int maxinfo = Int_val (maxinfov); int maplen = Int_val (maplenv); virVcpuInfoPtr info; unsigned char *cpumaps; int r, i; info = calloc (maxinfo, sizeof (*info)); if (info == NULL) caml_raise_out_of_memory (); cpumaps = calloc (maxinfo * maplen, sizeof (*cpumaps)); if (cpumaps == NULL) { free (info); caml_raise_out_of_memory (); } NONBLOCKING (r = virDomainGetVcpus (dom, info, maxinfo, cpumaps, maplen)); CHECK_ERROR_CLEANUP (r == -1, free (info); free (cpumaps), "virDomainPinVcpu"); /* Copy the virVcpuInfo structures. */ infov = caml_alloc (maxinfo, 0); for (i = 0; i < maxinfo; ++i) { v2 = caml_alloc (4, 0); Store_field (infov, i, v2); Store_field (v2, 0, Val_int (info[i].number)); Store_field (v2, 1, Val_int (info[i].state)); v = caml_copy_int64 (info[i].cpuTime); Store_field (v2, 2, v); Store_field (v2, 3, Val_int (info[i].cpu)); } /* Copy the bitmap. */ strv = caml_alloc_string (maxinfo * maplen); memcpy (Bytes_val (strv), cpumaps, maxinfo * maplen); /* Allocate the tuple and return it. */ rv = caml_alloc_tuple (3); Store_field (rv, 0, Val_int (r)); /* number of CPUs. */ Store_field (rv, 1, infov); Store_field (rv, 2, strv); free (info); free (cpumaps); CAMLreturn (rv); } CAMLprim value ocaml_libvirt_domain_get_cpu_stats (value domv) { CAMLparam1 (domv); CAMLlocal5 (cpustats, param_head, param_node, typed_param, typed_param_value); CAMLlocal1 (v); virDomainPtr dom = Domain_val (domv); virTypedParameterPtr params; int r, cpu, ncpus, nparams, i, j, pos; int nr_pcpus; /* get number of pcpus */ NONBLOCKING (nr_pcpus = virDomainGetCPUStats(dom, NULL, 0, 0, 0, 0)); CHECK_ERROR (nr_pcpus < 0, "virDomainGetCPUStats"); /* get percpu information */ NONBLOCKING (nparams = virDomainGetCPUStats(dom, NULL, 0, 0, 1, 0)); CHECK_ERROR (nparams < 0, "virDomainGetCPUStats"); if ((params = malloc(sizeof(*params) * nparams * 128)) == NULL) caml_raise_out_of_memory (); cpustats = caml_alloc (nr_pcpus, 0); /* cpustats: array of params(list of typed_param) */ cpu = 0; while (cpu < nr_pcpus) { ncpus = nr_pcpus - cpu > 128 ? 128 : nr_pcpus - cpu; NONBLOCKING (r = virDomainGetCPUStats(dom, params, nparams, cpu, ncpus, 0)); CHECK_ERROR (r < 0, "virDomainGetCPUStats"); for (i = 0; i < ncpus; i++) { /* list of typed_param: single linked list of param_nodes */ param_head = Val_emptylist; /* param_head: the head param_node of list of typed_param */ if (params[i * nparams].type == 0) { Store_field(cpustats, cpu + i, param_head); continue; } for (j = r - 1; j >= 0; j--) { pos = i * nparams + j; if (params[pos].type == 0) continue; param_node = caml_alloc(2, 0); /* param_node: typed_param, next param_node */ Store_field(param_node, 1, param_head); param_head = param_node; typed_param = caml_alloc(2, 0); /* typed_param: field name(string), typed_param_value */ Store_field(param_node, 0, typed_param); Store_field(typed_param, 0, caml_copy_string(params[pos].field)); /* typed_param_value: value with the corresponding type tag */ switch(params[pos].type) { case VIR_TYPED_PARAM_INT: typed_param_value = caml_alloc (1, 0); v = caml_copy_int32 (params[pos].value.i); break; case VIR_TYPED_PARAM_UINT: typed_param_value = caml_alloc (1, 1); v = caml_copy_int32 (params[pos].value.ui); break; case VIR_TYPED_PARAM_LLONG: typed_param_value = caml_alloc (1, 2); v = caml_copy_int64 (params[pos].value.l); break; case VIR_TYPED_PARAM_ULLONG: typed_param_value = caml_alloc (1, 3); v = caml_copy_int64 (params[pos].value.ul); break; case VIR_TYPED_PARAM_DOUBLE: typed_param_value = caml_alloc (1, 4); v = caml_copy_double (params[pos].value.d); break; case VIR_TYPED_PARAM_BOOLEAN: typed_param_value = caml_alloc (1, 5); v = Val_bool (params[pos].value.b); break; case VIR_TYPED_PARAM_STRING: typed_param_value = caml_alloc (1, 6); v = caml_copy_string (params[pos].value.s); free (params[pos].value.s); break; default: /* XXX Memory leak on this path, if there are more * VIR_TYPED_PARAM_STRING past this point in the array. */ free (params); caml_failwith ("virDomainGetCPUStats: " "unknown parameter type returned"); } Store_field (typed_param_value, 0, v); Store_field (typed_param, 1, typed_param_value); } Store_field (cpustats, cpu + i, param_head); } cpu += ncpus; } free(params); CAMLreturn (cpustats); } value ocaml_libvirt_domain_get_all_domain_stats (value connv, value statsv, value flagsv) { CAMLparam3 (connv, statsv, flagsv); CAMLlocal5 (rv, dsv, tpv, v, v1); CAMLlocal1 (v2); virConnectPtr conn = Connect_val (connv); virDomainStatsRecordPtr *rstats; unsigned int stats = 0, flags = 0; int i, j, r; unsigned char uuid[VIR_UUID_BUFLEN]; /* Get stats and flags. */ for (; statsv != Val_int (0); statsv = Field (statsv, 1)) { v = Field (statsv, 0); if (v == Val_int (0)) stats |= VIR_DOMAIN_STATS_STATE; else if (v == Val_int (1)) stats |= VIR_DOMAIN_STATS_CPU_TOTAL; else if (v == Val_int (2)) stats |= VIR_DOMAIN_STATS_BALLOON; else if (v == Val_int (3)) stats |= VIR_DOMAIN_STATS_VCPU; else if (v == Val_int (4)) stats |= VIR_DOMAIN_STATS_INTERFACE; else if (v == Val_int (5)) stats |= VIR_DOMAIN_STATS_BLOCK; else if (v == Val_int (6)) stats |= VIR_DOMAIN_STATS_PERF; } for (; flagsv != Val_int (0); flagsv = Field (flagsv, 1)) { v = Field (flagsv, 0); if (v == Val_int (0)) flags |= VIR_CONNECT_GET_ALL_DOMAINS_STATS_ACTIVE; else if (v == Val_int (1)) flags |= VIR_CONNECT_GET_ALL_DOMAINS_STATS_INACTIVE; else if (v == Val_int (2)) flags |= VIR_CONNECT_GET_ALL_DOMAINS_STATS_OTHER; else if (v == Val_int (3)) flags |= VIR_CONNECT_GET_ALL_DOMAINS_STATS_PAUSED; else if (v == Val_int (4)) flags |= VIR_CONNECT_GET_ALL_DOMAINS_STATS_PERSISTENT; else if (v == Val_int (5)) flags |= VIR_CONNECT_GET_ALL_DOMAINS_STATS_RUNNING; else if (v == Val_int (6)) flags |= VIR_CONNECT_GET_ALL_DOMAINS_STATS_SHUTOFF; else if (v == Val_int (7)) flags |= VIR_CONNECT_GET_ALL_DOMAINS_STATS_TRANSIENT; else if (v == Val_int (8)) flags |= VIR_CONNECT_GET_ALL_DOMAINS_STATS_BACKING; else if (v == Val_int (9)) flags |= VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS; } NONBLOCKING (r = virConnectGetAllDomainStats (conn, stats, &rstats, flags)); CHECK_ERROR (r == -1, "virConnectGetAllDomainStats"); rv = caml_alloc (r, 0); /* domain_stats_record array. */ for (i = 0; i < r; ++i) { dsv = caml_alloc (2, 0); /* domain_stats_record */ /* Libvirt returns something superficially resembling a * virDomainPtr, but it's not a real virDomainPtr object * (eg. dom->id == -1, and its refcount is wrong). The only thing * we can safely get from it is the UUID. */ v = caml_alloc_string (VIR_UUID_BUFLEN); virDomainGetUUID (rstats[i]->dom, uuid); memcpy (Bytes_val (v), uuid, VIR_UUID_BUFLEN); Store_field (dsv, 0, v); tpv = caml_alloc (rstats[i]->nparams, 0); /* typed_param array */ for (j = 0; j < rstats[i]->nparams; ++j) { v2 = caml_alloc (2, 0); /* typed_param: field name, value */ Store_field (v2, 0, caml_copy_string (rstats[i]->params[j].field)); switch (rstats[i]->params[j].type) { case VIR_TYPED_PARAM_INT: v1 = caml_alloc (1, 0); v = caml_copy_int32 (rstats[i]->params[j].value.i); break; case VIR_TYPED_PARAM_UINT: v1 = caml_alloc (1, 1); v = caml_copy_int32 (rstats[i]->params[j].value.ui); break; case VIR_TYPED_PARAM_LLONG: v1 = caml_alloc (1, 2); v = caml_copy_int64 (rstats[i]->params[j].value.l); break; case VIR_TYPED_PARAM_ULLONG: v1 = caml_alloc (1, 3); v = caml_copy_int64 (rstats[i]->params[j].value.ul); break; case VIR_TYPED_PARAM_DOUBLE: v1 = caml_alloc (1, 4); v = caml_copy_double (rstats[i]->params[j].value.d); break; case VIR_TYPED_PARAM_BOOLEAN: v1 = caml_alloc (1, 5); v = Val_bool (rstats[i]->params[j].value.b); break; case VIR_TYPED_PARAM_STRING: v1 = caml_alloc (1, 6); v = caml_copy_string (rstats[i]->params[j].value.s); break; default: virDomainStatsRecordListFree (rstats); caml_failwith ("virConnectGetAllDomainStats: " "unknown parameter type returned"); } Store_field (v1, 0, v); Store_field (v2, 1, v1); Store_field (tpv, j, v2); } Store_field (dsv, 1, tpv); Store_field (rv, i, dsv); } virDomainStatsRecordListFree (rstats); CAMLreturn (rv); } CAMLprim value ocaml_libvirt_domain_migrate_native (value domv, value dconnv, value flagsv, value optdnamev, value opturiv, value optbandwidthv, value unitv) { CAMLparam5 (domv, dconnv, flagsv, optdnamev, opturiv); CAMLxparam2 (optbandwidthv, unitv); CAMLlocal2 (flagv, rv); virDomainPtr dom = Domain_val (domv); virConnectPtr dconn = Connect_val (dconnv); int flags = 0; const char *dname = Optstring_val (optdnamev); const char *uri = Optstring_val (opturiv); unsigned long bandwidth; virDomainPtr r; /* Iterate over the list of flags. */ for (; flagsv != Val_int (0); flagsv = Field (flagsv, 1)) { flagv = Field (flagsv, 0); if (flagv == Val_int (0)) flags |= VIR_MIGRATE_LIVE; } if (optbandwidthv == Val_int (0)) /* None */ bandwidth = 0; else /* Some bandwidth */ bandwidth = Int_val (Field (optbandwidthv, 0)); NONBLOCKING (r = virDomainMigrate (dom, dconn, flags, dname, uri, bandwidth)); CHECK_ERROR (!r, "virDomainMigrate"); rv = Val_domain (r, dconnv); CAMLreturn (rv); } CAMLprim value ocaml_libvirt_domain_migrate_bytecode (value *argv, int argn) { return ocaml_libvirt_domain_migrate_native (argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], argv[6]); } CAMLprim value ocaml_libvirt_domain_block_stats (value domv, value pathv) { CAMLparam2 (domv, pathv); CAMLlocal2 (rv,v); virDomainPtr dom = Domain_val (domv); const char *path = String_val (pathv); struct _virDomainBlockStats stats; int r; NONBLOCKING (r = virDomainBlockStats (dom, path, &stats, sizeof stats)); CHECK_ERROR (r == -1, "virDomainBlockStats"); rv = caml_alloc (5, 0); v = caml_copy_int64 (stats.rd_req); Store_field (rv, 0, v); v = caml_copy_int64 (stats.rd_bytes); Store_field (rv, 1, v); v = caml_copy_int64 (stats.wr_req); Store_field (rv, 2, v); v = caml_copy_int64 (stats.wr_bytes); Store_field (rv, 3, v); v = caml_copy_int64 (stats.errs); Store_field (rv, 4, v); CAMLreturn (rv); } CAMLprim value ocaml_libvirt_domain_interface_stats (value domv, value pathv) { CAMLparam2 (domv, pathv); CAMLlocal2 (rv,v); virDomainPtr dom = Domain_val (domv); const char *path = String_val (pathv); struct _virDomainInterfaceStats stats; int r; NONBLOCKING (r = virDomainInterfaceStats (dom, path, &stats, sizeof stats)); CHECK_ERROR (r == -1, "virDomainInterfaceStats"); rv = caml_alloc (8, 0); v = caml_copy_int64 (stats.rx_bytes); Store_field (rv, 0, v); v = caml_copy_int64 (stats.rx_packets); Store_field (rv, 1, v); v = caml_copy_int64 (stats.rx_errs); Store_field (rv, 2, v); v = caml_copy_int64 (stats.rx_drop); Store_field (rv, 3, v); v = caml_copy_int64 (stats.tx_bytes); Store_field (rv, 4, v); v = caml_copy_int64 (stats.tx_packets); Store_field (rv, 5, v); v = caml_copy_int64 (stats.tx_errs); Store_field (rv, 6, v); v = caml_copy_int64 (stats.tx_drop); Store_field (rv, 7, v); CAMLreturn (rv); } CAMLprim value ocaml_libvirt_domain_block_peek_native (value domv, value pathv, value offsetv, value sizev, value bufferv, value boffv) { CAMLparam5 (domv, pathv, offsetv, sizev, bufferv); CAMLxparam1 (boffv); virDomainPtr dom = Domain_val (domv); const char *path = String_val (pathv); unsigned long long offset = Int64_val (offsetv); size_t size = Int_val (sizev); unsigned char *buffer = Bytes_val (bufferv); int boff = Int_val (boffv); int r; /* Check that the return buffer is big enough. */ if (caml_string_length (bufferv) < boff + size) caml_failwith ("virDomainBlockPeek: return buffer too short"); /* NB. not NONBLOCKING because buffer might move (XXX) */ r = virDomainBlockPeek (dom, path, offset, size, buffer+boff, 0); CHECK_ERROR (r == -1, "virDomainBlockPeek"); CAMLreturn (Val_unit); } CAMLprim value ocaml_libvirt_domain_block_peek_bytecode (value *argv, int argn) { return ocaml_libvirt_domain_block_peek_native (argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]); } CAMLprim value ocaml_libvirt_domain_memory_peek_native (value domv, value flagsv, value offsetv, value sizev, value bufferv, value boffv) { CAMLparam5 (domv, flagsv, offsetv, sizev, bufferv); CAMLxparam1 (boffv); CAMLlocal1 (flagv); virDomainPtr dom = Domain_val (domv); int flags = 0; unsigned long long offset = Int64_val (offsetv); size_t size = Int_val (sizev); unsigned char *buffer = Bytes_val (bufferv); int boff = Int_val (boffv); int r; /* Check that the return buffer is big enough. */ if (caml_string_length (bufferv) < boff + size) caml_failwith ("virDomainMemoryPeek: return buffer too short"); /* Do flags. */ for (; flagsv != Val_int (0); flagsv = Field (flagsv, 1)) { flagv = Field (flagsv, 0); if (flagv == Val_int (0)) flags |= VIR_MEMORY_VIRTUAL; } /* NB. not NONBLOCKING because buffer might move (XXX) */ r = virDomainMemoryPeek (dom, offset, size, buffer+boff, flags); CHECK_ERROR (r == -1, "virDomainMemoryPeek"); CAMLreturn (Val_unit); } CAMLprim value ocaml_libvirt_domain_memory_peek_bytecode (value *argv, int argn) { return ocaml_libvirt_domain_memory_peek_native (argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]); } CAMLprim value ocaml_libvirt_domain_get_xml_desc_flags (value domv, value flagsv) { CAMLparam2 (domv, flagsv); CAMLlocal2 (rv, flagv); virDomainPtr dom = Domain_val (domv); int flags = 0; char *r; /* Do flags. */ for (; flagsv != Val_int (0); flagsv = Field (flagsv, 1)) { flagv = Field (flagsv, 0); if (flagv == Val_int (0)) flags |= VIR_DOMAIN_XML_SECURE; else if (flagv == Val_int (1)) flags |= VIR_DOMAIN_XML_INACTIVE; else if (flagv == Val_int (2)) flags |= VIR_DOMAIN_XML_UPDATE_CPU; else if (flagv == Val_int (3)) flags |= VIR_DOMAIN_XML_MIGRATABLE; } NONBLOCKING (r = virDomainGetXMLDesc (dom, flags)); CHECK_ERROR (!r, "virDomainGetXMLDesc"); rv = caml_copy_string (r); free (r); CAMLreturn (rv); } /*----------------------------------------------------------------------*/ /* Domain events */ CAMLprim value ocaml_libvirt_event_register_default_impl (value unitv) { CAMLparam1 (unitv); /* arg is of type unit = void */ int r; NONBLOCKING (r = virEventRegisterDefaultImpl ()); /* must be called before connection, therefore we can't use CHECK_ERROR */ if (r == -1) caml_failwith("virEventRegisterDefaultImpl"); CAMLreturn (Val_unit); } CAMLprim value ocaml_libvirt_event_run_default_impl (value unitv) { CAMLparam1 (unitv); /* arg is of type unit = void */ int r; NONBLOCKING (r = virEventRunDefaultImpl ()); if (r == -1) caml_failwith("virEventRunDefaultImpl"); CAMLreturn (Val_unit); } /* We register a single C callback function for every distinct callback signature. We encode the signature itself in the function name and also in the name of the assocated OCaml callback e.g.: a C function called i_i64_s_callback(virConnectPtr conn, virDomainPtr dom, int x, long y, char *z, void *opaque) would correspond to an OCaml callback Libvirt.i_i64_s_callback : int64 -> [`R] Domain.t -> int -> int64 -> string option -> unit where the initial int64 is a unique ID used by the OCaml to dispatch to the specific OCaml closure and stored by libvirt as the "opaque" data. */ /* Every one of the callbacks starts with a DOMAIN_CALLBACK_BEGIN(NAME) where NAME is the string name of the OCaml callback registered in libvirt.ml. */ #define DOMAIN_CALLBACK_BEGIN(NAME) \ value connv, domv, callback_id, result; \ connv = domv = callback_id = result = Val_int(0); \ static const value *callback = NULL; \ caml_leave_blocking_section(); \ if (callback == NULL) \ callback = caml_named_value(NAME); \ if (callback == NULL) \ abort(); /* C code out of sync with OCaml code */ \ if ((virDomainRef(dom) == -1) || (virConnectRef(conn) == -1)) \ abort(); /* should never happen in practice? */ \ \ Begin_roots4(connv, domv, callback_id, result); \ connv = Val_connect(conn); \ domv = Val_domain(dom, connv); \ callback_id = caml_copy_int64(*(long *)opaque); /* Every one of the callbacks ends with a CALLBACK_END */ #define DOMAIN_CALLBACK_END \ (void) caml_callback3(*callback, callback_id, domv, result); \ End_roots(); \ caml_enter_blocking_section(); static void i_i_callback(virConnectPtr conn, virDomainPtr dom, int x, int y, void * opaque) { DOMAIN_CALLBACK_BEGIN("Libvirt.i_i_callback") result = caml_alloc_tuple(2); Store_field(result, 0, Val_int(x)); Store_field(result, 1, Val_int(y)); DOMAIN_CALLBACK_END } static void u_callback(virConnectPtr conn, virDomainPtr dom, void *opaque) { DOMAIN_CALLBACK_BEGIN("Libvirt.u_callback") result = Val_int(0); /* () */ DOMAIN_CALLBACK_END } static void i64_callback(virConnectPtr conn, virDomainPtr dom, long long int64, void *opaque) { DOMAIN_CALLBACK_BEGIN("Libvirt.i64_callback") result = caml_copy_int64(int64); DOMAIN_CALLBACK_END } static void i_callback(virConnectPtr conn, virDomainPtr dom, int x, void *opaque) { DOMAIN_CALLBACK_BEGIN("Libvirt.i_callback") result = Val_int(x); DOMAIN_CALLBACK_END } static void s_i_callback(virConnectPtr conn, virDomainPtr dom, char *x, int y, void * opaque) { DOMAIN_CALLBACK_BEGIN("Libvirt.s_i_callback") result = caml_alloc_tuple(2); Store_field(result, 0, Val_opt(x, (Val_ptr_t) caml_copy_string)); Store_field(result, 1, Val_int(y)); DOMAIN_CALLBACK_END } static void s_i_i_callback(virConnectPtr conn, virDomainPtr dom, char *x, int y, int z, void * opaque) { DOMAIN_CALLBACK_BEGIN("Libvirt.s_i_i_callback") result = caml_alloc_tuple(3); Store_field(result, 0, Val_opt(x, (Val_ptr_t) caml_copy_string)); Store_field(result, 1, Val_int(y)); Store_field(result, 2, Val_int(z)); DOMAIN_CALLBACK_END } static void s_s_i_callback(virConnectPtr conn, virDomainPtr dom, char *x, char *y, int z, void *opaque) { DOMAIN_CALLBACK_BEGIN("Libvirt.s_s_i_callback") result = caml_alloc_tuple(3); Store_field(result, 0, Val_opt(x, (Val_ptr_t) caml_copy_string)); Store_field(result, 1, Val_opt(y, (Val_ptr_t) caml_copy_string)); Store_field(result, 2, Val_int(z)); DOMAIN_CALLBACK_END } static void s_s_i_s_callback(virConnectPtr conn, virDomainPtr dom, char *x, char *y, int z, char *a, void *opaque) { DOMAIN_CALLBACK_BEGIN("Libvirt.s_s_i_s_callback") result = caml_alloc_tuple(4); Store_field(result, 0, Val_opt(x, (Val_ptr_t) caml_copy_string)); Store_field(result, 1, Val_opt(y, (Val_ptr_t) caml_copy_string)); Store_field(result, 2, Val_int(z)); Store_field(result, 3, Val_opt(a, (Val_ptr_t) caml_copy_string)); DOMAIN_CALLBACK_END } static void s_s_s_i_callback(virConnectPtr conn, virDomainPtr dom, char * x, char * y, char * z, int a, void * opaque) { DOMAIN_CALLBACK_BEGIN("Libvirt.s_s_s_i_callback") result = caml_alloc_tuple(4); Store_field(result, 0, Val_opt(x, (Val_ptr_t) caml_copy_string)); Store_field(result, 1, Val_opt(y, (Val_ptr_t) caml_copy_string)); Store_field(result, 2, Val_opt(z, (Val_ptr_t) caml_copy_string)); Store_field(result, 3, Val_int(a)); DOMAIN_CALLBACK_END } static value Val_event_graphics_address(virDomainEventGraphicsAddressPtr x) { CAMLparam0 (); CAMLlocal1(result); result = caml_alloc_tuple(3); Store_field(result, 0, Val_int(x->family)); Store_field(result, 1, Val_opt((void *) x->node, (Val_ptr_t) caml_copy_string)); Store_field(result, 2, Val_opt((void *) x->service, (Val_ptr_t) caml_copy_string)); CAMLreturn(result); } static value Val_event_graphics_subject_identity(virDomainEventGraphicsSubjectIdentityPtr x) { CAMLparam0 (); CAMLlocal1(result); result = caml_alloc_tuple(2); Store_field(result, 0, Val_opt((void *) x->type, (Val_ptr_t) caml_copy_string)); Store_field(result, 1, Val_opt((void *) x->name, (Val_ptr_t) caml_copy_string)); CAMLreturn(result); } static value Val_event_graphics_subject(virDomainEventGraphicsSubjectPtr x) { CAMLparam0 (); CAMLlocal1(result); int i; result = caml_alloc_tuple(x->nidentity); for (i = 0; i < x->nidentity; i++ ) Store_field(result, i, Val_event_graphics_subject_identity(x->identities + i)); CAMLreturn(result); } static void i_ga_ga_s_gs_callback(virConnectPtr conn, virDomainPtr dom, int i1, virDomainEventGraphicsAddressPtr ga1, virDomainEventGraphicsAddressPtr ga2, char *s1, virDomainEventGraphicsSubjectPtr gs1, void * opaque) { DOMAIN_CALLBACK_BEGIN("Libvirt.i_ga_ga_s_gs_callback") result = caml_alloc_tuple(5); Store_field(result, 0, Val_int(i1)); Store_field(result, 1, Val_event_graphics_address(ga1)); Store_field(result, 2, Val_event_graphics_address(ga2)); Store_field(result, 3, Val_opt(s1, (Val_ptr_t) caml_copy_string)); Store_field(result, 4, Val_event_graphics_subject(gs1)); DOMAIN_CALLBACK_END } static void timeout_callback(int timer, void *opaque) { value callback_id, result; callback_id = result = Val_int(0); static const value *callback = NULL; caml_leave_blocking_section(); if (callback == NULL) callback = caml_named_value("Libvirt.timeout_callback"); if (callback == NULL) abort(); /* C code out of sync with OCaml code */ Begin_roots2(callback_id, result); callback_id = caml_copy_int64(*(long *)opaque); (void)caml_callback_exn(*callback, callback_id); End_roots(); caml_enter_blocking_section(); } CAMLprim value ocaml_libvirt_event_add_timeout (value connv, value ms, value callback_id) { CAMLparam3 (connv, ms, callback_id); void *opaque; virFreeCallback freecb = free; virEventTimeoutCallback cb = timeout_callback; int r; /* Store the int64 callback_id as the opaque data so the OCaml callback can demultiplex to the correct OCaml handler. */ if ((opaque = malloc(sizeof(long))) == NULL) caml_raise_out_of_memory (); *((long*)opaque) = Int64_val(callback_id); NONBLOCKING(r = virEventAddTimeout(Int_val(ms), cb, opaque, freecb)); CHECK_ERROR(r == -1, "virEventAddTimeout"); CAMLreturn(Val_int(r)); } CAMLprim value ocaml_libvirt_event_remove_timeout (value connv, value timer_id) { CAMLparam2 (connv, timer_id); int r; NONBLOCKING(r = virEventRemoveTimeout(Int_val(timer_id))); CHECK_ERROR(r == -1, "virEventRemoveTimeout"); CAMLreturn(Val_int(r)); } CAMLprim value ocaml_libvirt_connect_domain_event_register_any(value connv, value domv, value callback, value callback_id) { CAMLparam4(connv, domv, callback, callback_id); virConnectPtr conn = Connect_val (connv); virDomainPtr dom = NULL; int eventID = Tag_val(callback); virConnectDomainEventGenericCallback cb; void *opaque; virFreeCallback freecb = free; int r; if (domv != Val_int(0)) dom = Domain_val (Field(domv, 0)); switch (eventID){ case VIR_DOMAIN_EVENT_ID_LIFECYCLE: cb = VIR_DOMAIN_EVENT_CALLBACK(i_i_callback); break; case VIR_DOMAIN_EVENT_ID_REBOOT: cb = VIR_DOMAIN_EVENT_CALLBACK(u_callback); break; case VIR_DOMAIN_EVENT_ID_RTC_CHANGE: cb = VIR_DOMAIN_EVENT_CALLBACK(i64_callback); break; case VIR_DOMAIN_EVENT_ID_WATCHDOG: cb = VIR_DOMAIN_EVENT_CALLBACK(i_callback); break; case VIR_DOMAIN_EVENT_ID_IO_ERROR: cb = VIR_DOMAIN_EVENT_CALLBACK(s_s_i_callback); break; case VIR_DOMAIN_EVENT_ID_GRAPHICS: cb = VIR_DOMAIN_EVENT_CALLBACK(i_ga_ga_s_gs_callback); break; case VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON: cb = VIR_DOMAIN_EVENT_CALLBACK(s_s_i_s_callback); break; case VIR_DOMAIN_EVENT_ID_CONTROL_ERROR: cb = VIR_DOMAIN_EVENT_CALLBACK(u_callback); break; case VIR_DOMAIN_EVENT_ID_BLOCK_JOB: cb = VIR_DOMAIN_EVENT_CALLBACK(s_i_i_callback); break; case VIR_DOMAIN_EVENT_ID_DISK_CHANGE: cb = VIR_DOMAIN_EVENT_CALLBACK(s_s_s_i_callback); break; case VIR_DOMAIN_EVENT_ID_TRAY_CHANGE: cb = VIR_DOMAIN_EVENT_CALLBACK(s_i_callback); break; case VIR_DOMAIN_EVENT_ID_PMWAKEUP: cb = VIR_DOMAIN_EVENT_CALLBACK(i_callback); break; case VIR_DOMAIN_EVENT_ID_PMSUSPEND: cb = VIR_DOMAIN_EVENT_CALLBACK(i_callback); break; case VIR_DOMAIN_EVENT_ID_BALLOON_CHANGE: cb = VIR_DOMAIN_EVENT_CALLBACK(i64_callback); break; case VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK: cb = VIR_DOMAIN_EVENT_CALLBACK(i_callback); break; default: caml_failwith("vifConnectDomainEventRegisterAny: unimplemented eventID"); } /* Store the int64 callback_id as the opaque data so the OCaml callback can demultiplex to the correct OCaml handler. */ if ((opaque = malloc(sizeof(long))) == NULL) caml_raise_out_of_memory (); *((long*)opaque) = Int64_val(callback_id); NONBLOCKING(r = virConnectDomainEventRegisterAny(conn, dom, eventID, cb, opaque, freecb)); CHECK_ERROR(r == -1, "virConnectDomainEventRegisterAny"); CAMLreturn(Val_int(r)); } CAMLprim value ocaml_libvirt_storage_pool_get_info (value poolv) { CAMLparam1 (poolv); CAMLlocal2 (rv, v); virStoragePoolPtr pool = Pool_val (poolv); virStoragePoolInfo info; int r; NONBLOCKING (r = virStoragePoolGetInfo (pool, &info)); CHECK_ERROR (r == -1, "virStoragePoolGetInfo"); rv = caml_alloc (4, 0); Store_field (rv, 0, Val_int (info.state)); v = caml_copy_int64 (info.capacity); Store_field (rv, 1, v); v = caml_copy_int64 (info.allocation); Store_field (rv, 2, v); v = caml_copy_int64 (info.available); Store_field (rv, 3, v); CAMLreturn (rv); } CAMLprim value ocaml_libvirt_storage_vol_get_info (value volv) { CAMLparam1 (volv); CAMLlocal2 (rv, v); virStorageVolPtr vol = Volume_val (volv); virStorageVolInfo info; int r; NONBLOCKING (r = virStorageVolGetInfo (vol, &info)); CHECK_ERROR (r == -1, "virStorageVolGetInfo"); rv = caml_alloc (3, 0); Store_field (rv, 0, Val_int (info.type)); v = caml_copy_int64 (info.capacity); Store_field (rv, 1, v); v = caml_copy_int64 (info.allocation); Store_field (rv, 2, v); CAMLreturn (rv); } CAMLprim value ocaml_libvirt_secret_lookup_by_usage (value connv, value usagetypev, value usageidv) { CAMLparam3 (connv, usagetypev, usageidv); CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); int usageType = Int_val (usagetypev); const char *usageID = String_val (usageidv); virSecretPtr r; NONBLOCKING (r = virSecretLookupByUsage (conn, usageType, usageID)); CHECK_ERROR (!r, "virSecretLookupByUsage"); rv = Val_secret (r, connv); CAMLreturn (rv); } CAMLprim value ocaml_libvirt_secret_set_value (value secv, value vv) { CAMLparam2 (secv, vv); virSecretPtr sec = Secret_val (secv); const unsigned char *secval = (unsigned char *) String_val (vv); const size_t size = caml_string_length (vv); int r; NONBLOCKING (r = virSecretSetValue (sec, secval, size, 0)); CHECK_ERROR (r == -1, "virSecretSetValue"); CAMLreturn (Val_unit); } CAMLprim value ocaml_libvirt_secret_get_value (value secv) { CAMLparam1 (secv); CAMLlocal1 (rv); virSecretPtr sec = Secret_val (secv); unsigned char *secval; size_t size = 0; NONBLOCKING (secval = virSecretGetValue (sec, &size, 0)); CHECK_ERROR (secval == NULL, "virSecretGetValue"); rv = caml_alloc_string (size); memcpy (Bytes_val (rv), secval, size); free (secval); CAMLreturn (rv); } /*----------------------------------------------------------------------*/ CAMLprim value ocaml_libvirt_virterror_get_last_error (value unitv) { CAMLparam1 (unitv); CAMLlocal1 (rv); virErrorPtr err = virGetLastError (); rv = Val_opt (err, (Val_ptr_t) Val_virterror); CAMLreturn (rv); } CAMLprim value ocaml_libvirt_virterror_get_last_conn_error (value connv) { CAMLparam1 (connv); CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); rv = Val_opt (conn, (Val_ptr_t) Val_connect); CAMLreturn (rv); } CAMLprim value ocaml_libvirt_virterror_reset_last_error (value unitv) { CAMLparam1 (unitv); virResetLastError (); CAMLreturn (Val_unit); } CAMLprim value ocaml_libvirt_virterror_reset_last_conn_error (value connv) { CAMLparam1 (connv); virConnectPtr conn = Connect_val (connv); virConnResetLastError (conn); CAMLreturn (Val_unit); } /*----------------------------------------------------------------------*/ static void ignore_errors (void *user_data, virErrorPtr error) { /* do nothing */ } /* Initialise the library. */ CAMLprim value ocaml_libvirt_init (value unit) { CAMLparam1 (unit); virSetErrorFunc (NULL, ignore_errors); virInitialize (); CAMLreturn (Val_unit); } virt-v2v-1.44.2/bundled/libvirt-ocaml/PaxHeaders/generator.pl0000644000000000000000000000013213631710510021060 xustar0030 mtime=1583845704.125871044 30 atime=1637862779.596973085 30 ctime=1637862790.584851351 virt-v2v-1.44.2/bundled/libvirt-ocaml/generator.pl0000775000175000017500000006222413631710510022677 0ustar00rjonesrjones00000000000000#!/usr/bin/env perl # # OCaml bindings for libvirt. # (C) Copyright 2007-2015 Richard W.M. Jones, Red Hat Inc. # https://libvirt.org/ # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version, # with the OCaml linking exception described in ../COPYING.LIB. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # This generates libvirt_generated.c (the core of the bindings). You don't # need to run this program unless you are extending the bindings # themselves (eg. because libvirt has been extended). # # Please read libvirt/README. use strict; use warnings; #---------------------------------------------------------------------- # The functions in the libvirt API that we can generate. # The 'sig' (signature) doesn't have a meaning or any internal structure. # It is interpreted by the generation functions below to indicate what # "class" the function falls into, and to generate the right class of # binding. my @functions = ( { name => "virConnectClose", sig => "conn : free" }, { name => "virConnectGetHostname", sig => "conn : string" }, { name => "virConnectGetURI", sig => "conn : string" }, { name => "virConnectGetType", sig => "conn : static string" }, { name => "virConnectNumOfDomains", sig => "conn : int" }, { name => "virConnectListDomains", sig => "conn, int : int array" }, { name => "virConnectNumOfDefinedDomains", sig => "conn : int" }, { name => "virConnectListDefinedDomains", sig => "conn, int : string array" }, { name => "virConnectNumOfNetworks", sig => "conn : int" }, { name => "virConnectListNetworks", sig => "conn, int : string array" }, { name => "virConnectNumOfDefinedNetworks", sig => "conn : int" }, { name => "virConnectListDefinedNetworks", sig => "conn, int : string array" }, { name => "virConnectNumOfStoragePools", sig => "conn : int" }, { name => "virConnectListStoragePools", sig => "conn, int : string array" }, { name => "virConnectNumOfDefinedStoragePools", sig => "conn : int" }, { name => "virConnectListDefinedStoragePools", sig => "conn, int : string array" }, { name => "virConnectNumOfSecrets", sig => "conn : int" }, { name => "virConnectListSecrets", sig => "conn, int : string array" }, { name => "virConnectGetCapabilities", sig => "conn : string" }, { name => "virConnectDomainEventDeregisterAny", sig => "conn, int : unit" }, { name => "virDomainCreateLinux", sig => "conn, string, 0U : dom" }, { name => "virDomainCreateXML", sig => "conn, string, unsigned : dom" }, { name => "virDomainFree", sig => "dom : free" }, { name => "virDomainDestroy", sig => "dom : free" }, { name => "virDomainLookupByName", sig => "conn, string : dom" }, { name => "virDomainLookupByID", sig => "conn, int : dom" }, { name => "virDomainLookupByUUID", sig => "conn, uuid : dom" }, { name => "virDomainLookupByUUIDString", sig => "conn, string : dom" }, { name => "virDomainGetName", sig => "dom : static string" }, { name => "virDomainGetOSType", sig => "dom : string" }, { name => "virDomainGetXMLDesc", sig => "dom, 0 : string" }, { name => "virDomainGetUUID", sig => "dom : uuid" }, { name => "virDomainGetUUIDString", sig => "dom : uuid string" }, { name => "virDomainGetMaxVcpus", sig => "dom : int" }, { name => "virDomainSave", sig => "dom, string : unit" }, { name => "virDomainRestore", sig => "conn, string : unit" }, { name => "virDomainCoreDump", sig => "dom, string, 0 : unit" }, { name => "virDomainSuspend", sig => "dom : unit" }, { name => "virDomainResume", sig => "dom : unit" }, { name => "virDomainShutdown", sig => "dom : unit" }, { name => "virDomainReboot", sig => "dom, 0 : unit" }, { name => "virDomainDefineXML", sig => "conn, string : dom" }, { name => "virDomainUndefine", sig => "dom : unit" }, { name => "virDomainCreate", sig => "dom : unit" }, { name => "virDomainAttachDevice", sig => "dom, string : unit" }, { name => "virDomainDetachDevice", sig => "dom, string : unit" }, { name => "virDomainGetAutostart", sig => "dom : bool" }, { name => "virDomainSetAutostart", sig => "dom, bool : unit" }, { name => "virNetworkFree", sig => "net : free" }, { name => "virNetworkDestroy", sig => "net : free" }, { name => "virNetworkLookupByName", sig => "conn, string : net" }, { name => "virNetworkLookupByUUID", sig => "conn, uuid : net" }, { name => "virNetworkLookupByUUIDString", sig => "conn, string : net" }, { name => "virNetworkGetName", sig => "net : static string" }, { name => "virNetworkGetXMLDesc", sig => "net, 0 : string" }, { name => "virNetworkGetBridgeName", sig => "net : string" }, { name => "virNetworkGetUUID", sig => "net : uuid" }, { name => "virNetworkGetUUIDString", sig => "net : uuid string" }, { name => "virNetworkUndefine", sig => "net : unit" }, { name => "virNetworkCreateXML", sig => "conn, string : net" }, { name => "virNetworkDefineXML", sig => "conn, string : net" }, { name => "virNetworkCreate", sig => "net : unit" }, { name => "virNetworkGetAutostart", sig => "net : bool" }, { name => "virNetworkSetAutostart", sig => "net, bool : unit" }, { name => "virStoragePoolFree", sig => "pool : free" }, { name => "virStoragePoolDestroy", sig => "pool : free" }, { name => "virStoragePoolLookupByName", sig => "conn, string : pool" }, { name => "virStoragePoolLookupByUUID", sig => "conn, uuid : pool" }, { name => "virStoragePoolLookupByUUIDString", sig => "conn, string : pool" }, { name => "virStoragePoolGetName", sig => "pool : static string" }, { name => "virStoragePoolGetXMLDesc", sig => "pool, 0U : string" }, { name => "virStoragePoolGetUUID", sig => "pool : uuid" }, { name => "virStoragePoolGetUUIDString", sig => "pool : uuid string" }, { name => "virStoragePoolCreateXML", sig => "conn, string, 0U : pool" }, { name => "virStoragePoolDefineXML", sig => "conn, string, 0U : pool" }, { name => "virStoragePoolBuild", sig => "pool, uint : unit" }, { name => "virStoragePoolUndefine", sig => "pool : unit" }, { name => "virStoragePoolCreate", sig => "pool, 0U : unit" }, { name => "virStoragePoolDelete", sig => "pool, uint : unit" }, { name => "virStoragePoolRefresh", sig => "pool, 0U : unit" }, { name => "virStoragePoolGetAutostart", sig => "pool : bool" }, { name => "virStoragePoolSetAutostart", sig => "pool, bool : unit" }, { name => "virStoragePoolNumOfVolumes", sig => "pool : int" }, { name => "virStoragePoolListVolumes", sig => "pool, int : string array" }, { name => "virStorageVolFree", sig => "vol : free" }, { name => "virStorageVolDelete", sig => "vol, uint : unit" }, { name => "virStorageVolLookupByName", sig => "pool, string : vol from pool" }, { name => "virStorageVolLookupByKey", sig => "conn, string : vol" }, { name => "virStorageVolLookupByPath", sig => "conn, string : vol" }, { name => "virStorageVolCreateXML", sig => "pool, string, 0U : vol from pool" }, { name => "virStorageVolGetXMLDesc", sig => "vol, 0U : string" }, { name => "virStorageVolGetPath", sig => "vol : string" }, { name => "virStorageVolGetKey", sig => "vol : static string" }, { name => "virStorageVolGetName", sig => "vol : static string" }, { name => "virStoragePoolLookupByVolume", sig => "vol : pool from vol" }, { name => "virSecretFree", sig => "sec : free" }, { name => "virSecretUndefine", sig => "sec : unit" }, { name => "virSecretLookupByUUID", sig => "conn, uuid : sec" }, { name => "virSecretLookupByUUIDString", sig => "conn, string : sec" }, { name => "virSecretDefineXML", sig => "conn, string, 0 : sec" }, { name => "virSecretGetUUID", sig => "sec : uuid" }, { name => "virSecretGetUUIDString", sig => "sec : uuid string" }, { name => "virSecretGetUsageType", sig => "sec : int" }, { name => "virSecretGetUsageID", sig => "sec : static string" }, { name => "virSecretGetXMLDesc", sig => "sec, 0 : string" }, ); # Functions we haven't implemented anywhere yet but which are mentioned # in 'libvirt.ml'. # # We create stubs for these, but eventually they need to either be # moved ^^^ so they are auto-generated, or implementations of them # written in 'libvirt_c_oneoffs.c'. my @unimplemented = ( ); #---------------------------------------------------------------------- # Open the output file. my $filename = "libvirt_generated.c"; open F, ">$filename" or die "$filename: $!"; # Write the prologue. print F <<'END'; /* !!! WARNING WARNING WARNING WARNING WARNING WARNING WARNING !!! * * THIS FILE IS AUTOMATICALLY GENERATED BY 'generator.pl'. * * Any changes you make to this file may be overwritten. */ /* OCaml bindings for libvirt. * (C) Copyright 2007-2015 Richard W.M. Jones, Red Hat Inc. * https://libvirt.org/ * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version, * with the OCaml linking exception described in ../COPYING.LIB. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "libvirt_c.h" #ifdef __GNUC__ #pragma GCC diagnostic ignored "-Wmissing-prototypes" #endif END #---------------------------------------------------------------------- sub camel_case_to_underscores { my $name = shift; $name =~ s/([A-Z][a-z]+|XML|URI|OS|UUID)/$1,/g; my @subs = split (/,/, $name); @subs = map { lc($_) } @subs; join "_", @subs } # Helper functions dealing with signatures. sub short_name_to_c_type { local $_ = shift; if ($_ eq "conn") { "virConnectPtr" } elsif ($_ eq "dom") { "virDomainPtr" } elsif ($_ eq "net") { "virNetworkPtr" } elsif ($_ eq "pool") { "virStoragePoolPtr" } elsif ($_ eq "vol") { "virStorageVolPtr" } elsif ($_ eq "sec") { "virSecretPtr" } else { die "unknown short name $_" } } # OCaml argument names. sub gen_arg_names { my $sig = shift; if ($sig =~ /^(\w+) : string$/) { ( "$1v" ) } elsif ($sig =~ /^(\w+) : static string$/) { ( "$1v" ) } elsif ($sig =~ /^(\w+) : int$/) { ( "$1v" ) } elsif ($sig =~ /^(\w+) : uuid$/) { ( "$1v" ) } elsif ($sig =~ /^(\w+) : uuid string$/) { ( "$1v" ) } elsif ($sig =~ /^(\w+) : bool$/) { ( "$1v" ) } elsif ($sig =~ /^(\w+), bool : unit$/) { ( "$1v", "bv" ) } elsif ($sig eq "conn, int : int array") { ( "connv", "iv" ) } elsif ($sig =~ /^(\w+), int : string array$/) { ( "$1v", "iv" ) } elsif ($sig =~ /^(\w+), 0U? : string$/) { ( "$1v" ) } elsif ($sig =~ /^(\w+), 0U? : unit$/) { ( "$1v" ) } elsif ($sig =~ /^(\w+) : unit$/) { ( "$1v" ) } elsif ($sig =~ /^(\w+) : free$/) { ( "$1v" ) } elsif ($sig =~ /^(\w+), string : unit$/) { ( "$1v", "strv" ) } elsif ($sig =~ /^(\w+), string, 0U? : unit$/) { ( "$1v", "strv" ) } elsif ($sig =~ /^(\w+), string : (\w+)$/) { ( "$1v", "strv" ) } elsif ($sig =~ /^(\w+), string, 0U? : (\w+)$/) { ( "$1v", "strv" ) } elsif ($sig =~ /^(\w+), string, unsigned : (\w+)$/) { ( "$1v", "strv", "uv" ) } elsif ($sig =~ /^(\w+), u?int : (\w+)$/) { ( "$1v", "iv" ) } elsif ($sig =~ /^(\w+), uuid : (\w+)$/) { ( "$1v", "uuidv" ) } elsif ($sig =~ /^(\w+), 0U? : (\w+)$/) { ( "$1v" ) } elsif ($sig =~ /^(\w+) : (\w+)$/) { ( "$1v" ) } elsif ($sig =~ /^(\w+), string : (\w+) from \w+$/) { ( "$1v", "strv" ) } elsif ($sig =~ /^(\w+), string, 0U? : (\w+) from \w+$/) { ( "$1v", "strv" ) } elsif ($sig =~ /^(\w+), 0U? : (\w+) from \w+$/) { ( "$1v" ) } elsif ($sig =~ /^(\w+) : (\w+) from \w+$/) { ( "$1v" ) } else { die "unknown signature $sig" } } # Unpack the first (object) argument. sub gen_unpack_args { local $_ = shift; if ($_ eq "conn") { "virConnectPtr conn = Connect_val (connv);" } elsif ($_ eq "dom") { "virDomainPtr dom = Domain_val (domv);" } elsif ($_ eq "net") { "virNetworkPtr net = Network_val (netv);" } elsif ($_ eq "pool") { "virStoragePoolPtr pool = Pool_val (poolv);" } elsif ($_ eq "vol") { "virStorageVolPtr vol = Volume_val (volv);" } elsif ($_ eq "sec") { "virSecretPtr sec = Secret_val (secv);" } else { die "unknown short name $_" } } # Pack the result if it's an object. sub gen_pack_result { local $_ = shift; if ($_ eq "dom") { "rv = Val_domain (r, connv);" } elsif ($_ eq "net") { "rv = Val_network (r, connv);" } elsif ($_ eq "pool") { "rv = Val_pool (r, connv);" } elsif ($_ eq "vol") { "rv = Val_volume (r, connv);" } elsif ($_ eq "sec") { "rv = Val_secret (r, connv);" } else { die "unknown short name $_" } } sub gen_free_arg { local $_ = shift; if ($_ eq "conn") { "Connect_val (connv) = NULL;" } elsif ($_ eq "dom") { "Domain_val (domv) = NULL;" } elsif ($_ eq "net") { "Network_val (netv) = NULL;" } elsif ($_ eq "pool") { "Pool_val (poolv) = NULL;" } elsif ($_ eq "vol") { "Volume_val (volv) = NULL;" } elsif ($_ eq "sec") { "Secret_val (secv) = NULL;" } else { die "unknown short name $_" } } # Generate the C body for each signature (class of function). sub gen_c_code { my $sig = shift; my $c_name = shift; if ($sig =~ /^(\w+) : string$/) { "\ CAMLlocal1 (rv); " . gen_unpack_args ($1) . " char *r; NONBLOCKING (r = $c_name ($1)); CHECK_ERROR (!r, \"$c_name\"); rv = caml_copy_string (r); free (r); CAMLreturn (rv); " } elsif ($sig =~ /^(\w+) : static string$/) { "\ CAMLlocal1 (rv); " . gen_unpack_args ($1) . " const char *r; NONBLOCKING (r = $c_name ($1)); CHECK_ERROR (!r, \"$c_name\"); rv = caml_copy_string (r); CAMLreturn (rv); " } elsif ($sig =~ /^(\w+) : int$/) { "\ " . gen_unpack_args ($1) . " int r; NONBLOCKING (r = $c_name ($1)); CHECK_ERROR (r == -1, \"$c_name\"); CAMLreturn (Val_int (r)); " } elsif ($sig =~ /^(\w+) : uuid$/) { "\ CAMLlocal1 (rv); " . gen_unpack_args ($1) . " unsigned char uuid[VIR_UUID_BUFLEN]; int r; NONBLOCKING (r = $c_name ($1, uuid)); CHECK_ERROR (r == -1, \"$c_name\"); /* UUIDs are byte arrays with a fixed length. */ rv = caml_alloc_string (VIR_UUID_BUFLEN); memcpy (Bytes_val (rv), uuid, VIR_UUID_BUFLEN); CAMLreturn (rv); " } elsif ($sig =~ /^(\w+) : uuid string$/) { "\ CAMLlocal1 (rv); " . gen_unpack_args ($1) . " char uuid[VIR_UUID_STRING_BUFLEN]; int r; NONBLOCKING (r = $c_name ($1, uuid)); CHECK_ERROR (r == -1, \"$c_name\"); rv = caml_copy_string (uuid); CAMLreturn (rv); " } elsif ($sig =~ /^(\w+) : bool$/) { "\ " . gen_unpack_args ($1) . " int r, b; NONBLOCKING (r = $c_name ($1, &b)); CHECK_ERROR (r == -1, \"$c_name\"); CAMLreturn (b ? Val_true : Val_false); " } elsif ($sig =~ /^(\w+), bool : unit$/) { "\ " . gen_unpack_args ($1) . " int r, b; b = bv == Val_true ? 1 : 0; NONBLOCKING (r = $c_name ($1, b)); CHECK_ERROR (r == -1, \"$c_name\"); CAMLreturn (Val_unit); " } elsif ($sig eq "conn, int : int array") { "\ CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); int i = Int_val (iv); int *ids, r; /* Some libvirt List* functions still throw exceptions if i == 0, * so catch that and return an empty array directly. This changes * the semantics slightly (masking other failures) but it's * unlikely anyone will care. RWMJ 2008/06/10 */ if (i == 0) { rv = caml_alloc (0, 0); CAMLreturn (rv); } ids = malloc (sizeof (*ids) * i); if (ids == NULL) caml_raise_out_of_memory (); NONBLOCKING (r = $c_name (conn, ids, i)); CHECK_ERROR_CLEANUP (r == -1, free (ids), \"$c_name\"); rv = caml_alloc (r, 0); for (i = 0; i < r; ++i) Store_field (rv, i, Val_int (ids[i])); free (ids); CAMLreturn (rv); " } elsif ($sig =~ /^(\w+), int : string array$/) { "\ CAMLlocal2 (rv, strv); " . gen_unpack_args ($1) . " int i = Int_val (iv); char **names; int r; /* Some libvirt List* functions still throw exceptions if i == 0, * so catch that and return an empty array directly. This changes * the semantics slightly (masking other failures) but it's * unlikely anyone will care. RWMJ 2008/06/10 */ if (i == 0) { rv = caml_alloc (0, 0); CAMLreturn (rv); } names = malloc (sizeof (*names) * i); if (names == NULL) caml_raise_out_of_memory (); NONBLOCKING (r = $c_name ($1, names, i)); CHECK_ERROR_CLEANUP (r == -1, free (names), \"$c_name\"); rv = caml_alloc (r, 0); for (i = 0; i < r; ++i) { strv = caml_copy_string (names[i]); Store_field (rv, i, strv); free (names[i]); } free (names); CAMLreturn (rv); " } elsif ($sig =~ /^(\w+), 0U? : string$/) { "\ CAMLlocal1 (rv); " . gen_unpack_args ($1) . " char *r; NONBLOCKING (r = $c_name ($1, 0)); CHECK_ERROR (!r, \"$c_name\"); rv = caml_copy_string (r); free (r); CAMLreturn (rv); " } elsif ($sig =~ /^(\w+), 0U? : unit$/) { "\ " . gen_unpack_args ($1) . " int r; NONBLOCKING (r = $c_name ($1, 0)); CHECK_ERROR (r == -1, \"$c_name\"); CAMLreturn (Val_unit); " } elsif ($sig =~ /^(\w+) : unit$/) { "\ " . gen_unpack_args ($1) . " int r; NONBLOCKING (r = $c_name ($1)); CHECK_ERROR (r == -1, \"$c_name\"); CAMLreturn (Val_unit); " } elsif ($sig =~ /^(\w+) : free$/) { "\ " . gen_unpack_args ($1) . " int r; NONBLOCKING (r = $c_name ($1)); CHECK_ERROR (r == -1, \"$c_name\"); /* So that we don't double-free in the finalizer: */ " . gen_free_arg ($1) . " CAMLreturn (Val_unit); " } elsif ($sig =~ /^(\w+), string : unit$/) { "\ " . gen_unpack_args ($1) . " const char *str = String_val (strv); int r; NONBLOCKING (r = $c_name ($1, str)); CHECK_ERROR (r == -1, \"$c_name\"); CAMLreturn (Val_unit); " } elsif ($sig =~ /^(\w+), string, 0U? : unit$/) { "\ CAMLlocal1 (rv); " . gen_unpack_args ($1) . " const char *str = String_val (strv); int r; NONBLOCKING (r = $c_name ($1, str, 0)); CHECK_ERROR (!r, \"$c_name\"); CAMLreturn (Val_unit); " } elsif ($sig =~ /^(\w+), string : (\w+)$/) { my $c_ret_type = short_name_to_c_type ($2); "\ CAMLlocal1 (rv); " . gen_unpack_args ($1) . " const char *str = String_val (strv); $c_ret_type r; NONBLOCKING (r = $c_name ($1, str)); CHECK_ERROR (!r, \"$c_name\"); " . gen_pack_result ($2) . " CAMLreturn (rv); " } elsif ($sig =~ /^(\w+), string, 0U? : (\w+)$/) { my $c_ret_type = short_name_to_c_type ($2); "\ CAMLlocal1 (rv); " . gen_unpack_args ($1) . " const char *str = String_val (strv); $c_ret_type r; NONBLOCKING (r = $c_name ($1, str, 0)); CHECK_ERROR (!r, \"$c_name\"); " . gen_pack_result ($2) . " CAMLreturn (rv); " } elsif ($sig =~ /^(\w+), string, unsigned : (\w+)$/) { my $c_ret_type = short_name_to_c_type ($2); "\ CAMLlocal1 (rv); " . gen_unpack_args ($1) . " const char *str = String_val (strv); unsigned int u = Int_val (uv); $c_ret_type r; NONBLOCKING (r = $c_name ($1, str, u)); CHECK_ERROR (!r, \"$c_name\"); " . gen_pack_result ($2) . " CAMLreturn (rv); " } elsif ($sig =~ /^(\w+), (u?)int : unit$/) { my $unsigned = $2 eq "u" ? "unsigned " : ""; "\ " . gen_unpack_args ($1) . " ${unsigned}int i = Int_val (iv); int r; NONBLOCKING (r = $c_name ($1, i)); CHECK_ERROR (r == -1, \"$c_name\"); CAMLreturn (Val_unit); " } elsif ($sig =~ /^(\w+), (u?)int : (\w+)$/) { my $c_ret_type = short_name_to_c_type ($3); my $unsigned = $2 eq "u" ? "unsigned " : ""; "\ CAMLlocal1 (rv); " . gen_unpack_args ($1) . " ${unsigned}int i = Int_val (iv); $c_ret_type r; NONBLOCKING (r = $c_name ($1, i)); CHECK_ERROR (!r, \"$c_name\"); " . gen_pack_result ($3) . " CAMLreturn (rv); " } elsif ($sig =~ /^(\w+), uuid : (\w+)$/) { my $c_ret_type = short_name_to_c_type ($2); "\ CAMLlocal1 (rv); " . gen_unpack_args ($1) . " unsigned char *uuid = (unsigned char *) String_val (uuidv); $c_ret_type r; NONBLOCKING (r = $c_name ($1, uuid)); CHECK_ERROR (!r, \"$c_name\"); " . gen_pack_result ($2) . " CAMLreturn (rv); " } elsif ($sig =~ /^(\w+), 0U? : (\w+)$/) { my $c_ret_type = short_name_to_c_type ($2); "\ CAMLlocal1 (rv); " . gen_unpack_args ($1) . " $c_ret_type r; NONBLOCKING (r = $c_name ($1, 0)); CHECK_ERROR (!r, \"$c_name\"); " . gen_pack_result ($2) . " CAMLreturn (rv); " } elsif ($sig =~ /^(\w+) : (\w+)$/) { my $c_ret_type = short_name_to_c_type ($2); "\ CAMLlocal1 (rv); " . gen_unpack_args ($1) . " $c_ret_type r; NONBLOCKING (r = $c_name ($1)); CHECK_ERROR (!r, \"$c_name\"); " . gen_pack_result ($2) . " CAMLreturn (rv); " } elsif ($sig =~ /^(\w+), string : (\w+) from (\w+)$/) { my $c_ret_type = short_name_to_c_type ($2); "\ CAMLlocal2 (rv, connv); " . gen_unpack_args ($1) . " const char *str = String_val (strv); $c_ret_type r; NONBLOCKING (r = $c_name ($1, str)); CHECK_ERROR (!r, \"$c_name\"); connv = Field ($3v, 1); " . gen_pack_result ($2) . " CAMLreturn (rv); " } elsif ($sig =~ /^(\w+), string, 0U? : (\w+) from (\w+)$/) { my $c_ret_type = short_name_to_c_type ($2); "\ CAMLlocal2 (rv, connv); " . gen_unpack_args ($1) . " const char *str = String_val (strv); $c_ret_type r; NONBLOCKING (r = $c_name ($1, str, 0)); CHECK_ERROR (!r, \"$c_name\"); connv = Field ($3v, 1); " . gen_pack_result ($2) . " CAMLreturn (rv); " } elsif ($sig =~ /^(\w+), 0U? : (\w+) from (\w+)$/) { my $c_ret_type = short_name_to_c_type ($2); "\ CAMLlocal2 (rv, connv); " . gen_unpack_args ($1) . " $c_ret_type r; NONBLOCKING (r = $c_name ($1, 0)); CHECK_ERROR (!r, \"$c_name\"); connv = Field ($3v, 1); " . gen_pack_result ($2) . " CAMLreturn (rv); " } elsif ($sig =~ /^(\w+) : (\w+) from (\w+)$/) { my $c_ret_type = short_name_to_c_type ($2); "\ CAMLlocal2 (rv, connv); " . gen_unpack_args ($1) . " $c_ret_type r; NONBLOCKING (r = $c_name ($1)); CHECK_ERROR (!r, \"$c_name\"); connv = Field ($3v, 1); " . gen_pack_result ($2) . " CAMLreturn (rv); " } else { die "unknown signature $sig" } } # Generate each function. foreach my $function (@functions) { my $c_name = $function->{name}; my $sig = $function->{sig}; #print "generating $c_name with sig \"$sig\" ...\n"; #my $is_pool_func = $c_name =~ /^virStoragePool/; #my $is_vol_func = $c_name =~ /^virStorageVol/; # Generate an equivalent C-external name for the function, unless # one is defined already. my $c_external_name; if (exists ($function->{c_external_name})) { $c_external_name = $function->{c_external_name}; } elsif ($c_name =~ /^vir/) { $c_external_name = substr $c_name, 3; $c_external_name = camel_case_to_underscores ($c_external_name); $c_external_name = "ocaml_libvirt_" . $c_external_name; } else { die "cannot convert c_name $c_name to c_external_name" } print F < #include #include #include #include #include #include #include #include #include #include #include #include #include /* Please read libvirt/README file. */ /* Make sure to not expose our internal helpers as public symbols. * https://gcc.gnu.org/wiki/Visibility */ #ifdef __GNUC__ #pragma GCC visibility push(hidden) #endif /* Bytes_val was added in OCaml 4.06. In earlier versions we can * simply cast String_val to the expected type. */ #ifndef Bytes_val #define Bytes_val(x) ((unsigned char *)String_val(x)) #endif const char *Optstring_val (value strv); typedef value (*Val_ptr_t) (void *); value Val_opt (void *ptr, Val_ptr_t Val_ptr); typedef value (*Val_const_ptr_t) (const void *); value Val_opt_const (const void *ptr, Val_const_ptr_t Val_ptr); /*value option_default (value option, value deflt);*/ void _raise_virterror (const char *fn) Noreturn; value Val_virterror (virErrorPtr err); int _list_length (value listv); value Val_virconnectcredential (const virConnectCredentialPtr cred); /* Use this around synchronous libvirt API calls to release the OCaml * lock, allowing other threads to run simultaneously. 'code' must not * perform any caml_* calls, run any OCaml code, or raise any exception. * https://web.archive.org/web/20030521020915/http://caml.inria.fr/archives/200106/msg00199.html */ #define NONBLOCKING(code) \ do { \ caml_enter_blocking_section (); \ code; \ caml_leave_blocking_section (); \ } while (0) /* Empty macro to use as empty parameter for other macros, since * a null token as parameter when calling a macro is not allowed * before C99. */ #define EMPTY /* Check error condition from a libvirt function, and automatically raise * an exception if one is found. */ #define CHECK_ERROR_CLEANUP(cond, cleanup, fn) \ do { if (cond) { cleanup; _raise_virterror (fn); } } while (0) #define CHECK_ERROR(cond, fn) \ CHECK_ERROR_CLEANUP(cond, EMPTY, fn) /*----------------------------------------------------------------------*/ /* Some notes about the use of custom blocks to store virConnectPtr, * virDomainPtr and virNetworkPtr. *------------------------------------------------------------------ * * Libvirt does some tricky reference counting to keep track of * virConnectPtr's, virDomainPtr's and virNetworkPtr's. * * There is only one function which can return a virConnectPtr * (virConnectOpen*) and that allocates a new one each time. * * virDomainPtr/virNetworkPtr's on the other hand can be returned * repeatedly (for the same underlying domain/network), and we must * keep track of each one and explicitly free it with virDomainFree * or virNetworkFree. If we lose track of one then the reference * counting in libvirt will keep it open. We therefore wrap these * in a custom block with a finalizer function. * * We also have to allow the user to explicitly free them, in * which case we set the pointer inside the custom block to NULL. * The finalizer notices this and doesn't free the object. * * Domains and networks "belong to" a connection. We have to avoid * the situation like this: * * let conn = Connect.open ... in * let dom = Domain.lookup_by_id conn 0 in * (* conn goes out of scope and is garbage collected *) * printf "dom name = %s\n" (Domain.get_name dom) * * The reason is that when conn is garbage collected, virConnectClose * is called and any subsequent operations on dom will fail (in fact * will probably segfault). To stop this from happening, the OCaml * wrappers store domains (and networks) as explicit (dom, conn) * pairs. * * Update 2008/01: Storage pools and volumes work the same way as * domains and networks. */ /* Unwrap a custom block. */ #define Connect_val(rv) (*((virConnectPtr *)Data_custom_val(rv))) #define Dom_val(rv) (*((virDomainPtr *)Data_custom_val(rv))) #define Net_val(rv) (*((virNetworkPtr *)Data_custom_val(rv))) #define Pol_val(rv) (*((virStoragePoolPtr *)Data_custom_val(rv))) #define Vol_val(rv) (*((virStorageVolPtr *)Data_custom_val(rv))) #define Sec_val(rv) (*((virSecretPtr *)Data_custom_val(rv))) /* Wrap up a pointer to something in a custom block. */ value Val_connect (virConnectPtr conn); value Val_dom (virDomainPtr dom); value Val_net (virNetworkPtr net); value Val_pol (virStoragePoolPtr pool); value Val_vol (virStorageVolPtr vol); value Val_sec (virSecretPtr sec); /* Domains and networks are stored as pairs (dom/net, conn), so have * some convenience functions for unwrapping and wrapping them. */ #define Domain_val(rv) (Dom_val(Field((rv),0))) #define Network_val(rv) (Net_val(Field((rv),0))) #define Pool_val(rv) (Pol_val(Field((rv),0))) #define Volume_val(rv) (Vol_val(Field((rv),0))) #define Secret_val(rv) (Sec_val(Field((rv),0))) #define Connect_domv(rv) (Connect_val(Field((rv),1))) #define Connect_netv(rv) (Connect_val(Field((rv),1))) #define Connect_polv(rv) (Connect_val(Field((rv),1))) #define Connect_volv(rv) (Connect_val(Field((rv),1))) #define Connect_secv(rv) (Connect_val(Field((rv),1))) value Val_domain (virDomainPtr dom, value connv); value Val_network (virNetworkPtr net, value connv); value Val_pool (virStoragePoolPtr pol, value connv); value Val_volume (virStorageVolPtr vol, value connv); value Val_secret (virSecretPtr sec, value connv); #ifdef __GNUC__ #pragma GCC visibility pop #endif #endif virt-v2v-1.44.2/bundled/libvirt-ocaml/PaxHeaders/Makefile.in0000644000000000000000000000013114147746514020621 xustar0029 mtime=1637862732.91949022 30 atime=1637862737.535439081 30 ctime=1637862790.567851539 virt-v2v-1.44.2/bundled/libvirt-ocaml/Makefile.in0000644000175000017500000011075314147746514022435 0ustar00rjonesrjones00000000000000# Makefile.in generated by automake 1.16.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # libguestfs OCaml tools common code # Copyright (C) 2018 Red Hat Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # libguestfs # Copyright (C) 2009-2020 Red Hat Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # subdir-rules.mk should be included in every *subdirectory* Makefile.am. # libguestfs # Copyright (C) 2013 Red Hat Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # 'common-rules.mk' should be included in every Makefile.am. # cf. 'subdir-rules.mk' VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = bundled/libvirt-ocaml ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/guestfs-ocaml-gettext.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/ocaml.m4 \ $(top_srcdir)/m4/guestfs-progs.m4 \ $(top_srcdir)/m4/guestfs-c.m4 \ $(top_srcdir)/m4/guestfs-libraries.m4 \ $(top_srcdir)/m4/guestfs-ocaml.m4 \ $(top_srcdir)/m4/guestfs-perl.m4 \ $(top_srcdir)/m4/guestfs-v2v.m4 \ $(top_srcdir)/m4/guestfs-bash-completion.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LIBRARIES = $(noinst_LIBRARIES) ARFLAGS = cru AM_V_AR = $(am__v_AR_@AM_V@) am__v_AR_ = $(am__v_AR_@AM_DEFAULT_V@) am__v_AR_0 = @echo " AR " $@; am__v_AR_1 = libmllibvirt_a_AR = $(AR) $(ARFLAGS) libmllibvirt_a_LIBADD = am__objects_1 = libmllibvirt_a-libvirt_c_common.$(OBJEXT) \ libmllibvirt_a-libvirt_generated.$(OBJEXT) \ libmllibvirt_a-libvirt_c_oneoffs.$(OBJEXT) am_libmllibvirt_a_OBJECTS = $(am__objects_1) libmllibvirt_a_OBJECTS = $(am_libmllibvirt_a_OBJECTS) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp am__maybe_remake_depfiles = depfiles am__depfiles_remade = ./$(DEPDIR)/libmllibvirt_a-libvirt_c_common.Po \ ./$(DEPDIR)/libmllibvirt_a-libvirt_c_oneoffs.Po \ ./$(DEPDIR)/libmllibvirt_a-libvirt_generated.Po am__mv = mv -f AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libmllibvirt_a_SOURCES) DIST_SOURCES = $(libmllibvirt_a_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac DATA = $(noinst_DATA) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in \ $(top_srcdir)/build-aux/depcomp $(top_srcdir)/common-rules.mk \ $(top_srcdir)/subdir-rules.mk DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BASH_COMPLETIONS_DIR = @BASH_COMPLETIONS_DIR@ BASH_COMPLETION_CFLAGS = @BASH_COMPLETION_CFLAGS@ BASH_COMPLETION_LIBS = @BASH_COMPLETION_LIBS@ BRANCH_NUMBER = @BRANCH_NUMBER@ BRANCH_TYPE = @BRANCH_TYPE@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ GMSGFMT = @GMSGFMT@ GMSGFMT_015 = @GMSGFMT_015@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INTLLIBS = @INTLLIBS@ INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ JANSSON_CFLAGS = @JANSSON_CFLAGS@ JANSSON_LIBS = @JANSSON_LIBS@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBGUESTFS_CFLAGS = @LIBGUESTFS_CFLAGS@ LIBGUESTFS_LIBS = @LIBGUESTFS_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBOBJS = @LIBOBJS@ LIBOSINFO_CFLAGS = @LIBOSINFO_CFLAGS@ LIBOSINFO_LIBS = @LIBOSINFO_LIBS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIBVIRT_CFLAGS = @LIBVIRT_CFLAGS@ LIBVIRT_LIBS = @LIBVIRT_LIBS@ LIBXML2_CFLAGS = @LIBXML2_CFLAGS@ LIBXML2_LIBS = @LIBXML2_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBICONV = @LTLIBICONV@ LTLIBINTL = @LTLIBINTL@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ MKISOFS = @MKISOFS@ MSGCAT = @MSGCAT@ MSGFMT = @MSGFMT@ MSGMERGE = @MSGMERGE@ MSGMERGE_FOR_MSGFMT_OPTION = @MSGMERGE_FOR_MSGFMT_OPTION@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OCAMLBEST = @OCAMLBEST@ OCAMLBUILD = @OCAMLBUILD@ OCAMLC = @OCAMLC@ OCAMLCDOTOPT = @OCAMLCDOTOPT@ OCAMLDEP = @OCAMLDEP@ OCAMLDEP_ALL = @OCAMLDEP_ALL@ OCAMLDEP_ONE_LINE = @OCAMLDEP_ONE_LINE@ OCAMLDOC = @OCAMLDOC@ OCAMLFIND = @OCAMLFIND@ OCAMLLIB = @OCAMLLIB@ OCAMLMKLIB = @OCAMLMKLIB@ OCAMLMKTOP = @OCAMLMKTOP@ OCAMLOPT = @OCAMLOPT@ OCAMLOPTDOTOPT = @OCAMLOPTDOTOPT@ OCAMLVERSION = @OCAMLVERSION@ OCAML_FLAGS = @OCAML_FLAGS@ OCAML_GETTEXT = @OCAML_GETTEXT@ OCAML_PKG_gettext = @OCAML_PKG_gettext@ OCAML_PKG_guestfs = @OCAML_PKG_guestfs@ OCAML_PKG_ounit2 = @OCAML_PKG_ounit2@ OCAML_RUNTIME_VARIANT_PIC_OPTION = @OCAML_RUNTIME_VARIANT_PIC_OPTION@ OCAML_WARN_ERROR = @OCAML_WARN_ERROR@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PACKAGE_VERSION_FULL = @PACKAGE_VERSION_FULL@ PATH_SEPARATOR = @PATH_SEPARATOR@ PCRE2_CFLAGS = @PCRE2_CFLAGS@ PCRE2_CONFIG = @PCRE2_CONFIG@ PCRE2_LIBS = @PCRE2_LIBS@ PERL = @PERL@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PO4A_GETTEXTIZE = @PO4A_GETTEXTIZE@ PO4A_TRANSLATE = @PO4A_TRANSLATE@ PODWRAPPER = @PODWRAPPER@ POSUB = @POSUB@ PYCODESTYLE = @PYCODESTYLE@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SQLITE3 = @SQLITE3@ STRIP = @STRIP@ UNZIP = @UNZIP@ USE_NLS = @USE_NLS@ VALGRIND = @VALGRIND@ VERSION = @VERSION@ VIRT_V2V_NBDKIT_PYTHON_PLUGIN = @VIRT_V2V_NBDKIT_PYTHON_PLUGIN@ WARN_CFLAGS = @WARN_CFLAGS@ WERROR_CFLAGS = @WERROR_CFLAGS@ XGETTEXT = @XGETTEXT@ XGETTEXT_015 = @XGETTEXT_015@ XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ ZIP = @ZIP@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ libvirt_ro_uri = @libvirt_ro_uri@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ ounit_is_v2 = @ounit_is_v2@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # Files that should universally be removed by 'make clean'. Note if # there is any case in any subdirectory where a file should not be # removed by 'make clean', it should not be listed here! # Editor backup files # Patch original and reject files. # OCaml intermediate and generated files. # OCaml -annot files (used for displaying types in some IDEs). # OCaml oUnit generated files. # Manual pages - these are all generated from *.pod, so the # pages themselves should all be removed by 'make clean'. # Stamp files used when generating man pages. # Bindtests temporary files used in many language bindings. CLEANFILES = *~ *.bak *.orig *.rej *.cmi *.cmo *.cma *.cmx *.cmxa \ dll*.so *.a *.annot oUnit-*.cache oUnit-*.log *.1 *.3 *.5 *.8 \ stamp-*.pod bindtests.tmp libvirt_generated.c # Files that should be universally removed by 'make distclean'. DISTCLEANFILES = .depend stamp-* # Special suffixes used by OCaml. # Special suffixes used by PO files. SUFFIXES = .cmo .cmi .cmx .ml .mli .mll .mly .po .gmo # Rules for building OCaml objects. # See also: # guestfs-hacking(1) section "HOW OCAML PROGRAMS ARE COMPILED AND LINKED" @HAVE_OCAMLOPT_FALSE@MLARCHIVE = cma @HAVE_OCAMLOPT_TRUE@MLARCHIVE = cmxa @HAVE_OCAMLOPT_FALSE@LINK_CUSTOM_OCAMLC_ONLY = -custom @HAVE_OCAMLOPT_FALSE@BEST = c @HAVE_OCAMLOPT_TRUE@BEST = opt # custom silent rules guestfs_am_v_ocamlc = $(guestfs_am_v_ocamlc_@AM_V@) guestfs_am_v_ocamlc_ = $(guestfs_am_v_ocamlc_@AM_DEFAULT_V@) guestfs_am_v_ocamlc_0 = @echo " OCAMLC " $@; guestfs_am_v_ocamlcmi = $(guestfs_am_v_ocamlcmi_@AM_V@) guestfs_am_v_ocamlcmi_ = $(guestfs_am_v_ocamlcmi_@AM_DEFAULT_V@) guestfs_am_v_ocamlcmi_0 = @echo " OCAMLCMI" $@; guestfs_am_v_ocamlopt = $(guestfs_am_v_ocamlopt_@AM_V@) guestfs_am_v_ocamlopt_ = $(guestfs_am_v_ocamlopt_@AM_DEFAULT_V@) guestfs_am_v_ocamlopt_0 = @echo " OCAMLOPT" $@; guestfs_am_v_javac = $(guestfs_am_v_javac_@AM_V@) guestfs_am_v_javac_ = $(guestfs_am_v_javac_@AM_DEFAULT_V@) guestfs_am_v_javac_0 = @echo " JAVAC " $@; guestfs_am_v_erlc = $(guestfs_am_v_erlc_@AM_V@) guestfs_am_v_erlc_ = $(guestfs_am_v_erlc_@AM_DEFAULT_V@) guestfs_am_v_erlc_0 = @echo " ERLC " $@; guestfs_am_v_podwrapper = $(guestfs_am_v_podwrapper_@AM_V@) guestfs_am_v_podwrapper_ = $(guestfs_am_v_podwrapper_@AM_DEFAULT_V@) guestfs_am_v_podwrapper_0 = @echo " POD " $@; guestfs_am_v_jar = $(guestfs_am_v_jar_@AM_V@) guestfs_am_v_jar_ = $(guestfs_am_v_jar_@AM_DEFAULT_V@) guestfs_am_v_jar_0 = @echo " JAR " $@; guestfs_am_v_po4a_translate = $(guestfs_am_v_po4a_translate_@AM_V@) guestfs_am_v_po4a_translate_ = $(guestfs_am_v_po4a_translate_@AM_DEFAULT_V@) guestfs_am_v_po4a_translate_0 = @echo " PO4A-T " $@; EXTRA_DIST = \ $(SOURCES_MLI) \ $(SOURCES_ML) \ generator.pl \ libvirt.README SOURCES_MLI = \ libvirt.mli SOURCES_ML = \ libvirt.ml SOURCES_C = \ libvirt_c.h \ libvirt_c_common.c \ libvirt_generated.c \ libvirt_c_oneoffs.c # We pretend that we're building a C library. automake handles the # compilation of the C sources for us. At the end we take the C # objects and OCaml objects and link them into the OCaml library. # This C library is never used. noinst_LIBRARIES = libmllibvirt.a @HAVE_OCAMLOPT_FALSE@MLLIBVIRT_CMA = mllibvirt.cma @HAVE_OCAMLOPT_TRUE@MLLIBVIRT_CMA = mllibvirt.cmxa noinst_DATA = $(MLLIBVIRT_CMA) libmllibvirt_a_SOURCES = $(SOURCES_C) libmllibvirt_a_CPPFLAGS = \ -DCAML_NAME_SPACE \ -I. \ -I$(top_builddir) \ -I$(shell $(OCAMLC) -where) libmllibvirt_a_CFLAGS = \ $(WARN_CFLAGS) $(WERROR_CFLAGS) \ $(LIBVIRT_CFLAGS) \ -fPIC BOBJECTS = $(SOURCES_ML:.ml=.cmo) XOBJECTS = $(BOBJECTS:.cmo=.cmx) OCAMLPACKAGES = OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR) @HAVE_OCAMLOPT_FALSE@OBJECTS = $(BOBJECTS) @HAVE_OCAMLOPT_TRUE@OBJECTS = $(XOBJECTS) libmllibvirt_a_DEPENDENCIES = $(OBJECTS) all: all-am .SUFFIXES: .SUFFIXES: .cmo .cmi .cmx .ml .mli .mll .mly .po .gmo .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/subdir-rules.mk $(top_srcdir)/common-rules.mk $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign bundled/libvirt-ocaml/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign bundled/libvirt-ocaml/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_srcdir)/subdir-rules.mk $(top_srcdir)/common-rules.mk $(am__empty): $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstLIBRARIES: -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) libmllibvirt.a: $(libmllibvirt_a_OBJECTS) $(libmllibvirt_a_DEPENDENCIES) $(EXTRA_libmllibvirt_a_DEPENDENCIES) $(AM_V_at)-rm -f libmllibvirt.a $(AM_V_AR)$(libmllibvirt_a_AR) libmllibvirt.a $(libmllibvirt_a_OBJECTS) $(libmllibvirt_a_LIBADD) $(AM_V_at)$(RANLIB) libmllibvirt.a mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmllibvirt_a-libvirt_c_common.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmllibvirt_a-libvirt_c_oneoffs.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmllibvirt_a-libvirt_generated.Po@am__quote@ # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) @echo '# dummy' >$@-t && $(am__mv) $@-t $@ am--depfiles: $(am__depfiles_remade) .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< libmllibvirt_a-libvirt_c_common.o: libvirt_c_common.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmllibvirt_a_CPPFLAGS) $(CPPFLAGS) $(libmllibvirt_a_CFLAGS) $(CFLAGS) -MT libmllibvirt_a-libvirt_c_common.o -MD -MP -MF $(DEPDIR)/libmllibvirt_a-libvirt_c_common.Tpo -c -o libmllibvirt_a-libvirt_c_common.o `test -f 'libvirt_c_common.c' || echo '$(srcdir)/'`libvirt_c_common.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmllibvirt_a-libvirt_c_common.Tpo $(DEPDIR)/libmllibvirt_a-libvirt_c_common.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='libvirt_c_common.c' object='libmllibvirt_a-libvirt_c_common.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmllibvirt_a_CPPFLAGS) $(CPPFLAGS) $(libmllibvirt_a_CFLAGS) $(CFLAGS) -c -o libmllibvirt_a-libvirt_c_common.o `test -f 'libvirt_c_common.c' || echo '$(srcdir)/'`libvirt_c_common.c libmllibvirt_a-libvirt_c_common.obj: libvirt_c_common.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmllibvirt_a_CPPFLAGS) $(CPPFLAGS) $(libmllibvirt_a_CFLAGS) $(CFLAGS) -MT libmllibvirt_a-libvirt_c_common.obj -MD -MP -MF $(DEPDIR)/libmllibvirt_a-libvirt_c_common.Tpo -c -o libmllibvirt_a-libvirt_c_common.obj `if test -f 'libvirt_c_common.c'; then $(CYGPATH_W) 'libvirt_c_common.c'; else $(CYGPATH_W) '$(srcdir)/libvirt_c_common.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmllibvirt_a-libvirt_c_common.Tpo $(DEPDIR)/libmllibvirt_a-libvirt_c_common.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='libvirt_c_common.c' object='libmllibvirt_a-libvirt_c_common.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmllibvirt_a_CPPFLAGS) $(CPPFLAGS) $(libmllibvirt_a_CFLAGS) $(CFLAGS) -c -o libmllibvirt_a-libvirt_c_common.obj `if test -f 'libvirt_c_common.c'; then $(CYGPATH_W) 'libvirt_c_common.c'; else $(CYGPATH_W) '$(srcdir)/libvirt_c_common.c'; fi` libmllibvirt_a-libvirt_generated.o: libvirt_generated.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmllibvirt_a_CPPFLAGS) $(CPPFLAGS) $(libmllibvirt_a_CFLAGS) $(CFLAGS) -MT libmllibvirt_a-libvirt_generated.o -MD -MP -MF $(DEPDIR)/libmllibvirt_a-libvirt_generated.Tpo -c -o libmllibvirt_a-libvirt_generated.o `test -f 'libvirt_generated.c' || echo '$(srcdir)/'`libvirt_generated.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmllibvirt_a-libvirt_generated.Tpo $(DEPDIR)/libmllibvirt_a-libvirt_generated.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='libvirt_generated.c' object='libmllibvirt_a-libvirt_generated.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmllibvirt_a_CPPFLAGS) $(CPPFLAGS) $(libmllibvirt_a_CFLAGS) $(CFLAGS) -c -o libmllibvirt_a-libvirt_generated.o `test -f 'libvirt_generated.c' || echo '$(srcdir)/'`libvirt_generated.c libmllibvirt_a-libvirt_generated.obj: libvirt_generated.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmllibvirt_a_CPPFLAGS) $(CPPFLAGS) $(libmllibvirt_a_CFLAGS) $(CFLAGS) -MT libmllibvirt_a-libvirt_generated.obj -MD -MP -MF $(DEPDIR)/libmllibvirt_a-libvirt_generated.Tpo -c -o libmllibvirt_a-libvirt_generated.obj `if test -f 'libvirt_generated.c'; then $(CYGPATH_W) 'libvirt_generated.c'; else $(CYGPATH_W) '$(srcdir)/libvirt_generated.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmllibvirt_a-libvirt_generated.Tpo $(DEPDIR)/libmllibvirt_a-libvirt_generated.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='libvirt_generated.c' object='libmllibvirt_a-libvirt_generated.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmllibvirt_a_CPPFLAGS) $(CPPFLAGS) $(libmllibvirt_a_CFLAGS) $(CFLAGS) -c -o libmllibvirt_a-libvirt_generated.obj `if test -f 'libvirt_generated.c'; then $(CYGPATH_W) 'libvirt_generated.c'; else $(CYGPATH_W) '$(srcdir)/libvirt_generated.c'; fi` libmllibvirt_a-libvirt_c_oneoffs.o: libvirt_c_oneoffs.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmllibvirt_a_CPPFLAGS) $(CPPFLAGS) $(libmllibvirt_a_CFLAGS) $(CFLAGS) -MT libmllibvirt_a-libvirt_c_oneoffs.o -MD -MP -MF $(DEPDIR)/libmllibvirt_a-libvirt_c_oneoffs.Tpo -c -o libmllibvirt_a-libvirt_c_oneoffs.o `test -f 'libvirt_c_oneoffs.c' || echo '$(srcdir)/'`libvirt_c_oneoffs.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmllibvirt_a-libvirt_c_oneoffs.Tpo $(DEPDIR)/libmllibvirt_a-libvirt_c_oneoffs.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='libvirt_c_oneoffs.c' object='libmllibvirt_a-libvirt_c_oneoffs.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmllibvirt_a_CPPFLAGS) $(CPPFLAGS) $(libmllibvirt_a_CFLAGS) $(CFLAGS) -c -o libmllibvirt_a-libvirt_c_oneoffs.o `test -f 'libvirt_c_oneoffs.c' || echo '$(srcdir)/'`libvirt_c_oneoffs.c libmllibvirt_a-libvirt_c_oneoffs.obj: libvirt_c_oneoffs.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmllibvirt_a_CPPFLAGS) $(CPPFLAGS) $(libmllibvirt_a_CFLAGS) $(CFLAGS) -MT libmllibvirt_a-libvirt_c_oneoffs.obj -MD -MP -MF $(DEPDIR)/libmllibvirt_a-libvirt_c_oneoffs.Tpo -c -o libmllibvirt_a-libvirt_c_oneoffs.obj `if test -f 'libvirt_c_oneoffs.c'; then $(CYGPATH_W) 'libvirt_c_oneoffs.c'; else $(CYGPATH_W) '$(srcdir)/libvirt_c_oneoffs.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmllibvirt_a-libvirt_c_oneoffs.Tpo $(DEPDIR)/libmllibvirt_a-libvirt_c_oneoffs.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='libvirt_c_oneoffs.c' object='libmllibvirt_a-libvirt_c_oneoffs.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmllibvirt_a_CPPFLAGS) $(CPPFLAGS) $(libmllibvirt_a_CFLAGS) $(CFLAGS) -c -o libmllibvirt_a-libvirt_c_oneoffs.obj `if test -f 'libvirt_c_oneoffs.c'; then $(CYGPATH_W) 'libvirt_c_oneoffs.c'; else $(CYGPATH_W) '$(srcdir)/libvirt_c_oneoffs.c'; fi` mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LIBRARIES) $(DATA) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -f ./$(DEPDIR)/libmllibvirt_a-libvirt_c_common.Po -rm -f ./$(DEPDIR)/libmllibvirt_a-libvirt_c_oneoffs.Po -rm -f ./$(DEPDIR)/libmllibvirt_a-libvirt_generated.Po -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/libmllibvirt_a-libvirt_c_common.Po -rm -f ./$(DEPDIR)/libmllibvirt_a-libvirt_c_oneoffs.Po -rm -f ./$(DEPDIR)/libmllibvirt_a-libvirt_generated.Po -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ clean-generic clean-libtool clean-noinstLIBRARIES \ cscopelist-am ctags ctags-am distclean distclean-compile \ distclean-generic distclean-libtool distclean-tags distdir dvi \ dvi-am html html-am info info-am install install-am \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am .PRECIOUS: Makefile -include $(top_builddir)/localenv # Individual Makefile.am's should define generator_built if that # subdirectory contains any files which are built by the generator. # Set generator_built to the list of those files. $(generator_built): $(top_builddir)/generator/stamp-generator $(top_builddir)/generator/stamp-generator: $(top_builddir)/generator/generator @if test -f $(top_builddir)/generator/Makefile; then \ $(MAKE) -C $(top_builddir)/generator stamp-generator; \ else \ echo "warning: Run 'make' at the top level to build $(generator_built)"; \ fi # If this file doesn't exist, just print a warning and continue. # During 'make distclean' we can end up deleting this file. $(top_builddir)/generator/generator: @if test -f $(top_builddir)/generator/Makefile; then \ $(MAKE) -C $(top_builddir)/generator generator; \ else \ echo "warning: Run 'make' at the top level to build $@"; \ fi %.cmi: %.mli $(guestfs_am_v_ocamlcmi)$(OCAMLFIND) ocamlc -package guestfs $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@ %.cmo: %.ml $(guestfs_am_v_ocamlc)$(OCAMLFIND) ocamlc -package guestfs $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@ @HAVE_OCAMLOPT_TRUE@%.cmx: %.ml @HAVE_OCAMLOPT_TRUE@ $(guestfs_am_v_ocamlopt)$(OCAMLFIND) ocamlopt -package guestfs $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@ # Test shell scripts should use '$TEST_FUNCTIONS' to get a predefined # set of helper functions for running tests (see # tests/test-functions.sh). # # Notes: # # (1) This is in fact a single command all on one line. The variables # are evaluated in test-functions.sh. # # (2) We use absolute paths here and in test-functions.sh so that the # test can change directory freely. But we also include the # non-absolute values so they can be used by the test script itself. export TEST_FUNCTIONS := \ source $(abs_top_srcdir)/tests/test-functions.sh \ abs_srcdir="$(abs_srcdir)" \ abs_builddir="$(abs_builddir)" \ top_srcdir="$(top_srcdir)" \ top_builddir="$(top_builddir)" \ abs_top_srcdir="$(abs_top_srcdir)" \ abs_top_builddir="$(abs_top_builddir)" # Automatically generate the C code from a Perl script 'generator.pl'. libvirt_generated.c: $(srcdir)/generator.pl $(PERL) -w $< $(MLLIBVIRT_CMA): $(OBJECTS) libmllibvirt.a $(OCAMLFIND) mklib $(OCAMLPACKAGES) \ $(OBJECTS) $(libmllibvirt_a_OBJECTS) -cclib -lvirt -o mllibvirt # Dependencies. .depend: $(srcdir)/*.mli $(srcdir)/*.ml $(top_builddir)/ocaml-dep.sh $^ -include .depend .PHONY: depend docs # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: virt-v2v-1.44.2/PaxHeaders/valgrind-suppressions0000644000000000000000000000013213646010514016663 xustar0030 mtime=1587024204.562233648 30 atime=1637752334.921869137 30 ctime=1637862786.723894127 virt-v2v-1.44.2/valgrind-suppressions0000664000175000017500000001607513646010514020502 0ustar00rjonesrjones00000000000000# libguestfs # Copyright (C) 2009-2020 Red Hat Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Valgrind suppressions used when testing only. There are no known # resource leaks in libguestfs. This file is only for leaks in # libraries that libguestfs uses. # libnuma { libnuma_numa_node_size64_cond Memcheck:Cond fun:* fun:numa_node_size64 fun:numa_init } { libnuma_numa_node_size64_cond_2 Memcheck:Cond fun:numa_node_size64 fun:numa_init } { libnuma_numa_node_size64_cond_3 Memcheck:Cond fun:* fun:numa_node_size64 obj:/usr/lib64/libnuma.so.1 } { libnuma_numa_node_size64_cond_4 Memcheck:Cond fun:numa_node_size64 obj:/usr/lib64/libnuma.so.1 } { libnuma_numa_node_size64_value8 Memcheck:Value8 fun:numa_node_size64 fun:numa_init } { libnuma_numa_node_size64_value8_2 Memcheck:Value8 fun:numa_node_size64 obj:/usr/lib64/libnuma.so.1 } # libnl { libnl_add_routing_table_name_leak Memcheck:Leak fun:malloc fun:strdup fun:add_routing_table_name } { libnl_add_routing_table_name_leak_2 Memcheck:Leak fun:calloc fun:add_routing_table_name } { libnl_add_proto_name_leak Memcheck:Leak fun:malloc fun:strdup fun:add_proto_name } { libnl_add_proto_name_leak_2 Memcheck:Leak fun:calloc fun:add_proto_name } { libnl1_malloc_leak Memcheck:Leak fun:malloc fun:strdup obj:/usr/lib/libnl.so.1.1 } { libnl1_malloc_leak_2 Memcheck:Leak fun:malloc fun:strdup obj:/lib64/libnl.so.1.1 } { libnl1_malloc_leak_3 Memcheck:Leak fun:malloc fun:strdup obj:/usr/lib64/libnl.so.1.1 } { libnl1_calloc_leak Memcheck:Leak fun:calloc obj:/usr/lib/libnl.so.1.1 } { libnl1_calloc_leak_2 Memcheck:Leak fun:calloc obj:/lib64/libnl.so.1.1 } { libnl1_calloc_leak_3 Memcheck:Leak fun:calloc obj:/usr/lib64/libnl.so.1.1 } # OCaml, by design, doesn't bother to free the major heap before # calling exit. Ignore that leak. { ocaml_heap_leak Memcheck:Leak ... fun:caml_alloc_for_heap } # On the other hand, these seem to be a real bugs in OCaml: { ocaml_heap_leak_2 Memcheck:Leak fun:malloc fun:caml_thread_new_descriptor fun:caml_thread_new } { ocaml_heap_leak_3 Memcheck:Leak fun:malloc fun:caml_thread_new_descriptor fun:caml_thread_initialize } { ocaml_heap_leak_4 Memcheck:Leak ... fun:pthread_create* ... fun:caml_thread_new } { ocaml_heap_leak_5 Memcheck:Leak fun:malloc fun:caml_stat_alloc } { ocaml_heap_leak_6 Memcheck:Leak fun:malloc ... fun:caml_build_primitive_table } # Add for OCaml 4.10. { ocaml_heap_leak_7 Memcheck:Leak fun:malloc ... fun:caml_init_domain } { ocaml_heap_leak_8 Memcheck:Leak fun:malloc ... fun:caml_init_atom_table } # The OCaml PCRE.compile function calls pcre_compile2 which allocates # memory. If these regexps are stored in a global variable then they # can never be freed. This is not really a bug, so ignore it. { ocaml_pcre_globals Memcheck:Leak fun:malloc fun:pcre_compile2 ... } # glibc { glibc_cond Memcheck:Cond fun:index fun:expand_dynamic_string_token } # Not a real leak - glibc doesn't bother to free thread # data (TLS in this case). { glibc_leak_1 Memcheck:Leak fun:calloc fun:allocate_dtv } # Not a real leak - same as above, but glibc renamed the function. { glibc_leak_2 Memcheck:Leak fun:calloc fun:_dl_allocate_tls } # Not a real leak. { glibc_leak_3 Memcheck:Leak ... fun:__add_to_environ fun:setenv } # libvirt calls gnutls_global_init but doesn't call the # corresponding gnutls_global_deinit function because of # thread-safety issues (in GnuTLS). { libvirt_leak_1 Memcheck:Leak ... fun:gnutls_global_init fun:virInitialize } # RHBZ#847429 { libvirt_leak_2 Memcheck:Leak ... fun:tryLoadOne fun:VBoxCGlueInit fun:vboxRegister fun:virInitialize } # Variant of RHBZ#847429 with libvirt 1.0.2 { libvirt_leak_3 Memcheck:Leak ... fun:tryLoadOne fun:VBoxCGlueInit fun:vboxRegister fun:virGlobalInit } # RHBZ#913145 { libvirt_leak_4 Memcheck:Leak ... fun:virNetClientProgramCall } # RHBZ#1116427 { libvirt_leak_5 Memcheck:Leak ... fun:virFileFindResourceFull } # RHBZ#1135388 { libvirt_leak_6 Memcheck:Leak ... fun:testDomainGenerateIfnames } # Possibly RHBZ#1145649 { libvirt_leak_7 Memcheck:Leak ... fun:selabel_close fun:virSecuritySELinuxSecurityDriverClose } # RHBZ#1215042 { libvirt_leak_8 Memcheck:Leak ... fun:virGetUserRuntimeDirectory fun:virNetSocketNewConnectUNIX } # FUSE leaks the per-thread context (although the code looks # like it attempts to clean it up). In older fuse, it uses # malloc. In newer fuse it uses calloc. { fuse_leak_1 Memcheck:Leak fun:malloc fun:fuse_get_context_internal } { fuse_leak_2 Memcheck:Leak fun:calloc fun:fuse_get_context_internal } # ld-*.so { ld_leak Memcheck:Leak ... fun:_dl_init } # Memory leak in libmagic (RHBZ#919466). { libmagic_leak Memcheck:Leak ... fun:magic_getpath } # Another memory leak in libmagic. { libmagic_leak_2 Memcheck:Leak ... fun:file_apprentice } # Gtk { gtk_leak Memcheck:Leak ... fun:gtk_init_check } { gtk_leak_2 Memcheck:Leak ... fun:gdk_display_manager_get } { gtk_leak_3 Memcheck:Leak ... fun:_gdk_x11_screen_new } { glib_leak_1 Memcheck:Leak ... fun:g_type_register_static } { glib_leak_2 Memcheck:Leak ... fun:g_type_class_ref } # Perl # note: Perl leaks memory by design, this just suppresses them. { perl_leak_1 Memcheck:Leak ... fun:Perl_safesysmalloc } { perl_leak_2 Memcheck:Leak ... fun:Perl_safesysrealloc } { perl_leak_3 Memcheck:Leak ... fun:Perl_safesyscalloc } { perl_leak_4 Memcheck:Leak ... fun:Perl_yyparse } { perl_leak_5 Memcheck:Leak ... fun:Perl_re_compile } { perl_leak_6 Memcheck:Leak fun:malloc fun:Perl_refcounted_he_new_pvn } { perl_leak_7 Memcheck:Leak ... fun:Perl_re_op_compile } # libosinfo database reference is deliberately leaked # see v2v/libosinfo_utils.ml:get_db { libosinfo_leak_1 Memcheck:Leak ... fun:v2v_osinfo_db_load } # https://www.redhat.com/archives/libguestfs/2020-April/thread.html#00103 { libosinfo_leak_2 Memcheck:Leak ... fun:osinfo_* } virt-v2v-1.44.2/PaxHeaders/COPYING0000644000000000000000000000013213631710510013407 xustar0030 mtime=1583845704.118871141 30 atime=1637752334.902869347 30 ctime=1637862786.691894481 virt-v2v-1.44.2/COPYING0000664000175000017500000004325413631710510015225 0ustar00rjonesrjones00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. virt-v2v-1.44.2/PaxHeaders/installcheck.sh.in0000644000000000000000000000013213631710510015761 xustar0030 mtime=1583845704.130870974 30 atime=1637862729.264530713 30 ctime=1637862786.657894858 virt-v2v-1.44.2/installcheck.sh.in0000664000175000017500000000735413631710510017600 0ustar00rjonesrjones00000000000000#!/bin/bash # @configure_input@ # # (C) Copyright 2015 Red Hat Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # Run 'make check' on installed packages. # # The version of installed libguestfs being tested, and the version of # the libguestfs source tree must be the same. unset CDPATH export LANG=C set -e set -x # Grrrrrrr autoconf. prefix=@prefix@ exec_prefix=@exec_prefix@ # Remove all libtool crappage. find -name 'lt-*' | grep '/.libs/lt-' | xargs -r rm # Copy the installed library into libtool directory. rm -f lib/.libs/libguestfs.so* cp @libdir@/libguestfs.so lib/.libs/ cp @libdir@/libguestfs.so.0 lib/.libs/ cp @libdir@/libguestfs.so.0.* lib/.libs/ # Copy installed binaries into the right places. cp @bindir@/libguestfs-test-tool test-tool/ cp @bindir@/guestfish fish/ cp @bindir@/guestmount fuse/ cp @bindir@/virt-alignment-scan align/ cp @bindir@/virt-builder builder/ cp @bindir@/virt-builder-repository builder/ cp @bindir@/virt-cat cat/ cp @bindir@/virt-copy-in fish/ cp @bindir@/virt-copy-out fish/ cp @bindir@/virt-customize customize/ cp @bindir@/virt-dib dib/ cp @bindir@/virt-diff diff/ cp @bindir@/virt-df df/ cp @bindir@/virt-edit edit/ cp @bindir@/virt-filesystems cat/ cp @bindir@/virt-format format/ cp @bindir@/virt-get-kernel get-kernel/ cp @bindir@/virt-inspector inspector/ cp @bindir@/virt-ls cat/ cp @bindir@/virt-make-fs make-fs/ cp @bindir@/virt-rescue rescue/ cp @bindir@/virt-resize resize/ cp @bindir@/virt-sparsify sparsify/ cp @bindir@/virt-sysprep sysprep/ cp @bindir@/virt-tar-in fish/ cp @bindir@/virt-tar-out fish/ cp @bindir@/virt-v2v v2v/ cp @bindir@/virt-v2v-copy-to-local v2v/ cp @bindir@/virt-win-reg tools/ # virt-list-filesystems, virt-list-partitions and virt-tar are not # tested, because they are not routinely installed by Linux distros # (being legacy programs). # XXX No language bindings are copied at the moment. # Copy the installed appliance. rm -rf appliance/supermin.d cp -r @libdir@/guestfs/supermin.d appliance/ # Try to force the appliance not to get rebuilt: touch appliance/stamp-supermin rm -rf "tmp/.guestfs-$(id -u)" # Run the tests. make check -k # Check the library and some critical binaries didn't get rebuilt # during the 'make check', which would invalidate the results of # the test. compare () { sum1=`md5sum $1 | @AWK@ '{print $1}'` sum2=`md5sum $2 | @AWK@ '{print $1}'` if [ "$sum1" != "$sum2" ]; then echo "$2 was overwritten during the test. Test results are invalid." exit 1 fi } compare @libdir@/libguestfs.so lib/.libs/libguestfs.so compare @bindir@/guestfish fish/guestfish compare @bindir@/guestmount fuse/guestmount compare @bindir@/virt-df df/virt-df compare @bindir@/virt-v2v v2v/virt-v2v compare @libdir@/guestfs/supermin.d/daemon.tar.gz \ appliance/supermin.d/daemon.tar.gz # Now do a make clean to remove all the above. make clean >/dev/null 2>&1 ||: virt-v2v-1.44.2/PaxHeaders/v2v0000644000000000000000000000013214147746606013036 xustar0030 mtime=1637862790.966847119 30 atime=1637862793.119823266 30 ctime=1637862790.966847119 virt-v2v-1.44.2/v2v/0000755000175000017500000000000014147746606014717 5ustar00rjonesrjones00000000000000virt-v2v-1.44.2/v2v/PaxHeaders/libosinfo.ml0000644000000000000000000000013213631710510015407 xustar0030 mtime=1583845704.268869063 30 atime=1637862739.516417133 30 ctime=1637862790.835848571 virt-v2v-1.44.2/v2v/libosinfo.ml0000664000175000017500000000332613631710510017221 0ustar00rjonesrjones00000000000000(* virt-v2v * Copyright (C) 2020 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *) open Std_utils open Tools_utils open Common_gettext.Gettext type osinfo_db_t type osinfo_os_t type osinfo_device_driver = { architecture : string; location : string; pre_installable : bool; signed : bool; priority : int64; files : string list; } external osinfo_os_get_id : osinfo_os_t -> string = "v2v_osinfo_os_get_id" external osinfo_os_get_device_drivers : osinfo_os_t -> osinfo_device_driver list = "v2v_osinfo_os_get_device_drivers" class osinfo_os h = object (self) method get_id () = osinfo_os_get_id h method get_device_drivers () = osinfo_os_get_device_drivers h end external osinfo_db_load : unit -> osinfo_db_t = "v2v_osinfo_db_load" external osinfo_db_find_os_by_short_id : osinfo_db_t -> string -> osinfo_os_t = "v2v_osinfo_os_find_os_by_short_id" class osinfo_db () = let h = osinfo_db_load () in object (self) method find_os_by_short_id name = let os = osinfo_db_find_os_by_short_id h name in new osinfo_os os end virt-v2v-1.44.2/v2v/PaxHeaders/types.ml0000644000000000000000000000013014147141674014601 xustar0029 mtime=1637663676.16161591 30 atime=1637862739.533416945 29 ctime=1637862790.81784877 virt-v2v-1.44.2/v2v/types.ml0000644000175000017500000003742114147141674016416 0ustar00rjonesrjones00000000000000(* virt-v2v * Copyright (C) 2009-2020 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *) open Printf open Std_utils open Tools_utils open Common_gettext.Gettext (* Types. See types.mli for documentation. *) type source = { s_hypervisor : source_hypervisor; s_name : string; s_genid : string option; s_memory : int64; s_vcpu : int; s_cpu_vendor : string option; s_cpu_model : string option; s_cpu_topology : source_cpu_topology option; s_features : string list; s_firmware : source_firmware; s_display : source_display option; s_video : source_video option; s_sound : source_sound option; s_removables : source_removable list; s_nics : source_nic list; } and source_hypervisor = | QEmu | KQemu | KVM | Xen | LXC | UML | OpenVZ | Test | VMware | HyperV | VBox | Phyp | Parallels | Bhyve | Physical (* used by virt-p2v *) | UnknownHV (* used by -i disk *) | OtherHV of string and source_firmware = | BIOS | UEFI | UnknownFirmware and source_disk = { s_disk_id : int; s_qemu_uri : string; s_format : string; s_controller : s_controller option; } and s_controller = Source_IDE | Source_SATA | Source_SCSI | Source_virtio_blk | Source_virtio_SCSI and source_removable = { s_removable_type : s_removable_type; s_removable_controller : s_controller option; s_removable_slot : int option; } and s_removable_type = CDROM | Floppy and source_nic = { s_mac : string option; s_nic_model : s_nic_model option; s_vnet : string; s_vnet_type : vnet_type; s_mapping_explanation : string option; } and s_nic_model = Source_other_nic of string | Source_rtl8139 | Source_e1000 | Source_virtio_net and vnet_type = Bridge | Network and source_display = { s_display_type : s_display_type; s_keymap : string option; s_password : string option; s_listen : s_display_listen; s_port : int option; } and s_display_type = Window | VNC | Spice and s_display_listen = | LNoListen | LAddress of string | LNetwork of string | LSocket of string option | LNone and source_video = Source_other_video of string | Source_Cirrus | Source_QXL and source_sound = { s_sound_model : source_sound_model; } and source_sound_model = AC97 | ES1370 | ICH6 | ICH9 | PCSpeaker | SB16 | USBAudio and source_cpu_topology = { s_cpu_sockets : int; s_cpu_cores : int; s_cpu_threads : int; } let rec string_of_source s source_disks = sprintf " source name: %s hypervisor type: %s VM genid: %s memory: %Ld (bytes) nr vCPUs: %d CPU vendor: %s CPU model: %s CPU topology: %s CPU features: %s firmware: %s display: %s video: %s sound: %s disks: %s removable media: %s NICs: %s " s.s_name (string_of_source_hypervisor s.s_hypervisor) (Option.default "" s.s_genid) s.s_memory s.s_vcpu (Option.default "" s.s_cpu_vendor) (Option.default "" s.s_cpu_model) (match s.s_cpu_topology with | None -> "" | Some topology -> string_of_source_cpu_topology topology) (String.concat "," (List.sort compare s.s_features)) (string_of_source_firmware s.s_firmware) (match s.s_display with | None -> "" | Some display -> string_of_source_display display) (match s.s_video with | None -> "" | Some video -> string_of_source_video video) (match s.s_sound with | None -> "" | Some sound -> string_of_source_sound sound) (String.concat "\n" (List.map string_of_source_disk source_disks)) (String.concat "\n" (List.map string_of_source_removable s.s_removables)) (String.concat "\n" (List.map string_of_source_nic s.s_nics)) and string_of_source_hypervisor = function | QEmu -> "qemu" | KQemu -> "kqemu" | KVM -> "kvm" | Xen -> "xen" | LXC -> "lxc" | UML -> "uml" | OpenVZ -> "openvz" | Test -> "test" | VMware -> "vmware" | HyperV -> "hyperv" | VBox -> "vbox" | Phyp -> "phyp" | Parallels -> "parallels" | Bhyve -> "bhyve" | Physical -> "physical" | UnknownHV -> "unknownhv" | OtherHV s -> s and source_hypervisor_of_string = function | "qemu" -> QEmu | "kqemu" -> KQemu | "kvm" -> KVM | "xen" -> Xen | "lxc" -> LXC | "uml" -> UML | "openvz" -> OpenVZ | "test" -> Test | "vmware" -> VMware | "hyperv" -> HyperV | "vbox" -> VBox | "phyp" -> Phyp | "parallels" -> Parallels | "bhyve" -> Bhyve | "physical" -> Physical | "unknownhv" -> UnknownHV | s -> OtherHV s and string_of_source_firmware = function | BIOS -> "bios" | UEFI -> "uefi" | UnknownFirmware -> "unknown" and string_of_source_disk { s_qemu_uri = qemu_uri; s_format = format; s_controller = controller } = sprintf "\t%s (%s)%s" qemu_uri format (match controller with | None -> "" | Some controller -> " [" ^ string_of_controller controller ^ "]") and string_of_controller = function | Source_IDE -> "ide" | Source_SATA -> "sata" | Source_SCSI -> "scsi" | Source_virtio_blk -> "virtio-blk" | Source_virtio_SCSI -> "virtio-scsi" and string_of_source_removable { s_removable_type = typ; s_removable_controller = controller; s_removable_slot = i } = sprintf "\t%s%s%s" (match typ with CDROM -> "CD-ROM" | Floppy -> "Floppy") (match controller with | None -> "" | Some controller -> " [" ^ string_of_controller controller ^ "]") (match i with None -> "" | Some i -> sprintf " in slot %d" i) and string_of_source_nic { s_mac = mac; s_nic_model = model; s_vnet = vnet; s_vnet_type = typ } = sprintf "\t%s \"%s\"%s%s" (string_of_vnet_type typ) vnet (match mac with | None -> "" | Some mac -> " mac: " ^ mac) (match model with | None -> "" | Some model -> " [" ^ string_of_nic_model model ^ "]") and string_of_vnet_type = function | Bridge -> "Bridge" | Network -> "Network" and string_of_nic_model = function | Source_virtio_net -> "virtio" | Source_e1000 -> "e1000" | Source_rtl8139 -> "rtl8139" | Source_other_nic model -> model and nic_model_of_string = function | "virtio" -> Source_virtio_net | "e1000" -> Source_e1000 | "rtl8139" -> Source_rtl8139 | model -> Source_other_nic model and string_of_source_display { s_display_type = typ; s_keymap = keymap; s_password = password; s_listen = listen } = sprintf "%s%s%s%s" (match typ with Window -> "window" | VNC -> "vnc" | Spice -> "spice") (match keymap with None -> "" | Some km -> " " ^ km) (match password with None -> "" | Some _ -> " with password") (match listen with | LNoListen -> "" | LAddress a -> sprintf " listening on address %s" a | LNetwork n -> sprintf " listening on network %s" n | LSocket (Some s) -> sprintf " listening on Unix domain socket %s" s | LSocket None -> sprintf " listening on automatically created Unix domain socket" | LNone -> " listening on private fd" ) and string_of_source_video = function | Source_QXL -> "qxl" | Source_Cirrus -> "cirrus" | Source_other_video video -> video and source_video_of_string = function | "qxl" -> Source_QXL | "cirrus" -> Source_Cirrus | video -> Source_other_video video and string_of_source_sound { s_sound_model = model } = string_of_source_sound_model model (* NB: This function must produce names compatible with libvirt. The * documentation for libvirt is incomplete, look instead at the * sources. *) and string_of_source_sound_model = function | AC97 -> "ac97" | ES1370 -> "es1370" | ICH6 -> "ich6" | ICH9 -> "ich9" | PCSpeaker -> "pcspk" | SB16 -> "sb16" | USBAudio -> "usb" and source_sound_model_of_string = function | "ac97" -> Some AC97 | "es1370" -> Some ES1370 | "ich6" -> Some ICH6 | "ich9" -> Some ICH9 | "pcspk" -> Some PCSpeaker | "sb16" -> Some SB16 | "usb" -> Some USBAudio | _ -> None and string_of_source_cpu_topology { s_cpu_sockets; s_cpu_cores; s_cpu_threads } = sprintf "sockets: %d cores/socket: %d threads/core: %d" s_cpu_sockets s_cpu_cores s_cpu_threads type disk_stats = { mutable target_estimated_size : int64 option; mutable target_actual_size : int64 option; } type overlay = { ov_overlay_file : string; ov_sd : string; ov_virtual_size : int64; ov_source : source_disk; ov_stats : disk_stats; } let string_of_overlay ov = sprintf " overlay file: %s overlay device name: %s overlay virtual disk size: %Ld overlay source qemu URI: %s target estimated size: %s target actual size: %s " ov.ov_overlay_file ov.ov_sd ov.ov_virtual_size ov.ov_source.s_qemu_uri (match ov.ov_stats.target_estimated_size with | None -> "None" | Some i -> Int64.to_string i) (match ov.ov_stats.target_actual_size with | None -> "None" | Some i -> Int64.to_string i) type target = { target_file : target_file; target_format : string; target_overlay : overlay; } and target_file = | TargetFile of string | TargetURI of string let string_of_target t = sprintf " target file: %s target format: %s " (match t.target_file with | TargetFile s -> "[file] " ^ s | TargetURI s -> "[qemu] " ^ s) t.target_format type target_firmware = TargetBIOS | TargetUEFI let string_of_target_firmware = function | TargetBIOS -> "bios" | TargetUEFI -> "uefi" type i_firmware = | I_BIOS | I_UEFI of string list type inspect = { i_root : string; i_type : string; i_distro : string; i_osinfo : string; i_arch : string; i_major_version : int; i_minor_version : int; i_package_format : string; i_package_management : string; i_product_name : string; i_product_variant : string; i_mountpoints : (string * string) list; i_apps : Guestfs.application2 list; i_apps_map : Guestfs.application2 list StringMap.t; i_firmware : i_firmware; i_windows_systemroot : string; i_windows_software_hive : string; i_windows_system_hive : string; i_windows_current_control_set : string; } let string_of_inspect inspect = sprintf "\ i_root = %s i_type = %s i_distro = %s i_osinfo = %s i_arch = %s i_major_version = %d i_minor_version = %d i_package_format = %s i_package_management = %s i_product_name = %s i_product_variant = %s i_firmware = %s i_windows_systemroot = %s i_windows_software_hive = %s i_windows_system_hive = %s i_windows_current_control_set = %s " inspect.i_root inspect.i_type inspect.i_distro inspect.i_osinfo inspect.i_arch inspect.i_major_version inspect.i_minor_version inspect.i_package_format inspect.i_package_management inspect.i_product_name inspect.i_product_variant (match inspect.i_firmware with | I_BIOS -> "BIOS" | I_UEFI devices -> sprintf "UEFI [%s]" (String.concat ", " devices)) inspect.i_windows_systemroot inspect.i_windows_software_hive inspect.i_windows_system_hive inspect.i_windows_current_control_set type guestcaps = { gcaps_block_bus : guestcaps_block_type; gcaps_net_bus : guestcaps_net_type; gcaps_video : guestcaps_video_type; gcaps_virtio_rng : bool; gcaps_virtio_balloon : bool; gcaps_isa_pvpanic : bool; gcaps_virtio_socket : bool; gcaps_machine : guestcaps_machine; gcaps_arch : string; gcaps_acpi : bool; } and requested_guestcaps = { rcaps_block_bus : guestcaps_block_type option; rcaps_net_bus : guestcaps_net_type option; rcaps_video : guestcaps_video_type option; } and guestcaps_block_type = Virtio_blk | Virtio_SCSI | IDE and guestcaps_net_type = Virtio_net | E1000 | RTL8139 and guestcaps_video_type = QXL | Cirrus and guestcaps_machine = I440FX | Q35 | Virt let string_of_block_type = function | Virtio_blk -> "virtio-blk" | Virtio_SCSI -> "virtio-scsi" | IDE -> "ide" let string_of_net_type = function | Virtio_net -> "virtio-net" | E1000 -> "e1000" | RTL8139 -> "rtl8139" let string_of_video = function | QXL -> "qxl" | Cirrus -> "cirrus" let string_of_machine = function | I440FX -> "i440fx" | Q35 -> "q35" | Virt -> "virt" let string_of_guestcaps gcaps = sprintf "\ gcaps_block_bus = %s gcaps_net_bus = %s gcaps_video = %s gcaps_machine = %s gcaps_arch = %s gcaps_acpi = %b " (string_of_block_type gcaps.gcaps_block_bus) (string_of_net_type gcaps.gcaps_net_bus) (string_of_video gcaps.gcaps_video) (string_of_machine gcaps.gcaps_machine) gcaps.gcaps_arch gcaps.gcaps_acpi let string_of_requested_guestcaps rcaps = sprintf "\ rcaps_block_bus = %s rcaps_net_bus = %s rcaps_video = %s " (match rcaps.rcaps_block_bus with | None -> "unspecified" | Some block_type -> (string_of_block_type block_type)) (match rcaps.rcaps_net_bus with | None -> "unspecified" | Some net_type -> (string_of_net_type net_type)) (match rcaps.rcaps_video with | None -> "unspecified" | Some video -> (string_of_video video)) type target_buses = { target_virtio_blk_bus : target_bus_slot array; target_ide_bus : target_bus_slot array; target_scsi_bus : target_bus_slot array; target_floppy_bus : target_bus_slot array; } and target_bus_slot = | BusSlotEmpty | BusSlotDisk of source_disk | BusSlotRemovable of source_removable let string_of_target_bus_slots bus_name slots = let slots = Array.mapi ( fun slot_nr slot -> sprintf "%s slot %d:\n" bus_name slot_nr ^ (match slot with | BusSlotEmpty -> "\t(slot empty)\n" | BusSlotDisk d -> string_of_source_disk d | BusSlotRemovable r -> string_of_source_removable r ^ "\n" ) ) slots in String.concat "" (Array.to_list slots) let string_of_target_buses buses = string_of_target_bus_slots "virtio-blk" buses.target_virtio_blk_bus ^ string_of_target_bus_slots "ide" buses.target_ide_bus ^ string_of_target_bus_slots "scsi" buses.target_scsi_bus type root_choice = AskRoot | SingleRoot | FirstRoot | RootDev of string type output_allocation = Sparse | Preallocated type bandwidth = | StaticBandwidth of string | DynamicBandwidth of string option * string type static_ip = { if_mac_addr : string; if_ip_address : string; if_default_gateway : string option; if_prefix_length : int option; if_nameservers : string list; } class virtual input = object method precheck () = () method virtual as_options : string method virtual source : ?bandwidth:bandwidth -> unit -> (source * source_disk list) end class virtual output = object method precheck () = () method virtual as_options : string method virtual supported_firmware : target_firmware list method check_target_firmware (_ : guestcaps) (_ : target_firmware) = () method override_output_format (_ : overlay) = (None : string option) method transfer_format t = t.target_format method virtual prepare_targets : string -> (string * overlay) list -> guestcaps -> target_file list method disk_create = (open_guestfs ())#disk_create method disk_copied (_ : target) (_ : int) (_ : int) = () method virtual create_metadata : source -> target list -> target_buses -> guestcaps -> inspect -> target_firmware -> unit method keep_serial_console = true method install_rhev_apt = false method write_out_of_order = false end type output_settings = < keep_serial_console : bool; install_rhev_apt : bool > virt-v2v-1.44.2/v2v/PaxHeaders/output_null.ml0000644000000000000000000000013014001524055016012 xustar0028 mtime=1611049005.7425519 30 atime=1637862739.522417067 30 ctime=1637862790.906847784 virt-v2v-1.44.2/v2v/output_null.ml0000644000175000017500000000647214001524055017631 0ustar00rjonesrjones00000000000000(* virt-v2v * Copyright (C) 2009-2020 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *) open Printf open Std_utils open Tools_utils open Unix_utils open Common_gettext.Gettext open Types open Utils (* Notes: * * This only happens to work because we run qemu-img convert * with the -n [no create output] option, since null-co doesn't * support creation. If -n is removed in the main program then * the tests will break very obviously. * * The null-co device is not zero-sized. It actually has a fixed * size (defaults to 2^30 I believe). * * qemu-img convert checks the output size and will fail if it's * too small, so we have to set the size. We could set it to * match the input size but it's easier to set it to some huge * size instead. * * In case neither the null-co driver nor the JSON syntax for URLs * is supported, fall back by writing the disks to a temporary * directory removed at exit. *) let can_use_qemu_null_co_device () = (* We actually attempt to convert a raw file to the null-co device * using a JSON URL. *) let tmp = Filename.temp_file "v2vqemunullcotst" ".img" in Unix.truncate tmp 1024; let json = [ "file.driver", JSON.String "null-co"; "file.size", JSON.String "1E"; ] in let cmd = sprintf "qemu-img convert -n -f raw -O raw %s json:%s >/dev/null%s" (quote tmp) (quote (JSON.string_of_doc ~fmt:JSON.Compact json)) (if verbose () then "" else " 2>&1") in debug "%s" cmd; let r = 0 = Sys.command cmd in Unix.unlink tmp; debug "qemu-img supports the null-co device: %b" r; r class output_null = (* Create a temporary directory which is always deleted at exit, * so we can put the drives there in case qemu does not support * the null-co device w/ a JSON URL. *) let tmpdir = let t = Mkdtemp.temp_dir ~base_dir:large_tmpdir "null." in rmdir_on_exit t; t in object inherit output method as_options = "-o null" method supported_firmware = [ TargetBIOS; TargetUEFI ] (* Force raw output, ignoring -of command line option. *) method override_output_format _ = Some "raw" method prepare_targets _ overlays _ = if can_use_qemu_null_co_device () then ( let json_params = [ "file.driver", JSON.String "null-co"; "file.size", JSON.String "1E"; ] in let target_file = TargetURI ("json:" ^ JSON.string_of_doc json_params) in List.map (fun _ -> target_file) overlays ) else ( List.map (fun (_, ov) -> TargetFile (tmpdir // ov.ov_sd)) overlays ) method create_metadata _ _ _ _ _ _ = () end let output_null () = new output_null let () = Modules_list.register_output_module "null" virt-v2v-1.44.2/v2v/PaxHeaders/input_libvirtxml.mli0000644000000000000000000000013213641354341017216 xustar0030 mtime=1585830113.309308028 30 atime=1637862739.490417421 30 ctime=1637862790.711849944 virt-v2v-1.44.2/v2v/input_libvirtxml.mli0000664000175000017500000000175513641354341021034 0ustar00rjonesrjones00000000000000(* virt-v2v * Copyright (C) 2009-2020 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *) (** [-i libvirtxml] source. *) val input_libvirtxml : string -> Types.input (** [input_libvirtxml xml_file] creates and returns a new {!Types.input} object specialized for reading input from local libvirt XML files. *) virt-v2v-1.44.2/v2v/PaxHeaders/input_libvirt_vddk.ml0000644000000000000000000000013214147141674017341 xustar0030 mtime=1637663676.159615932 30 atime=1637862739.512417178 30 ctime=1637862790.885848016 virt-v2v-1.44.2/v2v/input_libvirt_vddk.ml0000644000175000017500000001571514147141674021156 0ustar00rjonesrjones00000000000000(* virt-v2v * Copyright (C) 2009-2020 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *) (** [-i libvirt] when the source is VMware via nbdkit vddk plugin *) open Common_gettext.Gettext open Tools_utils open Std_utils open Unix_utils open Types open Utils open Input_libvirt_other open Parse_libvirt_xml open Xpath_helpers open Printf type vddk_options = (string * string) list (* List of vddk-* input options. *) let vddk_option_keys = [ "config"; "cookie"; "libdir"; "nfchostport"; "port"; "snapshot"; "thumbprint"; "transports" ] let print_input_options () = printf (f_"Input options (-io) which can be used with -it vddk: -io vddk-thumbprint=xx:xx:xx:... VDDK server thumbprint (required) All other settings are optional: -io vddk-config=FILE VDDK configuration file -io vddk-cookie=COOKIE VDDK cookie -io vddk-libdir=LIBDIR VDDK library parent directory -io vddk-nfchostport=PORT VDDK nfchostport -io vddk-port=PORT VDDK port -io vddk-snapshot=SNAPSHOT-MOREF VDDK snapshot moref -io vddk-transports=MODE:MODE:.. VDDK transports Refer to nbdkit-vddk-plugin(1) and the VDDK documentation for further information on these settings. ") let parse_input_options options = (* Check there are no options we don't understand. Also removes * the "vddk-" prefix from the internal list. *) let options = List.map ( fun (key, value) -> let error_invalid_key () = error (f_"-it vddk: ‘-io %s’ is not a valid input option") key in if not (String.is_prefix key "vddk-") then error_invalid_key (); let key = String.sub key 5 (String.length key-5) in if not (List.mem key vddk_option_keys) then error_invalid_key (); (key, value) ) options in (* Check no option appears more than once. *) let keys = List.map fst options in if List.length keys <> List.length (List.sort_uniq keys) then error (f_"-it vddk: duplicate -io options on the command line"); options (* Subclass specialized for handling VMware via nbdkit vddk plugin. *) class input_libvirt_vddk libvirt_conn input_conn input_password vddk_options parsed_uri guest = let error_unless_thumbprint () = if not (List.mem_assoc "thumbprint" vddk_options) then error (f_"You must pass the ‘-io vddk-thumbprint’ option with the SSL thumbprint of the VMware server. To find the thumbprint, see the nbdkit-vddk-plugin(1) manual. See also the virt-v2v-input-vmware(1) manual.") in object (self) inherit input_libvirt libvirt_conn ~input_conn guest as super method precheck () = error_unless_thumbprint () method as_options = let pt_options = String.concat "" (List.map (fun (k, v) -> sprintf " -io vddk-%s=%s" k v) vddk_options) in sprintf "%s -it vddk %s" super#as_options (* superclass prints "-i libvirt etc" *) pt_options method source ?bandwidth () = let source, disks, xml = parse_libvirt_domain ?bandwidth self#conn guest in (* Find the element from the XML. This was added * in libvirt >= 3.7 and is required. *) let moref = let doc = Xml.parse_memory xml in let xpathctx = Xml.xpath_new_context doc in Xml.xpath_register_ns xpathctx "vmware" "http://libvirt.org/schemas/domain/vmware/1.0"; let xpath_string = xpath_string xpathctx in match xpath_string "/domain/vmware:moref" with | Some moref -> moref | None -> error (f_" was not found in the output of ‘virsh dumpxml \"%s\"’. The most likely reason is that libvirt is too old, try upgrading libvirt to ≥ 3.7.") guest in (* It probably never happens that the server name can be missing * from the libvirt URI, but we need a server name to pass to * nbdkit, so ... *) let server = match parsed_uri.Xml.uri_server with | Some server -> server | None -> error (f_"‘-ic %s’ URL does not contain a host name field") input_conn in let user = parsed_uri.Xml.uri_user in let config = try Some (List.assoc "config" vddk_options) with Not_found -> None in let cookie = try Some (List.assoc "cookie" vddk_options) with Not_found -> None in let libdir = try Some (List.assoc "libdir" vddk_options) with Not_found -> None in let nfchostport = try Some (List.assoc "nfchostport" vddk_options) with Not_found -> None in let port = try Some (List.assoc "port" vddk_options) with Not_found -> None in let snapshot = try Some (List.assoc "snapshot" vddk_options) with Not_found -> None in let thumbprint = try List.assoc "thumbprint" vddk_options with Not_found -> assert false (* checked in precheck method *) in let transports = try Some (List.assoc "transports" vddk_options) with Not_found -> None in (* Create an nbdkit instance for each disk and rewrite the source * paths to point to the NBD socket. *) let disks = List.map ( function | { p_source_disk = disk; p_source = P_dont_rewrite } -> disk | { p_source = P_source_dev _ } -> (* Should never happen. *) error (f_"source disk has attribute in XML") | { p_source_disk = disk; p_source = P_source_file path } -> (* The attribute returned by the libvirt * VMX driver looks like "[datastore] path". We can use it * directly as the nbdkit file= parameter, and it is passed * directly in this form to VDDK. *) let nbdkit = Nbdkit_sources.create_vddk ?bandwidth ?config ?cookie ?libdir ~moref ?nfchostport ?password_file:input_password ?port ~server ?snapshot ~thumbprint ?transports ?user path in let qemu_uri = Nbdkit_sources.run nbdkit in (* nbdkit always presents us with the raw disk blocks from * the guest, so force the format to raw here. *) { disk with s_qemu_uri = qemu_uri; s_format = "raw" } ) disks in source, disks end let input_libvirt_vddk = new input_libvirt_vddk virt-v2v-1.44.2/v2v/PaxHeaders/dummy.c0000644000000000000000000000013213631710510014370 xustar0030 mtime=1583845704.266869091 30 atime=1637862781.110956312 30 ctime=1637862790.674850354 virt-v2v-1.44.2/v2v/dummy.c0000664000175000017500000000013213631710510016172 0ustar00rjonesrjones00000000000000/* Dummy source, to be used for OCaml-based tools with no C sources. */ enum { foo = 1 }; virt-v2v-1.44.2/v2v/PaxHeaders/input_libvirt_other.ml0000644000000000000000000000013213665154464017537 xustar0030 mtime=1591007540.874706874 30 atime=1637862739.512417178 30 ctime=1637862790.881848061 virt-v2v-1.44.2/v2v/input_libvirt_other.ml0000664000175000017500000000460113665154464021346 0ustar00rjonesrjones00000000000000(* virt-v2v * Copyright (C) 2009-2020 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *) open Printf open Common_gettext.Gettext open Tools_utils open Types open Utils open Parse_libvirt_xml (* Libvirt < 2.1.0 did not support the "json:" pseudo-URLs that * we use as backingfiles, when accessing Xen over SSH or vCenter * over HTTPS. Check this and print a workaround. * * We can remove this when/if we ever require libvirt >= 2.1.0 as * a minimum version. * * See also RHBZ#1134878. *) let error_if_libvirt_does_not_support_json_backingfile () = if backend_is_libvirt () && Libvirt_utils.libvirt_get_version () < (2, 1, 0) then error (f_"because of libvirt bug https://bugzilla.redhat.com/1134878 you must EITHER upgrade to libvirt >= 2.1.0 OR set this environment variable:\n\nexport LIBGUESTFS_BACKEND=direct\n\nand then rerun the virt-v2v command.") (* Superclass. *) class virtual input_libvirt libvirt_conn ?input_conn guest = object (self) inherit input method as_options = sprintf "-i libvirt%s %s" (match input_conn with | None -> "" | Some uri -> " -ic " ^ uri) guest method private conn : Libvirt.rw Libvirt.Connect.t = Lazy.force libvirt_conn end (* Subclass specialized for handling anything that's *not* VMware vCenter * or Xen. *) class input_libvirt_other libvirt_conn ?input_conn guest = object (self) inherit input_libvirt libvirt_conn ?input_conn guest method source ?bandwidth () = debug "input_libvirt_other: source ()"; let source, disks, _ = parse_libvirt_domain ?bandwidth self#conn guest in let disks = List.map (fun { p_source_disk = disk } -> disk) disks in source, disks end let input_libvirt_other = new input_libvirt_other virt-v2v-1.44.2/v2v/PaxHeaders/var_expander_tests.ml0000644000000000000000000000013213631710510017323 xustar0030 mtime=1583845704.275868966 30 atime=1637862739.540416868 30 ctime=1637862790.964847141 virt-v2v-1.44.2/v2v/var_expander_tests.ml0000664000175000017500000001106613631710510021135 0ustar00rjonesrjones00000000000000(* virt-v2v * Copyright (C) 2019 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *) open Printf open OUnit open Std_utils let assert_equal_string = assert_equal ~printer:identity let assert_equal_stringlist = assert_equal ~printer:(fun x -> "(" ^ (String.escaped (String.concat "," x)) ^ ")") let replace_none_fn _ = None let replace_empty_fn _ = Some "" let test_no_replacement () = assert_equal_string "" (Var_expander.replace_fn "" replace_none_fn); assert_equal_string "x" (Var_expander.replace_fn "x" replace_none_fn); assert_equal_string "%{}" (Var_expander.replace_fn "%{}" replace_none_fn); assert_equal_string "%{EMPTY}" (Var_expander.replace_fn "%{EMPTY}" replace_none_fn); assert_equal_string "%{EMPTY} %{no}" (Var_expander.replace_fn "%{EMPTY} %{no}" replace_none_fn); assert_equal_string "a %{EMPTY} b" (Var_expander.replace_fn "a %{EMPTY} b" replace_none_fn); () let test_replacements () = assert_equal_string "" (Var_expander.replace_fn "%{EMPTY}" replace_empty_fn); assert_equal_string "x " (Var_expander.replace_fn "x %{EMPTY}" replace_empty_fn); assert_equal_string "xy" (Var_expander.replace_fn "x%{EMPTY}y" replace_empty_fn); assert_equal_string "x<->y" (Var_expander.replace_fn "x%{FOO}y" (function | "FOO" -> Some "<->" | _ -> None)); assert_equal_string "a x b" (Var_expander.replace_fn "a %{FOO} b" (function | "FOO" -> Some "x" | _ -> None)); assert_equal_string "%{FOO} x" (Var_expander.replace_fn "%{FOO} %{BAR}" (function | "BAR" -> Some "x" | _ -> None)); assert_equal_string "%{FOO}" (Var_expander.replace_fn "%{BAR}" (function | "BAR" -> Some "%{FOO}" | _ -> None)); assert_equal_string "%{FOO} x" (Var_expander.replace_fn "%{BAR} %{FOO}" (function | "BAR" -> Some "%{FOO}" | "FOO" -> Some "x" | _ -> None)); begin let str = "%{INDEX}, %{INDEX}, %{INDEX}" in let index = ref 0 in let fn = function | "INDEX" -> incr index; Some (string_of_int !index) | _ -> None in assert_equal_string "1, 2, 3" (Var_expander.replace_fn str fn) end; () let test_escape () = assert_equal_string "%%{FOO}" (Var_expander.replace_fn "%%{FOO}" replace_empty_fn); assert_equal_string "x %%{FOO} x" (Var_expander.replace_fn "%{FOO} %%{FOO} %{FOO}" (function | "FOO" -> Some "x" | _ -> None)); () let test_list () = assert_equal_string "x %{NONE}" (Var_expander.replace_list "%{FOO} %{NONE}" [("FOO", "x")]); () let test_scan_variables () = let assert_invalid_variable var = let str = "%{" ^ var ^ "}" in assert_raises (Var_expander.Invalid_variable var) (fun () -> Var_expander.scan_variables str) in assert_equal_stringlist [] (Var_expander.scan_variables ""); assert_equal_stringlist [] (Var_expander.scan_variables "foo"); assert_equal_stringlist ["FOO"] (Var_expander.scan_variables "%{FOO}"); assert_equal_stringlist ["FOO"; "BAR"] (Var_expander.scan_variables "%{FOO} %{BAR}"); assert_equal_stringlist ["FOO"; "BAR"] (Var_expander.scan_variables "%{FOO} %{BAR} %{FOO}"); assert_equal_stringlist ["FOO"; "BAR"] (Var_expander.scan_variables "%{FOO} %%{ESCAPED} %{BAR}"); assert_invalid_variable "FOO/BAR"; () let test_errors () = let assert_invalid_variable var = let str = "%{" ^ var ^ "}" in assert_raises (Var_expander.Invalid_variable var) (fun () -> Var_expander.replace_fn str replace_none_fn) in assert_invalid_variable "FOO/BAR"; assert_invalid_variable "FOO:BAR"; assert_invalid_variable "FOO(BAR"; assert_invalid_variable "FOO)BAR"; assert_invalid_variable "FOO@BAR"; () (* Suites declaration. *) let suite = TestList ([ "basic" >::: [ "no_replacement" >:: test_no_replacement; "replacements" >:: test_replacements; "escape" >:: test_escape; "list" >:: test_list; "scan_variables" >:: test_scan_variables; "errors" >:: test_errors; ]; ]) let () = ignore (run_test_tt_main suite); Printf.fprintf stderr "\n" virt-v2v-1.44.2/v2v/PaxHeaders/output_rhv_upload_vmcheck_source.mli0000644000000000000000000000013113631710510022436 xustar0030 mtime=1583845704.271869022 30 atime=1637862739.493417388 29 ctime=1637862790.78084918 virt-v2v-1.44.2/v2v/output_rhv_upload_vmcheck_source.mli0000664000175000017500000000142613631710510024250 0ustar00rjonesrjones00000000000000(* virt-v2v * Copyright (C) 2018 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *) val code : string virt-v2v-1.44.2/v2v/PaxHeaders/config.ml.in0000644000000000000000000000013213631710510015275 xustar0030 mtime=1583845704.265869105 30 atime=1637862730.740514361 30 ctime=1637862790.667850432 virt-v2v-1.44.2/v2v/config.ml.in0000664000175000017500000000205313631710510017103 0ustar00rjonesrjones00000000000000(* virt-v2v * Copyright (C) 2019 Red Hat Inc. * @configure_input@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *) let package_name = "@PACKAGE_NAME@" let package_version = "@PACKAGE_VERSION@" let package_version_full = "@PACKAGE_VERSION_FULL@" let prefix = "@prefix@" let datadir = prefix ^ "/share" let host_cpu = "@host_cpu@" let nbdkit_python_plugin = "@VIRT_V2V_NBDKIT_PYTHON_PLUGIN@" virt-v2v-1.44.2/v2v/PaxHeaders/embed.sh0000644000000000000000000000013213631710510014501 xustar0030 mtime=1583845704.266869091 30 atime=1637752334.921869137 30 ctime=1637862790.948847319 virt-v2v-1.44.2/v2v/embed.sh0000775000175000017500000000255013631710510016314 0ustar00rjonesrjones00000000000000#!/bin/bash - # Embed code or other content into an OCaml file. # Copyright (C) 2018 Red Hat Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Embed code or other content into an OCaml file. # # It is embedded into a string. As OCaml string literals have virtually # no restrictions on length or content we only have to escape double # quotes for backslash characters. if [ $# -ne 3 ]; then echo "embed.sh identifier input output" exit 1 fi set -e set -u ident="$1" input="$2" output="$3" rm -f "$output" "$output"-t exec >"$output"-t echo "(* Generated by embed.sh from $input *)" echo echo let "$ident" = '"' sed -e 's/\(["\]\)/\\\1/g' < "$input" echo '"' chmod -w "$output"-t mv "$output"-t "$output" virt-v2v-1.44.2/v2v/PaxHeaders/linux_bootloaders.mli0000644000000000000000000000013213710014521017325 xustar0030 mtime=1595939153.395563699 30 atime=1637862739.490417421 30 ctime=1637862790.730849734 virt-v2v-1.44.2/v2v/linux_bootloaders.mli0000664000175000017500000000435213710014521021137 0ustar00rjonesrjones00000000000000(* virt-v2v * Copyright (C) 2009-2020 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *) class virtual bootloader : object method virtual name : string (** The name of the bootloader, for debugging messages. *) method virtual augeas_device_patterns : string list (** A list of Augeas patterns to search for device names when we need to rewrite device names (eg. [/dev/hda] to [/dev/vda]). *) method virtual list_kernels : string list (** Lists all the kernels configured in the bootloader. *) method virtual set_default_kernel : string -> unit (** Sets the specified vmlinuz path as default bootloader entry. *) method set_augeas_configuration : unit -> bool (** Checks whether the bootloader configuration file is included in Augeas load list, and if it is not, then include it. Returns true if Augeas needs to be reloaded. *) method virtual configure_console : unit -> unit method virtual remove_console : unit -> unit (** Adds or removes a serial console to all the available kernels. *) method update : unit -> unit (** Update the bootloader: For grub2 only this runs the [grub2-mkconfig] command to rebuild the configuration. This is not necessary for grub-legacy. *) method virtual get_config_file : unit -> string (** Returns the path to the bootloader config file, e.g /boot/grub/grub.cfg *) end (** Encapsulates a Linux boot loader as object. *) val detect_bootloader : Guestfs.guestfs -> Types.inspect -> bootloader (** Detects the bootloader on the guest, and creates the object representing it. *) virt-v2v-1.44.2/v2v/PaxHeaders/utils.mli0000644000000000000000000000013214001524055014733 xustar0030 mtime=1611049005.743551889 30 atime=1637862739.496417355 30 ctime=1637862790.803848925 virt-v2v-1.44.2/v2v/utils.mli0000644000175000017500000000521114001524055016536 0ustar00rjonesrjones00000000000000(* virt-v2v * Copyright (C) 2009-2020 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *) (** Utilities used in virt-v2v only. *) val large_tmpdir : string (** [VIRT_V2V_TMPDIR] or [/var/tmp]. Create all large temporary files such as overlays in this directory. Small temporary files can use the default behaviour eg. of {!Filename.temp_file} *) val have_selinux : bool (** True if SELinux is enabled and enforcing on the host. *) val uri_quote : string -> string (** Take a string and perform %xx escaping as used in some parts of URLs. *) val kvm_arch : string -> string (** Map guest architecture found by inspection to the architecture that KVM must emulate. Note for x86 we assume a 64 bit hypervisor. *) val qemu_supports_sound_card : Types.source_sound_model -> bool (** Does qemu support the given sound card? *) val find_uefi_firmware : string -> Uefi.uefi_firmware (** Find the UEFI firmware for the guest architecture. This cannot return an error, it calls [error] and fails instead. *) val error_unless_uefi_firmware : string -> unit (** Check UEFI firmware is installed on the local host and error out if not. *) val compare_app2_versions : Guestfs.application2 -> Guestfs.application2 -> int (** Compare two app versions. *) val du : string -> int64 (** Return the true size of a file in bytes, including any wasted space caused by internal fragmentation (the overhead of using blocks). This can raise either [Failure] or [Invalid_argument] in case of errors. *) val qemu_img_supports_offset_and_size : unit -> bool (** Return true iff [qemu-img] supports the ["offset"] and ["size"] parameters to open a subset of a file. *) val backend_is_libvirt : unit -> bool (** Return true iff the current backend is libvirt. *) val error_if_no_ssh_agent : unit -> unit val wait_for_file : string -> int -> bool (** [wait_for_file filename timeout] waits up to [timeout] seconds for [filename] to appear. It returns [true] if the file appeared. *) virt-v2v-1.44.2/v2v/PaxHeaders/v2v_unit_tests.ml0000644000000000000000000000013213641354341016430 xustar0030 mtime=1585830113.312307986 30 atime=1637862739.536416912 30 ctime=1637862790.966847119 virt-v2v-1.44.2/v2v/v2v_unit_tests.ml0000664000175000017500000012254413641354341020246 0ustar00rjonesrjones00000000000000(* virt-v2v * Copyright (C) 2011-2020 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *) (* This file tests individual virt-v2v functions. *) open Printf open OUnit2 open Std_utils open Tools_utils open Types let inspect_defaults = { i_type = ""; i_distro = ""; i_osinfo = ""; i_arch = ""; i_major_version = 0; i_minor_version = 0; i_root = ""; i_package_format = ""; i_package_management = ""; i_product_name = ""; i_product_variant = ""; i_mountpoints = []; i_apps = []; i_apps_map = StringMap.empty; i_firmware = I_BIOS; i_windows_systemroot = ""; i_windows_software_hive = ""; i_windows_system_hive = ""; i_windows_current_control_set = ""; } let test_get_ostype ctx = let printer = identity in assert_equal ~printer "RHEL6" (Create_ovf.get_ostype { inspect_defaults with i_type = "linux"; i_distro = "rhel"; i_major_version = 6; i_minor_version = 0; i_arch = "i386" }); assert_equal ~printer "RHEL6x64" (Create_ovf.get_ostype { inspect_defaults with i_type = "linux"; i_distro = "rhel"; i_major_version = 6; i_minor_version = 0; i_arch = "x86_64" }); assert_equal ~printer "rhel_7x64" (Create_ovf.get_ostype { inspect_defaults with i_type = "linux"; i_distro = "rhel"; i_major_version = 7; i_minor_version = 0; i_arch = "x86_64" }); assert_equal ~printer "Windows7" (Create_ovf.get_ostype { inspect_defaults with i_type = "windows"; i_major_version = 6; i_minor_version = 1; i_product_variant = "Client"; i_arch = "i386" }); assert_equal ~printer "Windows7x64" (Create_ovf.get_ostype { inspect_defaults with i_type = "windows"; i_major_version = 6; i_minor_version = 1; i_product_variant = "Client"; i_arch = "x86_64" }); assert_equal ~printer "windows_8" (Create_ovf.get_ostype { inspect_defaults with i_type = "windows"; i_major_version = 6; i_minor_version = 2; i_product_variant = "Client"; i_arch = "i386" }); assert_equal ~printer "windows_8x64" (Create_ovf.get_ostype { inspect_defaults with i_type = "windows"; i_major_version = 6; i_minor_version = 2; i_product_variant = "Client"; i_arch = "x86_64" }); assert_equal ~printer "windows_2012x64" (Create_ovf.get_ostype { inspect_defaults with i_type = "windows"; i_major_version = 6; i_minor_version = 2; i_product_variant = "Server"; i_arch = "x86_64" }); assert_equal ~printer "windows_2012R2x64" (Create_ovf.get_ostype { inspect_defaults with i_type = "windows"; i_major_version = 6; i_minor_version = 3; i_product_variant = "Server"; i_arch = "x86_64" }) let test_virtio_iso_path_matches_guest_os ctx = (* Windows OSes fake inspection data. *) let make_win name major minor variant arch = { inspect_defaults with i_product_name = name; i_product_variant = variant; i_major_version = major; i_minor_version = minor; i_arch = arch; } in let winxp_32 = make_win "winxp_32" 5 1 "Client" "i386" in let winxp_64 = make_win "winxp_64" 5 1 "Client" "x86_64" in let win2k3_32 = make_win "win2k3_32" 5 2 "Server" "i386" in let win2k3_64 = make_win "win2k3_64" 5 2 "Server" "x86_64" in let winvista_32 = make_win "winvista_32" 6 0 "Client" "i386" in let winvista_64 = make_win "winvista_64" 6 0 "Client" "x86_64" in let win2k8_32 = make_win "win2k8_32" 6 0 "Server" "i386" in let win2k8_64 = make_win "win2k8_64" 6 0 "Server" "x86_64" in let win7_32 = make_win "win7_32" 6 1 "Client" "i386" in let win7_64 = make_win "win7_64" 6 1 "Client" "x86_64" in let win2k8r2_32 = make_win "win2k8r2_32" 6 1 "Server" "i386" in let win2k8r2_64 = make_win "win2k8r2_64" 6 1 "Server" "x86_64" in let win8_32 = make_win "win8_32" 6 2 "Client" "i386" in let win8_64 = make_win "win8_64" 6 2 "Client" "x86_64" in let win2k12_32 = make_win "win2k12_32" 6 2 "Server" "i386" in let win2k12_64 = make_win "win2k12_64" 6 2 "Server" "x86_64" in let win8_1_32 = make_win "win8_1_32" 6 3 "Client" "i386" in let win8_1_64 = make_win "win8_1_64" 6 3 "Client" "x86_64" in let win2k12r2_32 = make_win "win2k12r2_32" 6 3 "Server" "i386" in let win2k12r2_64 = make_win "win2k12r2_64" 6 3 "Server" "x86_64" in let win10_32 = make_win "win10_32" 10 0 "Client" "i386" in let win10_64 = make_win "win10_64" 10 0 "Client" "x86_64" in let all_windows = [ winxp_32; win2k3_32; winvista_32; win2k8_32; win7_32; win2k8r2_32; win8_32; win2k12_32; win8_1_32; win2k12r2_32; win10_32; winxp_64; win2k3_64; winvista_64; win2k8_64; win7_64; win2k8r2_64; win8_64; win2k12_64; win8_1_64; win2k12r2_64; win10_64 ] in let paths = [ (* Paths from the virtio-win 1.7.4 ISO. *) "Balloon/2k12/amd64/WdfCoInstaller01011.dll", Some win2k12_64; "Balloon/2k12/amd64/balloon.cat", Some win2k12_64; "Balloon/2k12/amd64/balloon.inf", Some win2k12_64; "Balloon/2k12/amd64/balloon.pdb", Some win2k12_64; "Balloon/2k12/amd64/balloon.sys", Some win2k12_64; "Balloon/2k12/amd64/blnsvr.exe", Some win2k12_64; "Balloon/2k12/amd64/blnsvr.pdb", Some win2k12_64; "Balloon/2k12R2/amd64/WdfCoInstaller01011.dll", Some win2k12r2_64; "Balloon/2k12R2/amd64/balloon.cat", Some win2k12r2_64; "Balloon/2k12R2/amd64/balloon.inf", Some win2k12r2_64; "Balloon/2k12R2/amd64/balloon.pdb", Some win2k12r2_64; "Balloon/2k12R2/amd64/balloon.sys", Some win2k12r2_64; "Balloon/2k12R2/amd64/blnsvr.exe", Some win2k12r2_64; "Balloon/2k12R2/amd64/blnsvr.pdb", Some win2k12r2_64; "Balloon/2k3/amd64/WdfCoInstaller01009.dll", Some win2k3_64; "Balloon/2k3/amd64/balloon.cat", Some win2k3_64; "Balloon/2k3/amd64/balloon.inf", Some win2k3_64; "Balloon/2k3/amd64/balloon.pdb", Some win2k3_64; "Balloon/2k3/amd64/balloon.sys", Some win2k3_64; "Balloon/2k3/amd64/blnsvr.exe", Some win2k3_64; "Balloon/2k3/amd64/blnsvr.pdb", Some win2k3_64; "Balloon/2k3/x86/WdfCoInstaller01009.dll", Some win2k3_32; "Balloon/2k3/x86/balloon.cat", Some win2k3_32; "Balloon/2k3/x86/balloon.inf", Some win2k3_32; "Balloon/2k3/x86/balloon.pdb", Some win2k3_32; "Balloon/2k3/x86/balloon.sys", Some win2k3_32; "Balloon/2k3/x86/blnsvr.exe", Some win2k3_32; "Balloon/2k3/x86/blnsvr.pdb", Some win2k3_32; "Balloon/2k8/amd64/WdfCoInstaller01009.dll", Some win2k8_64; "Balloon/2k8/amd64/balloon.cat", Some win2k8_64; "Balloon/2k8/amd64/balloon.inf", Some win2k8_64; "Balloon/2k8/amd64/balloon.pdb", Some win2k8_64; "Balloon/2k8/amd64/balloon.sys", Some win2k8_64; "Balloon/2k8/amd64/blnsvr.exe", Some win2k8_64; "Balloon/2k8/amd64/blnsvr.pdb", Some win2k8_64; "Balloon/2k8/x86/WdfCoInstaller01009.dll", Some win2k8_32; "Balloon/2k8/x86/balloon.cat", Some win2k8_32; "Balloon/2k8/x86/balloon.inf", Some win2k8_32; "Balloon/2k8/x86/balloon.pdb", Some win2k8_32; "Balloon/2k8/x86/balloon.sys", Some win2k8_32; "Balloon/2k8/x86/blnsvr.exe", Some win2k8_32; "Balloon/2k8/x86/blnsvr.pdb", Some win2k8_32; "Balloon/2k8R2/amd64/WdfCoInstaller01009.dll", Some win2k8r2_64; "Balloon/2k8R2/amd64/balloon.cat", Some win2k8r2_64; "Balloon/2k8R2/amd64/balloon.inf", Some win2k8r2_64; "Balloon/2k8R2/amd64/balloon.pdb", Some win2k8r2_64; "Balloon/2k8R2/amd64/balloon.sys", Some win2k8r2_64; "Balloon/2k8R2/amd64/blnsvr.exe", Some win2k8r2_64; "Balloon/2k8R2/amd64/blnsvr.pdb", Some win2k8r2_64; "Balloon/w7/amd64/WdfCoInstaller01009.dll", Some win7_64; "Balloon/w7/amd64/balloon.cat", Some win7_64; "Balloon/w7/amd64/balloon.inf", Some win7_64; "Balloon/w7/amd64/balloon.pdb", Some win7_64; "Balloon/w7/amd64/balloon.sys", Some win7_64; "Balloon/w7/amd64/blnsvr.exe", Some win7_64; "Balloon/w7/amd64/blnsvr.pdb", Some win7_64; "Balloon/w7/x86/WdfCoInstaller01009.dll", Some win7_32; "Balloon/w7/x86/balloon.cat", Some win7_32; "Balloon/w7/x86/balloon.inf", Some win7_32; "Balloon/w7/x86/balloon.pdb", Some win7_32; "Balloon/w7/x86/balloon.sys", Some win7_32; "Balloon/w7/x86/blnsvr.exe", Some win7_32; "Balloon/w7/x86/blnsvr.pdb", Some win7_32; "Balloon/w8.1/amd64/WdfCoInstaller01011.dll", Some win8_1_64; "Balloon/w8.1/amd64/balloon.cat", Some win8_1_64; "Balloon/w8.1/amd64/balloon.inf", Some win8_1_64; "Balloon/w8.1/amd64/balloon.pdb", Some win8_1_64; "Balloon/w8.1/amd64/balloon.sys", Some win8_1_64; "Balloon/w8.1/amd64/blnsvr.exe", Some win8_1_64; "Balloon/w8.1/amd64/blnsvr.pdb", Some win8_1_64; "Balloon/w8.1/x86/WdfCoInstaller01011.dll", Some win8_1_32; "Balloon/w8.1/x86/balloon.cat", Some win8_1_32; "Balloon/w8.1/x86/balloon.inf", Some win8_1_32; "Balloon/w8.1/x86/balloon.pdb", Some win8_1_32; "Balloon/w8.1/x86/balloon.sys", Some win8_1_32; "Balloon/w8.1/x86/blnsvr.exe", Some win8_1_32; "Balloon/w8.1/x86/blnsvr.pdb", Some win8_1_32; "Balloon/w8/amd64/WdfCoInstaller01011.dll", Some win8_64; "Balloon/w8/amd64/balloon.cat", Some win8_64; "Balloon/w8/amd64/balloon.inf", Some win8_64; "Balloon/w8/amd64/balloon.pdb", Some win8_64; "Balloon/w8/amd64/balloon.sys", Some win8_64; "Balloon/w8/amd64/blnsvr.exe", Some win8_64; "Balloon/w8/amd64/blnsvr.pdb", Some win8_64; "Balloon/w8/x86/WdfCoInstaller01011.dll", Some win8_32; "Balloon/w8/x86/balloon.cat", Some win8_32; "Balloon/w8/x86/balloon.inf", Some win8_32; "Balloon/w8/x86/balloon.pdb", Some win8_32; "Balloon/w8/x86/balloon.sys", Some win8_32; "Balloon/w8/x86/blnsvr.exe", Some win8_32; "Balloon/w8/x86/blnsvr.pdb", Some win8_32; "Balloon/xp/x86/WdfCoInstaller01009.dll", Some winxp_32; "Balloon/xp/x86/balloon.cat", Some winxp_32; "Balloon/xp/x86/balloon.inf", Some winxp_32; "Balloon/xp/x86/balloon.pdb", Some winxp_32; "Balloon/xp/x86/balloon.sys", Some winxp_32; "Balloon/xp/x86/blnsvr.exe", Some winxp_32; "Balloon/xp/x86/blnsvr.pdb", Some winxp_32; "NetKVM/2k12/amd64/netkvm.cat", Some win2k12_64; "NetKVM/2k12/amd64/netkvm.inf", Some win2k12_64; "NetKVM/2k12/amd64/netkvm.pdb", Some win2k12_64; "NetKVM/2k12/amd64/netkvm.sys", Some win2k12_64; "NetKVM/2k12/amd64/netkvmco.dll", Some win2k12_64; "NetKVM/2k12/amd64/readme.doc", Some win2k12_64; "NetKVM/2k12R2/amd64/netkvm.cat", Some win2k12r2_64; "NetKVM/2k12R2/amd64/netkvm.inf", Some win2k12r2_64; "NetKVM/2k12R2/amd64/netkvm.pdb", Some win2k12r2_64; "NetKVM/2k12R2/amd64/netkvm.sys", Some win2k12r2_64; "NetKVM/2k12R2/amd64/netkvmco.dll", Some win2k12r2_64; "NetKVM/2k12R2/amd64/readme.doc", Some win2k12r2_64; "NetKVM/2k3/amd64/netkvm.cat", Some win2k3_64; "NetKVM/2k3/amd64/netkvm.inf", Some win2k3_64; "NetKVM/2k3/amd64/netkvm.pdb", Some win2k3_64; "NetKVM/2k3/amd64/netkvm.sys", Some win2k3_64; "NetKVM/2k3/x86/netkvm.cat", Some win2k3_32; "NetKVM/2k3/x86/netkvm.inf", Some win2k3_32; "NetKVM/2k3/x86/netkvm.pdb", Some win2k3_32; "NetKVM/2k3/x86/netkvm.sys", Some win2k3_32; "NetKVM/2k8/amd64/netkvm.cat", Some win2k8_64; "NetKVM/2k8/amd64/netkvm.inf", Some win2k8_64; "NetKVM/2k8/amd64/netkvm.pdb", Some win2k8_64; "NetKVM/2k8/amd64/netkvm.sys", Some win2k8_64; "NetKVM/2k8/amd64/netkvmco.dll", Some win2k8_64; "NetKVM/2k8/amd64/readme.doc", Some win2k8_64; "NetKVM/2k8/x86/netkvm.cat", Some win2k8_32; "NetKVM/2k8/x86/netkvm.inf", Some win2k8_32; "NetKVM/2k8/x86/netkvm.pdb", Some win2k8_32; "NetKVM/2k8/x86/netkvm.sys", Some win2k8_32; "NetKVM/2k8/x86/netkvmco.dll", Some win2k8_32; "NetKVM/2k8/x86/readme.doc", Some win2k8_32; "NetKVM/2k8R2/amd64/netkvm.cat", Some win2k8r2_64; "NetKVM/2k8R2/amd64/netkvm.inf", Some win2k8r2_64; "NetKVM/2k8R2/amd64/netkvm.pdb", Some win2k8r2_64; "NetKVM/2k8R2/amd64/netkvm.sys", Some win2k8r2_64; "NetKVM/2k8R2/amd64/netkvmco.dll", Some win2k8r2_64; "NetKVM/2k8R2/amd64/readme.doc", Some win2k8r2_64; "NetKVM/w7/amd64/netkvm.cat", Some win7_64; "NetKVM/w7/amd64/netkvm.inf", Some win7_64; "NetKVM/w7/amd64/netkvm.pdb", Some win7_64; "NetKVM/w7/amd64/netkvm.sys", Some win7_64; "NetKVM/w7/amd64/netkvmco.dll", Some win7_64; "NetKVM/w7/amd64/readme.doc", Some win7_64; "NetKVM/w7/x86/netkvm.cat", Some win7_32; "NetKVM/w7/x86/netkvm.inf", Some win7_32; "NetKVM/w7/x86/netkvm.pdb", Some win7_32; "NetKVM/w7/x86/netkvm.sys", Some win7_32; "NetKVM/w7/x86/netkvmco.dll", Some win7_32; "NetKVM/w7/x86/readme.doc", Some win7_32; "NetKVM/w8.1/amd64/netkvm.cat", Some win8_1_64; "NetKVM/w8.1/amd64/netkvm.inf", Some win8_1_64; "NetKVM/w8.1/amd64/netkvm.pdb", Some win8_1_64; "NetKVM/w8.1/amd64/netkvm.sys", Some win8_1_64; "NetKVM/w8.1/amd64/netkvmco.dll", Some win8_1_64; "NetKVM/w8.1/amd64/readme.doc", Some win8_1_64; "NetKVM/w8.1/x86/netkvm.cat", Some win8_1_32; "NetKVM/w8.1/x86/netkvm.inf", Some win8_1_32; "NetKVM/w8.1/x86/netkvm.pdb", Some win8_1_32; "NetKVM/w8.1/x86/netkvm.sys", Some win8_1_32; "NetKVM/w8.1/x86/netkvmco.dll", Some win8_1_32; "NetKVM/w8.1/x86/readme.doc", Some win8_1_32; "NetKVM/w8/amd64/netkvm.cat", Some win8_64; "NetKVM/w8/amd64/netkvm.inf", Some win8_64; "NetKVM/w8/amd64/netkvm.pdb", Some win8_64; "NetKVM/w8/amd64/netkvm.sys", Some win8_64; "NetKVM/w8/amd64/netkvmco.dll", Some win8_64; "NetKVM/w8/amd64/readme.doc", Some win8_64; "NetKVM/w8/x86/netkvm.cat", Some win8_32; "NetKVM/w8/x86/netkvm.inf", Some win8_32; "NetKVM/w8/x86/netkvm.pdb", Some win8_32; "NetKVM/w8/x86/netkvm.sys", Some win8_32; "NetKVM/w8/x86/netkvmco.dll", Some win8_32; "NetKVM/w8/x86/readme.doc", Some win8_32; "NetKVM/xp/x86/netkvm.cat", Some winxp_32; "NetKVM/xp/x86/netkvm.inf", Some winxp_32; "NetKVM/xp/x86/netkvm.pdb", Some winxp_32; "NetKVM/xp/x86/netkvm.sys", Some winxp_32; "guest-agent/qemu-ga-x64.msi", None; "guest-agent/qemu-ga-x86.msi", None; "qemupciserial/qemupciserial.inf", None; "viorng/2k12/amd64/WdfCoInstaller01011.dll", Some win2k12_64; "viorng/2k12/amd64/viorng.cat", Some win2k12_64; "viorng/2k12/amd64/viorng.inf", Some win2k12_64; "viorng/2k12/amd64/viorng.pdb", Some win2k12_64; "viorng/2k12/amd64/viorng.sys", Some win2k12_64; "viorng/2k12/amd64/viorngci.dll", Some win2k12_64; "viorng/2k12/amd64/viorngum.dll", Some win2k12_64; "viorng/2k12R2/amd64/WdfCoInstaller01011.dll", Some win2k12r2_64; "viorng/2k12R2/amd64/viorng.cat", Some win2k12r2_64; "viorng/2k12R2/amd64/viorng.inf", Some win2k12r2_64; "viorng/2k12R2/amd64/viorng.pdb", Some win2k12r2_64; "viorng/2k12R2/amd64/viorng.sys", Some win2k12r2_64; "viorng/2k12R2/amd64/viorngci.dll", Some win2k12r2_64; "viorng/2k12R2/amd64/viorngum.dll", Some win2k12r2_64; "viorng/2k8/amd64/WdfCoInstaller01009.dll", Some win2k8_64; "viorng/2k8/amd64/viorng.cat", Some win2k8_64; "viorng/2k8/amd64/viorng.inf", Some win2k8_64; "viorng/2k8/amd64/viorng.pdb", Some win2k8_64; "viorng/2k8/amd64/viorng.sys", Some win2k8_64; "viorng/2k8/amd64/viorngci.dll", Some win2k8_64; "viorng/2k8/amd64/viorngum.dll", Some win2k8_64; "viorng/2k8/x86/WdfCoInstaller01009.dll", Some win2k8_32; "viorng/2k8/x86/viorng.cat", Some win2k8_32; "viorng/2k8/x86/viorng.inf", Some win2k8_32; "viorng/2k8/x86/viorng.pdb", Some win2k8_32; "viorng/2k8/x86/viorng.sys", Some win2k8_32; "viorng/2k8/x86/viorngci.dll", Some win2k8_32; "viorng/2k8/x86/viorngum.dll", Some win2k8_32; "viorng/2k8R2/amd64/WdfCoInstaller01009.dll", Some win2k8r2_64; "viorng/2k8R2/amd64/viorng.cat", Some win2k8r2_64; "viorng/2k8R2/amd64/viorng.inf", Some win2k8r2_64; "viorng/2k8R2/amd64/viorng.pdb", Some win2k8r2_64; "viorng/2k8R2/amd64/viorng.sys", Some win2k8r2_64; "viorng/2k8R2/amd64/viorngci.dll", Some win2k8r2_64; "viorng/2k8R2/amd64/viorngum.dll", Some win2k8r2_64; "viorng/w7/amd64/WdfCoInstaller01009.dll", Some win7_64; "viorng/w7/amd64/viorng.cat", Some win7_64; "viorng/w7/amd64/viorng.inf", Some win7_64; "viorng/w7/amd64/viorng.pdb", Some win7_64; "viorng/w7/amd64/viorng.sys", Some win7_64; "viorng/w7/amd64/viorngci.dll", Some win7_64; "viorng/w7/amd64/viorngum.dll", Some win7_64; "viorng/w7/x86/WdfCoInstaller01009.dll", Some win7_32; "viorng/w7/x86/viorng.cat", Some win7_32; "viorng/w7/x86/viorng.inf", Some win7_32; "viorng/w7/x86/viorng.pdb", Some win7_32; "viorng/w7/x86/viorng.sys", Some win7_32; "viorng/w7/x86/viorngci.dll", Some win7_32; "viorng/w7/x86/viorngum.dll", Some win7_32; "viorng/w8.1/amd64/WdfCoInstaller01011.dll", Some win8_1_64; "viorng/w8.1/amd64/viorng.cat", Some win8_1_64; "viorng/w8.1/amd64/viorng.inf", Some win8_1_64; "viorng/w8.1/amd64/viorng.pdb", Some win8_1_64; "viorng/w8.1/amd64/viorng.sys", Some win8_1_64; "viorng/w8.1/amd64/viorngci.dll", Some win8_1_64; "viorng/w8.1/amd64/viorngum.dll", Some win8_1_64; "viorng/w8.1/x86/WdfCoInstaller01011.dll", Some win8_1_32; "viorng/w8.1/x86/viorng.cat", Some win8_1_32; "viorng/w8.1/x86/viorng.inf", Some win8_1_32; "viorng/w8.1/x86/viorng.pdb", Some win8_1_32; "viorng/w8.1/x86/viorng.sys", Some win8_1_32; "viorng/w8.1/x86/viorngci.dll", Some win8_1_32; "viorng/w8.1/x86/viorngum.dll", Some win8_1_32; "viorng/w8/amd64/WdfCoInstaller01011.dll", Some win8_64; "viorng/w8/amd64/viorng.cat", Some win8_64; "viorng/w8/amd64/viorng.inf", Some win8_64; "viorng/w8/amd64/viorng.pdb", Some win8_64; "viorng/w8/amd64/viorng.sys", Some win8_64; "viorng/w8/amd64/viorngci.dll", Some win8_64; "viorng/w8/amd64/viorngum.dll", Some win8_64; "viorng/w8/x86/WdfCoInstaller01011.dll", Some win8_32; "viorng/w8/x86/viorng.cat", Some win8_32; "viorng/w8/x86/viorng.inf", Some win8_32; "viorng/w8/x86/viorng.pdb", Some win8_32; "viorng/w8/x86/viorng.sys", Some win8_32; "viorng/w8/x86/viorngci.dll", Some win8_32; "viorng/w8/x86/viorngum.dll", Some win8_32; "vioscsi/2k12/amd64/vioscsi.cat", Some win2k12_64; "vioscsi/2k12/amd64/vioscsi.inf", Some win2k12_64; "vioscsi/2k12/amd64/vioscsi.pdb", Some win2k12_64; "vioscsi/2k12/amd64/vioscsi.sys", Some win2k12_64; "vioscsi/2k12R2/amd64/vioscsi.cat", Some win2k12r2_64; "vioscsi/2k12R2/amd64/vioscsi.inf", Some win2k12r2_64; "vioscsi/2k12R2/amd64/vioscsi.pdb", Some win2k12r2_64; "vioscsi/2k12R2/amd64/vioscsi.sys", Some win2k12r2_64; "vioscsi/2k8/amd64/vioscsi.cat", Some win2k8_64; "vioscsi/2k8/amd64/vioscsi.inf", Some win2k8_64; "vioscsi/2k8/amd64/vioscsi.pdb", Some win2k8_64; "vioscsi/2k8/amd64/vioscsi.sys", Some win2k8_64; "vioscsi/2k8/x86/vioscsi.cat", Some win2k8_32; "vioscsi/2k8/x86/vioscsi.inf", Some win2k8_32; "vioscsi/2k8/x86/vioscsi.pdb", Some win2k8_32; "vioscsi/2k8/x86/vioscsi.sys", Some win2k8_32; "vioscsi/2k8R2/amd64/vioscsi.cat", Some win2k8r2_64; "vioscsi/2k8R2/amd64/vioscsi.inf", Some win2k8r2_64; "vioscsi/2k8R2/amd64/vioscsi.pdb", Some win2k8r2_64; "vioscsi/2k8R2/amd64/vioscsi.sys", Some win2k8r2_64; "vioscsi/w7/amd64/vioscsi.cat", Some win7_64; "vioscsi/w7/amd64/vioscsi.inf", Some win7_64; "vioscsi/w7/amd64/vioscsi.pdb", Some win7_64; "vioscsi/w7/amd64/vioscsi.sys", Some win7_64; "vioscsi/w7/x86/vioscsi.cat", Some win7_32; "vioscsi/w7/x86/vioscsi.inf", Some win7_32; "vioscsi/w7/x86/vioscsi.pdb", Some win7_32; "vioscsi/w7/x86/vioscsi.sys", Some win7_32; "vioscsi/w8.1/amd64/vioscsi.cat", Some win8_1_64; "vioscsi/w8.1/amd64/vioscsi.inf", Some win8_1_64; "vioscsi/w8.1/amd64/vioscsi.pdb", Some win8_1_64; "vioscsi/w8.1/amd64/vioscsi.sys", Some win8_1_64; "vioscsi/w8.1/x86/vioscsi.cat", Some win8_1_32; "vioscsi/w8.1/x86/vioscsi.inf", Some win8_1_32; "vioscsi/w8.1/x86/vioscsi.pdb", Some win8_1_32; "vioscsi/w8.1/x86/vioscsi.sys", Some win8_1_32; "vioscsi/w8/amd64/vioscsi.cat", Some win8_64; "vioscsi/w8/amd64/vioscsi.inf", Some win8_64; "vioscsi/w8/amd64/vioscsi.pdb", Some win8_64; "vioscsi/w8/amd64/vioscsi.sys", Some win8_64; "vioscsi/w8/x86/vioscsi.cat", Some win8_32; "vioscsi/w8/x86/vioscsi.inf", Some win8_32; "vioscsi/w8/x86/vioscsi.pdb", Some win8_32; "vioscsi/w8/x86/vioscsi.sys", Some win8_32; "vioserial/2k12/amd64/WdfCoInstaller01011.dll", Some win2k12_64; "vioserial/2k12/amd64/vioser.cat", Some win2k12_64; "vioserial/2k12/amd64/vioser.inf", Some win2k12_64; "vioserial/2k12/amd64/vioser.pdb", Some win2k12_64; "vioserial/2k12/amd64/vioser.sys", Some win2k12_64; "vioserial/2k12R2/amd64/WdfCoInstaller01011.dll", Some win2k12r2_64; "vioserial/2k12R2/amd64/vioser.cat", Some win2k12r2_64; "vioserial/2k12R2/amd64/vioser.inf", Some win2k12r2_64; "vioserial/2k12R2/amd64/vioser.pdb", Some win2k12r2_64; "vioserial/2k12R2/amd64/vioser.sys", Some win2k12r2_64; "vioserial/2k3/amd64/WdfCoInstaller01009.dll", Some win2k3_64; "vioserial/2k3/amd64/vioser.cat", Some win2k3_64; "vioserial/2k3/amd64/vioser.inf", Some win2k3_64; "vioserial/2k3/amd64/vioser.pdb", Some win2k3_64; "vioserial/2k3/amd64/vioser.sys", Some win2k3_64; "vioserial/2k3/x86/WdfCoInstaller01009.dll", Some win2k3_32; "vioserial/2k3/x86/vioser.cat", Some win2k3_32; "vioserial/2k3/x86/vioser.inf", Some win2k3_32; "vioserial/2k3/x86/vioser.pdb", Some win2k3_32; "vioserial/2k3/x86/vioser.sys", Some win2k3_32; "vioserial/2k8/amd64/WdfCoInstaller01009.dll", Some win2k8_64; "vioserial/2k8/amd64/vioser.cat", Some win2k8_64; "vioserial/2k8/amd64/vioser.inf", Some win2k8_64; "vioserial/2k8/amd64/vioser.pdb", Some win2k8_64; "vioserial/2k8/amd64/vioser.sys", Some win2k8_64; "vioserial/2k8/x86/WdfCoInstaller01009.dll", Some win2k8_32; "vioserial/2k8/x86/vioser.cat", Some win2k8_32; "vioserial/2k8/x86/vioser.inf", Some win2k8_32; "vioserial/2k8/x86/vioser.pdb", Some win2k8_32; "vioserial/2k8/x86/vioser.sys", Some win2k8_32; "vioserial/2k8R2/amd64/WdfCoInstaller01009.dll", Some win2k8r2_64; "vioserial/2k8R2/amd64/vioser.cat", Some win2k8r2_64; "vioserial/2k8R2/amd64/vioser.inf", Some win2k8r2_64; "vioserial/2k8R2/amd64/vioser.pdb", Some win2k8r2_64; "vioserial/2k8R2/amd64/vioser.sys", Some win2k8r2_64; "vioserial/w7/amd64/WdfCoInstaller01009.dll", Some win7_64; "vioserial/w7/amd64/vioser.cat", Some win7_64; "vioserial/w7/amd64/vioser.inf", Some win7_64; "vioserial/w7/amd64/vioser.pdb", Some win7_64; "vioserial/w7/amd64/vioser.sys", Some win7_64; "vioserial/w7/x86/WdfCoInstaller01009.dll", Some win7_32; "vioserial/w7/x86/vioser.cat", Some win7_32; "vioserial/w7/x86/vioser.inf", Some win7_32; "vioserial/w7/x86/vioser.pdb", Some win7_32; "vioserial/w7/x86/vioser.sys", Some win7_32; "vioserial/w8.1/amd64/WdfCoInstaller01011.dll", Some win8_1_64; "vioserial/w8.1/amd64/vioser.cat", Some win8_1_64; "vioserial/w8.1/amd64/vioser.inf", Some win8_1_64; "vioserial/w8.1/amd64/vioser.pdb", Some win8_1_64; "vioserial/w8.1/amd64/vioser.sys", Some win8_1_64; "vioserial/w8.1/x86/WdfCoInstaller01011.dll", Some win8_1_32; "vioserial/w8.1/x86/vioser.cat", Some win8_1_32; "vioserial/w8.1/x86/vioser.inf", Some win8_1_32; "vioserial/w8.1/x86/vioser.pdb", Some win8_1_32; "vioserial/w8.1/x86/vioser.sys", Some win8_1_32; "vioserial/w8/amd64/WdfCoInstaller01011.dll", Some win8_64; "vioserial/w8/amd64/vioser.cat", Some win8_64; "vioserial/w8/amd64/vioser.inf", Some win8_64; "vioserial/w8/amd64/vioser.pdb", Some win8_64; "vioserial/w8/amd64/vioser.sys", Some win8_64; "vioserial/w8/x86/WdfCoInstaller01011.dll", Some win8_32; "vioserial/w8/x86/vioser.cat", Some win8_32; "vioserial/w8/x86/vioser.inf", Some win8_32; "vioserial/w8/x86/vioser.pdb", Some win8_32; "vioserial/w8/x86/vioser.sys", Some win8_32; "vioserial/xp/x86/WdfCoInstaller01009.dll", Some winxp_32; "vioserial/xp/x86/vioser.cat", Some winxp_32; "vioserial/xp/x86/vioser.inf", Some winxp_32; "vioserial/xp/x86/vioser.pdb", Some winxp_32; "vioserial/xp/x86/vioser.sys", Some winxp_32; "viostor/2k12/amd64/viostor.cat", Some win2k12_64; "viostor/2k12/amd64/viostor.inf", Some win2k12_64; "viostor/2k12/amd64/viostor.pdb", Some win2k12_64; "viostor/2k12/amd64/viostor.sys", Some win2k12_64; "viostor/2k12R2/amd64/viostor.cat", Some win2k12r2_64; "viostor/2k12R2/amd64/viostor.inf", Some win2k12r2_64; "viostor/2k12R2/amd64/viostor.pdb", Some win2k12r2_64; "viostor/2k12R2/amd64/viostor.sys", Some win2k12r2_64; "viostor/2k3/amd64/viostor.cat", Some win2k3_64; "viostor/2k3/amd64/viostor.inf", Some win2k3_64; "viostor/2k3/amd64/viostor.pdb", Some win2k3_64; "viostor/2k3/amd64/viostor.sys", Some win2k3_64; "viostor/2k3/x86/viostor.cat", Some win2k3_32; "viostor/2k3/x86/viostor.inf", Some win2k3_32; "viostor/2k3/x86/viostor.pdb", Some win2k3_32; "viostor/2k3/x86/viostor.sys", Some win2k3_32; "viostor/2k8/amd64/viostor.cat", Some win2k8_64; "viostor/2k8/amd64/viostor.inf", Some win2k8_64; "viostor/2k8/amd64/viostor.pdb", Some win2k8_64; "viostor/2k8/amd64/viostor.sys", Some win2k8_64; "viostor/2k8/x86/viostor.cat", Some win2k8_32; "viostor/2k8/x86/viostor.inf", Some win2k8_32; "viostor/2k8/x86/viostor.pdb", Some win2k8_32; "viostor/2k8/x86/viostor.sys", Some win2k8_32; "viostor/2k8R2/amd64/viostor.cat", Some win2k8r2_64; "viostor/2k8R2/amd64/viostor.inf", Some win2k8r2_64; "viostor/2k8R2/amd64/viostor.pdb", Some win2k8r2_64; "viostor/2k8R2/amd64/viostor.sys", Some win2k8r2_64; "viostor/w7/amd64/viostor.cat", Some win7_64; "viostor/w7/amd64/viostor.inf", Some win7_64; "viostor/w7/amd64/viostor.pdb", Some win7_64; "viostor/w7/amd64/viostor.sys", Some win7_64; "viostor/w7/x86/viostor.cat", Some win7_32; "viostor/w7/x86/viostor.inf", Some win7_32; "viostor/w7/x86/viostor.pdb", Some win7_32; "viostor/w7/x86/viostor.sys", Some win7_32; "viostor/w8.1/amd64/viostor.cat", Some win8_1_64; "viostor/w8.1/amd64/viostor.inf", Some win8_1_64; "viostor/w8.1/amd64/viostor.pdb", Some win8_1_64; "viostor/w8.1/amd64/viostor.sys", Some win8_1_64; "viostor/w8.1/x86/viostor.cat", Some win8_1_32; "viostor/w8.1/x86/viostor.inf", Some win8_1_32; "viostor/w8.1/x86/viostor.pdb", Some win8_1_32; "viostor/w8.1/x86/viostor.sys", Some win8_1_32; "viostor/w8/amd64/viostor.cat", Some win8_64; "viostor/w8/amd64/viostor.inf", Some win8_64; "viostor/w8/amd64/viostor.pdb", Some win8_64; "viostor/w8/amd64/viostor.sys", Some win8_64; "viostor/w8/x86/viostor.cat", Some win8_32; "viostor/w8/x86/viostor.inf", Some win8_32; "viostor/w8/x86/viostor.pdb", Some win8_32; "viostor/w8/x86/viostor.sys", Some win8_32; "viostor/xp/x86/viostor.cat", Some winxp_32; "viostor/xp/x86/viostor.inf", Some winxp_32; "viostor/xp/x86/viostor.pdb", Some winxp_32; "viostor/xp/x86/viostor.sys", Some winxp_32; "virtio-win-1.7.4_amd64.vfd", None; "virtio-win-1.7.4_x86.vfd", None; "virtio-win_license.txt", None; (* Paths from the unpacked virtio-win 1.7.4 directory. *) "virtio-win-1.7.4.iso", None; "virtio-win-1.7.4_amd64.vfd", None; "guest-agent/qemu-ga-x86.msi", None; "guest-agent/qemu-ga-x64.msi", None; "drivers/i386/Win8.1/viostor.inf", Some win8_1_32; "drivers/i386/Win8.1/viostor.sys", Some win8_1_32; "drivers/i386/Win8.1/vioscsi.cat", Some win8_1_32; "drivers/i386/Win8.1/netkvm.inf", Some win8_1_32; "drivers/i386/Win8.1/netkvm.sys", Some win8_1_32; "drivers/i386/Win8.1/viostor.cat", Some win8_1_32; "drivers/i386/Win8.1/vioscsi.sys", Some win8_1_32; "drivers/i386/Win8.1/netkvm.cat", Some win8_1_32; "drivers/i386/Win8.1/vioscsi.inf", Some win8_1_32; "drivers/i386/Win2008/viostor.inf", Some win2k8_32; "drivers/i386/Win2008/viostor.sys", Some win2k8_32; "drivers/i386/Win2008/vioscsi.cat", Some win2k8_32; "drivers/i386/Win2008/netkvm.inf", Some win2k8_32; "drivers/i386/Win2008/netkvm.sys", Some win2k8_32; "drivers/i386/Win2008/viostor.cat", Some win2k8_32; "drivers/i386/Win2008/vioscsi.sys", Some win2k8_32; "drivers/i386/Win2008/netkvm.cat", Some win2k8_32; "drivers/i386/Win2008/vioscsi.inf", Some win2k8_32; "drivers/i386/Win7/viostor.inf", Some win7_32; "drivers/i386/Win7/viostor.sys", Some win7_32; "drivers/i386/Win7/qxldd.dll", Some win7_32; "drivers/i386/Win7/qxl.sys", Some win7_32; "drivers/i386/Win7/vioscsi.cat", Some win7_32; "drivers/i386/Win7/netkvm.inf", Some win7_32; "drivers/i386/Win7/netkvm.sys", Some win7_32; "drivers/i386/Win7/viostor.cat", Some win7_32; "drivers/i386/Win7/qxl.inf", Some win7_32; "drivers/i386/Win7/vioscsi.sys", Some win7_32; "drivers/i386/Win7/qxl.cat", Some win7_32; "drivers/i386/Win7/netkvm.cat", Some win7_32; "drivers/i386/Win7/vioscsi.inf", Some win7_32; "drivers/i386/Win2003/viostor.inf", Some win2k3_32; "drivers/i386/Win2003/viostor.sys", Some win2k3_32; "drivers/i386/Win2003/netkvm.inf", Some win2k3_32; "drivers/i386/Win2003/netkvm.sys", Some win2k3_32; "drivers/i386/Win2003/viostor.cat", Some win2k3_32; "drivers/i386/Win2003/netkvm.cat", Some win2k3_32; "drivers/i386/Win8/viostor.inf", Some win8_32; "drivers/i386/Win8/viostor.sys", Some win8_32; "drivers/i386/Win8/vioscsi.cat", Some win8_32; "drivers/i386/Win8/netkvm.inf", Some win8_32; "drivers/i386/Win8/netkvm.sys", Some win8_32; "drivers/i386/Win8/viostor.cat", Some win8_32; "drivers/i386/Win8/vioscsi.sys", Some win8_32; "drivers/i386/Win8/netkvm.cat", Some win8_32; "drivers/i386/Win8/vioscsi.inf", Some win8_32; "drivers/i386/WinXP/viostor.inf", Some winxp_32; "drivers/i386/WinXP/viostor.sys", Some winxp_32; "drivers/i386/WinXP/qxldd.dll", Some winxp_32; "drivers/i386/WinXP/qxl.sys", Some winxp_32; "drivers/i386/WinXP/netkvm.inf", Some winxp_32; "drivers/i386/WinXP/netkvm.sys", Some winxp_32; "drivers/i386/WinXP/viostor.cat", Some winxp_32; "drivers/i386/WinXP/qxl.inf", Some winxp_32; "drivers/i386/WinXP/qxl.cat", Some winxp_32; "drivers/i386/WinXP/netkvm.cat", Some winxp_32; "drivers/amd64/Win8.1/viostor.inf", Some win8_1_64; "drivers/amd64/Win8.1/viostor.sys", Some win8_1_64; "drivers/amd64/Win8.1/vioscsi.cat", Some win8_1_64; "drivers/amd64/Win8.1/netkvm.inf", Some win8_1_64; "drivers/amd64/Win8.1/netkvm.sys", Some win8_1_64; "drivers/amd64/Win8.1/viostor.cat", Some win8_1_64; "drivers/amd64/Win8.1/vioscsi.sys", Some win8_1_64; "drivers/amd64/Win8.1/netkvm.cat", Some win8_1_64; "drivers/amd64/Win8.1/vioscsi.inf", Some win8_1_64; "drivers/amd64/Win2008/viostor.inf", Some win2k8_64; "drivers/amd64/Win2008/viostor.sys", Some win2k8_64; "drivers/amd64/Win2008/vioscsi.cat", Some win2k8_64; "drivers/amd64/Win2008/netkvm.inf", Some win2k8_64; "drivers/amd64/Win2008/netkvm.sys", Some win2k8_64; "drivers/amd64/Win2008/viostor.cat", Some win2k8_64; "drivers/amd64/Win2008/vioscsi.sys", Some win2k8_64; "drivers/amd64/Win2008/netkvm.cat", Some win2k8_64; "drivers/amd64/Win2008/vioscsi.inf", Some win2k8_64; "drivers/amd64/Win7/viostor.inf", Some win7_64; "drivers/amd64/Win7/viostor.sys", Some win7_64; "drivers/amd64/Win7/qxldd.dll", Some win7_64; "drivers/amd64/Win7/qxl.sys", Some win7_64; "drivers/amd64/Win7/vioscsi.cat", Some win7_64; "drivers/amd64/Win7/netkvm.inf", Some win7_64; "drivers/amd64/Win7/netkvm.sys", Some win7_64; "drivers/amd64/Win7/viostor.cat", Some win7_64; "drivers/amd64/Win7/qxl.inf", Some win7_64; "drivers/amd64/Win7/vioscsi.sys", Some win7_64; "drivers/amd64/Win7/qxl.cat", Some win7_64; "drivers/amd64/Win7/netkvm.cat", Some win7_64; "drivers/amd64/Win7/vioscsi.inf", Some win7_64; "drivers/amd64/Win2003/viostor.inf", Some win2k3_64; "drivers/amd64/Win2003/viostor.sys", Some win2k3_64; "drivers/amd64/Win2003/netkvm.inf", Some win2k3_64; "drivers/amd64/Win2003/netkvm.sys", Some win2k3_64; "drivers/amd64/Win2003/viostor.cat", Some win2k3_64; "drivers/amd64/Win2003/netkvm.cat", Some win2k3_64; "drivers/amd64/Win8/viostor.inf", Some win8_64; "drivers/amd64/Win8/viostor.sys", Some win8_64; "drivers/amd64/Win8/vioscsi.cat", Some win8_64; "drivers/amd64/Win8/netkvm.inf", Some win8_64; "drivers/amd64/Win8/netkvm.sys", Some win8_64; "drivers/amd64/Win8/viostor.cat", Some win8_64; "drivers/amd64/Win8/vioscsi.sys", Some win8_64; "drivers/amd64/Win8/netkvm.cat", Some win8_64; "drivers/amd64/Win8/vioscsi.inf", Some win8_64; "drivers/amd64/Win2012/viostor.inf", Some win2k12_64; "drivers/amd64/Win2012/viostor.sys", Some win2k12_64; "drivers/amd64/Win2012/vioscsi.cat", Some win2k12_64; "drivers/amd64/Win2012/netkvm.inf", Some win2k12_64; "drivers/amd64/Win2012/netkvm.sys", Some win2k12_64; "drivers/amd64/Win2012/viostor.cat", Some win2k12_64; "drivers/amd64/Win2012/vioscsi.sys", Some win2k12_64; "drivers/amd64/Win2012/netkvm.cat", Some win2k12_64; "drivers/amd64/Win2012/vioscsi.inf", Some win2k12_64; "drivers/amd64/Win2008R2/viostor.inf", Some win2k8r2_64; "drivers/amd64/Win2008R2/viostor.sys", Some win2k8r2_64; "drivers/amd64/Win2008R2/qxldd.dll", Some win2k8r2_64; "drivers/amd64/Win2008R2/qxl.sys", Some win2k8r2_64; "drivers/amd64/Win2008R2/vioscsi.cat", Some win2k8r2_64; "drivers/amd64/Win2008R2/netkvm.inf", Some win2k8r2_64; "drivers/amd64/Win2008R2/netkvm.sys", Some win2k8r2_64; "drivers/amd64/Win2008R2/viostor.cat", Some win2k8r2_64; "drivers/amd64/Win2008R2/qxl.inf", Some win2k8r2_64; "drivers/amd64/Win2008R2/vioscsi.sys", Some win2k8r2_64; "drivers/amd64/Win2008R2/qxl.cat", Some win2k8r2_64; "drivers/amd64/Win2008R2/netkvm.cat", Some win2k8r2_64; "drivers/amd64/Win2008R2/vioscsi.inf", Some win2k8r2_64; "drivers/amd64/Win2012R2/viostor.inf", Some win2k12r2_64; "drivers/amd64/Win2012R2/viostor.sys", Some win2k12r2_64; "drivers/amd64/Win2012R2/vioscsi.cat", Some win2k12r2_64; "drivers/amd64/Win2012R2/netkvm.inf", Some win2k12r2_64; "drivers/amd64/Win2012R2/netkvm.sys", Some win2k12r2_64; "drivers/amd64/Win2012R2/viostor.cat", Some win2k12r2_64; "drivers/amd64/Win2012R2/vioscsi.sys", Some win2k12r2_64; "drivers/amd64/Win2012R2/netkvm.cat", Some win2k12r2_64; "drivers/amd64/Win2012R2/vioscsi.inf", Some win2k12r2_64; "virtio-win-1.7.4_x86.vfd", None; ] in (* Test each path against each version of Windows. *) let printer = string_of_bool in List.iter ( fun (path, correct_windows) -> match correct_windows with | None -> List.iter ( fun win -> let msg = sprintf "path %s should not match %s" path win.i_product_name in assert_equal ~printer ~msg false (Windows_virtio.UNIT_TESTS.virtio_iso_path_matches_guest_os path win) ) all_windows | Some correct_windows -> List.iter ( fun win -> let expected = win = correct_windows in let msg = if expected then sprintf "path %s should match %s" path win.i_product_name else sprintf "path %s should not match %s" path win.i_product_name in assert_equal ~printer ~msg expected (Windows_virtio.UNIT_TESTS.virtio_iso_path_matches_guest_os path win) ) all_windows ) paths let test_qemu_img_supports ctx = (* No assertion here, we don't know if qemu-img supports the * feature, so just run the code and make sure it doesn't crash. *) ignore (Utils.qemu_img_supports_offset_and_size ()) (* Test the VMX file parser in the Parse_vmx module. *) let test_vmx_parse_string ctx = let cmp = Parse_vmx.equal in let printer = Parse_vmx.to_string 0 in (* This should be identical to the empty file. *) let t = Parse_vmx.parse_string "\ test.foo = \"a\" test.bar = \"b\" test.present = \"FALSE\" " in assert_equal ~cmp ~printer Parse_vmx.empty t; (* Test weird escapes. *) let t1 = Parse_vmx.parse_string "\ foo = \"a|20|21b\" " in let t2 = Parse_vmx.parse_string "\ foo = \"a !b\" " in assert_equal ~cmp ~printer t1 t2; (* Test case insensitivity. *) let t1 = Parse_vmx.parse_string "\ foo = \"abc\" " in let t2 = Parse_vmx.parse_string "\ fOO = \"abc\" " in assert_equal ~cmp ~printer t1 t2; let t = Parse_vmx.parse_string "\ flag = \"true\" " in assert_bool "parse_vmx: failed case insensitivity test for booleans #1" (Parse_vmx.get_bool t ["FLAG"] = Some true); let t = Parse_vmx.parse_string "\ flag = \"TRUE\" " in assert_bool "parse_vmx: failed case insensitivity test for booleans #2" (Parse_vmx.get_bool t ["Flag"] = Some true); (* Missing keys. *) let t = Parse_vmx.parse_string "\ foo = \"a\" " in assert_bool "parse_vmx: failed missing key test" (Parse_vmx.get_string t ["bar"] = None); (* namespace_present function *) let t = Parse_vmx.parse_string "\ foo.bar.present = \"TRUE\" foo.baz.present = \"FALSE\" foo.a.b = \"abc\" foo.a.c = \"abc\" foo.b = \"abc\" foo.c.a = \"abc\" foo.c.b = \"abc\" " in assert_bool "parse_vmx: namespace_present #1" (Parse_vmx.namespace_present t ["foo"] = true); assert_bool "parse_vmx: namespace_present #2" (Parse_vmx.namespace_present t ["foo"; "bar"] = true); assert_bool "parse_vmx: namespace_present #3" (* this whole namespace should have been culled *) (Parse_vmx.namespace_present t ["foo"; "baz"] = false); assert_bool "parse_vmx: namespace_present #4" (Parse_vmx.namespace_present t ["foo"; "a"] = true); assert_bool "parse_vmx: namespace_present #5" (* this is a key, not a namespace *) (Parse_vmx.namespace_present t ["foo"; "a"; "b"] = false); assert_bool "parse_vmx: namespace_present #6" (Parse_vmx.namespace_present t ["foo"; "b"] = false); assert_bool "parse_vmx: namespace_present #7" (Parse_vmx.namespace_present t ["foo"; "c"] = true); assert_bool "parse_vmx: namespace_present #8" (Parse_vmx.namespace_present t ["foo"; "d"] = false); (* map function *) let t = Parse_vmx.parse_string "\ foo.bar.present = \"TRUE\" foo.baz.present = \"FALSE\" foo.a.b = \"abc\" foo.a.c = \"abc\" foo.b = \"abc\" foo.c.a = \"abc\" foo.c.b = \"abc\" " in let xs = Parse_vmx.map ( fun path -> let path = String.concat "." path in function | None -> sprintf "%s.present = \"true\"\n" path | Some v -> sprintf "%s = \"%s\"\n" path v ) t in let xs = List.sort compare xs in let s = String.concat "" xs in assert_equal ~printer:identity "\ foo.a.b = \"abc\" foo.a.c = \"abc\" foo.a.present = \"true\" foo.b = \"abc\" foo.bar.present = \"TRUE\" foo.bar.present = \"true\" foo.c.a = \"abc\" foo.c.b = \"abc\" foo.c.present = \"true\" foo.present = \"true\" " s; (* select_namespaces function *) let t1 = Parse_vmx.parse_string "\ foo.bar.present = \"TRUE\" foo.a.b = \"abc\" foo.a.c = \"abc\" foo.b = \"abc\" foo.c.a = \"abc\" foo.c.b = \"abc\" " in let t2 = Parse_vmx.select_namespaces (function ["foo"] -> true | _ -> false) t1 in assert_equal ~cmp ~printer t1 t2; let t1 = Parse_vmx.parse_string "\ foo.bar.present = \"TRUE\" foo.a.b = \"abc\" foo.a.c = \"abc\" foo.b = \"abc\" foo.c.a = \"abc\" foo.c.b = \"abc\" foo.c.c.d.e.f = \"abc\" " in let t1 = Parse_vmx.select_namespaces (function ["foo"; "a"] -> true | _ -> false) t1 in let t2 = Parse_vmx.parse_string "\ foo.a.b = \"abc\" foo.a.c = \"abc\" " in assert_equal ~cmp ~printer t2 t1 (* Suites declaration. *) let suite = "virt-v2v" >::: [ "Create_ovf.get_ostype" >:: test_get_ostype; "Windows_virtio.virtio_iso_path_matches_guest_os" >:: test_virtio_iso_path_matches_guest_os; "Utils.qemu_img_supports" >:: test_qemu_img_supports; "Parse_vmx.parse_string" >::test_vmx_parse_string; ] let () = run_test_tt_main suite virt-v2v-1.44.2/v2v/PaxHeaders/libosinfo_utils.mli0000644000000000000000000000013214010266573017007 xustar0030 mtime=1612803451.489715306 30 atime=1637862739.490417421 30 ctime=1637862790.723849812 virt-v2v-1.44.2/v2v/libosinfo_utils.mli0000644000175000017500000000227614010266573020622 0ustar00rjonesrjones00000000000000(* virt-v2v * Copyright (C) 2020 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *) (** This module implements helper functions based on libosinfo. *) val get_os_by_short_id : string -> Libosinfo.osinfo_os (** [get_os_by_short_id short-id] get the [Libosinfo.osinfo_os] that has the specified [short-id]. Raise [Not_found] in case there is no matching OS. *) val string_of_osinfo_device_driver : Libosinfo.osinfo_device_driver -> string (** Convert a [osinfo_device_driver] to a printable string for debugging. *) virt-v2v-1.44.2/v2v/PaxHeaders/input_libvirt_vcenter_https.mli0000644000000000000000000000013213665154464021457 xustar0030 mtime=1591007540.875706861 30 atime=1637862739.489417433 30 ctime=1637862790.704850022 virt-v2v-1.44.2/v2v/input_libvirt_vcenter_https.mli0000664000175000017500000000171713665154464023273 0ustar00rjonesrjones00000000000000(* virt-v2v * Copyright (C) 2009-2020 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *) (** [-i libvirt] when the source is VMware vCenter *) val input_libvirt_vcenter_https : Libvirt.rw Libvirt.Connect.t Lazy.t -> string -> string option -> Xml.uri -> string -> string -> Types.input virt-v2v-1.44.2/v2v/PaxHeaders/var_expander.mli0000644000000000000000000000013213631710510016252 xustar0030 mtime=1583845704.275868966 30 atime=1637862739.496417355 30 ctime=1637862790.810848848 virt-v2v-1.44.2/v2v/var_expander.mli0000664000175000017500000000522213631710510020061 0ustar00rjonesrjones00000000000000(* virt-v2v * Copyright (C) 2019 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *) (** Simple variable expander. This module provides the support to expand variables in strings, specified in the form of [%{name}]. For example: {v let str = "variable-%{INDEX} in %{INDEX} replaced %{INDEX} times" let index = ref 0 let fn = function | "INDEX" -> incr index; Some (string_of_int !index) | _ -> None in let str = Var_expander.replace_fn str fn (* now str is "variable-1 in 2 replaced 3 times" *) v} The names of variables can contain only ASCII letters (uppercase, and lowercase), digits, underscores, and dashes. The replacement is done in a single pass: this means that if a variable is replaced with the text of a variable, that new text is kept as is in the final output. In practice: {v let str = "%{VAR}" let str = Var_expander.replace_list str [("VAR", "%{VAR}")] (* now str is "%{VAR}" *) v} *) exception Invalid_variable of string (** Invalid variable name error. In case a variable contains characters not allowed, then this exception with the actual unacceptable variable. *) val scan_variables : string -> string list (** Scan the pattern string for all the variables available. This can raise {!Invalid_variable} in case there are invalid variable names. *) val replace_fn : string -> (string -> string option) -> string (** Replaces a string expanding all the variables. The replacement function specify how a variable is replaced; if [None] is returned, then that variable is not replaced. This can raise {!Invalid_variable} in case there are invalid variable names. *) val replace_list : string -> (string * string) list -> string (** Replaces a string expanding all the variables. The replacement list specify how a variable is replaced; if it is not specified in the list, then that variable is not replaced. This can raise {!Invalid_variable} in case there are invalid variable names. *) virt-v2v-1.44.2/v2v/PaxHeaders/create_json.ml0000644000000000000000000000013214016222342015716 xustar0030 mtime=1614357730.944228819 30 atime=1637862739.506417245 30 ctime=1637862790.853848371 virt-v2v-1.44.2/v2v/create_json.ml0000644000175000017500000002526014016222342017527 0ustar00rjonesrjones00000000000000(* virt-v2v * Copyright (C) 2019 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *) open Std_utils open C_utils open Tools_utils open Types open Utils module G = Guestfs let json_list_of_string_list = List.map (fun x -> JSON.String x) let json_list_of_string_string_list = List.map (fun (x, y) -> x, JSON.String y) let push_optional_string lst name = function | None -> () | Some v -> List.push_back lst (name, JSON.String v) let push_optional_int lst name = function | None -> () | Some v -> List.push_back lst (name, JSON.Int (Int64.of_int v)) let json_unknown_string = function | "unknown" -> JSON.Null | v -> JSON.String v let find_target_disk targets { s_disk_id = id } = try List.find (fun t -> t.target_overlay.ov_source.s_disk_id = id) targets with Not_found -> assert false let create_json_metadata source targets target_buses guestcaps inspect target_firmware = let doc = ref [ "version", JSON.Int 1L; "name", JSON.String source.s_name; "memory", JSON.Int source.s_memory; "vcpu", JSON.Int (Int64.of_int source.s_vcpu); ] in (match source.s_genid with | None -> () | Some genid -> List.push_back doc ("genid", JSON.String genid) ); if source.s_cpu_vendor <> None || source.s_cpu_model <> None || source.s_cpu_topology <> None then ( let cpu = ref [] in push_optional_string cpu "vendor" source.s_cpu_vendor; push_optional_string cpu "model" source.s_cpu_model; (match source.s_cpu_topology with | None -> () | Some { s_cpu_sockets; s_cpu_cores; s_cpu_threads } -> let attrs = [ "sockets", JSON.Int (Int64.of_int s_cpu_sockets); "cores", JSON.Int (Int64.of_int s_cpu_cores); "threads", JSON.Int (Int64.of_int s_cpu_threads); ] in List.push_back cpu ("topology", JSON.Dict attrs) ); List.push_back doc ("cpu", JSON.Dict !cpu); ); let firmware = let firmware_type = match target_firmware with | TargetBIOS -> "bios" | TargetUEFI -> "uefi" in let fw = ref [ "type", JSON.String firmware_type; ] in (match target_firmware with | TargetBIOS -> () | TargetUEFI -> let uefi_firmware = find_uefi_firmware guestcaps.gcaps_arch in let flags = List.map ( function | Uefi.UEFI_FLAG_SECURE_BOOT_REQUIRED -> "secure_boot_required" ) uefi_firmware.Uefi.flags in let uefi = ref [ "code", JSON.String uefi_firmware.Uefi.code; "vars", JSON.String uefi_firmware.Uefi.vars; "flags", JSON.List (json_list_of_string_list flags); ] in push_optional_string uefi "code-debug" uefi_firmware.Uefi.code_debug; List.push_back fw ("uefi", JSON.Dict !uefi) ); !fw in List.push_back doc ("firmware", JSON.Dict firmware); List.push_back doc ("features", JSON.List (json_list_of_string_list source.s_features)); let machine = match guestcaps.gcaps_machine with | I440FX -> "pc" | Q35 -> "q35" | Virt -> "virt" in List.push_back doc ("machine", JSON.String machine); let disks, removables = let disks = ref [] and removables = ref [] in let iter_bus bus_name drive_prefix i = function | BusSlotEmpty -> () | BusSlotDisk d -> (* Find the corresponding target disk. *) let t = find_target_disk targets d in let target_file = match t.target_file with | TargetFile s -> s | TargetURI _ -> assert false in let disk = [ "dev", JSON.String (drive_prefix ^ drive_name i); "bus", JSON.String bus_name; "format", JSON.String t.target_format; "file", JSON.String (absolute_path target_file); ] in List.push_back disks (JSON.Dict disk) | BusSlotRemovable { s_removable_type = CDROM } -> let cdrom = [ "type", JSON.String "cdrom"; "dev", JSON.String (drive_prefix ^ drive_name i); "bus", JSON.String bus_name; ] in List.push_back removables (JSON.Dict cdrom) | BusSlotRemovable { s_removable_type = Floppy } -> let floppy = [ "type", JSON.String "floppy"; "dev", JSON.String (drive_prefix ^ drive_name i); ] in List.push_back removables (JSON.Dict floppy) in Array.iteri (iter_bus "virtio" "vd") target_buses.target_virtio_blk_bus; Array.iteri (iter_bus "ide" "hd") target_buses.target_ide_bus; Array.iteri (iter_bus "scsi" "sd") target_buses.target_scsi_bus; Array.iteri (iter_bus "floppy" "fd") target_buses.target_floppy_bus; !disks, !removables in List.push_back doc ("disks", JSON.List disks); List.push_back doc ("removables", JSON.List removables); let nics = List.map ( fun { s_mac = mac; s_vnet_type = vnet_type; s_nic_model = nic_model; s_vnet = vnet; } -> let vnet_type_str = match vnet_type with | Bridge -> "bridge" | Network -> "network" in let nic = ref [ "vnet", JSON.String vnet; "vnet-type", JSON.String vnet_type_str; ] in let nic_model_str = Option.map string_of_nic_model nic_model in push_optional_string nic "model" nic_model_str; push_optional_string nic "mac" mac; JSON.Dict !nic ) source.s_nics in List.push_back doc ("nics", JSON.List nics); let guestcaps_dict = let block_bus = match guestcaps.gcaps_block_bus with | Virtio_blk -> "virtio-blk" | Virtio_SCSI -> "virtio-scsi" | IDE -> "ide" in let net_bus = match guestcaps.gcaps_net_bus with | Virtio_net -> "virtio-net" | E1000 -> "e1000" | RTL8139 -> "rtl8139" in let video = match guestcaps.gcaps_video with | QXL -> "qxl" | Cirrus -> "cirrus" in let machine = match guestcaps.gcaps_machine with | I440FX -> "i440fx" | Q35 -> "q35" | Virt -> "virt" in [ "block-bus", JSON.String block_bus; "net-bus", JSON.String net_bus; "video", JSON.String video; "machine", JSON.String machine; "arch", JSON.String guestcaps.gcaps_arch; "virtio-rng", JSON.Bool guestcaps.gcaps_virtio_rng; "virtio-balloon", JSON.Bool guestcaps.gcaps_virtio_balloon; "isa-pvpanic", JSON.Bool guestcaps.gcaps_isa_pvpanic; "virtio-socket", JSON.Bool guestcaps.gcaps_virtio_socket; "acpi", JSON.Bool guestcaps.gcaps_acpi; ] in List.push_back doc ("guestcaps", JSON.Dict guestcaps_dict); (match source.s_sound with | None -> () | Some { s_sound_model = model } -> let sound = [ "model", JSON.String (string_of_source_sound_model model); ] in List.push_back doc ("sound", JSON.Dict sound) ); (match source.s_display with | None -> () | Some d -> let display_type = match d.s_display_type with | Window -> "window" | VNC -> "vnc" | Spice -> "spice" in let display = ref [ "type", JSON.String display_type; ] in push_optional_string display "keymap" d.s_keymap; push_optional_string display "password" d.s_password; let listen = match d.s_listen with | LNoListen -> None | LAddress address -> Some [ "type", JSON.String "address"; "address", JSON.String address; ] | LNetwork network -> Some [ "type", JSON.String "network"; "network", JSON.String network; ] | LSocket None -> Some [ "type", JSON.String "socket"; "socket", JSON.Null; ] | LSocket (Some socket) -> Some [ "type", JSON.String "socket"; "socket", JSON.String socket; ] | LNone -> Some [ "type", JSON.String "none"; ] in (match listen with | None -> () | Some l -> List.push_back display ("listen", JSON.Dict l) ); push_optional_int display "port" d.s_port; List.push_back doc ("display", JSON.Dict !display) ); let inspect_dict = let apps = List.map ( fun { G.app2_name = name; app2_display_name = display_name; app2_epoch = epoch; app2_version = version; app2_release = release; app2_arch = arch; } -> JSON.Dict [ "name", JSON.String name; "display-name", JSON.String display_name; "epoch", JSON.Int (Int64.of_int32 epoch); "version", JSON.String version; "release", JSON.String release; "arch", JSON.String arch; ] ) inspect.i_apps in let firmware_dict = match inspect.i_firmware with | I_BIOS -> [ "type", JSON.String "bios"; ] | I_UEFI devices -> [ "type", JSON.String "uefi"; "devices", JSON.List (json_list_of_string_list devices); ] in [ "root", JSON.String inspect.i_root; "type", JSON.String inspect.i_type; "distro", json_unknown_string inspect.i_distro; "osinfo", json_unknown_string inspect.i_osinfo; "arch", JSON.String inspect.i_arch; "major-version", JSON.Int (Int64.of_int inspect.i_major_version); "minor-version", JSON.Int (Int64.of_int inspect.i_minor_version); "package-format", json_unknown_string inspect.i_package_format; "package-management", json_unknown_string inspect.i_package_management; "product-name", json_unknown_string inspect.i_product_name; "product-variant", json_unknown_string inspect.i_product_variant; "mountpoints", JSON.Dict (json_list_of_string_string_list inspect.i_mountpoints); "applications", JSON.List apps; "windows-systemroot", JSON.String inspect.i_windows_systemroot; "windows-software-hive", JSON.String inspect.i_windows_software_hive; "windows-system-hive", JSON.String inspect.i_windows_system_hive; "windows-current-control-set", JSON.String inspect.i_windows_current_control_set; "firmware", JSON.Dict firmware_dict; ] in List.push_back doc ("inspect", JSON.Dict inspect_dict); !doc virt-v2v-1.44.2/v2v/PaxHeaders/changeuid.mli0000644000000000000000000000013213641354341015532 xustar0030 mtime=1585830113.308308042 30 atime=1637862739.488417443 30 ctime=1637862790.676850332 virt-v2v-1.44.2/v2v/changeuid.mli0000664000175000017500000000533013641354341017341 0ustar00rjonesrjones00000000000000(* virt-v2v * Copyright (C) 2009-2020 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *) (** Functions for making files and directories as another user. [-o rhv] output mode has to write files as UID:GID 36:36, otherwise RHV cannot read them. Because the files are located on NFS (and hence might be root-squashed) we also cannot chown the files. We cannot setuid the whole process to 36:36 because it needs to do other root things like mounting and unmounting the NFS volume. The solution to this craziness is to fork a subprocess every time we need to create a file, setuid in the subprocess, and write the file. The subprocess then exits, leaving the main process still running as root. This mini-library encapsulates this tomfoolery into something that is slightly more sane to use. NB. We are {b not} dropping permissions for security reasons. This file has nothing to do with security. *) type t (** Abstract handle. *) val create : ?uid:int -> ?gid:int -> unit -> t (** Create handle. The optional [?uid] and [?gid] parameters are the user/group to run as. If omitted, then we don't change user and/or group (but we still do the forking anyway). *) val mkdir : t -> string -> int -> unit (** [mkdir t path perm] creates the directory [path] with mode [perm]. *) val rmdir : t -> string -> unit (** [rmdir t path] removes the directory [path]. *) val make_file : t -> string -> string -> unit (** [make_file t path content] creates the file [path] with content [content]. The current umask controls file permissions. *) val output : t -> string -> (out_channel -> unit) -> unit (** [output t path f] creates the file [path] with content from function [f]. The current umask controls file permissions. *) val unlink : t -> string -> unit (** [unlink t path] deletes the file [path]. *) val func : t -> (unit -> unit) -> unit (** [func t f] runs the arbitrary function [f]. *) val command : t -> string -> unit (** [command t cmd] runs [cmd] as the alternate user/group after forking. *) virt-v2v-1.44.2/v2v/PaxHeaders/DOM.mli0000644000000000000000000000013213641354341014222 xustar0030 mtime=1585830113.308308042 30 atime=1637862739.487417455 30 ctime=1637862790.695850122 virt-v2v-1.44.2/v2v/DOM.mli0000664000175000017500000000544413641354341016037 0ustar00rjonesrjones00000000000000(* virt-v2v * Copyright (C) 2009-2020 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *) (** Poor man's XML DOM, mutable for ease of modification. *) type element type doc = Doc of element type attr = string * string type node = | PCData of string (** Text. *) | Comment of string (** *) | Element of element (** with attrs and children *) val doc : string -> attr list -> node list -> doc (** A quick way to create a document. *) val e : string -> attr list -> node list -> node (** A quick way to create elements. Typical use is: {v e "foo" [] [ e "bar" [] [] e "baz" [ "a", "b"; "c", "d"] [] ] v} which creates the following OCaml tree structure: {v Element { e_name = "foo"; e_attrs = []; e_children = [ Element { e_name = "bar"; ... }; Element { e_name = "baz"; e_attrs = [ "a", "b"; "c", "d" ]; ... }; ] } v} which corresponds to the following XML: {v v} *) val doc_to_string : doc -> string (** Convert a document to a string representation. *) val doc_to_chan : out_channel -> doc -> unit (** Write the XML document to an output channel. *) val path_to_nodes : doc -> string list -> node list (** Search down the path and return a list of all matching elements. Returns an empty list if none were found. *) val filter_node_list_by_attr : node list -> attr -> node list (** Find DOM elements which have a particular attribute name=value (not recursively). If not found, returns an empty list. *) val find_node_by_attr : node list -> attr -> node (** Find the first DOM element which has a particular attribute name=value (not recursively). If not found, raises [Not_found]. *) val append_attr : attr -> node -> unit (** [element] must be an [Element _] node. [append_attr attr element] appends [attr] to the attributes of [element]. This mutates [element]. *) val append_child : node -> node -> unit (** [element] must be an [Element _] node. [append_child child element] appends [child] to the children of [element]. This mutates [element]. *) virt-v2v-1.44.2/v2v/PaxHeaders/create_json.mli0000644000000000000000000000013213631710510016070 xustar0030 mtime=1583845704.266869091 30 atime=1637862739.489417433 30 ctime=1637862790.688850199 virt-v2v-1.44.2/v2v/create_json.mli0000664000175000017500000000241513631710510017700 0ustar00rjonesrjones00000000000000(* virt-v2v * Copyright (C) 2019 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *) (** Create JSON metadata for [-o json]. *) val create_json_metadata : Types.source -> Types.target list -> Types.target_buses -> Types.guestcaps -> Types.inspect -> Types.target_firmware -> JSON.doc (** [create_json_metadata source targets target_buses guestcaps inspect target_firmware] creates the JSON with the majority of the data that virt-v2v used for the conversion. *) virt-v2v-1.44.2/v2v/PaxHeaders/input_libvirt_xen_ssh.ml0000644000000000000000000000013214011247676020057 xustar0030 mtime=1613057982.440453488 30 atime=1637862739.513417166 30 ctime=1637862790.887847994 virt-v2v-1.44.2/v2v/input_libvirt_xen_ssh.ml0000664000175000017500000000466514011247676021700 0ustar00rjonesrjones00000000000000(* virt-v2v * Copyright (C) 2009-2020 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *) (** [-i libvirt] when the source is Xen *) open Common_gettext.Gettext open Tools_utils open Types open Xml open Utils open Parse_libvirt_xml open Input_libvirt_other open Printf (* Subclass specialized for handling Xen over SSH. *) class input_libvirt_xen_ssh libvirt_conn input_conn input_password parsed_uri server guest = object (self) inherit input_libvirt libvirt_conn ~input_conn guest method precheck () = error_if_libvirt_does_not_support_json_backingfile (); error_if_no_ssh_agent () method source ?bandwidth () = debug "input_libvirt_xen_ssh: source: server %s" server; let source, disks, _ = parse_libvirt_domain ?bandwidth self#conn guest in let port = match parsed_uri.uri_port with | 0 | 22 -> None | i -> Some (string_of_int i) in let user = parsed_uri.uri_user in (* Map the filename (which is relative to the remote * Xen server) to an ssh URI pointing to nbdkit. *) let disks = List.map ( function | { p_source_disk = disk; p_source = P_dont_rewrite } -> disk | { p_source_disk = disk; p_source = P_source_dev path } | { p_source_disk = disk; p_source = P_source_file path } -> let password = match input_password with | None -> Nbdkit_sources.NoPassword | Some ip -> Nbdkit_sources.PasswordFile ip in let nbdkit = Nbdkit_sources.create_ssh ?bandwidth ~password ?port ~server ?user path in let qemu_uri = Nbdkit_sources.run nbdkit in { disk with s_qemu_uri = qemu_uri } ) disks in source, disks end let input_libvirt_xen_ssh = new input_libvirt_xen_ssh virt-v2v-1.44.2/v2v/PaxHeaders/output_local.ml0000644000000000000000000000013213641354341016144 xustar0030 mtime=1585830113.310308014 30 atime=1637862739.522417067 30 ctime=1637862790.915847684 virt-v2v-1.44.2/v2v/output_local.ml0000664000175000017500000000466213641354341017762 0ustar00rjonesrjones00000000000000(* virt-v2v * Copyright (C) 2009-2020 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *) open Printf open Std_utils open Tools_utils open Common_gettext.Gettext open Types open Utils open Create_libvirt_xml class output_local dir = object inherit output method as_options = sprintf "-o local -os %s" dir method prepare_targets source_name overlays _ = List.map ( fun (_, ov) -> TargetFile (dir // source_name ^ "-" ^ ov.ov_sd) ) overlays method supported_firmware = [ TargetBIOS; TargetUEFI ] method check_target_firmware guestcaps target_firmware = match target_firmware with | TargetBIOS -> () | TargetUEFI -> (* XXX Can remove this method when libvirt supports * since then it will be up to * libvirt to check this. *) error_unless_uefi_firmware guestcaps.gcaps_arch method create_metadata source targets target_buses guestcaps inspect target_firmware = (* We don't know what target features the hypervisor supports, but * assume a common set that libvirt supports. *) let target_features = match guestcaps.gcaps_arch with | "i686" -> [ "acpi"; "apic"; "pae" ] | "x86_64" -> [ "acpi"; "apic" ] | _ -> [] in let doc = create_libvirt_xml source targets target_buses guestcaps target_features target_firmware inspect in let name = source.s_name in let file = dir // name ^ ".xml" in with_open_out file (fun chan -> DOM.doc_to_chan chan doc); if verbose () then ( eprintf "resulting local libvirt XML:\n"; DOM.doc_to_chan stderr doc; eprintf "\n%!"; ) end let output_local = new output_local let () = Modules_list.register_output_module "local" virt-v2v-1.44.2/v2v/PaxHeaders/openstack_image_properties.ml0000644000000000000000000000013213641354341021037 xustar0030 mtime=1585830113.310308014 30 atime=1637862739.521417078 30 ctime=1637862790.874848139 virt-v2v-1.44.2/v2v/openstack_image_properties.ml0000664000175000017500000000616113641354341022651 0ustar00rjonesrjones00000000000000(* virt-v2v * Copyright (C) 2009-2020 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *) (* Convert metadata to a list of OpenStack image properties. *) open Printf open Std_utils open Types let create source target_buses guestcaps inspect target_firmware = let properties = ref [] in List.push_back_list properties [ "architecture", guestcaps.gcaps_arch; "hypervisor_type", "kvm"; "vm_mode", "hvm"; "hw_disk_bus", (match guestcaps.gcaps_block_bus with | Virtio_blk -> "virtio" | Virtio_SCSI -> "scsi" | IDE -> "ide"); "hw_vif_model", (match guestcaps.gcaps_net_bus with | Virtio_net -> "virtio" | E1000 -> "e1000" | RTL8139 -> "rtl8139"); "hw_video_model", (match guestcaps.gcaps_video with | QXL -> "qxl" | Cirrus -> "cirrus"); "hw_machine_type", (match guestcaps.gcaps_machine with | I440FX -> "pc" | Q35 -> "q35" | Virt -> "virt"); "os_type", inspect.i_type; "os_distro", (match inspect.i_distro with (* https://docs.openstack.org/python-glanceclient/latest/cli/property-keys.html *) | "archlinux" -> "arch" | "sles" -> "sled" | x -> x (* everything else is the same in libguestfs and OpenStack*) ) ]; (match source.s_cpu_topology with | None -> List.push_back properties ("hw_cpu_sockets", "1"); List.push_back properties ("hw_cpu_cores", string_of_int source.s_vcpu); | Some { s_cpu_sockets = sockets; s_cpu_cores = cores; s_cpu_threads = threads } -> List.push_back properties ("hw_cpu_sockets", string_of_int sockets); List.push_back properties ("hw_cpu_cores", string_of_int cores); List.push_back properties ("hw_cpu_threads", string_of_int threads); ); (match guestcaps.gcaps_block_bus with | Virtio_SCSI -> List.push_back properties ("hw_scsi_model", "virtio-scsi") | Virtio_blk | IDE -> () ); (match inspect.i_major_version, inspect.i_minor_version with | 0, 0 -> () | x, 0 -> List.push_back properties ("os_version", string_of_int x) | x, y -> List.push_back properties ("os_version", sprintf "%d.%d" x y) ); if guestcaps.gcaps_virtio_rng then List.push_back properties ("hw_rng_model", "virtio"); (* XXX Neither memory balloon nor pvpanic are supported by * Glance at this time. *) (match target_firmware with | TargetBIOS -> () | TargetUEFI -> List.push_back properties ("hw_firmware_type", "uefi") ); !properties virt-v2v-1.44.2/v2v/PaxHeaders/convert_windows.ml0000644000000000000000000000013214147141533016663 xustar0030 mtime=1637663579.466663138 30 atime=1637862739.503417277 30 ctime=1637862790.903847817 virt-v2v-1.44.2/v2v/convert_windows.ml0000644000175000017500000007445614147141533020507 0ustar00rjonesrjones00000000000000(* virt-v2v * Copyright (C) 2009-2020 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *) open Printf open Std_utils open Tools_utils open Common_gettext.Gettext open Utils open Types module G = Guestfs (* Convert Windows guests. * * This only does a "pre-conversion", the steps needed to get the * Windows guest to boot on KVM. Unlike the [Convert_linux] module, * this is not a full conversion. Instead it just installs the * [viostor] (Windows virtio block) driver, so that the Windows guest * will be able to boot on the target. A [RunOnce] script is also * added to the VM which does all the rest of the conversion the first * time the Windows VM is booted on KVM. *) let convert (g : G.guestfs) inspect _ output rcaps static_ips = (*----------------------------------------------------------------------*) (* Inspect the Windows guest. *) (* If the Windows guest appears to be using group policy. * * Since this was written, it has been noted that it may be possible * to remove this restriction: * * 12:35 < StenaviN> here is the article from MS: https://support.microsoft.com/uk-ua/help/2773300/stop-0x0000007b-error-after-you-use-a-group-policy-setting-to-prevent * 12:35 < StenaviN> aside of that the following registry hive should be deleted as well: [-HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\DeviceInstall] * 12:36 < StenaviN> more precisely, [-HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\DeviceInstall\Restrictions] *) let has_group_policy = Registry.with_hive_readonly g inspect.i_windows_software_hive (fun reg -> try let path = ["Microsoft"; "Windows"; "CurrentVersion"; "Group Policy"; "History"] in let node = match Registry.get_node reg path with | None -> raise Not_found | Some node -> node in let children = g#hivex_node_children node in let children = Array.to_list children in let children = List.map (fun { G.hivex_node_h = h } -> g#hivex_node_name h) children in (* Just assume any children looking like "{}" mean that * some GPOs were installed. * * In future we might want to look for nodes which match: * History\{}\ where is a small integer (the order * in which policy objects were applied. * * For an example registry containing GPOs, see RHBZ#1219651. * See also: https://support.microsoft.com/en-us/kb/201453 *) let is_gpo_guid name = let len = String.length name in len > 3 && name.[0] = '{' && Char.isxdigit name.[1] && name.[len-1] = '}' in List.exists is_gpo_guid children with Not_found -> false ) in (* If the Windows guest has AV installed. *) let has_antivirus = Windows.detect_antivirus inspect in (* Open the software hive (readonly) and find the Xen PV uninstaller, * if it exists. *) let xenpv_uninst = let xenpvreg = "Red Hat Paravirtualized Xen Drivers for Windows(R)" in Registry.with_hive_readonly g inspect.i_windows_software_hive (fun reg -> try let path = ["Microsoft"; "Windows"; "CurrentVersion"; "Uninstall"; xenpvreg] in let node = match Registry.get_node reg path with | None -> raise Not_found | Some node -> node in let uninstkey = "UninstallString" in let valueh = g#hivex_node_get_value node uninstkey in if valueh = 0L then ( warning (f_"cannot uninstall Xen PV drivers: registry key ‘HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%s’ does not contain an ‘%s’ key") xenpvreg uninstkey; raise Not_found ); let data = g#hivex_value_value valueh in let data = Registry.decode_utf16le data in (* The uninstall program will be uninst.exe. This is a wrapper * around _uninst.exe which prompts the user. As we don't want * the user to be prompted, we run _uninst.exe explicitly. *) let len = String.length data in let data = if len >= 8 && String.lowercase_ascii (String.sub data (len-8) 8) = "uninst.exe" then (String.sub data 0 (len-8)) ^ "_uninst.exe" else data in Some data with Not_found -> None ) in (* Locate and retrieve all the uninstallation commands for installed * applications. *) let uninstallation_commands pretty_name matchfn modfn extra_uninstall_params = let path = ["Microsoft"; "Windows"; "CurrentVersion"; "Uninstall"] in let uninstval = "UninstallString" in let ret = ref [] in Registry.with_hive_readonly g inspect.i_windows_software_hive ( fun reg -> match Registry.get_node reg path with | None -> () | Some node -> let uninstnodes = g#hivex_node_children node in Array.iter ( fun { G.hivex_node_h = uninstnode } -> let valueh = g#hivex_node_get_value uninstnode "DisplayName" in if valueh <> 0L then ( let dispname = g#hivex_value_string valueh in if matchfn dispname then ( let valueh = g#hivex_node_get_value uninstnode uninstval in if valueh <> 0L then ( let reg_cmd = g#hivex_value_string valueh in let reg_cmd = modfn reg_cmd in let cmd = sprintf "%s /quiet /norestart /l*v+ \"%%~dpn0.log\" REBOOT=ReallySuppress REMOVE=ALL %s" reg_cmd extra_uninstall_params in List.push_front cmd ret ) else let name = g#hivex_node_name uninstnode in warning (f_"cannot uninstall %s: registry key ‘HKLM\\SOFTWARE\\%s\\%s’ with DisplayName ‘%s’ doesn't contain value ‘%s’") pretty_name (String.concat "\\" path) name dispname uninstval ) ) ) uninstnodes ) (* with_hive_readonly *); !ret in (* Locate and retrieve all uninstallation commands for Parallels Tools. *) let prltools_uninsts = let matchfn s = String.find s "Parallels Tools" != -1 || String.find s "Virtuozzo Tools" != -1 in (* Without these custom Parallels-specific MSI properties the * uninstaller still shows a no-way-out reboot dialog. *) let extra_uninstall_params = "PREVENT_REBOOT=Yes LAUNCHED_BY_SETUP_EXE=Yes" in uninstallation_commands "Parallels Tools" matchfn identity extra_uninstall_params in (* Locate and retrieve all uninstallation commands for VMware Tools. *) let vmwaretools_uninst = let matchfn s = String.find s "VMware Tools" != -1 in (* VMware Tools writes the install command (MsiExec /I) into the * UninstallString key in the registry, rather than the uninstall * command. Try to spot this and rewrite. (RHBZ#1917760). *) let re1 = PCRE.compile ~caseless:true "msiexec" in let re2 = PCRE.compile ~caseless:true "/i" in let msifn s = if PCRE.matches re1 s then PCRE.replace re2 "/x" s else s in uninstallation_commands "VMware Tools" matchfn msifn "" in (*----------------------------------------------------------------------*) (* Perform the conversion of the Windows guest. *) let rec do_convert () = (* Firstboot configuration. *) configure_firstboot (); (* Open the system hive for writes and update it. *) let block_driver, net_driver, video_driver, virtio_rng_supported, virtio_ballon_supported, isa_pvpanic_supported, virtio_socket_supported = Registry.with_hive_write g inspect.i_windows_system_hive update_system_hive in (* Open the software hive for writes and update it. *) Registry.with_hive_write g inspect.i_windows_software_hive update_software_hive; configure_network_interfaces net_driver; fix_ntfs_heads (); fix_win_esp (); (* Warn if installation of virtio block drivers might conflict with * group policy or AV software causing a boot 0x7B error (RHBZ#1260689). *) if block_driver = Virtio_blk then ( if has_group_policy then warning (f_"this guest has Windows Group Policy Objects (GPO) and a new virtio block device driver was installed. In some circumstances, Group Policy may prevent new drivers from working (resulting in a 7B boot error). If this happens, try disabling Group Policy before doing the conversion."); if has_antivirus then warning (f_"this guest has Anti-Virus (AV) software and a new virtio block device driver was installed. In some circumstances, AV may prevent new drivers from working (resulting in a 7B boot error). If this happens, try disabling AV before doing the conversion."); ); (* Pivot on the year 2007. Any Windows version from earlier than * 2007 should use i440fx, anything 2007 or newer should use q35. * Luckily this coincides almost exactly with the release of NT 6. * XXX Look up this information in libosinfo in future. *) let machine = match inspect.i_arch, inspect.i_major_version with | ("i386"|"x86_64"), major -> if major < 6 then I440FX else Q35 | _ -> Virt in (* Return guest capabilities from the convert () function. *) let guestcaps = { gcaps_block_bus = block_driver; gcaps_net_bus = net_driver; gcaps_video = video_driver; gcaps_virtio_rng = virtio_rng_supported; gcaps_virtio_balloon = virtio_ballon_supported; gcaps_isa_pvpanic = isa_pvpanic_supported; gcaps_virtio_socket = virtio_socket_supported; gcaps_machine = machine; gcaps_arch = Utils.kvm_arch inspect.i_arch; gcaps_acpi = true; } in guestcaps and configure_firstboot () = (* Note that pnp_wait.exe must be the first firstboot script as it * suppresses PnP for all following scripts. *) let tool_path = virt_tools_data_dir () // "pnp_wait.exe" in if Sys.file_exists tool_path then configure_wait_pnp tool_path else debug (f_"%s is missing. Firstboot scripts may conflict with PnP.") tool_path; (* Install RHEV-APT only if appropriate for the output hypervisor. *) if output#install_rhev_apt then ( let tool_path = virt_tools_data_dir () // "rhev-apt.exe" in if Sys.file_exists tool_path then configure_rhev_apt tool_path else warning (f_"%s is missing, but the output hypervisor is oVirt or RHV. Installing RHEV-APT in the guest would mean the guest is automatically updated with new drivers etc. You may wish to install RHEV-APT manually after conversion.") tool_path ); (* Install VMDP unconditionally, if available, but don't * warn about it if not. *) let tool_path = virt_tools_data_dir () // "vmdp.exe" in if Sys.file_exists tool_path then configure_vmdp tool_path; (* Install QEMU Guest Agent unconditionally and warn if missing *) let qemu_ga_files = Windows_virtio.copy_qemu_ga g inspect in if qemu_ga_files <> [] then configure_qemu_ga qemu_ga_files else warning (f_"QEMU Guest Agent MSI not found on tools ISO/directory. You may want to install the guest agent manually after conversion."); unconfigure_xenpv (); unconfigure_prltools (); unconfigure_vmwaretools () (* [set_reg_val_dword_1 path name] creates a registry key * called [name = dword:1] in the registry [path]. * Intermediate nodes are created along the path if required. * * It returns the old value, if there was one, else [None]. *) and set_reg_val_dword_1 ((g, root) as reg) path name = let node = Registry.create_path reg path in let valueh = g#hivex_node_get_value node name in let value = match valueh with | 0L -> None | _ -> Some (int_of_le32 (g#hivex_value_value valueh)) in g#hivex_node_set_value node name 4_L (le32_of_int 1_L); value and reg_restore key name value = let strkey = String.concat "\\" key in match value with | Some value -> sprintf "\ reg add \"%s\" /v %s /t REG_DWORD /d %Ld /f" strkey name value | None -> sprintf "\ reg delete \"%s\" /v %s /f" strkey name and configure_wait_pnp tool_path = (* Prevent destructive interactions of firstboot with PnP. *) (* Suppress "New Hardware Wizard" until PnP settles (see * https://support.microsoft.com/en-us/kb/938596) and restore it * afterwards. *) let reg_restore_str = match inspect.i_major_version, inspect.i_minor_version with (* WinXP 32bit *) | 5, 1 -> let key_path = ["Policies"; "Microsoft"; "Windows"; "DeviceInstall"; "Settings"] in let name = "SuppressNewHWUI" in let value = Registry.with_hive_write g inspect.i_windows_software_hive ( fun reg -> set_reg_val_dword_1 reg key_path name ) in reg_restore ("HKLM\\Software" :: key_path) name value (* WinXP 64bit / Win2k3 *) | 5, 2 -> let key_path = ["Services"; "PlugPlay"; "Parameters"] in let name = "SuppressUI" in let value = Registry.with_hive_write g inspect.i_windows_system_hive ( fun reg -> let path = inspect.i_windows_current_control_set :: key_path in set_reg_val_dword_1 reg path name ) in reg_restore ("HKLM\\SYSTEM\\CurrentControlSet" :: key_path) name value (* any later Windows *) | _ -> "" in let pnp_wait_path = "/Program Files/Guestfs/Firstboot/pnp_wait.exe" in let fb_script = sprintf "\ @echo off echo Wait for PnP to complete \"%s\" >\"%%~dpn0.log\" 2>&1 %s" (String.replace_char pnp_wait_path '/' '\\') reg_restore_str in Firstboot.add_firstboot_script g inspect.i_root "wait pnp" fb_script; (* add_firstboot_script has created the path already. *) g#upload tool_path (g#case_sensitive_path pnp_wait_path) and configure_rhev_apt tool_path = (* Configure RHEV-APT (the RHV guest agent). However if it doesn't * exist just warn about it and continue. *) g#upload tool_path "/rhev-apt.exe"; (* XXX *) let fb_script = "\ @echo off echo installing rhev-apt \"\\rhev-apt.exe\" /S /v/qn /v/l*vx \"/v\\\"%cd%\\rhev-apt.log\\\"\" echo starting rhev-apt net start rhev-apt " in Firstboot.add_firstboot_script g inspect.i_root "configure rhev-apt" fb_script and configure_vmdp tool_path = (* Configure VMDP if possible *) g#upload tool_path "/vmdp.exe"; let fb_script = "\ echo V2V first boot script started echo Decompressing VMDP installer \"\\vmdp.exe\" pushd \"VMDP-*\" echo Installing VMDP setup.exe /eula_accepted /no_reboot popd " in let fb_recover_script = "\ echo Finishing VMDP installation if not exist VMDP-* ( \"\\vmdp.exe\" ) pushd \"VMDP-*\" setup.exe /eula_accepted /no_reboot popd " in Firstboot.add_firstboot_script g inspect.i_root "configure vmdp" fb_script; Firstboot.add_firstboot_script g inspect.i_root "finish vmdp setup" fb_recover_script and configure_qemu_ga files = List.iter ( fun msi_path -> (* Windows is a trashfire. https://stackoverflow.com/a/18730884 *) let fb_script = sprintf "\ echo Removing any previously scheduled qemu-ga installation schtasks.exe /Delete /TN Firstboot-qemu-ga /F echo Scheduling delayed installation of qemu-ga from %s powershell.exe -command \"$d = (get-date).AddSeconds(120); $FormatHack = ($([System.Globalization.DateTimeFormatInfo]::CurrentInfo.ShortDatePattern) -replace 'M+/', 'MM/') -replace 'd+/', 'dd/'; schtasks.exe /Create /SC ONCE /ST $d.ToString('HH:mm') /SD $d.ToString($FormatHack) /RU SYSTEM /TN Firstboot-qemu-ga /TR \\\"C:\\%s /forcerestart /qn /l+*vx C:\\%s.log\\\"\" " msi_path msi_path msi_path in Firstboot.add_firstboot_script g inspect.i_root ("install " ^ msi_path) fb_script; ) files and unconfigure_xenpv () = match xenpv_uninst with | None -> () (* nothing to be uninstalled *) | Some uninst -> let fb_script = sprintf "\ @echo off echo uninstalling Xen PV driver \"%s\" " uninst in Firstboot.add_firstboot_script g inspect.i_root "uninstall Xen PV" fb_script and unconfigure_prltools () = List.iter ( fun uninst -> let fb_script = "\ @echo off REG DELETE HKLM\\System\\CurrentControlSet\\Services\\prl_strg\\DriverInfo /v RefCount /f echo uninstalling Parallels guest tools " ^ uninst ^ (* ERROR_SUCCESS_REBOOT_REQUIRED == 3010 is OK too *) " if errorlevel 3010 exit /b 0 " in Firstboot.add_firstboot_script g inspect.i_root "uninstall Parallels tools" fb_script ) prltools_uninsts and unconfigure_vmwaretools () = List.iter ( fun uninst -> let fb_script = "\ @echo off echo uninstalling VMware Tools " ^ uninst ^ (* ERROR_SUCCESS_REBOOT_REQUIRED == 3010 is OK too *) " if errorlevel 3010 exit /b 0 " in Firstboot.add_firstboot_script g inspect.i_root "uninstall VMware Tools" fb_script ) vmwaretools_uninst and update_system_hive reg = (* Update the SYSTEM hive. When this function is called the hive has * already been opened as a hivex handle inside guestfs. *) disable_xenpv_win_drivers reg; disable_prl_drivers reg; disable_autoreboot reg; Windows_virtio.install_drivers reg inspect rcaps and disable_xenpv_win_drivers reg = (* Disable xenpv-win service (RHBZ#809273). *) let services = Registry.get_node reg [inspect.i_windows_current_control_set; "Services"] in match services with | None -> () | Some services -> let node = g#hivex_node_get_child services "rhelscsi" in if node <> 0L then g#hivex_node_set_value node "Start" 4_L (le32_of_int 4_L) and disable_prl_drivers reg = (* Prevent Parallels drivers from loading at boot. *) let services = Registry.get_node reg [inspect.i_windows_current_control_set; "Services"] in let prl_svcs = [ "prl_boot"; "prl_dd"; "prl_eth5"; "prl_fs"; "prl_memdev"; "prl_mouf"; "prl_pv32"; "prl_pv64"; "prl_scsi"; "prl_sound"; "prl_strg"; "prl_tg"; "prl_time"; "prl_uprof"; "prl_va" ] in match services with | None -> () | Some services -> List.iter ( fun svc -> let svc_node = g#hivex_node_get_child services svc in if svc_node <> 0L then ( (* Disable the service rather than delete the node as it would * confuse the uninstaller called from firstboot script. *) g#hivex_node_set_value svc_node "Start" 4_L (le32_of_int 4_L) ) ) prl_svcs; (* perfrom the equivalent of DelReg from prl_strg.inf: * HKLM, System\CurrentControlSet\Control\Class\{4d36e967-e325-11ce-bfc1-08002be10318}, LowerFilters, 0x00018002, prl_strg *) let strg_cls = Registry.get_node reg [inspect.i_windows_current_control_set; "Control"; "Class"; "{4d36e967-e325-11ce-bfc1-08002be10318}"] in match strg_cls with | None -> () | Some strg_cls -> let lfkey = "LowerFilters" in let valueh = g#hivex_node_get_value strg_cls lfkey in if valueh <> 0L then ( let data = g#hivex_value_value valueh in let filters = String.nsplit "\000" (Registry.decode_utf16le data) in let filters = List.filter ( fun x -> x <> "prl_strg" && x <> "" ) filters in let filters = List.map ( fun x -> Registry.encode_utf16le x ^ "\000\000" ) (filters @ [""]) in let data = String.concat "" filters in g#hivex_node_set_value strg_cls lfkey 7_L data ) and disable_autoreboot reg = (* If the guest reboots after a crash, it's hard to see the original * error (eg. the infamous 0x0000007B). Turn off autoreboot. *) let crash_control = Registry.get_node reg [inspect.i_windows_current_control_set; "Control"; "CrashControl"] in match crash_control with | None -> () | Some crash_control -> g#hivex_node_set_value crash_control "AutoReboot" 4_L (le32_of_int 0_L) and update_software_hive reg = (* Update the SOFTWARE hive. When this function is called the * hive has already been opened as a hivex handle inside * guestfs. *) (* Find the node \Microsoft\Windows\CurrentVersion. If the node * has a key called DevicePath then append the virtio driver * path to this key. * * Note that simply adding the directory to DevicePath doesn't * seem to be a 100% reliable way of enabling the drivers. In * particular it does not work for my self-built Windows Server Core * 2012 + R2 releases (although that might be an artifact of * the way I build them). In any case I had to add a firstboot * batch file which did this single command: * * %systemroot%\Sysnative\PnPutil -i -a %systemroot%\Drivers\Virtio\*.inf *) let node = Registry.get_node reg ["Microsoft"; "Windows"; "CurrentVersion"] in match node with | Some node -> let append = Registry.encode_utf16le ";%SystemRoot%\\Drivers\\VirtIO" in let values = Array.to_list (g#hivex_node_values node) in let rec loop = function | [] -> () (* DevicePath not found -- ignore this case *) | { G.hivex_value_h = valueh } :: values -> let key = g#hivex_value_key valueh in if key <> "DevicePath" then loop values else ( let data = g#hivex_value_value valueh in let len = String.length data in let t = g#hivex_value_type valueh in (* Only add the appended path if it doesn't exist already. *) if String.find data append = -1 then ( (* Remove the explicit [\0\0] at the end of the string. * This is the UTF-16LE NUL-terminator. *) let data = if len >= 2 && String.sub data (len-2) 2 = "\000\000" then String.sub data 0 (len-2) else data in (* Append the path and the explicit NUL. *) let data = data ^ append ^ "\000\000" in g#hivex_node_set_value node key t data ) ) in loop values | None -> warning (f_"could not find registry key HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion") and configure_network_interfaces net_driver = (* If we were asked to force network interfaces to have particular * static IP addresses then it is done here by installing a * Powershell script which runs at boot. *) if static_ips <> [] then ( let psh_filename = "v2vnetcf.ps1" in let psh = ref [] in let add = List.push_back psh in add "# Uncomment this line for lots of debug output."; add "# Set-PSDebug -Trace 1"; add ""; (* If virtio-net was added to the registry, we must wait for * it to be installed at runtime. *) if net_driver = Virtio_net then ( add "# Wait for the netkvm (virtio-net) driver to become active."; add "$adapters = @()"; add "While (-Not $adapters) {"; add " Start-Sleep -Seconds 5"; add " $adapters = Get-NetAdapter -Physical | Where DriverFileName -eq \"netkvm.sys\""; add " Write-Host \"adapters = '$adapters'\""; add "}"; add "" ); List.iter ( fun { if_mac_addr; if_ip_address; if_default_gateway; if_prefix_length; if_nameservers } -> add (sprintf "$mac_address = '%s'" (String.replace if_mac_addr ":" "-")); add "$ifindex = (Get-NetAdapter -Physical | Where MacAddress -eq $mac_address).ifIndex"; add "if ($ifindex) {"; add " Write-Host \"setting IP address of adapter at $ifindex\""; (* New-NetIPAddress command *) let args = ref [] in List.push_back args "-InterfaceIndex"; List.push_back args "$ifindex"; List.push_back args "-IPAddress"; List.push_back args (sprintf "'%s'" if_ip_address); (match if_default_gateway with | None -> () | Some gw -> List.push_back args "-DefaultGateway"; List.push_back args (sprintf "'%s'" gw) ); (match if_prefix_length with | None -> () | Some len -> List.push_back args "-PrefixLength"; List.push_back args (string_of_int len) ); let cmd1 = "New-NetIPAddress " ^ String.concat " " !args in add (" " ^ cmd1); (* Set-DnsClientServerAddress command *) if if_nameservers <> [] then ( add (sprintf " Set-DnsClientServerAddress -InterfaceIndex $ifindex -ServerAddresses (%s)" (String.concat "," (List.map (sprintf "'%s'") if_nameservers))) ); add "}"; add "" ) static_ips; (* Install the Powershell script to run at firstboot. *) Windows.install_firstboot_powershell g inspect psh_filename !psh ) (* static_ips <> [] *) and fix_ntfs_heads () = (* NTFS hardcodes the number of heads on the drive which created it in the filesystem header. Modern versions of Windows sensibly ignore it, but both Windows XP and Windows 2000 require it to be correct in order to boot from the drive. If it isn't you get: 'A disk read error occurred. Press Ctrl+Alt+Del to restart' QEMU has some code in block.c:guess_disk_lchs() which on the face of it appears to infer the drive geometry from the MBR if it's valid. However, my tests have shown that a Windows XP guest hosted on both RHEL 5 and F14 requires the heads field in NTFS to be the following, based solely on drive size: Range Heads size < 2114445312 0x40 2114445312 <= size < 4228374780 0x80 4228374780 <= size 0xFF I have not tested drive sizes less than 1G, which require fewer heads, as this limitation applies only to the boot device and it is not possible to install XP on a drive this size. The following page has good information on the layout of NTFS in Windows XP/2000: http://mirror.href.com/thestarman/asm/mbr/NTFSBR.htm Technet has this: http://technet.microsoft.com/en-us/library/cc781134(WS.10).aspx#w2k3tr_ntfs_how_dhao however, as this is specific to Windows 2003 it lists location 0x1A as unused. *) if inspect.i_major_version < 6 (* is Windows 2000/XP *) then ( let rootpart = inspect.i_root in (* Ignore if the rootpart is something like /dev/sda. RHBZ#1276540. *) if not (g#is_whole_device rootpart) then ( (* Check that the root device contains NTFS magic. *) let magic = g#pread_device rootpart 8 3L in if magic = "NTFS " then ( (* Get the size of the whole disk containing the root partition. *) let rootdev = g#part_to_dev rootpart in (* eg. /dev/sda *) let size = g#blockdev_getsize64 rootdev in let heads = (* refer to the table above *) if size < 2114445312L then 0x40 else if size < 4228374780L then 0x80 else 0xff in (* Update NTFS's idea of the number of heads. This is an * unsigned 16 bit little-endian integer, offset 0x1a from the * beginning of the partition. *) let b = Bytes.create 2 in Bytes.unsafe_set b 0 (Char.chr heads); Bytes.unsafe_set b 1 '\000'; ignore (g#pwrite_device rootpart (Bytes.to_string b) 0x1a_L) ) ) ) and fix_win_esp () = let fix_win_uefi_bcd esp_path = try let bcd_path = "/EFI/Microsoft/Boot/BCD" in Registry.with_hive_write g (esp_path ^ bcd_path) ( (* Remove the 'graphicsmodedisabled' key in BCD *) fun reg -> let path = ["Objects"; "{9dea862c-5cdd-4e70-acc1-f32b344d4795}"; "Elements"; "23000003"] in let boot_mgr_default_link = match Registry.get_node reg path with | None -> raise Not_found | Some node -> node in let current_boot_entry = g#hivex_value_string ( g#hivex_node_get_value boot_mgr_default_link "Element") in let path = ["Objects"; current_boot_entry; "Elements"; "16000046"] in match Registry.get_node reg path with | None -> raise Not_found | Some graphics_mode_disabled -> g#hivex_node_delete_child graphics_mode_disabled ); with Not_found -> () in match inspect.i_firmware with | I_BIOS -> () | I_UEFI esp_list -> let esp_temp_path = g#mkdtemp "/Windows/Temp/ESP_XXXXXX" in List.iter ( fun dev_path -> g#mount dev_path esp_temp_path; fix_win_uefi_bcd esp_temp_path; g#umount esp_temp_path; ) esp_list; g#rmdir esp_temp_path in do_convert () (* Register this conversion module. *) let () = let matching = function | { i_type = "windows" } -> true | _ -> false in Modules_list.register_convert_module matching "windows" convert virt-v2v-1.44.2/v2v/PaxHeaders/input_ova.mli0000644000000000000000000000013213641354341015607 xustar0030 mtime=1585830113.309308028 30 atime=1637862739.490417421 30 ctime=1637862790.714849911 virt-v2v-1.44.2/v2v/input_ova.mli0000664000175000017500000000161313641354341017416 0ustar00rjonesrjones00000000000000(* virt-v2v * Copyright (C) 2009-2020 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *) (** [-i ova] source. *) val input_ova : string -> Types.input (** [input_ova filename] sets up an input from vmware ova file. *) virt-v2v-1.44.2/v2v/PaxHeaders/Makefile.am0000644000000000000000000000013214035327111015125 xustar0030 mtime=1618325065.680893175 30 atime=1637862733.516483606 30 ctime=1637862790.662850487 virt-v2v-1.44.2/v2v/Makefile.am0000644000175000017500000002533114035327111016735 0ustar00rjonesrjones00000000000000# libguestfs virt-v2v tool # Copyright (C) 2009-2020 Red Hat Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. include $(top_srcdir)/subdir-rules.mk BUILT_SOURCES = \ output_rhv_upload_createvm_source.ml \ output_rhv_upload_deletedisks_source.ml \ output_rhv_upload_plugin_source.ml \ output_rhv_upload_precheck_source.ml \ output_rhv_upload_vmcheck_source.ml CONFIGURE_GENERATED_ML = \ config.ml EXTRA_DIST = \ $(SOURCES_MLI) \ $(filter-out $(CONFIGURE_GENERATED_ML) $(BUILT_SOURCES),$(SOURCES_ML)) \ $(SOURCES_C) \ copy_to_local.ml \ copy_to_local.mli \ embed.sh \ rhv-upload-createvm.py \ rhv-upload-deletedisks.py \ rhv-upload-plugin.py \ rhv-upload-precheck.py \ rhv-upload-vmcheck.py \ test-v2v-python-syntax.sh \ var_expander_tests.ml \ v2v_unit_tests.ml SOURCES_MLI = \ changeuid.mli \ cmdline.mli \ config.mli \ convert_linux.mli \ convert_windows.mli \ create_json.mli \ create_libvirt_xml.mli \ create_ovf.mli \ DOM.mli \ input_disk.mli \ input_libvirt.mli \ input_libvirt_other.mli \ input_libvirt_vcenter_https.mli \ input_libvirt_vddk.mli \ input_libvirt_xen_ssh.mli \ input_libvirtxml.mli \ input_ova.mli \ input_vmx.mli \ inspect_source.mli \ libosinfo.mli \ libosinfo_utils.mli \ libvirt_utils.mli \ linux.mli \ linux_bootloaders.mli \ linux_kernels.mli \ measure_disk.mli \ modules_list.mli \ name_from_disk.mli \ nbdkit.mli \ nbdkit_sources.mli \ networks.mli \ openstack_image_properties.mli \ output_glance.mli \ output_json.mli \ output_libvirt.mli \ output_local.mli \ output_null.mli \ output_openstack.mli \ output_qemu.mli \ output_rhv.mli \ output_rhv_upload.mli \ output_rhv_upload_createvm_source.mli \ output_rhv_upload_deletedisks_source.mli \ output_rhv_upload_plugin_source.mli \ output_rhv_upload_precheck_source.mli \ output_rhv_upload_vmcheck_source.mli \ output_vdsm.mli \ parse_ova.mli \ parse_ovf_from_ova.mli \ parse_libvirt_xml.mli \ parse_vmx.mli \ python_script.mli \ qemuopts.mli \ target_bus_assignment.mli \ types.mli \ utils.mli \ v2v.mli \ vCenter.mli \ var_expander.mli \ windows.mli \ windows_virtio.mli SOURCES_ML = \ $(CONFIGURE_GENERATED_ML) \ types.ml \ utils.ml \ var_expander.ml \ python_script.ml \ name_from_disk.ml \ nbdkit.ml \ nbdkit_sources.ml \ vCenter.ml \ libosinfo.ml \ libosinfo_utils.ml \ libvirt_utils.ml \ DOM.ml \ changeuid.ml \ parse_ovf_from_ova.ml \ parse_ova.ml \ create_ovf.ml \ create_json.ml \ linux.ml \ windows.ml \ windows_virtio.ml \ modules_list.ml \ input_disk.ml \ parse_vmx.ml \ parse_libvirt_xml.ml \ create_libvirt_xml.ml \ openstack_image_properties.ml \ qemuopts.ml \ input_libvirtxml.ml \ input_libvirt_other.ml \ input_libvirt_vcenter_https.ml \ input_libvirt_vddk.ml \ input_libvirt_xen_ssh.ml \ input_libvirt.ml \ input_ova.ml \ input_vmx.ml \ linux_bootloaders.ml \ linux_kernels.ml \ convert_linux.ml \ convert_windows.ml \ output_null.ml \ output_glance.ml \ output_json.ml \ output_libvirt.ml \ output_local.ml \ output_qemu.ml \ output_rhv.ml \ output_rhv_upload_createvm_source.ml \ output_rhv_upload_deletedisks_source.ml \ output_rhv_upload_plugin_source.ml \ output_rhv_upload_precheck_source.ml \ output_rhv_upload_vmcheck_source.ml \ output_rhv_upload.ml \ output_vdsm.ml \ output_openstack.ml \ inspect_source.ml \ target_bus_assignment.ml \ measure_disk.ml \ networks.ml \ cmdline.ml \ v2v.ml SOURCES_C = \ libosinfo-c.c \ qemuopts-c.c # These files are generated and contain *.py embedded as an OCaml string. output_rhv_upload_createvm_source.ml: $(srcdir)/rhv-upload-createvm.py $(srcdir)/embed.sh code $^ $@ output_rhv_upload_deletedisks_source.ml: $(srcdir)/rhv-upload-deletedisks.py $(srcdir)/embed.sh code $^ $@ output_rhv_upload_plugin_source.ml: $(srcdir)/rhv-upload-plugin.py $(srcdir)/embed.sh code $^ $@ output_rhv_upload_precheck_source.ml: $(srcdir)/rhv-upload-precheck.py $(srcdir)/embed.sh code $^ $@ output_rhv_upload_vmcheck_source.ml: $(srcdir)/rhv-upload-vmcheck.py $(srcdir)/embed.sh code $^ $@ bin_PROGRAMS = virt-v2v virt-v2v-copy-to-local virt_v2v_SOURCES = $(SOURCES_C) virt_v2v_CPPFLAGS = \ -DCAML_NAME_SPACE \ -I. \ -I$(top_builddir) \ -I$(shell $(OCAMLC) -where) \ -I$(top_srcdir)/common/qemuopts \ -I$(top_srcdir)/lib virt_v2v_CFLAGS = \ -pthread \ $(WARN_CFLAGS) $(WERROR_CFLAGS) \ $(LIBGUESTFS_CFLAGS) \ $(LIBVIRT_CFLAGS) \ $(LIBOSINFO_CFLAGS) BOBJECTS = \ $(top_builddir)/common/mlcustomize/firstboot.cmo \ $(top_builddir)/common/mlcustomize/SELinux_relabel.cmo \ $(SOURCES_ML:.ml=.cmo) XOBJECTS = $(BOBJECTS:.cmo=.cmx) # -I $(top_builddir)/lib/.libs is a hack which forces corresponding -L # option to be passed to gcc, so we don't try linking against an # installed copy of libguestfs. OCAMLPACKAGES = \ -package str,unix,guestfs \ -I $(top_builddir)/common/utils/.libs \ -I $(top_builddir)/common/qemuopts/.libs \ -I $(top_builddir)/lib/.libs \ -I $(top_builddir)/gnulib/lib/.libs \ -I $(top_builddir)/common/mlstdutils \ -I $(top_builddir)/common/mlutils \ -I $(top_builddir)/common/mlgettext \ -I $(top_builddir)/common/mlpcre \ -I $(top_builddir)/common/mlxml \ -I $(top_builddir)/common/mltools \ -I $(top_builddir)/bundled/libvirt-ocaml \ -I $(top_builddir)/common/mlcustomize \ -I $(top_builddir)/common/mlv2v if HAVE_OCAML_PKG_GETTEXT OCAMLPACKAGES += -package gettext-stub endif OCAMLCLIBS = \ -pthread \ -lqemuopts \ $(LIBGUESTFS_LIBS) \ $(LIBVIRT_LIBS) \ $(LIBXML2_LIBS) \ $(JANSSON_LIBS) \ $(LIBOSINFO_LIBS) \ $(LIBINTL) \ -lgnu OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR) -ccopt '$(CFLAGS)' if !HAVE_OCAMLOPT OBJECTS = $(BOBJECTS) else OBJECTS = $(XOBJECTS) endif OCAMLLINKFLAGS = \ mlstdutils.$(MLARCHIVE) \ mlgettext.$(MLARCHIVE) \ mlpcre.$(MLARCHIVE) \ mlxml.$(MLARCHIVE) \ mlcutils.$(MLARCHIVE) \ mltools.$(MLARCHIVE) \ mllibvirt.$(MLARCHIVE) \ mlcustomize.$(MLARCHIVE) \ mlv2v.$(MLARCHIVE) \ $(LINK_CUSTOM_OCAMLC_ONLY) virt_v2v_DEPENDENCIES = $(OBJECTS) $(top_srcdir)/ocaml-link.sh virt_v2v_LINK = \ $(top_srcdir)/ocaml-link.sh -cclib '$(OCAMLCLIBS)' -- \ $(OCAMLFIND) $(BEST) $(OCAMLFLAGS) $(OCAMLPACKAGES) $(OCAMLLINKFLAGS) \ $(OBJECTS) -o $@ virt_v2v_copy_to_local_SOURCES = \ dummy.c virt_v2v_copy_to_local_CPPFLAGS = \ -DCAML_NAME_SPACE \ -I. \ -I$(top_builddir) \ -I$(shell $(OCAMLC) -where) \ -I$(top_srcdir)/lib virt_v2v_copy_to_local_CFLAGS = \ $(WARN_CFLAGS) $(WERROR_CFLAGS) \ $(LIBVIRT_CFLAGS) COPY_TO_LOCAL_BOBJECTS = \ config.cmo \ types.cmo \ utils.cmo \ libvirt_utils.cmo \ nbdkit.cmo \ nbdkit_sources.cmo \ vCenter.cmo \ copy_to_local.cmo COPY_TO_LOCAL_XOBJECTS = $(COPY_TO_LOCAL_BOBJECTS:.cmo=.cmx) if !HAVE_OCAMLOPT COPY_TO_LOCAL_OBJECTS = $(COPY_TO_LOCAL_BOBJECTS) else COPY_TO_LOCAL_OBJECTS = $(COPY_TO_LOCAL_XOBJECTS) endif virt_v2v_copy_to_local_DEPENDENCIES = \ $(COPY_TO_LOCAL_OBJECTS) \ ../common/mlstdutils/mlstdutils.$(MLARCHIVE) \ ../common/mlxml/mlxml.$(MLARCHIVE) \ ../common/mlgettext/mlgettext.$(MLARCHIVE) \ ../common/mlpcre/mlpcre.$(MLARCHIVE) \ ../common/mlutils/mlcutils.$(MLARCHIVE) \ ../common/mltools/mltools.$(MLARCHIVE) \ ../bundled/libvirt-ocaml/mllibvirt.$(MLARCHIVE) \ ../common/mlcustomize/mlcustomize.$(MLARCHIVE) \ ../common/mlv2v/mlv2v.$(MLARCHIVE) \ $(top_srcdir)/ocaml-link.sh virt_v2v_copy_to_local_LINK = \ $(top_srcdir)/ocaml-link.sh -cclib '$(OCAMLCLIBS)' -- \ $(OCAMLFIND) $(BEST) $(OCAMLFLAGS) $(OCAMLPACKAGES) $(OCAMLLINKFLAGS) \ $(COPY_TO_LOCAL_OBJECTS) -o $@ # Data directory. virttoolsdatadir = $(datadir)/virt-tools # Unit tests. TESTS_ENVIRONMENT = $(top_builddir)/run --test TESTS = test-v2v-python-syntax.sh if HAVE_OCAML_PKG_OUNIT TESTS += \ v2v_unit_tests \ var_expander_tests check_PROGRAMS = \ v2v_unit_tests \ var_expander_tests endif v2v_unit_tests_BOBJECTS = \ config.cmo \ types.cmo \ utils.cmo \ libosinfo.cmo \ libosinfo_utils.cmo \ DOM.cmo \ create_ovf.cmo \ windows.cmo \ linux.cmo \ windows_virtio.cmo \ parse_vmx.cmo \ v2v_unit_tests.cmo v2v_unit_tests_XOBJECTS = $(v2v_unit_tests_BOBJECTS:.cmo=.cmx) v2v_unit_tests_SOURCES = $(virt_v2v_SOURCES) v2v_unit_tests_CPPFLAGS = $(virt_v2v_CPPFLAGS) v2v_unit_tests_CFLAGS = $(virt_v2v_CFLAGS) var_expander_tests_BOBJECTS = \ var_expander.cmo \ var_expander_tests.cmo var_expander_tests_XOBJECTS = $(var_expander_tests_BOBJECTS:.cmo=.cmx) var_expander_tests_SOURCES = dummy.c var_expander_tests_CPPFLAGS = $(virt_v2v_CPPFLAGS) var_expander_tests_CFLAGS = $(virt_v2v_CFLAGS) if !HAVE_OCAMLOPT # Can't call this v2v_unit_tests_OBJECTS because automake gets confused. v2v_unit_tests_THEOBJECTS = $(v2v_unit_tests_BOBJECTS) v2v_unit_tests.cmo: OCAMLPACKAGES += -package ounit2 var_expander_tests_THEOBJECTS = $(var_expander_tests_BOBJECTS) var_expander_tests.cmo: OCAMLPACKAGES += -package ounit2 else v2v_unit_tests_THEOBJECTS = $(v2v_unit_tests_XOBJECTS) v2v_unit_tests.cmx: OCAMLPACKAGES += -package ounit2 var_expander_tests_THEOBJECTS = $(var_expander_tests_XOBJECTS) var_expander_tests.cmx: OCAMLPACKAGES += -package ounit2 endif v2v_unit_tests_DEPENDENCIES = \ $(v2v_unit_tests_THEOBJECTS) \ ../common/mlstdutils/mlstdutils.$(MLARCHIVE) \ ../common/mlxml/mlxml.$(MLARCHIVE) \ ../common/mlgettext/mlgettext.$(MLARCHIVE) \ ../common/mlpcre/mlpcre.$(MLARCHIVE) \ ../common/mlutils/mlcutils.$(MLARCHIVE) \ ../common/mltools/mltools.$(MLARCHIVE) \ ../common/mlcustomize/mlcustomize.$(MLARCHIVE) \ ../common/mlv2v/mlv2v.$(MLARCHIVE) \ $(top_srcdir)/ocaml-link.sh v2v_unit_tests_LINK = \ $(top_srcdir)/ocaml-link.sh -cclib '$(OCAMLCLIBS)' -- \ $(OCAMLFIND) $(BEST) $(OCAMLFLAGS) \ $(OCAMLPACKAGES) -package ounit2 \ $(OCAMLLINKFLAGS) \ $(v2v_unit_tests_THEOBJECTS) -o $@ var_expander_tests_DEPENDENCIES = \ $(var_expander_tests_THEOBJECTS) \ ../common/mlpcre/mlpcre.$(MLARCHIVE) \ $(top_srcdir)/ocaml-link.sh var_expander_tests_LINK = \ $(top_srcdir)/ocaml-link.sh -cclib '$(OCAMLCLIBS)' -- \ $(OCAMLFIND) $(BEST) $(OCAMLFLAGS) \ $(OCAMLPACKAGES) -package ounit2 \ $(OCAMLLINKFLAGS) \ $(var_expander_tests_THEOBJECTS) -o $@ # Dependencies. .depend: \ $(srcdir)/*.mli \ $(srcdir)/*.ml \ $(CONFIGURE_GENERATED_ML) \ $(filter %.ml,$(BUILT_SOURCES)) $(top_builddir)/ocaml-dep.sh $^ -include .depend virt-v2v-1.44.2/v2v/PaxHeaders/linux.ml0000644000000000000000000000013013732617001014563 xustar0028 mtime=1600855553.8470355 30 atime=1637862739.516417133 30 ctime=1637862790.856848338 virt-v2v-1.44.2/v2v/linux.ml0000664000175000017500000001621013732617001016373 0ustar00rjonesrjones00000000000000(* virt-v2v * Copyright (C) 2009-2020 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *) open Printf open Std_utils open Tools_utils open Common_gettext.Gettext open Types open Utils module G = Guestfs let re_version = PCRE.compile "(\\d+)\\.(\\d+)" let augeas_reload g = g#aug_load (); debug_augeas_errors g let rec install_local g { i_package_format = package_format } packages = if packages <> [] then ( match package_format with | "rpm" -> let cmd = [ "rpm"; "--upgrade"; "-v" ] @ packages in let cmd = Array.of_list cmd in ignore (g#command cmd) | format -> error (f_"don’t know how to install packages using %s: packages: %s") format (String.concat " " packages) (* Reload Augeas in case anything changed. *) augeas_reload g ) let rec remove g inspect packages = if packages <> [] then ( do_remove g inspect packages; (* Reload Augeas in case anything changed. *) augeas_reload g ) and do_remove g { i_package_format = package_format } packages = assert (List.length packages > 0); match package_format with | "deb" -> let cmd = [ "dpkg"; "--purge" ] @ packages in let cmd = Array.of_list cmd in ignore (g#command cmd); | "rpm" -> let cmd = [ "rpm"; "-e" ] @ packages in let cmd = Array.of_list cmd in ignore (g#command cmd) | format -> error (f_"don’t know how to remove packages using %s: packages: %s") format (String.concat " " packages) let file_list_of_package (g : Guestfs.guestfs) inspect app = match inspect.i_package_format with | "deb" -> let cmd = [| "dpkg"; "-L"; app.G.app2_name |] in debug "%s" (String.concat " " (Array.to_list cmd)); let files = g#command_lines cmd in let files = Array.to_list files in List.sort compare files | "rpm" -> (* Since RPM allows multiple packages installed with the same * name, always check the full NEVR here (RHBZ#1161250). * * In RPM < 4.11 query commands that use the epoch number in the * package name did not work. * * For example: * RHEL 6 (rpm 4.8.0): * $ rpm -q tar-2:1.23-11.el6.x86_64 * package tar-2:1.23-11.el6.x86_64 is not installed * Fedora 20 (rpm 4.11.2): * $ rpm -q tar-2:1.26-30.fc20.x86_64 * tar-1.26-30.fc20.x86_64 *) let is_rpm_lt_4_11 () = let ver = try let ver = List.find_map ( function | { G.app2_name = name; G.app2_version = version } when name = "rpm" -> Some version | _ -> None ) inspect.i_apps in if PCRE.matches re_version ver then (int_of_string (PCRE.sub 1), int_of_string (PCRE.sub 2)) else (0, 0) with Not_found -> (* 'rpm' not installed? Hmm... *) (0, 0) in ver < (4, 11) in let pkg_name = if app.G.app2_epoch = Int32.zero || is_rpm_lt_4_11 () then sprintf "%s-%s-%s" app.G.app2_name app.G.app2_version app.G.app2_release else sprintf "%s-%ld:%s-%s" app.G.app2_name app.G.app2_epoch app.G.app2_version app.G.app2_release in let cmd = [| "rpm"; "-ql"; pkg_name |] in debug "%s" (String.concat " " (Array.to_list cmd)); let files = g#command_lines cmd in (* RPM prints "(contains no files)" on stdout when a package * has no files in it: * https://github.com/rpm-software-management/rpm/issues/962 *) if files = [| "(contains no files)" |] then [] else ( let files = Array.to_list files in List.sort compare files ) | format -> error (f_"don’t know how to get list of files from package using %s") format let is_file_owned (g : G.guestfs) { i_package_format = package_format } path = match package_format with | "deb" -> (* With dpkg usually the directories are owned by all the packages * that install anything in them. Also with multiarch the same * package is allowed (although with different architectures). * This function returns only one package in all the cases. *) let cmd = [| "dpkg"; "-S"; path |] in debug "%s" (String.concat " " (Array.to_list cmd)); (try let lines = g#command_lines cmd in if Array.length lines = 0 then error (f_"internal error: is_file_owned: dpkg command returned no output"); (* Just check the output looks something like "pkg: filename". *) if String.find lines.(0) ": " >= 0 then true else error (f_"internal error: is_file_owned: unexpected output from dpkg command: %s") lines.(0) with Guestfs.Error msg as exn -> if String.find msg "no path found matching pattern" >= 0 then false else raise exn ) | "rpm" -> (* Run rpm -qf and print a magic string if the file is owned. * If not owned, rpm will print "... is not owned by any package" * and exit with an error. Unfortunately the string is sent to * stdout, so here we ignore the exit status of rpm and just * look for one of the two strings. *) let magic = "FILE_OWNED_TEST" in let cmd = sprintf "rpm -qf --qf %s %s 2>&1 ||:" (quote (magic ^ "\n")) (quote path) in let r = g#sh cmd in if String.find r magic >= 0 then true else if String.find r "is not owned" >= 0 then false else failwithf "RPM file owned test failed: %s" r | format -> error (f_"don’t know how to find file owner using %s") format let is_package_manager_save_file filename = (* Recognized suffixes of package managers. *) let suffixes = [ ".dpkg-old"; ".dpkg-new"; ".rpmsave"; ".rpmnew"; ] in List.exists (Filename.check_suffix filename) suffixes let binary_package_extension { i_package_format = package_format } = match package_format with | "deb" -> "deb" | "rpm" -> "rpm" | format -> error (f_"don’t know what is the extension of binary packages using %s") format let architecture_string { i_package_format = package_format; i_arch = arch; i_distro = distro } = match package_format, distro, arch with | "deb", _, "x86_64" -> "amd64" | "deb", _, a -> a | "rpm", ("sles"|"suse-based"|"opensuse"), "i386" -> "i586" | "rpm", ("sles"|"suse-based"|"opensuse"), a -> a | "rpm", _, "i386" -> "i686" | "rpm", _, a -> a | format, distro, arch -> error (f_"don’t know what is the architecture string of %s using %s on %s") arch format distro virt-v2v-1.44.2/v2v/PaxHeaders/parse_libvirt_xml.ml0000644000000000000000000000012714147420157017164 xustar0030 mtime=1637752943.739127229 27 atime=1637862739.528417 30 ctime=1637862790.869848194 virt-v2v-1.44.2/v2v/parse_libvirt_xml.ml0000644000175000017500000004633114147420157020773 0ustar00rjonesrjones00000000000000(* virt-v2v * Copyright (C) 2009-2020 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *) open Printf open C_utils open Std_utils open Tools_utils open Common_gettext.Gettext open Xpath_helpers open Types open Utils type parsed_disk = { p_source_disk : source_disk; p_source : parsed_source; } and parsed_source = | P_source_dev of string | P_source_file of string | P_dont_rewrite (* Turn string like "hda" into controller slot number. See also * common/utils/utils.c:guestfs_int_drive_index which this function calls. *) let get_drive_slot str offset = let name = String.sub str offset (String.length str - offset) in try Some (drive_index name) with Invalid_argument _ -> warning (f_"could not parse device name ‘%s’ from the source libvirt XML") str; None let parse_libvirt_xml ?bandwidth ?conn xml = debug "libvirt xml is:\n%s" xml; (* Create a default libvirt connection on request, to not open one * in case there is no need to fetch more data (for example inspect * the storage pools). *) let libvirt_conn = lazy (Libvirt.Connect.connect ()) in let get_conn () = match conn with | None -> Lazy.force libvirt_conn | Some conn -> conn in let doc = Xml.parse_memory xml in let xpathctx = Xml.xpath_new_context doc in let xpath_string = xpath_string xpathctx and xpath_int = xpath_int xpathctx and xpath_int64 = xpath_int64 xpathctx in let hypervisor = match xpath_string "/domain/@type" with | None | Some "" -> error (f_"in the libvirt XML metadata, is missing or empty") | Some s -> source_hypervisor_of_string s in let name = match xpath_string "/domain/name/text()" with | None | Some "" -> error (f_"in the libvirt XML metadata, is missing or empty") | Some s -> s in let genid = match xpath_string "/domain/genid/text()" with | None | Some "" -> None | Some _ as s -> s in let memory = Option.default (1024L *^ 1024L) (xpath_int64 "/domain/memory/text()") in let memory = memory *^ 1024L in let cpu_vendor = xpath_string "/domain/cpu/vendor/text()" in let cpu_model = xpath_string "/domain/cpu/model/text()" in let cpu_sockets = xpath_int "/domain/cpu/topology/@sockets" in let cpu_cores = xpath_int "/domain/cpu/topology/@cores" in let cpu_threads = xpath_int "/domain/cpu/topology/@threads" in (* Get the field from the input XML. If not set then * try calculating it from the node. If that's * not set either, then assume 1 vCPU. *) let vcpu = xpath_int "/domain/vcpu/text()" in let vcpu = match vcpu, cpu_sockets, cpu_cores, cpu_threads with | Some vcpu, _, _, _ -> vcpu | None, None, None, None -> 1 | None, _, _, _ -> let sockets = Option.default 1 cpu_sockets and cores = Option.default 1 cpu_cores and threads = Option.default 1 cpu_threads in sockets * cores * threads in let cpu_topology = match cpu_sockets, cpu_cores, cpu_threads with | Some sockets, Some cores, Some threads -> Some { s_cpu_sockets = sockets; s_cpu_cores = cores; s_cpu_threads = threads; } | _, _, _ -> None in let features = let nodes = xpath_get_nodes xpathctx "/domain/features/*" in List.map Xml.node_name nodes in let display = let obj = Xml.xpath_eval_expression xpathctx "/domain/devices/graphics" in let nr_nodes = Xml.xpathobj_nr_nodes obj in if nr_nodes < 1 then None else ( (* Ignore everything except the first device. *) let node = Xml.xpathobj_node obj 0 in Xml.xpathctx_set_current_context xpathctx node; let keymap = xpath_string "@keymap" in let password = xpath_string "@passwd" in let listen = let obj = Xml.xpath_eval_expression xpathctx "listen" in let nr_nodes = Xml.xpathobj_nr_nodes obj in if nr_nodes < 1 then ( match xpath_string "@listen" with | None -> LNoListen | Some a -> LAddress a ) else ( (* Use only the first configuration. *) match xpath_string "listen[1]/@type" with | None -> LNoListen | Some "address" -> (match xpath_string "listen[1]/@address" with | None -> LNoListen | Some a -> LAddress a ) | Some "network" -> (match xpath_string "listen[1]/@network" with | None -> LNoListen | Some n -> LNetwork n ) | Some "socket" -> (match xpath_string "listen[1]/@socket" with | None -> LSocket None | Some n -> LSocket (Some n) ) | Some "none" -> LNone | Some t -> warning (f_" in the input libvirt XML was ignored") t; LNoListen ) in let port = match xpath_string "@autoport" with | Some "no" -> (match xpath_int "@port" with | Some port when port > 0 -> Some port | Some _ | None -> None) | _ -> None in match xpath_string "@type" with | None -> None | Some "vnc" -> Some { s_display_type = VNC; s_keymap = keymap; s_password = password; s_listen = listen; s_port = port } | Some "spice" -> Some { s_display_type = Spice; s_keymap = keymap; s_password = password; s_listen = listen; s_port = port } | Some ("sdl"|"desktop" as t) -> warning (f_"virt-v2v does not support local displays, so in the input libvirt XML was ignored") t; None | Some t -> warning (f_"display in the input libvirt XML was ignored") t; None ) in (* Video adapter. *) let video = let obj = Xml.xpath_eval_expression xpathctx "/domain/devices/video" in let nr_nodes = Xml.xpathobj_nr_nodes obj in if nr_nodes < 1 then None else ( (* Ignore everything except the first