Commit Graph

10486 Commits

Author SHA1 Message Date
Pino Toscano
9bb1e52253 Fully initialize the custom_operations structs
Use also custom_compare_ext_default for the compare_ext field.

According to the git logs, this was introduced in OCaml 3.12.1, which is
earlier than out minimum required version.

mlaugeas is not touched by this change, since it is a copy of a 3rd
party library (and thus it will be fixed there first).
2017-10-09 12:53:43 +02:00
Cédric Bosdonnat
7291fed7fb builder: rename docs test script
Rename test-virt-builder-docs.sh into test-docs.sh to include test
for another tool's documentation.
2017-10-09 10:38:56 +01:00
Richard W.M. Jones
5741b3734c Version 1.37.29. v1.37.29 2017-10-07 17:13:10 +01:00
Richard W.M. Jones
85388f09a3 builder: Add FreeBSD 11.1 template. 2017-10-06 14:47:12 +01:00
Richard W.M. Jones
83d6ad3790 builder: template: Add minimal support for creating FreeBSD templates.
These cannot be automated yet.
2017-10-06 14:47:12 +01:00
Richard W.M. Jones
92fa2d3794 builder: make-template: Don't need --os-type=linux.
The --os-type option is obsolete.  All the information is conveyed in
the --os-variant option.
2017-10-06 14:47:12 +01:00
Richard W.M. Jones
319fddb54b builder: make-template: Use the virt-install --transient option.
Ensures that we don't need to clean up the libvirt domain.
2017-10-06 14:47:12 +01:00
Richard W.M. Jones
fbf044a11c m4: Rename guestfs_*.m4 to guestfs-*.m4.
For consistency with other code.
2017-10-06 14:36:16 +01:00
Richard W.M. Jones
aad2c9413f lib/inspect-icon.c: Return error if guestfs_int_cmd_run has internal error.
This function returns -1 if things like fork(2) fail, so it is right
to return an error here.  If the PBMTEXT command fails then that's a
NOT_FOUND case.
2017-10-06 13:53:14 +01:00
Richard W.M. Jones
45d6f8bef9 daemon: Use O_CLOEXEC instead of Unix.set_close_on_exec.
In fact we already used O_CLOEXEC in daemon/inspect_fs_windows.c,
meaning that the code wouldn't have compiled on OCaml 3.11.

Thanks: Pino Toscano
2017-10-05 11:32:54 +01:00
Richard W.M. Jones
457bdb4e2f common/mlstdutils: Drop our implementations of functions now in OCaml 4.01.
We reimplemented some functions which can now be found in the OCaml
stdlib since 4.01 (or earlier).  The functions I have dropped are:

 - String.map
 - |>
 - iteri  (replaced by List.iteri)
 - mapi   (replaced by List.mapi)

Note that our definition of iteri was slightly wrong: the type of the
function parameter was too wide, allowing (int -> 'a -> 'b) instead of
(int -> 'a -> unit).

I also added this new function to the Std_utils.String module as an
export from stdlib String:

 - String.iteri

Thanks: Pino Toscano
2017-10-05 11:32:54 +01:00
Richard W.M. Jones
a702858664 ocaml: Enable warn-error on warning 52.
Since the previous commits have fixed all instances of this warning,
it should now be safe to enable warn-error on it.
2017-10-05 11:32:54 +01:00
Richard W.M. Jones
e44562dd6f ocaml: Avoid Warning 52 for Planner.plan function.
Change the Planner.plan function so it returns an optional type.  This
means it no longer raises Failure "plan" on error, so we can both
force the caller to deal with the error case and avoid Warning 52.
2017-10-05 11:32:54 +01:00
Richard W.M. Jones
20edfd672c ocaml: Avoid Warning 52 for Visit.visit function.
Similar to the previous commit, this creates a new Visit.Failure
exception for the visit function, avoiding Warning 52.
2017-10-05 11:32:54 +01:00
Richard W.M. Jones
0970bd0608 ocaml: Avoid Warning 52 for URI.parse_uri function.
This avoids warning 52 in OCaml code such as:

  try URI.parse_uri arg
  with Invalid_argument "URI.parse_uri" -> ...

which prints:

  Warning 52: Code should not depend on the actual values of
  this constructor's arguments. They are only for information
  and may change in future versions. (See manual section 8.5)

In the long term we need to change fish/uri.c so that we can throw
proper errors.
2017-10-05 11:32:54 +01:00
Richard W.M. Jones
4f46a425d4 ocaml: Replace Filename.temp_dir_name with get_temp_dir_name.
This was deprecated and replaced in OCaml >= 4.00.
2017-10-05 11:32:54 +01:00
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