Commit Graph

9895 Commits

Author SHA1 Message Date
Richard W.M. Jones
a1b3d8d04b tests: Extend $TEST_FUNCTIONS with predefined functions for skipping tests etc.
Apply this change across all the shell scripts containing tests.

Additionally this defines the environment variables $abs_srcdir,
$abs_builddir, $top_srcdir, $top_builddir, $abs_top_srcdir and
$abs_top_builddir which can now be used throughout test scripts.
2017-02-21 17:23:22 +00:00
Richard W.M. Jones
e66be44016 tests: Add $TEST_FUNCTIONS.
This macro(?) expands to some shell script to source the
tests/test-functions.sh file from its correct location.  The intention
is to use this in all tests, but in this commit only the existing
tests which already include test-functions.sh are modified.
2017-02-21 17:23:22 +00:00
Richard W.M. Jones
51a703775c tests: Rename test-data/test-utils.sh -> tests/test-functions.sh.
This is pure code motion.
2017-02-21 17:23:22 +00:00
Richard W.M. Jones
3a4a491712 generator: Put all the daemon procedure numbers (proc_nr) into a single table.
Daemon 'proc_nr's have to be assigned monotonically and uniquely to
each daemon function.  However in practice it can be difficult to work
out which is the next free proc_nr.  Placing all of them into a single
table in a new file (proc_nr.ml) should make this easier.
2017-02-21 17:23:21 +00:00
Richard W.M. Jones
cf3001c2ed generator: Move guestfish commands to new module Fish_commands. 2017-02-21 17:23:21 +00:00
Richard W.M. Jones
97773d2bbe generator: Group and move APIs from actions.ml into actions_*.ml.
Group the APIs logically and move them into new modules:

Actions_core:
  Core APIs and anything that doesn't fit into another group, eg. launch.
  (With some more effort this could be split further.)

Actions_augeas:
  Augeas APIs, eg. aug-init.

Actions_debug:
  Debug APIs.

Actions_hivex:
  Hivex APIs, eg. hivex-open.

Actions_inspection:
  Inspection APIs, eg. inspect-get-type.

Actions_properties:
  Handle properties, eg. set-hv, get-hv.

Actions_tsk:
  SleuthKit APIs, eg. filesystem-walk.

*_deprecated:
  All of the above modules have deprecated variants, where we
  place the deprecated actions.
2017-02-21 17:23:21 +00:00
Richard W.M. Jones
736ee3586f generator: Move test APIs to new module. 2017-02-21 17:23:21 +00:00
Richard W.M. Jones
7d6fcfc733 generator: Move defaults to Types module.
Just code motion in preparation for the following commits.
2017-02-21 17:23:21 +00:00
Richard W.M. Jones
18777adf31 generator: Stablise output of common/protocol/*, daemon/*, lib/* and tests/c-api/tests.c
Sort the functions so the output is stable.

This changes the order in which the C API tests run.  Previously we
ran the newest tests first, which was useful when we were frequently
adding new APIs.  Now we run them in sorted order.
2017-02-21 17:23:21 +00:00
Richard W.M. Jones
5b0fa9ced9 generator: Generate stable UUID from contents of all action*.ml files.
Also rename the function 'uuidgen ()' (conflicts with a same-named
function in Common_utils) to 'stable_uuid'.  Notice that the UUID is
now only computed once per run of the generator, whereas previously
the same value was computed over and over again.
2017-02-21 17:23:21 +00:00
Pino Toscano
dc159ac5a1 dib: rename "aux" to "in_target.aux"
Sadly, there are elements (hello "gentoo"!) that, during the cleanup.d
phase, wipe out almost everything in the /tmp of the guest, including
the /tmp/aux where virt-dib mounts the auxiliary data. Since that
removal excludes things starting with "in_target" (mostly to avoid
wiping the "in_target.d" that disk-image-create itself sets up, then
rename our "aux" subdirectory to "in_target.aux" to work it around.

Hopefully, the "gentoo" element will be fixed upstream:
https://review.openstack.org/#/c/436101/
2017-02-21 18:05:03 +01:00
Pino Toscano
57a638234e dib: handle lack of phases when reloading scripts list
Commit 8ee51ee396 re-scans for the
available scripts when running certain phases; OTOH, some of them may be
missing, usually due to the lack of scripts for that phase in the
selected set of elements.

Indeed, if there is no directory for a phase, safely raise Not_found so
the case is handled as if the phase was missing in the final_hooks
Hashtbl.
2017-02-21 18:05:03 +01:00
Pino Toscano
e4adfed804 dib: unset all temporary dirs envvars in fake-sudo
The real sudo does it as well, and leaving them when preserving the
environment (-E) maybe breaks the applications, as e.g. chroot will have
a TMPDIR path pointing outside of it.
2017-02-21 18:05:02 +01:00
Richard W.M. Jones
cc0b961b68 Use the new Windows software/system hive APIs in various places. 2017-02-21 13:33:42 +00:00
Richard W.M. Jones
7ac977f12c New APIs: guestfs_inspect_get_windows_software_hive and guestfs_inspect_get_windows_system_hive.
The inspection code already computed the paths of the software hive
(twice!) and the system hive, plus we also recompute the same paths
elsewhere, in virt-v2v for example.  Therefore it makes sense to store
the paths from the inspection code and make them available through two
new APIs.
2017-02-21 13:33:42 +00:00
Richard W.M. Jones
e2a661f49b v2v: Simplify and document gnarly set_reg_val_dword_1 function. 2017-02-21 12:08:45 +00:00
Richard W.M. Jones
a210aaafd3 mllib: registry: New function for creating paths in the registry. 2017-02-21 12:08:45 +00:00
Richard W.M. Jones
b4809a12ea mllib: Add Registry.t = Guestfs.guestfs * Registry.node
Add a convenient tuple Registry.t for the currently open hive.  It
contains the guestfs handle and the root node of a registry.

The functions with_hive_readonly and with_hive_write are modified to
pass this tuple to their callbacks.
2017-02-21 12:08:45 +00:00
Richard W.M. Jones
5b48a8d59d customize, v2v: Use %systemroot% and CurrentControlSet from inspection.
For reasons unknown virt-v2v recomputed the CurrentControlSet from
first principles, and passed %systemroot% around to all functions.
However that data is available from the libguestfs inspection APIs.
2017-02-21 12:08:45 +00:00
Richard W.M. Jones
441db174f5 customize: firstboot: Use Registry.with_hive_write instead of open coding. 2017-02-21 12:08:45 +00:00
Richard W.M. Jones
ca5e7233df mllib: Move Windows Registry functions from v2v to common code.
Move the functions decode_utf16le, encode_utf16le, get_node,
with_hive_readonly and with_hive_write to common code in a new module
called Registry.

This also defines types for nodes and values, instead of using int64
directly.

Just code motion.
2017-02-21 12:08:45 +00:00
Richard W.M. Jones
2643c4d5f4 tail: Fix mistake in the man page (RHBZ#1425306).
Thanks: Xianghua Chen
2017-02-21 12:06:44 +00:00
Richard W.M. Jones
08e7506aba p2v: Fix slow test to pass LIBGUESTFS_PATH & LIBGUESTFS_CACHEDIR to virt-v2v.
Adding a new optional parameter to hivex_open in
commit 1f99251223 reveals a subtle bug
in the virt-p2v slow test.

Because we didn't pass LIBGUESTFS_PATH through to the instance of
virt-v2v, it was running with the new binary and library code, but
with the installed appliance (or would have failed if libguestfs
wasn't installed on the host when running the test).  In particular
this bug was revealed when the new virt-v2v binary passed the
GUESTFS_HIVEX_OPEN_UNSAFE flag to the guestfs_hivex_open call, which
the (old, installed) daemon did not recognize and rejected with an
error.

For the same reason we also have to pass in LIBGUESTFS_CACHEDIR to
make sure that supermin doesn't reuse the cached appliance from
/var/tmp.
2017-02-20 20:16:49 +00:00
Richard W.M. Jones
3feb957c8a 9p: Update test for virtio-pci on aarch64.
Fixes commit 4a9af91e36.
2017-02-20 12:06:14 +00:00
Pino Toscano
911317dc66 dib: small documentation improvements
Improve the grammar, and the wording, and make few details explicit.
No change in the actual content.
2017-02-17 16:06:09 +01:00
Pino Toscano
654eb25407 dib: preserve xattrs and SELinux attributes when exporting as tar
When extracting the content of the guest as tar, save also the extended
attributes and the SELinux attributes.  This makes sure guests exported
as tar, tgz, and as docker image will work fine afterwards.

This is what disk-image-create does as well.
2017-02-17 16:06:09 +01:00
Richard W.M. Jones
8ee7da48c5 lib, tools, v2v: Use unsafe flag when reading (but NOT writing) hives.
Pass the HIVEX_OPEN_UNSAFE flag when opening hives for reading.
Do NOT pass it when opening hives for writing.

This should make inspection, virt-win-reg and virt-v2v more tolerant
about handling Windows Registry corruption, without increasing the
risk of causing new corruption in hives.
2017-02-17 14:51:15 +00:00
Richard W.M. Jones
1f99251223 hivex: Map new HIVEX_OPEN_UNSAFE flag into the API.
In hivex >= 1.3.14, there is a new HIVEX_OPEN_UNSAFE flag allowing
heuristics to be used to deal with corrupted hives.  Map this flag
into the libguestfs API.

If the flag is not supported (because libguestfs was compiled with
hivex < 1.3.14) then the flag is ignored.  This is safe behaviour:
opening corrupted hives will give an error, as happened previously.
2017-02-17 10:15:09 +00:00
Richard W.M. Jones
ad3c8fe7f4 v2v: Document conversion failure with RHEL 6.2 (RHBZ#1374232). 2017-02-16 14:06:18 +00:00
Richard W.M. Jones
7bc618c89d Version 1.35.25. v1.35.25 2017-02-15 15:37:23 +00:00
Richard W.M. Jones
462cc4a502 docs/C_SOURCE_FILES, po/POTFILES, po/POTFILES-ml: Update these files. 2017-02-15 15:37:21 +00:00
Richard W.M. Jones
e46b07ca1b docs/C_SOURCE_FILES, po/POTFILES: Remove duplicate files.
Because v2v/test-harness is a subdirectory of v2v, and because both
paths are listed in $(DIST_SUBDIRS), using find $(DIST_SUBDIRS) will
list files in v2v/test-harness twice.  (This probably happens in other
directories too, but I noticed it here.)  The easiest fix for this is
simply to use 'sort -u' to remove the duplicates.
2017-02-15 15:05:47 +00:00
Richard W.M. Jones
6dcfd85623 Update gnulib to latest. 2017-02-15 15:05:47 +00:00
Pino Toscano
3c0bd14852 dib: add squashfs output format
Implement the "squash" output format, i.e. a squashfs compressed
filesystem.

This was implemented in diskimage-builder upstream as
commit 9d13084c4183b63587e1f5e4b03395a8df6538f6.
2017-02-15 14:44:13 +01:00
Pino Toscano
7a3854001e New API: mksquashfs
Introduce a new API to create a new squashfs filesystem out of a path
in the guest.  It can be configured to exclude paths based on patterns,
and to select which compression use for the filesystem.

The advantage of running mksquashfs directly in the appliance is that
ownerships are properly saved, as opposed to tar_out + local untar.
2017-02-15 14:44:13 +01:00
Pino Toscano
35d97daa5a daemon: move make_exclude_from_file as common helper
It will be useful also for APIs different than tar-out, so move it to
guestfsd.c, and add it a parameter to specify the function name that
invoked it.

This is mostly code motion.
2017-02-15 14:44:12 +01:00
Pino Toscano
468d335fdf dib: add appliance check hook in Output_format
Add a new hook for Output_format's to check for prerequisites on the
appliance (which can be done only when the appliance is run).
2017-02-15 11:08:01 +01:00
Pino Toscano
c8236b2f1c dib: cleanup logs at end of build
Recently, diskimage-builder moved the log cleanup from the 'base'
element to disk-image-create proper; the cleanup done is:
- truncate any file in /var/log
- remove *.log files in /root

This was implemented in diskimage-builder upstream as
commit 022d93ee822e71245af52c4cf8f8a8e82f599af3.
2017-02-15 11:08:01 +01:00
Pino Toscano
8ee51ee396 dib: re-read list of scripts when running in-chroot hooks
Scripts (especially root.d and extra-data.d) may add new scripts to the
existing set during their execution: in this case, re-read the list of
available scripts, so we do not miss any new addition.
2017-02-15 11:08:00 +01:00
Pino Toscano
551eb2072f dib: change hooks path when running extra-data.d scripts
It looks like scripts (in particular in the extra-data.d phase) may
in-flight add new scripts to the existing ones.  As first step to
handle this situation, change the path of hooks passed for extra-data.d
scripts: instead of the local temporary directory, use the in-guest
location that is visible as result of the local fuse-based mount of the
guest.
2017-02-15 11:08:00 +01:00
Pino Toscano
dfc700d2b5 dib: source dib "die" script in some phases
Source the "die" script, part of the diskimage-builder library, when
running hooks that run outside the guest chroot.  This is what
disk-image-create does, and scripts expect to use the "die" function
without sourcing the "die" script containing it.
2017-02-15 11:08:00 +01:00
Pino Toscano
0ab539d82f dib: fix listing envvars in fake-sudo
Query awk for the list of environment variables, instead of trying to
extract the list from the output of `env`: the old approach breaks when
any of the environment variable contains more than one line.
2017-02-15 11:08:00 +01:00
Richard W.M. Jones
a75076f271 GCC 7: Allocate sufficient space for sprintf output.
GCC 7.0.1 can determine if there is likely to be sufficient space in
the output buffer when using sprintf/snprintf, based on the format
string.

The errors were all either of this form:

bindtests.c:717:29: error: '%zu' directive output may be truncated writing between 1 and 19 bytes into a region of size 16 [-Werror=format-truncation=]
     snprintf (strs[i], 16, "%zu", i);
                             ^~~
bindtests.c:717:28: note: directive argument in the range [0, 2305843009213693951]
     snprintf (strs[i], 16, "%zu", i);
                             ^~~~~

or this form:

sync.c: In function 'fsync_devices':
sync.c:108:50: error: '%s' directive output may be truncated writing up to 255 bytes into a region of size 251 [-Werror=format-truncation=]
       snprintf (dev_path, sizeof dev_path, "/dev/%s", d->d_name);
                                                  ^~

Fixed by converting these into dynamic allocation, or making the
output buffer larger, whichever was easier.

There is a gnulib macro we can use to make this simpler for integers.
It requires a new gnulib module (intprops), but it turns out that we
were already pulling that in through dependencies, so the change to
bootstrap is a no-op.  (thanks: Dan Berrange)
2017-02-14 17:53:28 +00:00
Richard W.M. Jones
0b3a5a0b00 GCC 7: Add __attribute__((noreturn)) to some usage functions which call exit.
This happens with GCC 7.0.1.  The errors were all of the form:

qemu-speed-test.c: In function 'main':
qemu-speed-test.c:153:7: error: this statement may fall through [-Werror=implicit-fallthrough=]
       usage (EXIT_SUCCESS);
       ^~~~~~~~~~~~~~~~~~~~
qemu-speed-test.c:155:5: note: here
     default:
     ^~~~~~~
2017-02-14 15:25:25 +00:00
Cédric Bosdonnat
39daa04181 mllib: add Xml.parse_file helper
Provide a helper function rather than having callers read the
file and then parse the string.
2017-02-14 15:25:25 +00:00
Cédric Bosdonnat
2fe2e17f7d Move xml and xpath_helpers OCAML code to mllib
To allow other pieces of code to process XML files easily, move the
xml.ml* and xpath_helpers.ml* from v2v to mllib.
2017-02-14 15:25:25 +00:00
Cédric Bosdonnat
c45ce1a7bb mllib: factorize code to add Checksum.get_checksum function
Getting checksum involves the same code than verifying them. Create
a get_checksum function and use it in verify_checksum.
2017-02-14 14:33:11 +00:00
Richard W.M. Jones
1230543f71 fish: Link to libtinfo (RHBZ#1417549).
Fixes commit a8c5739fd2.

Reported by: Jean-Christophe Manciot
2017-02-14 13:18:57 +01:00
Richard W.M. Jones
23c2351e36 Version 1.35.24. v1.35.24 2017-02-11 09:15:25 +00:00
Richard W.M. Jones
53317e3f07 test-data: Use qemu-img instead of guestfish to create blank disks.
Since this step runs during make (not make check), guestfish
hasn't been built yet.

Fixes commit fa83b47876
and commit 74ded0dbc1.
2017-02-11 09:07:09 +00:00