Commit Graph

10470 Commits

Author SHA1 Message Date
Richard W.M. Jones
c7651744da ocaml: Replace pattern matching { field = field } with { field }.
If you have a struct containing ‘field’, eg:

  type t = { field : int }

then previously to pattern-match on this type, eg. in function
parameters, you had to write:

  let f { field = field } =
    (* ... use field ... *)

In OCaml >= 3.12 it is possible to abbreviate cases where the field
being matched and the variable being bound have the same name, so now
you can just write:

  let f { field } =
    (* ... use field ... *)

(Similarly for a field prefixed by a Module name you can use
‘{ Module.field }’ instead of ‘{ Module.field = field }’).

This style is widely used inside the OCaml compiler sources, and is
briefer than the long form, so it makes sense to use it.  Furthermore
there was one place in virt-dib where we are already using this new
style, so the old code did not compile on OCaml < 3.12.

See also:
https://forge.ocamlcore.org/docman/view.php/77/112/leroy-cug2010.pdf
2017-10-05 11:32:54 +01:00
Richard W.M. Jones
2cdd2eb795 build: Require OCaml >= 4.01.
RHEL 6, Debian <= 7 and Ubuntu < 14.04 are no longer supported
(unless OCaml and other components are upgraded).

See: https://www.redhat.com/archives/libguestfs/2017-September/msg00203.html
2017-10-05 11:32:54 +01:00
Richard W.M. Jones
37c851697b rhel: Allow compilation with Augeas < 1.8.0 by making aug_source optional. 2017-10-05 11:32:07 +01:00
Richard W.M. Jones
a6a982f004 builder: Choose better weights in the planner. 2017-10-04 15:38:24 +01:00
Richard W.M. Jones
bbd54295d3 daemon: Reimplement statvfs API in OCaml, drop gnulib fallback.
common/mlutils: Unix_utils.StatVFS.statvfs: This commit implements a
full-featured binding for the statvfs(3) function.

We then use this to reimplement the daemon statvfs API in OCaml.

Note that the Gnulib fallback is dropped in this commit.  It
previously referenced non-existent field names in the fs_usage struct
so it didn't work.  Also it's not necessary as POSIX has supported
statvfs(3) since 2001, it's supported in *BSD, macOS > 10.4, and there
is already a Windows fallback.
2017-10-04 15:25:32 +01:00
Richard W.M. Jones
1695a9ef30 common/mltools: getopt: Use lowercase_ascii instead of deprecated lowercase. 2017-10-04 10:40:16 +01:00
Richard W.M. Jones
286a365166 mltools: planner: Documentation and minor refactoring of types and parameters.
Just documentation and code refactoring, no functional change.
2017-10-02 22:39:38 +01:00
Richard W.M. Jones
638e15f25a v2v: Document that Windows 10 is supported/tested. 2017-10-02 19:56:12 +01:00
Richard W.M. Jones
d4d166c96b v2v: Document that Windows Server 2016 is supported/tested.
Tested by Kun Wei.
2017-10-02 19:53:15 +01:00
Ken Stailey
fcacda8374 fish: In interactive mode, improve error message for help of unknown command (RHBZ#1497475) 2017-09-30 22:17:05 +01:00
Richard W.M. Jones
6127852d24 v2v: types: Rearrange types and headings.
Also moves the mpstat structure & print_mpstat function into the
v2v.ml file, since that is the only place which uses it.

No functional change.
2017-09-30 22:17:05 +01:00
Richard W.M. Jones
ae88a6676a v2v: -i vmx: Remove redundant parentheses in match cases. 2017-09-30 10:12:57 +01:00
Richard W.M. Jones
9368721f4a Version 1.37.28. v1.37.28 2017-09-28 15:28:13 +01:00
Richard W.M. Jones
cd304ad838 common/mltools: Rename Common_utils to Tools_utils.
Reflecting the purpose of this module now, which is to act as a place
for utility functions shared only by the OCaml virt tools.
2017-09-28 14:39:23 +01:00
Richard W.M. Jones
80fa8a91e3 Rename mllib -> common/mltools.
This directory which previously contained random modules and functions
now has an official purpose: to be the place for any OCaml utility
needed by the OCaml virt tools.

This is just code movement, I didn't (yet) rename or move any of the
modules.
2017-09-28 14:39:23 +01:00
Richard W.M. Jones
abf43c40ca po: Add common/ml* directories to POTFILES-ml.
Although it's not too likely that these libraries will contain
translatable strings, it's consistent to add them to po/POTFILES-ml
because mllib/*.ml are also in this file.
2017-09-28 14:39:23 +01:00
Richard W.M. Jones
2b00983f23 common/mlgettext: Move common_gettext.ml{,i} to common/mlgettext.
Mostly just code motion, but common_gettext.mli was the same whether
or not ocaml-gettext exists, so instead of generating it, add the file
to git.
2017-09-28 14:39:22 +01:00
Richard W.M. Jones
0d21ad4c10 common/utils: Move ‘full_path’ and ‘is_reg’ (etc) into utils (from visit).
I also renamed the functions with the correct ‘guestfs_int_*’
namespace.

The corresponding change is made for OCaml C_utils and Visit.

No functional change, just code motion.
2017-09-28 14:39:22 +01:00
Richard W.M. Jones
d5ce659e2c customize: Unconditionally set the machine-id if not set already.
systemd defined an /etc/machine-id file which is supposed to contain a
unique, unchanging ID for the host.  This file is initially zero-sized
and is meant to be set by systemd on the first boot of the system.  In
virt-builder Fedora templates, the file is empty.

Unfortunately the Fedora kernel %post script requires the machine-id
to have been set, else the script exits with an error:

  Running scriptlet: kernel-core-4.12.13-300.fc26.x86_64        209/209
  Could not determine your machine ID from /etc/machine-id.
  Please run 'systemd-machine-id-setup' as root. See man:machine-id(5)
  warning: %posttrans(kernel-core-4.12.13-300.fc26.x86_64) scriptlet failed, exit status 1

This also leaves the kernel package half-installed.  The files are
present in the filesystem, but important initialization is not done,
in particular the vmlinuz file is not copied into /boot.

A simple reproducer for this problem is:

  $ virt-builder fedora-26 --update

which will leave the image with a half-installed kernel.  (Add -v -x
to see the error above amongst the debug output).

This change makes virt-customize set /etc/machine-id to a random value
if the file exists and is zero sized.  This is done unconditionally at
the same time as setting the random seed (a similar issue), and before
running any customize options such as installing or updating packages.
2017-09-28 14:39:22 +01:00
Richard W.M. Jones
fa62e3a0cf v2v: utils: Replace Str.bounded_split with PCRE.nsplit.
Updates commit 8f91d3a9b0 similar to
Tomáš's original intended code.
2017-09-28 14:39:22 +01:00
Richard W.M. Jones
7e73fdece4 generator: Replace use of Str.split with String.nsplit.
Faster and equivalent.
2017-09-28 14:39:22 +01:00
Richard W.M. Jones
93851042f2 v2v: parse VMX: Replace Str with PCRE. 2017-09-28 14:39:22 +01:00
Richard W.M. Jones
49208f243f v2v: parse OVF: Replace Str with PCRE. 2017-09-28 14:39:22 +01:00
Richard W.M. Jones
9f0aad1f37 v2v: vCenter: Replace Str with PCRE. 2017-09-28 14:39:22 +01:00
Richard W.M. Jones
d0c8f0ffe1 v2v: -o libvirt: Use PCRE to verify arch is sane. 2017-09-28 14:39:22 +01:00
Richard W.M. Jones
9c191bb15f v2v: -i ova: Use PCRE to match lines in manifest files. 2017-09-28 14:39:22 +01:00
Richard W.M. Jones
6db4606948 v2v: windows: Convert the Windows-related conversion modules from Str to PCRE.
This is all new code since the virt-v2v conversion from Perl so there
was no need to check back with the original code.

See also commit 9d920732a3.
2017-09-28 14:39:22 +01:00
Richard W.M. Jones
524bf19661 v2v: linux: Convert the Linux-related conversion modules from Str to PCRE.
For each regular expression I went back to the original Perl code to
ensure that the regexp is correct.
2017-09-28 14:39:22 +01:00
Richard W.M. Jones
d279d602be v2v: linux: Properly ignore rpm/dpkg-move-aside kernels.
The old virt-v2v code ignored boot kernels with names like
"/boot/vmlinuz-*.rpmsave".  The transscribed code did not because the
Str module requires ‘|’ to be escaped as ‘\|’.

This changes the code to use a simpler test.

Thanks: Pino Toscano
2017-09-28 14:39:22 +01:00
Richard W.M. Jones
3a4410000e v2v: linux: Fix rewriting of grub2 GRUB_CMDLINE=...resume=<device>...
Commit dbe0b69f24 transscribed the Perl
regexp incorrectly so that it only matched the impossible case of
‘resume=/dev/X’ for a single non-whitespace character X.

This fixes the regular expression, referencing back to the original
Perl code in virt-v2v.
2017-09-28 14:39:22 +01:00
Richard W.M. Jones
95b0da8f37 v2v: linux: Fix uninstallation of kmod-xenpv from /etc/rc.local script.
In the original conversion of virt-v2v from Perl
(commit 0131d6f666), the Perl regular
expression was incorrectly transscribed.  ‘\b’ was not converted to
‘\\b’ so the new regexp was looking for an ASCII BEL character, not a
word boundary.  Also ‘|’ was used, but Str requires ‘\|’ (ie. "\\|"
in the final source).

To fix these problems I converted the code to use PCRE, and went back
to the original virt-v2v code (virt-v2v.git:
lib/Sys/VirtConvert/Converter/Linux.pm) to find out what the Perl
regular expression should have been.

Note I have also removed ‘.*’ at the beginning and end of the regexp
because PCRE regexps are not anchored.
2017-09-28 14:39:22 +01:00
Richard W.M. Jones
843ea53af0 mllib: Convert Common_utils.parse_size and parse_resize to use PCRE.
This also involved enhancing/fixing the test so that parse_size has
test coverage.
2017-09-28 14:39:22 +01:00
Richard W.M. Jones
508f3b29b8 customize: Remove use of Str module from virt-customize code. 2017-09-28 14:39:22 +01:00
Richard W.M. Jones
08ee044be1 builder: Simplify PCRE regular expression by using case-insensitive matching.
Updates commit e5182b87cf.
2017-09-28 14:39:22 +01:00
Richard W.M. Jones
75e7d7e36c valgrind: Ignore PCRE.compile regexps stored in a global variable. 2017-09-28 14:39:22 +01:00
Richard W.M. Jones
45ef3545d4 common/mlpcre: Add split and nsplit functions.
These work like our String.split and String.nsplit functions.
2017-09-28 14:39:22 +01:00
Richard W.M. Jones
8bd5933cc7 common/mlstdutils: Add String.nsplit ?max parameter, and tests.
This idea was previously proposed by Tomáš Golembiovský in
https://www.redhat.com/archives/libguestfs/2017-January/msg00138.html
2017-09-28 14:39:22 +01:00
Richard W.M. Jones
430029db0a common/mlpcre: Allow some PCRE_* flags to be passed to pcre_compile.
Only five simple flags are allowed so far, and not all of them are
actually used in any code.  They are:

  ~anchored / PCRE_ANCHORED   - implicit ^...$ around regexp
  ~caseless / PCRE_CASELESS   - fold upper and lower case
  ~dotall / PCRE_DOTALL       - ‘.’ matches anything
  ~extended / PCRE_EXTENDED   - extended regular expressions
  ~multiline / PCRE_MULTILINE - ^ and $ match lines within the subject string
2017-09-28 14:39:22 +01:00
Richard W.M. Jones
727b2a41ed common/mlpcre: Add PCRE.replace function.
Similar to Perl s/// but lacks backreferences.
2017-09-28 14:39:22 +01:00
Richard W.M. Jones
de3ffa2774 common/mlpcre: Add PCRE.subi to return indexes instead of the substring. 2017-09-28 14:39:22 +01:00
Richard W.M. Jones
d2daafe7b7 common/mlpcre: Add const-correctness to guestfs_int_pcre_sub. 2017-09-28 14:39:22 +01:00
Richard W.M. Jones
cbd20c0f01 common/mlpcre: Raise Invalid_argument if PCRE.sub n parameter is negative. 2017-09-28 14:00:42 +01:00
Hilko Bengen
0b3079ba39 builder: Fix problem about index-parse.h not being generated
If configured with --without-ocaml, the build might fail because the
fix added in df5bd5741b was not active.
According to the automake documentation, it should be enough to set
BUILT_SOURCES.
2017-09-26 18:50:53 +01:00
Richard W.M. Jones
ecef1708a5 diff: Remove bogus perror when guestfs_* functions return error.
Neither guestfs_copy_statns nor guestfs_copy_xattr_list set errno, so
it's wrong to call perror(3) here.
2017-09-25 22:22:37 +01:00
Hilko Bengen
4bbf8a321f Fix determining release date for builddir != srcdir 2017-09-25 22:17:01 +01:00
Richard W.M. Jones
5a2db925ec mllib: registry: Make with_hive_readonly, with_hive_write clearer.
Tiny refactoring to make the code clearer.
2017-09-25 14:49:17 +01:00
Richard W.M. Jones
c10b7aaf36 v2v: Refactor convert functions.
This pure refactoring changes the convert () functions so that the
conversion operations are listed first, followed by the
implementations of those operations.
2017-09-25 14:49:17 +01:00
Richard W.M. Jones
deadf7c415 p2v: test: Send sshd debugging messages to stderr.
So that we can see errors/problems in sshd from the test in the
ordinary test-suite.log file.
2017-09-25 14:49:17 +01:00
Pino Toscano
531316cc3f build: improve and simplify distro detection
Add a --with-distro=ID argument for configure, so it is possible to
manually specify the distro to use for the packages (in case os-release
does not provide ID=.., or the ID is not recognized yet).

In the case when --with-distro is not set, keep doing the autodetection,
but using os-release only, i.e. dropping the checks for all the other
-release files -- since there is --with-distro, older distros with no
os-release can still be used.

RWMJ: Add documentation to guestfs-building(1).
2017-09-25 14:49:17 +01:00
Richard W.M. Jones
2cc70fca71 Version 1.37.27. v1.37.27 2017-09-22 09:45:24 +01:00