Compare commits

...

3150 Commits

Author SHA1 Message Date
Richard W.M. Jones
50ca24b634 Version 1.37.34. 2017-11-16 23:05:17 +00:00
Richard W.M. Jones
6407f23e3d tests: Make filtering code in rhbz557655.sh test more liberal.
Because of vagaries in how the debug messages get printed they can get
split over lines:

  gulibguestfs: trace: truncate_size = 0
  estfsd: => truncate_size (0xc8) took 0.00 secs

and the code which filtered out those messages before comparison was
failing.  This makes the code more liberal on how it matches and
filters out these messages.
2017-11-16 22:43:53 +00:00
Richard W.M. Jones
068078ba95 Version 1.37.33. 2017-11-16 14:03:23 +00:00
Richard W.M. Jones
f42a6f056f po: Add osinfo_config.ml to POTFILES-ml.
Updates commit 02184f55f9.
2017-11-16 14:03:03 +00:00
Richard W.M. Jones
d156072c6b Update PO files from Zanata.
Adds po/cs.po and removes po/zh_TW.po.
2017-11-16 14:02:10 +00:00
Richard W.M. Jones
9dd81036ce builder: Add osinfo_config.mli file.
Every .ml file now needs a corresponding .mli file so that
dependencies are generated correctly.  The check-mli.sh script picks
up the problem:

  FAIL: check-mli.sh
  ==================
  ./builder/osinfo_config.ml: missing ./builder/osinfo_config.mli
  FAIL check-mli.sh (exit status: 1)

Fixes commit 46abca0ec3
and commit 02184f55f9.
2017-11-16 13:22:02 +00:00
Richard W.M. Jones
f2fe422909 lib: command: If command fails, exit with 126 or 127 as defined by POSIX.
If running the external command fails in "argv mode" (ie. when
not using the shell), then exit with either 126 or 127 as defined
by POSIX.

This is mostly the same as what bash does, see
execute_cmd.c:shell_execve in the bash sources.

Note: saving errno around perror(3) if necessary, otherwise you will
see different behaviour between verbose and non-verbose mode.  In
non-verbose mode, perror(3) tried to print to a closed file
descriptor, failing and overwriting errno.  That took some time to
debug.
2017-11-16 12:55:19 +00:00
Richard W.M. Jones
3ef6794b09 common/mlstdutils: Add with_openfile function.
This safe wrapper around Unix.openfile ensures that exceptions
escaping cannot leave unclosed files.

There are only a few places in the code where this wrapper can be used
currently.  There are other occurences of Unix.openfile but they are
not suitable for replacement.
2017-11-16 12:32:58 +00:00
Richard W.M. Jones
d17a70324c v2v: vddk: Atomicly chmod the password file.
Ensure we are chmodding the correct file, avoids possible races.

Thanks: Pino Toscano.
2017-11-16 12:32:58 +00:00
Richard W.M. Jones
2d1e2d12af common/mlstdutils: Add with_open_in and with_open_out functions.
These safe wrappers around Pervasives.open_in and Pervasives.open_out
ensure that exceptions escaping cannot leave unclosed files.
2017-11-16 12:32:58 +00:00
Richard W.M. Jones
6c24213d78 Version 1.37.32. 2017-11-16 10:36:19 +00:00
Richard W.M. Jones
46abca0ec3 builder: Add osinfo to virt-builder and hence to EXTRA_DIST.
Fixes commit 02184f55f9.
2017-11-16 10:33:42 +00:00
Richard W.M. Jones
dca92e4cf1 daemon: Use a configure-time test to find the best OCaml runtime.
In OCaml 4.06 we need to link to daemon to libasmrun_pic.a (the OCaml
runtime linked with -fPIC).  Otherwise you will see many errors like
this:

    /usr/bin/ld: /usr/lib64/ocaml/libasmrun.a(startup_aux.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
    /usr/bin/ld: /usr/lib64/ocaml/libasmrun.a(startup.o): relocation R_X86_64_32S against symbol `caml_data_segments' can not be used when making a shared object; recompile with -fPIC
    /usr/bin/ld: /usr/lib64/ocaml/libasmrun.a(fail.o): relocation R_X86_64_32 against symbol `caml_exn_Failure' can not be used when making a shared object; recompile with -fPIC
    /usr/bin/ld: /usr/lib64/ocaml/libasmrun.a(roots.o): relocation R_X86_64_32 against symbol `caml_frametable' can not be used when making a shared object; recompile with -fPIC

This commit use a configure-time test to find the best OCaml runtime.
2017-11-14 19:54:43 +00:00
Richard W.M. Jones
994ca8d873 builder: Add Fedora 27 templates for aarch64, armv7l, i686, ppc64, ppc64le. 2017-11-14 19:54:43 +00:00
Richard W.M. Jones
52f8e2b830 builder: Fedora 27 (x86_64) image.
Note this uses GPT, see commit a06e50e263.
2017-11-14 14:58:53 +00:00
Richard W.M. Jones
a52b7bdccc builder: template: Save the final virt-install command to a file.
For documentation purposes only.
2017-11-14 14:08:34 +00:00
Richard W.M. Jones
143d61745b builder: templates: Rebuild Fedora 26 ppc64 & ppc64le templates with GPT. 2017-11-14 14:08:34 +00:00
Richard W.M. Jones
a06e50e263 builder: templates: For RHEL, CentOS >= 7 and all Fedora, default to GPT.
The immediate issue is with Fedora/ppc64 and /ppc64le which currently
use extended partitions, breaking the virt-builder ‘--size’ parameter,
eg:

  $ virt-builder --arch ppc64le fedora-26 --size 20G
  ...
  [  21.6] Resizing (using virt-resize) to expand the disk to 20.0G
  virt-resize: error: /dev/sda5: partition not found in the source disk image
  (this error came from '--expand' option on the command line).  Try running
  this command: virt-filesystems --partitions --long -a /var/tmp/vbf67b8c.img

However more generally MBR is broken and should die.  GPT is supported
by all modern virtual bootloaders, so just default to it.

Notes:

* This is different from mandating a UEFI bootloader.

* I am not planning to rebuild any existing images except the
  F26 ppc64 & ppc64le ones.
2017-11-14 14:07:56 +00:00
Richard W.M. Jones
a88385add6 fuse: Don't use errno if libfuse fuse_mount fails.
libfuse prints errors on stderr and there seems to be no way to change
that.  It doesn't make any attempt to preserve errno either, so
printing an error based on errno is wrong.

Thanks: Assaf Gordon.
2017-11-14 09:41:05 +00:00
Cédric Bosdonnat
7e3689bfe0 builder: add Index.write_entry function
Add a function to properly write virt-builder source index entries.
Note that this function is very similar to Index.print_entry that is
meant for debugging purposes.
2017-11-07 12:51:28 +00:00
Cédric Bosdonnat
0933d2d818 builder: add Utils.get_image_infos function
This helper function calls qemu-img info on an image file and
returns the output as a JSON Yajl tree.

This function will be used in future commits.
2017-11-07 12:41:31 +00:00
Pino Toscano
02184f55f9 builder: add simple OCaml osinfo-db reader
Add a simple OCaml-based implementation of reader of the osinfo-db:
the only interface is an iterator that invokes an user-supplied
function with each XML file found.

This implementation behaves like the current C implementation, and
still supports the old libosinfo db.

[RWMJ: Fixed trailing whitespace]
2017-11-07 12:24:42 +00:00
Cédric Bosdonnat
8a661b1c48 mllib: add XPath helper xpath_get_nodes
This function will allow more OCaml-ish processing of XPath queries
with multiple results.
2017-11-07 12:16:21 +00:00
Cédric Bosdonnat
628141f302 Ignore builder/*.out and *.img files
These ignores are covering test-console-ubuntu-12.04 test data.
2017-11-07 12:01:31 +00:00
Pino Toscano
de5e39d7b9 v2v: expose 'in-place' as machine-readable feature
Even if two years later, expose it for clients, so they can check its
availability.

Updates commit d0069559a9.
2017-11-07 12:55:42 +01:00
Richard W.M. Jones
12d87361a4 v2v: vddk: Further rework documentation.
Thanks for suggestions from Ming Xie.
2017-11-07 11:32:50 +00:00
Richard W.M. Jones
415e9d82e9 v2v: vddk: Update minimum version of nbdkit to 1.1.16.
While 1.1.14 will technically still work, 1.1.16 adds the
‘selinux=yes|no’ flag to ‘--dump-config’ output.  It's also the more
widely available and tested version at the time of writing.

Thanks: Ming Xie.
2017-11-07 10:08:13 +00:00
Richard W.M. Jones
441fa82ee0 podwrapper: nbdkit-* man pages are libguestfs man pages.
Don't use the external link for these.

Thanks: Ming Xie.
2017-11-07 10:04:46 +00:00
Pino Toscano
0fa222c981 v2v: rework free space check in guest mountpoints
- move the space needed by mountpoint mapping to an own function,
  outside of the checking loop
- remove the minimum limit of 100M on partitions, since existing
  partitions that we check (e.g. /boot) may be smaller than that
- in case /boot is not on a separate mountpoint, enforce the space check
  on the root mountpoint instead, since it is where /boot is in that
  case
2017-11-06 15:31:01 +01:00
Pino Toscano
ca175108c4 diff: avoid potential null pointer dereference on error
If visit_guest() fails, then it returns a null pointer; later on,
free_tree() is called unconditionally on the variables, thus
dereferencing null pointers.

As a solution, make free_tree() behave like free(), i.e. become no-op
with null pointers.
2017-11-06 12:42:27 +01:00
Pino Toscano
b91ec0697d daemon: btrfs: fix bad handling of a couple of errors
Remove two wrong error handling situations in btrfs_balance_status:
- if the calloc for 'ret' fails, the 'goto error' would try to
  dereference the resulting null pointer (to free the items of the
  return struct); hence, just return null directly, instead of jumping
  to 'error'
- if the strdup() for 'btrfsbalance_status' fails, then the directly
  return would leak 'ret'
2017-11-03 16:44:20 +01:00
Pino Toscano
8213a572e4 daemon: btrfs: remove dead check
In btrfs_subvolume_show, an extra check on 'key' is used in a place
where this variable is already checked to be non-null.
2017-11-03 16:33:09 +01:00
Pino Toscano
62c9d5d8ca daemon: ldm: avoid manual free()
When the LDM code was converted to the CLEANUP_* macros, a free()
invocation for a CLEANUP_FREE variable was left in the
ldmtool_diskgroup_volumes implementation, causing double-free on
success.

Updates commit 950951c67d.
2017-11-03 16:29:28 +01:00
Richard W.M. Jones
e6bc59a7d4 v2v: Fix RPM file owned test (RHBZ#1503958).
Linux.file_owner is not used by any other function, so remove it.

Linux.is_file_owned is only used when removing kmod-xenpv on old RHEL
releases, and so is only required to work for RPM.

The old file_owner/is_file_owned functions were completely broken for
the RPM case.  This replaces them with a simpler, working
implementation of is_file_owned only.

Thanks: Ming Xie for finding and reporting the original bug.
2017-11-03 10:01:59 +00:00
Richard W.M. Jones
b6a9530a30 v2v: Handle SATA controller (RHBZ#1508874).
This also makes a fix to a related code comment.
2017-11-02 13:55:24 +00:00
Richard W.M. Jones
bcb40cb716 v2v: Add new Source_SATA for SATA disks.
Some hypervisors including KVM and VMware expose SATA as a separate
device emulation from IDE.  SATA devices are an evolution of IDE, but
in Linux they are handled like SCSI disks.

This change adds a new Source_SATA type to model this.  In the Linux
conversion module we treat them like SCSI (ie. with "sd" prefix).

It's not very clear how to handle them for target bus assignment, so I
arbitrarily mapped them to the SCSI bus.  It's possible we need a new
bus type to handle SATA properly.  As the code only applies to
removable devices it's not very important to get this right.
2017-11-02 13:55:24 +00:00
Richard W.M. Jones
359aa7fef6 v2v: Refactor some string_of_* functions.
Updates commit 94c83c0165.
2017-11-02 13:06:26 +00:00
Pino Toscano
a1b008e2d1 v2v: -i ova: parse MAC address from <rasd:Address> (RHBZ#1506572)
Read the MAC address of the network interfaces from the <rasd:Address>
tag of the OVF.  This seems to be one of the possible ways used in OVFs.
2017-11-02 11:13:42 +01:00
Richard W.M. Jones
22d5a20ed2 v2v: docs: SSL/TLS certificate problems with vCenter.
Thanks: Brett Thurber for diagnosis and testing.
2017-11-01 21:32:19 +00:00
Pino Toscano
0d4136c69f builder: ignore spaces after repo identifiers (RHBZ#1506511) 2017-10-27 16:30:21 +02:00
Pino Toscano
0942241395 rescue: initialize CLEANUP pointer variable
This way it will not try to free uninitialized memory when going out of
scope, and the inspector mode is not enabled.

Fixes commit 3637c42f4e.
2017-10-23 17:44:23 +02:00
Pino Toscano
0998e3f1cd rescue: fix size check
Compare it to the right variable, not to the pointer itself.

Fixes commit 3637c42f4e.
2017-10-23 17:42:03 +02:00
Richard W.M. Jones
f3330e144b python: tests: Allow some tests to be skipped.
Currently test820RHBZ912499.py fails with libvirt because libvirt
still doesn't work around qemu locking properly.  Allow this test to
be skipped on a temporary basis using SKIP_TEST820RHBZ912499_PY=1
2017-10-18 18:30:05 +01:00
Richard W.M. Jones
8295e44004 tests: disks: Enhance the test output by naming the test failures.
Makes it easier to find which test is failing.
2017-10-18 14:54:22 +01:00
Richard W.M. Jones
b7f5919aa7 tests: disks: Small adjustment for new libvirt iscsi qemu parameter.
Latest libvirt (3.8, I think) made a very small adjustment to the
format of the generated -drive parameter when using iscsi, from:

  file=iscsi://1.2.3.4:1234/iqn.2003-01.org.linux-iscsi.fedora,

to:

  file=iscsi://1.2.3.4:1234/iqn.2003-01.org.linux-iscsi.fedora/0,

This makes a corresponding change to the test so that both patterns
can be recognized.
2017-10-18 14:54:22 +01:00
Richard W.M. Jones
9f454918cc maintainer: Update to latest gnulib. 2017-10-18 13:01:03 +01:00
Richard W.M. Jones
f484403213 builder: template: Quote parameters when printing.
This is for documentation only so the quoting doesn't actually matter,
but it's better for the user to understand what is really being run.
2017-10-18 11:16:31 +01:00
Richard W.M. Jones
c4a6f2a23f builder: template: Factor out function for printing virt-install command.
Pure refactoring, no change.
2017-10-18 11:16:31 +01:00
Richard W.M. Jones
3b954bc097 p2v: Enable miniexpect debugging. 2017-10-18 11:16:31 +01:00
Richard W.M. Jones
4864216309 Version 1.37.31. 2017-10-17 23:59:31 +01:00
Richard W.M. Jones
f397049191 tests: Fix regression test to work with new debug messages from guestfsd.
Commit 0b631d739b changed the debug
message format from the main loop in guestfsd.  This test tried to
filter out these messages when comparing output, but that stopped
working.  The problem was only evident when enabling debugging while
running the tests.
2017-10-17 23:31:36 +01:00
Pino Toscano
32adb08efa v2v: -i libvirt: use precheck also for xen+ssh sources
Updates commit f87f254b2b.
2017-10-17 14:20:56 +02:00
Pino Toscano
840ac44c9b daemon: simplify usage of Chroot.f
Rely on currying, and avoid extra helper functions.

No behaviour changes.
2017-10-17 14:20:45 +02:00
Richard W.M. Jones
f87f254b2b v2v: In input and output classes move checks to new precheck () method.
Previously we were abusing the ‘input#source ()’ and
‘output#prepare_targets’ methods to perform environmental checks.

Small refactoring, no functional change.
2017-10-17 11:31:50 +01:00
Richard W.M. Jones
4852ffdc74 v2v: Minor correction to a debugging message. 2017-10-17 11:31:50 +01:00
Richard W.M. Jones
2ff287c4a7 v2v: vddk: Force source format to raw.
Thanks: Ming Xie.
2017-10-17 11:01:22 +01:00
Richard W.M. Jones
59b4c4779f v2v: vddk: Check if nbdkit supports --selinux-label before using.
Give a better error message if not.

Thanks: Ming Xie.
2017-10-17 10:45:24 +01:00
Richard W.M. Jones
200e0d40bd Version 1.37.30. 2017-10-16 21:00:18 +01:00
Richard W.M. Jones
3df3cc99b1 v2v: vmx: Add test files to EXTRA_DIST.
Fixes commit 6c54b68acb.
2017-10-16 21:00:03 +01:00
Pino Toscano
303abf899e daemon: use parse_key_value_strings
Make use of parse_key_value_strings to slightly simplify the parsing of
mdadm output, and the parsing of os-release, and lsb-release files.
In particular, the parsing of lsb-release is simplified a lot, bringing
it much like the parsing of os-release.
2017-10-16 18:31:37 +02:00
Pino Toscano
93ceed59a3 daemon: add split_key_value_strings helper
Add a simple helper to turn a list of strings into key/value pairs,
splitting by '=', with the possibility to apply a function to unquote
values.

Add also a simple unquote function.
2017-10-16 18:30:24 +02:00
Richard W.M. Jones
c380920034 v2v: vCenter: Handle disks with snapshots (RHBZ#1172425).
This implements a missing feature from old virt-v2v, namely being able
to cope with a guest with snapshots.  Note this only converts the top
(latest) snapshot.  As in old virt-v2v it does NOT convert the whole
chain of snapshots.
2017-10-16 17:08:54 +01:00
Richard W.M. Jones
388a701399 v2v: vCenter: Factor out get_https_url code.
Pure refactoring.
2017-10-16 17:08:54 +01:00
Richard W.M. Jones
2052fb7d1f v2v: vCenter: Split up get_session_cookie function.
This is a small refactoring where we split get_session_cookie into a
function to fetch the URL and a function to parse the cookie.
2017-10-16 17:08:54 +01:00
Richard W.M. Jones
fb79fcde29 v2v: vCenter: Refactor the API to this module.
This module had a selection of functions taking a different mix of
parameters and doing slightly different things.  You could call one
function to return an https://... URL, or another function to return a
qemu URL, and there was a third function to get the session cookie but
you generally had to call that anyway (and it was implicitly called
when making the qemu URL!)

Integrate these into a single function which returns a struct
returning all possible values.

This is conceptually refactoring, except that the session cookie is no
longer memoized, but we didn't use this feature (of calling
get_session_cookie multiple times) anyway.
2017-10-16 17:08:54 +01:00
Richard W.M. Jones
3fdd923ce2 v2v: Remove --dcpath parameter and related functionality.
With modern libvirt, when fetching the XML of a VMware guest libvirt
passes us the datacenter path (dcpath).  However with older libvirt we
had to guess this value, or else the user had to supply it on the
command line.

This commit removes all the guessing code and the --dcpath parameter
(which will now give an error).

This requires libvirt >= 1.2.20 for virt-v2v, released Oct 2015.
2017-10-16 17:08:54 +01:00
Richard W.M. Jones
ce2aa47d1d v2v: vddk: Print passthrough options.
Changes the output to look like:

[   0.0] Opening the source -i libvirt -ic vpx://... guestname --vddk ... --vddk-thumbprint ...
2017-10-16 17:08:54 +01:00
Pino Toscano
d583352b7e daemon: inspection: discard os-release w/o version
In case os-release does not contain VERSION_ID, and it is not an
exception (like Void Linux), then discard the results got from
os-release.

This matches what the old C code did -- e.g. see
commit 32d19e3289, and the changes in
commit 0251c0fcaa.
2017-10-16 17:12:37 +02:00
Richard W.M. Jones
d81a2ee185 v2v: vddk: Make it clearer that you should not run nbdkit 'make install'. 2017-10-16 10:07:31 +01:00
Richard W.M. Jones
c30dd32c9c daemon: blkid: Use Option.default.
Plain refactoring.
2017-10-13 21:33:33 +01:00
Richard W.M. Jones
6c54b68acb v2v: -i vmx: Add a test case which lacks scsi0:0.deviceType = "scsi-hardDisk"
VMX file from:
https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/

Thanks: Tom Sorensen
2017-10-12 16:31:49 +01:00
Richard W.M. Jones
418289029d v2v: -i vmx: Allow deviceType field to be completely omitted.
Microsoft make some VMX files available here which we could not parse.
These files lack the expected ‘scsi0:0.deviceType’ field:
https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/

According to
http://faq.sanbarrow.com/index.php?action=artikel&cat=7&id=54&artlang=en
this is permitted.  Also several other deviceType values may be found.

Allow such VMX to be parsed.

Thanks: Tom Sorensen
2017-10-12 16:31:49 +01:00
Richard W.M. Jones
aaff4a4619 common/mltools: xpath_helpers: Get rid of xpath_*_default functions.
Instead of using ‘xpath_(string|int|int64)_default’ we can write the
equivalent code using ‘Option.default’.  This is not quite so concise,
but may be easier to understand.

eg:
  xpath_int_default xctx "xpath_expr" 10
->
  Option.default 10 (xpath_int xctx "xpath_expr")
2017-10-12 16:31:49 +01:00
Richard W.M. Jones
b92f74458f common/mlstdutils: Introduce Option submodule.
Inspired by ocaml-extlib, introduce a module for handling option
types.

We already had the ‘may’ function (which becomes ‘Option.may’).  This
adds also ‘Option.map’ (unused), and ‘Option.default’ functions.

Note this does *not* introduce the unsafe ‘Option.get’ function from
extlib.
2017-10-12 16:31:47 +01:00
Richard W.M. Jones
0b631d739b daemon: proto: Make the guestfsd main loop messages consistent and useful.
After this change the debugging output looks like this:

  guestfsd: <= mount (0x1) request length 64 bytes
  commandrvf: stdout=n stderr=y flags=0x0
  commandrvf: udevadm --debug settle -E /dev/sda1
  calling: settle
  command: mount '/dev/sda1' '/sysroot//'
  [    1.152813] EXT4-fs (sda1): mounting ext2 file system using the ext4 subsystem
  [    1.154815] EXT4-fs (sda1): mounted filesystem without journal. Opts: (null)
  guestfsd: => mount (0x1) took 0.01 secs
  guestfsd: <= touch (0x3) request length 52 bytes
  guestfsd: => touch (0x3) took 0.00 secs

Thanks: Pino Toscano
2017-10-12 16:26:43 +01:00
Richard W.M. Jones
d60eaf7492 common/miniexpect: Synchronize to latest miniexpect.
Updated to miniexpect commit eba90008396f05e2c0fa752421793b797383fca7.
2017-10-12 15:49:11 +01:00
Richard W.M. Jones
cd08039d24 daemon: inspection: Add support for NeoKylin (RHBZ#1476081).
Thanks: Qingzheng Zhang
2017-10-12 15:38:06 +01:00
Richard W.M. Jones
bf22909dd6 daemon: inspection: Sort cases in check_package_* functions.
No change, just sorts the cases into alphabetical order for easier
modification.

Tidies up commit 394d11be49.
2017-10-12 10:39:07 +01:00
Richard W.M. Jones
fbc3ca4fe8 daemon: Enable warn-error in OCaml code.
This was accidentally disabled because I used the wrong
variable name.

Fixes commit d5b6f1df5f.
2017-10-12 10:39:07 +01:00
Richard W.M. Jones
18a6766124 customize: In verbose mode, run dnf --verbose.
We should do the same for other package managers.  However apt-get
doesn't have a clear verbose mode (omitting -q doesn't do what we
want).
2017-10-11 17:58:15 +01:00
Richard W.M. Jones
0cc6737374 appliance: Print /etc/resolv.conf in debugging output. 2017-10-11 17:58:15 +01:00
Richard W.M. Jones
4d869035b8 appliance: Create /dev/shm (RHBZ#1500537).
This is required by ansible and probably other applications.

Thanks: Nicolas Hicher
2017-10-11 17:58:15 +01:00
Pino Toscano
b3bc9cac4a common/mlutils: fix f_type comparisons
statfs::f_type is usually a signed type, so cast it to unsigned to check
its value against magic values of filesystems.

Fixes commit a6a982f004.
2017-10-11 17:30:30 +02:00
Richard W.M. Jones
085efc0ff2 p2v: Test for sudo requiring a password first (RHBZ#1500673).
When testing if sudo -n requires a password, we tested for the prompt
earlier than testing for the magic sudo message ‘a password is
required’.

Since the shell will print the prompt just after the sudo message:

  prompt$ sudo -n virt-v2v --version
  sudo: a password is required
  prompt$

the prompt nearly always matched and we missed the magic sudo message.
(The exception is in the case where we are running everything on
localhost where the sudo message could be read in a single call to
read(2) without seeing the prompt immediately afterwards.  Even this
exception was non-deterministic.)

By swapping the priority of the sudo message and prompt we avoid this.

Looking at the debug output (enabled by editing common/miniexpect)
makes this clearer:

  DEBUG: writing: sudo -n virt-v2v --version
  DEBUG: buffer content: sudo: a password is required
  ESC]0;rjones@hamr:~^G###bphcxtq5###

Fixes commit 5b6a8e0862.

Thanks: Ming Xie.
2017-10-11 16:27:07 +01:00
Richard W.M. Jones
e25a54f5bf docs: building: OCaml >= 4.01 is required (not 4.02).
Fix incorrect version number in the manual.

Fixes commit 2cdd2eb795.
2017-10-10 12:13:36 +01:00
Richard W.M. Jones
19fd25674d v2v: linux_bootloaders: Small code formatting and comment changes.
No functional change.
2017-10-09 22:12:32 +01:00
Richard W.M. Jones
300c7f4edd v2v: Inline call to Linux.augeas_init.
Two-line function, only called from one place, so inline it where it
is used.
2017-10-09 22:12:32 +01:00
Pino Toscano
a302c8b819 common/mlaugeas: Synchronize with latest ocaml-augeas
Synchronized up to commit fd480bd2086c498484e735b060a1c3e80491f02d.
2017-10-09 17:59:46 +02:00
Pino Toscano
364e4ce38b build: build mlaugeas with -Wno-unused-macros
The upstream ocaml-augeas defines macros which may not be used in all
the cases, triggering a warning (which turns into error with -Werror)
because of -Wunused-macros.

Since the code is correct, disable -Wunused-macros with
-Wno-unused-macros before updating the embedded copy of ocaml-augeas.
2017-10-09 17:56:55 +02:00
Pino Toscano
6020af6e2b build: build mlaugeas with -Wno-shift-negative-value
The embedded copy of ocaml-augeas does Val_int(-1), which in turns
triggers warnings in newer GCC versions about "left shift of negative
value".  The issue actually lies in the OCaml headers (mlvalues.h in
particular), and it was fixed in newer OCaml versions.

Since the code is actually correct, disable -Wshift-negative-value with
-Wno-shift-negative-value (checking whether the compiler has it).
2017-10-09 14:29:56 +02:00
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. 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. 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. 2017-09-22 09:45:24 +01:00
Richard W.M. Jones
4a7aba23c1 common/mlaugeas: Add readme file to EXTRA_DIST.
Fixes commit 2ffb8a6b25.
2017-09-22 09:42:39 +01:00
Richard W.M. Jones
e6cc355ae8 build: Add comment to OCaml dependencies .depend files.
Also mark them readonly, since they are generated.
2017-09-21 18:05:07 +01:00
Richard W.M. Jones
d79df649e0 build: Since .mli files are now required, always build .cmi first.
Here is an example of a failure with the previous dependency
calculation:

  $ make -j5
  make: Entering directory '/home/rjones/d/libguestfs/common/mlstdutils'
    OCAMLOPT guestfs_config.cmx
    CC       libmlstdutils_a-dummy.o
    OCAMLOPT libdir.cmx
    OCAMLCMI stringMap.cmi
    OCAMLCMI stringSet.cmi
    OCAMLCMI guestfs_config.cmi
    OCAMLCMI std_utils.cmi
    OCAMLC   guestfs_config.cmo
    OCAMLC   libdir.cmo
    OCAMLC   stringMap.cmo
    OCAMLC   stringSet.cmo
    OCAMLOPT stringMap.cmx
    OCAMLOPT stringSet.cmx
    OCAMLOPT std_utils.cmx
    OCAMLC   std_utils.cmo
  ocamlfind ocamlc -package str,unix -I . -a guestfs_config.cmo libdir.cmo stringMap.cmo stringSet.cmo std_utils.cmo -o mlstdutils.cma
  ocamlfind ocamlopt -package str,unix -I . -a guestfs_config.cmx libdir.cmx stringMap.cmx stringSet.cmx std_utils.cmx -o mlstdutils.cmxa
    AR       libmlstdutils.a
  File "_none_", line 1:
  Error: Files std_utils.cmx and guestfs_config.cmx
         make inconsistent assumptions over interface Guestfs_config
  make: *** [Makefile:2523: mlstdutils.cmxa] Error 2
  make: Leaving directory '/home/rjones/d/libguestfs/common/mlstdutils'

What seems to be happening is that there is a rule:

  std_utils.cmx : guestfs_config.cmi guestfs_config.cmx [...]

In this case, make chose to build guestfs_config.cmx and
guestfs_config.cmi in parallel (see the first 5 rules above).  However
building guestfs_config.cmx also creates guestfs_config.cmi
(implicitly - this is not expressed in make dependencies, and make
doesn't "know" that guestfs_config.cmi has already been created).

Unfortunately the OCaml compiler doesn't create output files
atomically.  Worse than that, it creates an intermediate version of
the output file, reads it back and then creates the final version.  It
seems if the build of std_utils.cmi reads this intermediate version.
In any case, Std_utils sees the wrong hash of the Guestfs_config
module.

The above only happens where we have a *.ml file without a
corresponding *.mli file.  That is because if there is a *.mli file,
ocamldep generates slightly different dependencies:

  guestfs_config.cmx [...] : guestfs_config.cmi guestfs_config.ml
  std_utils.cmx : guestfs_config.cmi guestfs_config.cmx [...]

std_utils.cmx still depends on both files, but there is an extra rule
which ensures that guestfs_config.cmx isn't built in parallel with
guestfs_config.cmi.

I tested this change by running this command:

  $ while ( rm common/mlstdutils/.depend; make -C common/mlstdutils/ clean && make -C common/mlstdutils/ ) >& /tmp/log; do echo -n .; done

Before the change it would fail after about 100 iterations.  After the
change it ran for 10000s iterations and did not fail ever.

Updates commit 6d0ad49d5e.
2017-09-21 18:05:07 +01:00
Richard W.M. Jones
d38fcf280a tests: Check that every *.ml file has a corresponding *.mli file.
This is so that we can finally express OCaml dependencies correctly.
2017-09-21 18:05:07 +01:00
Richard W.M. Jones
a706ecb8f7 Make sure every *.ml file has a corresponding *.mli file. 2017-09-21 18:05:07 +01:00
Richard W.M. Jones
f04561a1fe common/mlstdutils: Remove unused Libdir module.
Last used in commit fd63d89644 (in 2013).
2017-09-21 18:05:07 +01:00
Richard W.M. Jones
290e4608f4 daemon: Remove vestigial daemon/types.ml file.
This file was empty and unused, likely left over from refactorings
while the daemon inspection code was being written.

Fixes commit d5b6f1df5f.
2017-09-21 18:05:07 +01:00
Richard W.M. Jones
7e974b509c lib: Use guestfs_int_make_temp_path in a few more places.
There were various places in the library where we open coded making
temporary filenames.  This uses the utility function instead.
2017-09-21 18:05:07 +01:00
Richard W.M. Jones
0734afd41f lib: Fix guestfs_int_download_to_tmp.
Since commit 65cfecb0f5,
‘guestfs_int_download_to_tmp’ was buggy because it did not deal with
the case where a guest had multiple roots.  It cached the downloaded
file under a single name which was not distinguished by which root we
were looking at.  As a result, if you inspected (eg.) the icon on such
a guest, then in some circumstances the same icon could be returned
for all roots (incorrectly).

This changes the function in a few ways:

 - Don't cache downloaded files.  It wasn't a useful feature of the
   function in most scenarios.  Instead a new name is generated for
   every call.

 - Use guestfs_int_make_temp_path.

 - Allow an extension to be specified.
2017-09-21 18:05:07 +01:00
Richard W.M. Jones
0ec0af27c5 lib: Allow an extension to be specified in guestfs_int_make_temp_path.
In the function ‘guestfs_int_make_temp_path’, allow an optional
extension to be specified.  For example:

  r = guestfs_int_make_temp_path (g, "ls", "txt");

will create paths like ‘<tmpdir>/ls123.txt’.

NULL can also be passed for the extension, which means no extension.
2017-09-21 18:05:07 +01:00
Richard W.M. Jones
41df9aaf90 lib: Move guestfs_int_download_to_tmp and remove inspect.c.
Move the last remaining function ‘guestfs_int_download_to_tmp’ to
lib/inspect-icon.c (the main, but not only user of this function).
Then remove lib/inspect.c entirely.

This is not quite code motion because I updated the comment for the
function to reflect what it does in reality.
2017-09-21 18:05:07 +01:00
Richard W.M. Jones
26a5916a24 lib: Move guestfs_int_parse_unsigned_int to version.c
Just code motion, but this function seems to make more sense in
version.c since that is the main (but not only) user.
2017-09-21 18:05:07 +01:00
Richard W.M. Jones
439a5cf57b lib: Remove unused function guestfs_int_parse_unsigned_int_ignore_trailing.
Not used by any current code, removed.

Last use of the function was seen in
commit 65cfecb0f5.
2017-09-21 18:05:07 +01:00
Richard W.M. Jones
9fb5376db4 v2v: linux: Small fixes to documentation.
Also combine the match cases into one statement.

No functional change.
2017-09-21 11:52:23 +01:00
Pino Toscano
6037cb39d4 build: remove extra SUFFIXES from Makefile.am in 'po'
Commit c226656519 added them to
common-rules.mk, so they are redundant here.  Also, this assignment
overwrites the value set in common-rules.mk.
2017-09-21 09:22:29 +02:00
Richard W.M. Jones
64f49df747 docs: hivex >= 1.3.14 is required (RHBZ#1493048).
Bug reported by Jean-Christophe Manciot.
2017-09-20 17:57:47 +01:00
Richard W.M. Jones
8ae2281971 daemon: Fix configure check so it requires hivex.
Commit 4d3601eb4e made it clear that
ocaml-hivex is required, implying also that hivex is required.
However the configure test was still optional, and if you built
libguestfs without hivex you got a very long and confusing error in
the daemon/ subdirectory.

Thanks: Cédric Bosdonnat
2017-09-20 17:49:27 +01:00
Richard W.M. Jones
6a12065f34 daemon: inspect: Simplify parse_version_from_major_minor.
Thanks: Pino Toscano.

Updates commit cb7696a5d2.
2017-09-20 17:49:27 +01:00
Cédric Bosdonnat
5d323461b4 builder: remove useless fish dependency 2017-09-20 13:18:20 +02:00
Richard W.M. Jones
fe23cee926 builder: Add centos-7.4 image.
Requested by Gal Ben Haim.
2017-09-18 16:06:04 +01:00
Richard W.M. Jones
8800deb77b Version 1.37.26. 2017-09-16 23:42:46 +01:00
Richard W.M. Jones
64274c665b common/mlaugeas: Synchronize with latest ocaml-augeas.
Thanks: Pino Toscano.
2017-09-16 23:11:06 +01:00
Richard W.M. Jones
9ac5d9859c threads: Add a test. 2017-09-16 23:06:25 +01:00
Richard W.M. Jones
9679f608b2 threads: Update documentation in guestfs(3) to describe the new behaviour. 2017-09-16 23:06:25 +01:00
Richard W.M. Jones
b088eb5ef8 threads: Use thread-local storage for errors.
We permit the following constructs in libguestfs code:

  if (guestfs_some_call (g) == -1) {
    fprintf (stderr, "failed: error is %s\n", guestfs_last_error (g));
  }

and:

  guestfs_push_error_handler (g, NULL, NULL);
  guestfs_some_call (g);
  guestfs_pop_error_handler (g);

Neither of these would be safe if we allowed the handle to be used
from threads concurrently, since the error string or error handler
could be changed by another thread.

Solve this in approximately the same way that libvirt does: by making
the error, current error handler, and stack of error handlers use
thread-local storage (TLS).

The implementation is not entirely straightforward, mainly because
POSIX doesn't give us useful destructor behaviour, so effectively we
end up creating our own destructor using a linked list.

Note that you have to set the error handler in each thread separately,
which is an API change (eg: if you set the error handler in one
thread, then pass the handle 'g' to another thread, the error handler
in the second thread appears to have reset itself back to the default
error handler).  I haven't yet worked out a better way to solve this.
2017-09-16 23:06:25 +01:00
Richard W.M. Jones
b9847b404c threads: Acquire and release the lock around each public guestfs_* API.
Acquire the per-handle lock on entering each public API function.

The lock is released by a cleanup handler, so we only need to use the
ACQUIRE_LOCK_FOR_CURRENT_SCOPE macro at the top of each function.

Note this means we require __attribute__((cleanup)).  On platforms
where this is not supported, the code will probably hang whenever a
libguestfs function is called.

The only definitive list of public APIs is found indirectly in the
generator (in generator/c.ml : globals).
2017-09-16 23:06:25 +01:00
Richard W.M. Jones
d94a881d87 threads: Add a lock (a recursive mutex) to the handle.
Add a g->lock field.  This commit simply initializes and destroys the
lock on handle creation/free, and does nothing else.
2017-09-16 23:06:25 +01:00
Richard W.M. Jones
4662c95266 tests: md: Temporarily disable test which requires device name hints.
These are broken after inspection was rewritten, but we should
fix them before 1.38 is released.
2017-09-16 22:27:16 +01:00
Richard W.M. Jones
3a00c4d179 Remove inspection from the C library and switch to daemon/OCaml implementation. 2017-09-16 22:27:16 +01:00
Richard W.M. Jones
5aad7e779c daemon: Implement inspection of Windows.
Mostly a line-for-line translation of the C inspection code.
2017-09-16 22:27:16 +01:00
Richard W.M. Jones
394d11be49 daemon: Implement inspection of Linux and other Unix-like operating systems.
This is essentially a line-for-line translation of the C inspection
code.
2017-09-16 22:27:16 +01:00
Richard W.M. Jones
cb7696a5d2 daemon: Implement inspection types and utility functions.
Define the types which will be used to communicate between the
different parts of the inspection code.  The main types are:

  fs        corresponds to ‘struct inspect_fs’ in C code

  root      no direct correspondence with the C code, but in the C
            code, ‘inspect_fs’ was overloaded to store roots

  inspection_data
            the inspection data which is incrementally collected about
            each filesystem as we perform inspection steps

Other types have simple and obvious correspondences with the
equivalent C code.

Add some utility function which will be used by inspection.

Note that this commit has no effect on its own, it just links extra
dead code into the daemon.
2017-09-16 22:27:16 +01:00
Richard W.M. Jones
53ab995cf1 lib: inspect: Remove ‘fs’ parameter from ‘guestfs_int_download_to_tmp’.
After we move inspection code to the daemon, the library will no
longer have access to ‘struct inspect_fs’, and so we won't be able to
prefix downloads with the "root filesystem number".

Just remove this prefix (it's internal only).  However it does mean
that this function can no longer cache downloaded files.
2017-09-16 22:27:16 +01:00
Richard W.M. Jones
984d83ac57 generator: daemon: Implement RStringList (RMountable, _) and RHashtable (RPlainString, RMountable, _).
Implement returning these two types from OCaml daemon functions.
2017-09-16 22:27:16 +01:00
Richard W.M. Jones
9af6ee0d78 daemon: Implement umount_all in OCaml.
Unlike previous ‘daemon: Reimplement ...’ patches, this does not
reimplement the umount_all API completely (yet, but this
implementation could be completed in future and then replace the C
one).  However it is necessary to have a version of umount_all which
we can call from the OCaml inspection code.
2017-09-16 22:27:16 +01:00
Richard W.M. Jones
19940fc2bd New API: Deprecate hivex_value_utf8 and replace with hivex_value_string.
hivex has a function hivex_value_string.  We were not calling it under
the mistaken belief that because hivex implements this using iconv,
the function wouldn't work inside the daemon.  Instead we
reimplemented the functionality in the library.

This commit deprecates hivex_value_utf8 and removes the library side
code.  It replaces it with a plain wrapper around hivex_value_string.

Thanks: Pino Toscano
2017-09-16 22:27:16 +01:00
Richard W.M. Jones
11b8a5db19 daemon: utils: New functions and tests.
These utility functions will be used in the OCaml inspection code.
2017-09-16 22:27:16 +01:00
Richard W.M. Jones
2ffb8a6b25 common: Bundle the ocaml-augeas library for use by the daemon.
This commit bundles the ocaml-augeas library (upstream here:
http://git.annexia.org/?p=ocaml-augeas.git;a=summary).  It's identical
to the upstream version and should remain so.

We can work towards using system ocaml-augeas, when it's more widely
available.
2017-09-16 22:27:16 +01:00
Richard W.M. Jones
65cfecb0f5 inspection: Deprecate APIs and remove support for inspecting installer CDs.
This just duplicated libosinfo information, and because it was never
tested it didn't work most of the time.
2017-09-16 22:27:16 +01:00
Richard W.M. Jones
a0c1e6120c daemon: chroot: Enhance module documentation. 2017-09-16 22:26:58 +01:00
Pino Toscano
b06e7aa47d lib: qemu: ignore -Wnonnull also for GCC 4.8 and up
Versions older than 6 that have -Wnonnull need the flag too.

Fixes commit e2773e679f.
2017-09-15 17:49:57 +02:00
Richard W.M. Jones
a1428699c3 Version 1.37.25. 2017-09-15 14:37:20 +01:00
Richard W.M. Jones
6d0ad49d5e build: Add missing pattern rule to build *.cmi from *.ml.
In the case where we have a module.ml without a corresponding
module.mli file, ocamldep generates (correct) dependencies:

  module.cmx module.cmi : module.ml

but we had no rule telling make how to generate the module.cmi
file from module.ml.

This didn't matter very much because when make came to build
module.cmx, the module.cmi file is generated as a side-effect.

However for highly parallel builds, the build ordering was still
incorrect.  Any other module that depends on module.cmi could be built
in parallel.  You would very occasionally see errors like this one:

  File "_none_", line 1:
  Error: Files index.cmx and utils.cmx
         make inconsistent assumptions over interface Utils

Fixing this involves adding a ‘%.cmi: %.ml’ rule.  However we have to
be careful that make doesn't run this rule instead of the ‘%.cmi: %.mli’
rule (if module.mli did exist).  It turns out that GNU make says we
can depend on rule ordering in the Makefile for this.

I found that this only works correctly if we use "%"-style pattern
rules (not the ‘.ml.cmi:’ old-style rules).

This is *still* not a complete fix.  Make still doesn't know that the
rules ‘%.cmo: %.ml’ and ‘%.cmx: %.ml’ also build the .cmi file as a
side-effect, so you can still occasionally see build failures.
However I could not work out how to add the extra information to the
dependencies without causing make itself to go into an infinite loop.
It may be that in the end we will have to get rid of pattern rules
completely and generate the complete OCaml rule set.
2017-09-15 13:31:18 +01:00
Richard W.M. Jones
81419c4b88 get-kernel, resize: Fix dependencies.
Because there are no *.mli in either of these directories, the .depend
file was not being built (silently).  So dependencies were wrong.

Fixes commit 692195c6ba.
2017-09-15 12:08:30 +01:00
Richard W.M. Jones
b0a8b36eb1 ocaml: Remove duplicated OCaml implicit rules. 2017-09-15 11:58:15 +01:00
Richard W.M. Jones
c226656519 build: Move all SUFFIXES up to common-rules.mk.
They need to be available in all subdirectories.
2017-09-15 11:13:40 +01:00
Richard W.M. Jones
9ec726606c build: Use ocamldep -all and -one-line flags instead of hacking the output.
We ran some sed scripts over the output of ocamldep to get them into a
single line format.  This actually broke the output of ocamldep,
combining multiple dependencies into single lines.  I didn't debug
exactly why our sed rules were broken because modern ocamldep has an
option (-one-line) which make this hacking unnecessary.

Another useful option (-all) is added so that all dependencies are
made explicit.

Since old ocamldep in RHEL 6 doesn't support these options, we have to
detect them at configure time.

The historical reason we were trying to combine entries into a single
line was so we could sort them.  That was only needed back when we
used to commit the dependency files (so the files were stable), but we
haven't committed dependency files in a long time.
2017-09-15 10:46:12 +01:00
Richard W.M. Jones
730c7fd352 Version 1.37.24. 2017-09-14 19:46:41 +01:00
Richard W.M. Jones
e2773e679f lib: qemu: Also suppress -Wnonnull warning in yajl code.
Required by gcc-7.1.1.

Updates commit 3d2b84231f.
2017-09-14 19:29:59 +01:00
Richard W.M. Jones
2680263f68 Version 1.37.23. 2017-09-14 18:05:00 +01:00
Richard W.M. Jones
4c474aba91 tests/qemu: Make the isolation tests more read and write heavy.
Do more reading of the backing file data, and more writes to the
overlay.
2017-09-14 16:58:17 +01:00
Richard W.M. Jones
52be0a6c50 tests/qemu: Split qemu snapshot isolation into 3 tests.
It contained 3 tests before.  It's better to run them in parallel.

Just a simple refactoring, no change.
2017-09-14 16:58:17 +01:00
Richard W.M. Jones
9fe592808c launch: direct: Disable qemu locking when opening drives readonly (RHBZ#1417306). 2017-09-14 16:58:17 +01:00
Richard W.M. Jones
3d2b84231f lib: qemu: Add accessor to test if qemu does mandatory locking.
QEMU >= 2.10 started to do mandatory locking.  This checks the QMP
schema to see if we are using that version of qemu.  (Note it is
sometimes disabled in downstream builds, and it was also enabled in
upstream prereleases with version 2.9.9x, so we cannot just check the
version number).
2017-09-14 16:58:17 +01:00
Richard W.M. Jones
bf7d627305 lib: qemu: Allow parallel qemu binaries to be used with cache conflicts.
Rename the cache files like ‘qemu.stat’ etc so they include the qemu
binary "key" (ie. size and mtime) in the name.  This allows a single
user to use multiple qemu binaries in parallel without conflicts.
2017-09-14 16:58:16 +01:00
Richard W.M. Jones
a22eecbdb1 lib: qemu: Run QMP ‘query-qmp-schema’ against the qemu binary.
This adds an extra test using QMP (the QEMU Monitor Protocol).  This
allows us to get extra information about the qemu binary beyond what
is available from the version number or ‘qemu -help’.
2017-09-12 17:13:41 +01:00
Richard W.M. Jones
ea94f39e46 lib: qemu: Factor out common code for reading and writing cache files.
The previous code duplicated a lot of common code for reading and
writing the cache file per data field.  This change simply factors out
that common code.  This makes it simpler to add new tests in future.

This is just refactoring, it should have no effect.
2017-09-12 17:13:41 +01:00
Richard W.M. Jones
0eb1380ddc lib: qemu: Refactor guestfs_int_test_qemu so it doesn't return qemu version.
Rather unnecessarily this function returned the parsed qemu version.
This complicates further refactoring, so I have changed the function
not to return this, and instead there is a separate function you have
to call to get the version struct (‘guestfs_int_qemu_version’).

Apart from a tiny amount of extra copying this is simply refactoring
of the interface between the direct-mode backend and the qemu query
functions.
2017-09-12 10:57:32 +01:00
Richard W.M. Jones
410593e48b lib: command: Print command before running it with guestfs_int_cmd_pipe_run.
Unlike ordinary guestfs_int_cmd_run, the pipe version did not print
the command it was about to run when debugging was enabled.

Fixes commit e98bb86929.
2017-09-11 16:08:13 +01:00
Richard W.M. Jones
def7e10b60 builder: Fix rhel-7.X Server source baseurl (again).
Updates commit 91c950dfba.
2017-09-07 09:06:56 +01:00
Richard W.M. Jones
91c950dfba builder: Fix rhel-7.X Server source baseurl.
Thanks: Jiri Denemark
2017-09-06 18:17:58 +01:00
Richard W.M. Jones
9b2790c666 Version 1.37.22. 2017-09-04 17:25:41 +01:00
Richard W.M. Jones
bbda5a6a68 v2v: Implement input from nbdkit vddk plugin (RHBZ#1477912). 2017-09-04 16:20:50 +01:00
Richard W.M. Jones
e10814397c v2v: In --machine-readable output, advertize vcenter over HTTPS and Xen over SSH.
These have been supported since forever, but it's good to have an
indication in the ‘virt-v2v --machine-readable’ output that they are
available:

  $ virt-v2v --machine-readable
  virt-v2v
  libguestfs-rewrite
  vcenter-https
  xen-ssh
  colours-option
  vdsm-compat-option
  [etc]

Thanks: Pino Toscano.
2017-09-04 14:59:42 +01:00
Pino Toscano
5b60dd4eff launch: direct: limit kvm-pit.lost_tick_policy to x86
This QEMU property is specific to x86/x86_64, so add it only on these
architectures.
2017-09-01 14:05:38 +02:00
Pino Toscano
5f43b30a6f fish: add small documentation bit about format of URIs (RHBZ#1450325)
Mention which format URIs follow, with a small example on escaping
special characters.
2017-08-30 16:16:16 +02:00
Pino Toscano
57d8915791 v2v: warn when the guest has hostdev devices (RHBZ#1472719)
virt-v2v obviously cannot convert this kind of devices, since they are
specific to the host of the hypervisor.  Thus, emit a warning about the
presence of passthrough host devices, so at least this can be noticed
when converting a guest.
2017-08-30 13:05:32 +02:00
Florian Klink
84c9ba2898 builder/templates/debian.preseed: enable serial console
RWMJ:

 - Rebuilt the images, to fix RHBZ#1484957

 - Regenerated the index-fragment files as part of rebuilding the images.
2017-08-29 13:36:15 +01:00
Pino Toscano
6befd1464d resize: handle empty UUIDs for swap partitions (RHBZ#1482737)
Avoid passing an empty UUID string to mkswap, which mkswap does not
accept (correctly) as new UUID.

In addition, print a warning when the UUID of a swap partition changed,
since it may require manual fixups in the guest.
2017-08-18 16:55:54 +02:00
Florian Klink
b7fef61f46 builder: templates: debian: use single-partition layout
The previously selected 'atomic' recipe resulted in 2GB swap in a 6GB
volume. Also, we don't really need the boot partition, so just create a
partition using the whole disk space.
2017-08-18 10:36:11 +01:00
Richard W.M. Jones
9b01fe60a5 configure: Further split blocks of text in the script output.
Commit 0a94cae15b added useful
headings to parts of the configure script.  This refactors
the code by adding a common macro (‘HEADING’), and also changes
the output so it's clearer at a glance:

  --- Checking for Haskell ---
  checking for ghc... (cached) ghc

  --- Checking for PHP ---
  checking for php... (cached) php
  checking for phpize... (cached) phpize
2017-08-14 09:03:58 +01:00
Richard W.M. Jones
4e7e73b879 v2v: Mention update-crypto-policies in documentation.
Modern ssh and RHEL 5 sshd are not always interoperable, requiring
enabling legacy crypto policies on the converion server (ssh client).

Thanks: Nikos Mavrogiannopoulos, Jakub Jelen.
2017-08-14 09:03:58 +01:00
Pino Toscano
3050a58622 ruby: fix order of CFLAGS
Shuffle the order of the various CFLAGS used when building the Ruby
extension: first the flags from manywarnings (gnulib), then libguestfs
own CFLAGS, and then -DGUESTFS_PRIVATE=1 (so it is not overridden).

This matches also what happens in automake parts, and makes it possible
to override any flags from manywarnings also in the Ruby extension.
2017-08-10 15:03:37 +02:00
Richard W.M. Jones
e6e3854b6e valgrind: Ignore everything allocated through caml_stat_alloc.
As the name suggests, caml_stat* functions are used for allocating
static blocks.  The OCaml runtime doesn't bother freeing any of these
on exit.  OCaml 4.05 allocates caml_executable_name this way, a newly
seen global variable.  We might as well just ignore everything
allocated this way.

Further information here:

  e7cf3b1846/byterun/caml/memory.h (L66)
2017-08-09 17:57:54 +01:00
Richard W.M. Jones
91b293b3fd Version 1.37.21. 2017-08-09 15:31:01 +01:00
Richard W.M. Jones
692195c6ba build: Add a common script for generating OCaml dependencies correctly.
These are generated in many different ways in the various
subdirectories, and sometimes not generated correctly.  Introduce a
script to do this in one place, and hopefully correctly.

This is mostly simple refactoring, but I got rid of a couple of
things:

(1) The ‘make depend’ rule doesn't appear to be needed.  automake (or
make?)  seems to rebuild the ‘.depend’ file automatically just because
it is included.

(2) I got rid of the hairy path rewriting sed expression.  Possibly
that is needed for srcdir != builddir.
2017-08-09 14:45:48 +01:00
Pino Toscano
b95d9a74bb configure: output paths where java is searched in
Output each path where we attempt to find 'java', so it is easier to
spot whether the location for the current OS is missing.  This also
removes the need to print the location next to the version, since the
location was already printed above.
2017-08-09 14:56:50 +02:00
Pino Toscano
0a94cae15b configure: visually split the blocks of checks
Add sort of "headers" to split most of the logical sections of the
configure, so it is easier to get feedback on the progress of configure.
2017-08-09 14:54:03 +02:00
Richard W.M. Jones
b237418678 tests: Add a regression test for RHBZ#1477623. 2017-08-08 17:50:23 +01:00
Richard W.M. Jones
63071bb8f9 daemon: lvm: Pass device parameter of lvm_canonical_lv_name as PlainString.
All sorts of strings might be passed here hoping to make them
canonical LV names.  We cannot be sure that the strings passed will be
devices which exist in the appliance.
2017-08-08 17:50:23 +01:00
Richard W.M. Jones
58ecca0432 tests: discard: Remove dubious use of "/dev/urandom" as a Device parameter.
This API docs don't state that this is permitted.
2017-08-08 17:50:23 +01:00
Richard W.M. Jones
07ba8b6d6b daemon: Refine check for Device and Dev_or_Path parameters (RHBZ#1477623).
For Device parameters we expect a block device name.  However we were
only testing for "/dev/..." and so chardevs (from the appliance) could
be passed here, resulting in strange effects.  This adds a function
is_device_parameter which tests for a valid block device name.

For Dev_or_Path parameters much the same, except we can also use the
is_device_parameter function elsewhere in the daemon to distinguish if
we were called with a device or path parameter.  Previously we used a
simple test if the path begins with "/dev/...".

Reported by Mathieu Tarral.
2017-08-08 17:50:23 +01:00
Richard W.M. Jones
0bf521cfcb daemon: Deduplicate some utility functions.
The following functions were previously reimplemented in OCaml.  This
commit replaces them with calls to the C functions:

 - is_root_device
 - prog_exists
 - udev_settle

plus the internal get_verbose_flag function.

However note that we cannot do this for every utility function.  In
particular the C function must not call any reply* functions.
2017-08-08 16:23:42 +01:00
Richard W.M. Jones
403692bdac daemon: Move utility functions to a separate file.
This allows us to share certain utility functions with OCaml code.
2017-08-08 16:23:42 +01:00
Richard W.M. Jones
42085b6bd5 daemon: utils: Small refactoring to hide ‘chan’ from code. 2017-08-08 16:23:42 +01:00
Richard W.M. Jones
2eac205e25 daemon: Remove extra space from debug message. 2017-08-08 16:14:36 +01:00
Richard W.M. Jones
089ade6f95 Version 1.37.20. 2017-08-03 18:49:01 +01:00
Richard W.M. Jones
38359eaf3e daemon: Restore PCRE regular expressions in OCaml code.
When parts of the daemon were previously converted to OCaml, the
previous PCRE regexps were converted to Str regexps.  Restore the
original PCRE regexps.

There was also one case where an original call to glob(3) was replaced
by a Str regexp, and this is replaced by a PCRE regexp (although it is
in fact identical in this instance).

This updates commit b48da89dd6
and commit eeda6edca1
and commit 2ca0fa778d.
2017-08-03 17:36:09 +01:00
Richard W.M. Jones
e5182b87cf builder: Replace small usage of Str with new PCRE module. 2017-08-03 17:36:09 +01:00
Richard W.M. Jones
f33db99edf common: Add a lightweight OCaml binding for PCRE.
This uses the gnulib TLS macros.
2017-08-03 17:36:09 +01:00
Richard W.M. Jones
ff83a88b4c builder: Added RHEL 7.4 kickstarts. 2017-08-02 10:35:36 +01:00
Jamie Iles
18db01490c Add missing oraclelinux cases.
oraclelinux is the same as redhat/centos/scientificlinux, so add it
where it is missing.  This fixes amongst other things, running sysprep
on an Oracle Linux image where it would previously fail operations like
setting the hostname, saying that it was not supported on that distro.
2017-08-01 16:06:48 +02:00
Richard W.M. Jones
85d9c9325c docs: guestfs-hacking: Reorder directory names into alphabetical order. 2017-08-01 09:20:02 +01:00
Richard W.M. Jones
c73f0a6675 daemon: ntfs: fix name of the ntfs-3g.probe tool in one other place.
Fixes commit 381c8b68c4, which forgot to
add the dash in the name.

See also commit ef53cd5619 which fixed
the same thing elsewhere.
2017-07-31 16:20:50 +01:00
Pino Toscano
a903f8912e gobject: use bash for running the tests
Since the introduction of the TEST_FUNCTIONS framework in tests, with
commit 2cb0413049, using a non-bash shell
will not work anymore, since the framework currently relies on bash.

Hence, switch the interpreter of these tests to bash, so they can run
also on systems where /bin/sh is not bash (e.g. default Ubuntu
installations).
2017-07-31 12:09:26 +02:00
Pino Toscano
0028b99415 builder: templates: disable Debian support for NVRAM
It isn't ready to be pushed yet (needs more testing), and it was
accidentally committed by me with
commit ef53cd5619.

My mistake, my fix, apologies.
2017-07-31 11:19:33 +02:00
Pino Toscano
ef53cd5619 daemon: ntfs: fix name of the ntfs-3g.probe tool
Fixes commit 381c8b68c4, which forgot to
add the dash in the name.
2017-07-31 11:16:17 +02:00
Nikos Skalkotos
c355b744bf New partition API: part_resize
This can be used to enlarge or shrink an existing partition.
2017-07-31 10:51:18 +02:00
Pino Toscano
b934614057 build: require ocaml-hivex for the daemon
Since commit d5b6f1df5f, the daemon
requires ocaml-hivex; OTOH, nothing checks it is actually available, so
the build of the daemon will fail with a semi-cryptic error about the
lack of a directory in the OCaml install prefix.

As fix, check for the presence of the hivex module at build time,
failing earlier if not present.  The check is performed only when the
daemon is enabled, as ocaml-hivex is not used for anything else than the
daemon.
2017-07-31 10:12:59 +02:00
Richard W.M. Jones
4d3601eb4e docs: ocaml-hivex is now required to build the daemon.
Fixes commit d5b6f1df5f.
2017-07-29 08:29:22 +01:00
Richard W.M. Jones
7874006282 Version 1.37.19. 2017-07-27 23:04:11 +01:00
Richard W.M. Jones
70b6f33566 daemon: Reimplement ‘device_index’ API in OCaml. 2017-07-27 22:31:22 +01:00
Richard W.M. Jones
3027a33110 daemon: Reimplement ‘part_get_parttype’, ‘part_get_gpt_type’, ‘part_get_gpt_guid’ APIs in OCaml. 2017-07-27 22:31:22 +01:00
Richard W.M. Jones
1e956dfc7d daemon: Reimplement ‘realpath’ API in OCaml. 2017-07-27 22:31:22 +01:00
Richard W.M. Jones
fe01905729 daemon: Reimplement ‘md_detail’ API in OCaml. 2017-07-27 22:31:22 +01:00
Richard W.M. Jones
90c6bffcdd daemon: Reimplement ‘nr_devices’ API in OCaml. 2017-07-27 22:31:22 +01:00
Richard W.M. Jones
c37c8e770d daemon: Reimplement ‘findfs_uuid’ and ‘findfs_label’ APIs in OCaml.
This also reimplements the lv_canonical function in OCaml.  We cannot
call the original C function because it calls reply_with_perror which
would break the OCaml bindings.
2017-07-27 22:31:22 +01:00
Richard W.M. Jones
32e661f421 daemon: Reimplement ‘part_list’ API in OCaml. 2017-07-27 22:31:22 +01:00
Richard W.M. Jones
4052f613d2 daemon: Reimplement ‘list_filesystems’ API in the daemon, in OCaml.
Move the list_filesystems API into the daemon, reimplementing it in
OCaml.  Since this API makes many other API calls, it runs a lot
faster in the daemon.
2017-07-27 22:31:22 +01:00
Richard W.M. Jones
eeda6edca1 daemon: Reimplement ‘btrfs_subvolume_list’ and ‘btrfs_subvolume_get_default’ in OCaml. 2017-07-27 22:31:22 +01:00
Richard W.M. Jones
2ca0fa778d daemon: Reimplement ‘list_md_devices’ API in OCaml. 2017-07-27 22:31:22 +01:00
Richard W.M. Jones
5866271518 daemon: Reimplement ‘lvs’ API in OCaml. 2017-07-27 22:31:22 +01:00
Richard W.M. Jones
02adcd1cd9 daemon: Reimplement ‘list_ldm_(volumes|partitions)’ APIs in OCaml. 2017-07-27 22:31:22 +01:00
Richard W.M. Jones
b48da89dd6 daemon: Reimplement ‘file_architecture’ API in OCaml.
The previously library-side ‘file_architecture’ API is reimplemented
in the daemon, in OCaml.

There are some significant differences compared to the C
implementation:

 - The C code used libmagic.  That is replaced by calling the ‘file’
   command (because that is simpler than using the library).

 - The C code had extra cases to deal with compressed files.  This is
   not necessary since the ‘file’ command supports the ‘-z’ option
   which transparently looks inside compressed content (this is a
   consequence of the change above).

This commit demonstrates a number of techniques which will be useful
for moving inspection code to the daemon:

 - Moving an API from the C library to the OCaml daemon.

 - Calling from one OCaml API inside the daemon to another (from
   ‘Filearch.file_architecture’ to ‘File.file’).  This can be done and
   is done with C daemon APIs but correct reply_with_error handling is
   more difficult in C.

 - Use of Str for regular expression matching within the appliance.
2017-07-27 22:31:22 +01:00
Richard W.M. Jones
626a7fe80a daemon: Reimplement ‘case_sensitive_path’ API in OCaml. 2017-07-27 22:31:22 +01:00
Richard W.M. Jones
ff10ee035d daemon: Reimplement ‘part_get_mbr_id’ API in OCaml. 2017-07-27 22:31:22 +01:00
Richard W.M. Jones
82bbd9c8a5 daemon: Reimplement ‘mount’, ‘mount_ro’, ‘mount_options’, ‘mount_vfs’ APIs in OCaml.
Some of the oldest and most core APIs, reimplemented.

This also moves the strange ‘mount_vfs_nochroot’ function into
btrfs.c.
2017-07-27 22:31:22 +01:00
Richard W.M. Jones
eb0852687e daemon: Reimplement ‘readlink’ API in OCaml. 2017-07-27 22:31:22 +01:00
Richard W.M. Jones
408243da1d daemon: Reimplement ‘is_dir’, ‘is_file’ and ‘is_symlink’ APIs in OCaml.
This also demonstrates usage of optional arguments.
2017-07-27 22:31:22 +01:00
Richard W.M. Jones
7a084269ef daemon: Add unit tests of the ‘Utils’ module. 2017-07-27 22:31:22 +01:00
Richard W.M. Jones
bedb6c1322 daemon: Reimplement several devsparts APIs in OCaml.
The reimplemented APIs are:

* list_devices
* list_partitions
* part_to_dev
* part_to_partnum
* is_whole_device
2017-07-27 22:31:22 +01:00
Richard W.M. Jones
d573cfde5b daemon: Reimplement ‘vfs_type’ API in OCaml. 2017-07-27 22:31:22 +01:00
Richard W.M. Jones
032148d416 daemon: Reimplement ‘file’ API in OCaml.
‘file’ is a small, self-contained API which runs a single command, so
it's a good test case for reimplementing APIs.
2017-07-27 22:31:22 +01:00
Richard W.M. Jones
d5b6f1df5f daemon: Allow parts of the daemon and APIs to be written in OCaml.
This change allows parts of the daemon to be written in the OCaml
programming language.  I am using the ‘Main Program in C’ method along
with ‘-output-obj’ to create an object file from the OCaml code /
runtime, as described here:
https://caml.inria.fr/pub/docs/manual-ocaml/intfc.html

Furthermore, change the generator to allow individual APIs to be
implemented in OCaml.  This is picked by setting:

  impl = OCaml <ocaml_function>;

The generator creates ‘do_function’ (the same one you would have to
write by hand in C), with the function calling the named
‘ocaml_function’ and dealing with marshalling/unmarshalling the OCaml
parameters.
2017-07-27 22:31:22 +01:00
Richard W.M. Jones
10cf01419a daemon: Reimplement handling of lvm.conf and filters.
LVM is fine with a completely empty configuration file (meaning "all
defaults"), so start with one instead of copying the system
configuration file.

Also this means we can very easily implement lvm_set_filter
functionality without using Augeas, since we no longer have to worry
about existing filters being present.

Thanks: Alasdair Kergon, Zdenek Kabelac.
2017-07-27 22:31:22 +01:00
Richard W.M. Jones
fe8c11ae4d v2v: Add slow tests of opensuse 13.1, 13.2 and 42.1 conversions. 2017-07-27 22:27:08 +01:00
Richard W.M. Jones
ba41cf1a51 v2v: bootloaders: Handle no Bootloader::Tools default section (RHBZ#1472208).
In SUSE guests, handle the case where
Bootloader::Tools::GetDefaultSection () returns undef.

Previously this would return an empty string and cause a bogus error
in subsequent code:

virt-v2v: error: libguestfs error: statns: statns_stub: path must start
with a / character
2017-07-27 22:27:08 +01:00
Richard W.M. Jones
024efc0f2f common/mlstdutils: Fix parallel builds of bytes.ml.
With OCaml < 4.02 when using the alternate Bytes module, this module
would be compiled twice during parallel builds, resulting in
occasional corruption.  The reason for this is that the ocamldep file
mentions ‘bytes.cmo’ whereas the ‘$(OCAML_BYTES_COMPAT_ML)’ macro
expands to ‘../../common/mlstdutils/bytes.ml’.  Make doesn't recognize
these as the same file.

Use an alternate way to specify this file to fix this.
2017-07-27 22:27:08 +01:00
Richard W.M. Jones
381c8b68c4 daemon: Remove GUESTFSD_EXT_CMD.
GUESTFSD_EXT_CMD was used by OpenSUSE to track which external commands
are run by the daemon and package those commands into the appliance.

It is no longer used by recent SUSE builds, so remove it.

Thanks: Pino Toscano, Olaf Hering.
2017-07-27 17:31:41 +01:00
Richard W.M. Jones
8d09d716aa common/mlstdutils: Build a bytecode version of this library.
Even if ocamlopt is available, always build a bytecode version of
‘common/mlstdutils’.

Furthermore, because this library is pure OCaml, we should not be
using ‘ocamlmklib’.  We should use ‘ocaml{c,opt} -a’ instead.  This
doesn't make any difference for native code, but for bytecode it was
building a broken library.

The original reason for making this change is because the generator is
always built as bytecode, and it depended on
‘../common/mlstdutils/guestfs_config.cmo’ and
‘../common/mlstdutils/std_utils.cmo’.  On native code platforms these
were not built before the generator and so the generator races to
build the .cmi and .cmo files.  Since the generator doesn't have
correct dependencies covering the ‘common/mlstdutils’ directory you
can get a broken link on fast machines:

  File "../common/mlstdutils/std_utils.ml", line 1:
  Error: Corrupted compiled interface
  ../common/mlstdutils/guestfs_config.cmi
  make[2]: *** [Makefile:1993: ../common/mlstdutils/std_utils.cmo] Error 2
  make[2]: *** Waiting for unfinished jobs....
  make[2]: Leaving directory '/builddir/build/BUILD/libguestfs-1.37.17/generator'
2017-07-27 14:39:46 +01:00
Richard W.M. Jones
a20859f563 tests: lvm: Make the lvm_set_filter test easier to understand.
No functional change.
2017-07-27 14:39:46 +01:00
Richard W.M. Jones
d098d314e6 daemon: Tidy up the <daemon.h> header file.
No change, just tidy up the header file.
2017-07-27 13:16:46 +01:00
Richard W.M. Jones
b981ac0a6e v2v: uefi: Add function to error out unless UEFI firmware is installed.
No change, just refactoring.
2017-07-27 13:11:43 +01:00
Richard W.M. Jones
7cd2753115 common/mlstdutils: Don't export StringSet.map (for older OCaml).
Fixes commit 8548729cf2.

Thanks: Pino Toscano.
2017-07-24 14:15:56 +01:00
Richard W.M. Jones
60408cecd6 common/mlutils: Remove bogus suffix parameter from Mkdtemp.temp_dir.
The C function mkdtemp(3) requires that the string ends with 6 'X'
characters, so appending a non-empty suffix causes the function to
raise EINVAL.

Luckily we only ever called this function with the last parameter "".
2017-07-24 11:48:24 +01:00
Richard W.M. Jones
8548729cf2 common/mlstdutils: Implement StringSet. 2017-07-24 11:46:22 +01:00
Richard W.M. Jones
ac3db3d664 common/mlstdutils: Add chomp function to remove \n from end of strings.
This is like the Perl chomp function, it removes a single \n from the
end of a string if present, else leaves the string alone.

I believe I found the only (two) places where such a function is used,
but there may be a few more lurking.
2017-07-21 15:56:59 +01:00
Richard W.M. Jones
95dfa054c0 builder: templates: Rebuild all Fedora 26 templates with LVM disabled.
This also fixes virt-p2v-make-disk which could not handle the base
disk images using LVM.

Fixes commit 48874066b9
and commit 0a73032120.
2017-07-19 20:56:11 +01:00
Richard W.M. Jones
b62419c05b builder: templates: Calculate revision correctly when existing file has no revision. 2017-07-19 15:24:05 +01:00
Richard W.M. Jones
11a329b1b0 builder: templates: Generate plain partition layouts (without LVM).
This was a mistake when the original shell scripts were transcribed to
make-template.ml (in commit 65a0570385).
2017-07-19 14:50:59 +01:00
Richard W.M. Jones
a2aabffd81 p2v: make-disk: Add verbose option to dracut in post-install script.
The verbose output goes to /tmp/builder.log so it wouldn't normally be
seen by the end user, but it's useful for debugging.
2017-07-19 14:47:15 +01:00
Richard W.M. Jones
5c86c64c79 fuse: Make it clearer that -o allow_other must be enabled in /etc/fuse.conf.
It wasn't very clear in the manual before.
2017-07-19 11:50:16 +01:00
Richard W.M. Jones
ffdcb7cfeb build: Require <caml/unixsupport.h>
Require <caml/unixsupport.h> (an OCaml header file) and remove
alternate defintions of ‘Nothing’ and ‘unix_error’ which are defined
in this header file.

We require OCaml >= 3.11 which has this header file, so there is no
need to test for it or provide alternative definitions.

Thanks: Pino Toscano.
2017-07-18 18:42:23 +01:00
Richard W.M. Jones
318ca68408 build: Make OCaml compiler required for all builds.
Previously the OCaml compiler was only required if building from git
but was at least theoretically optional if building from tarballs
(although this was never tested).  Since we want to write parts of the
daemon in OCaml, this makes OCaml required for all builds.

Note that the ‘--disable-ocaml’ option remains, but it now only
disables OCaml bindings and OCaml virt tools.  Using this option does
not disable the OCaml compiler requirement.

Also note that ‘HAVE_OCAML’ changes meaning slightly, so it now means
"build OCaml bindings and tools" (analogous to ‘HAVE_PERL’ and
others).  The generator, daemon [in a future commit], and some utility
libraries needed by the generator or daemon do not test for this macro
because we can assume OCaml compiler availability.
2017-07-18 18:37:35 +01:00
Richard W.M. Jones
8ecfa6c638 Version 1.37.18. 2017-07-18 15:15:47 +01:00
Richard W.M. Jones
93a2f9d213 v2v: Set correct root device when rebuilding SUSE kdump initrd.
The ‘vmware-uninstall-tools.pl’ script tries to rebuild the initrd.
On SUSE, if kdump initrd has been enabled, this would use the wrong
root device because ‘mkdumprd’ doesn't know what root device to use.
Fix that by setting the ‘rootdev’ environment variable.

See also https://bugzilla.redhat.com/1465849 (this is not a fix).
2017-07-18 14:13:36 +01:00
Richard W.M. Jones
98641e26c8 lib: Move guestfs_int_parse_unsigned_int* functions.
Just code motion, no functional change.
2017-07-18 13:22:00 +01:00
Richard W.M. Jones
0c98971040 p2v: make-disk: Install p2v service in multi-user.target instead of default.target.
Tested by doing ‘make -C p2v run-virt-p2v-in-a-vm’.
2017-07-17 16:04:07 +01:00
Richard W.M. Jones
db5e6bd221 customize: firstboot: Remove default.target.wants/guestfs-firstboot.service too.
This file could be left over from earlier use of the ‘--firstboot’
option.

Thanks: Pino Toscano.
2017-07-17 16:04:07 +01:00
Richard W.M. Jones
00c4c5c8f8 customize: firstboot: Install firstboot scripts in multi-user.target (RHBZ#1469655).
When the guest uses systemd, install firstboot scripts under
‘multi-user.target’.

See this link for details:
https://lists.freedesktop.org/archives/systemd-devel/2017-July/039325.html

This fixes firstboot on Fedora 26 (and in general with systemd >= 233).

Thanks: Lennart Poettering
2017-07-17 16:04:07 +01:00
Richard W.M. Jones
1286129fac customize: firstboot: Factor out the name of the systemd target.
Currently we install the firstboot service under systemd target
‘default.target’.  This change simply factors out this name.

Note that the name is not factored out in the code which deletes the
old ‘/etc/systemd/system/default.target.wants/firstboot.service’ file,
since that would have always been installed in the same location.
2017-07-17 16:04:07 +01:00
Richard W.M. Jones
981d3c9630 docs: Add info about how the stable tarballs are signed. 2017-07-16 21:36:19 +01:00
Richard W.M. Jones
f60f8c47cc lib: Move implementation of ‘hivex_value_utf8’ to new file ‘lib/hivex.c’.
Just a code movement, no change.
2017-07-14 14:35:37 +01:00
Richard W.M. Jones
2afe62eb60 builder: templates: Prevent script from being run as root.
Or with LIBVIRT_DEFAULT_URI=qemu:///system which is the same
thing.

In either case the images are created as user qemu.qemu and then
aren't readable or modifiable by later parts of the script.
2017-07-13 12:07:35 +01:00
Richard W.M. Jones
9fd2231cb0 customize: Test firstboot in Fedora 26.
It currently fails because of this bug apparently in systemd:

https://bugzilla.redhat.com/show_bug.cgi?id=1469655
https://github.com/systemd/systemd/issues/6334
2017-07-13 12:00:38 +01:00
Pino Toscano
a1c559a0f4 ocaml: fix build with Bytes fallback
Place the Bytes fallback module in the right place (mlstdutils), with no
need to make it available directly also for generation, since it uses
mlstdutils now.

Fixes commit 61d4891ef4.
2017-07-12 09:52:46 +02:00
Pino Toscano
178a20f6c3 builder: fix paths to mlstdutils & mlutils
Followup/fix of commit 61d4891ef4.
2017-07-12 09:52:46 +02:00
Richard W.M. Jones
0a73032120 builder: Add Fedora 26 for aarch64, armv7l, i686, ppc64, ppc64le.
All the secondary architectures except s390x, which we cannot handle
because qemu doesn't emulate that architecture sufficiently yet.
2017-07-11 15:17:58 +01:00
Richard W.M. Jones
5aaa91b524 builder: templates: Use full path for nvram file.
Works around a virt-install or libvirt bug:
https://bugzilla.redhat.com/show_bug.cgi?id=1469491
2017-07-11 13:02:55 +01:00
Richard W.M. Jones
904578e8b9 builder: templates: Use dl.fedoraproject.org for secondary architectures.
Avoid redirecting to incomplete mirrors.
2017-07-11 12:00:58 +01:00
Richard W.M. Jones
48874066b9 builder: Add fedora-26 (x86_64) image. 2017-07-11 10:29:57 +01:00
Richard W.M. Jones
09b14a6076 Version 1.37.17. 2017-07-10 22:06:45 +01:00
Richard W.M. Jones
538ef8107c common/mlutils: Add test .ml file to EXTRA_DIST.
Fixes commit 8be72935dc.
2017-07-10 22:04:41 +01:00
Richard W.M. Jones
f30b2065a2 gobject: Add outline guestfs-gobject(3) manual page.
Since we removed gtk doc, we might as well replace it with a
manual page explaining the basics of how to run gjs.
2017-07-10 17:03:19 +01:00
Richard W.M. Jones
f5f7f00a46 gobject: Remove gtk-doc (RHBZ#1465665).
The gobject bindings are adequately covered in the usual manual pages:
guestfs(3).  There is no need for separate generation of gtk-doc.
Also generating gtk documentation is the slowest part of the build,
and the tooling around gtk-doc is broken
(https://bugzilla.redhat.com/show_bug.cgi?id=1465665).

Note this removes the configure ‘--enable-gtk-doc’ option.  Using this
option now gives a warning, but is otherwise ignored:

  configure: WARNING: unrecognized options: --enable-gtk-doc
2017-07-10 17:03:19 +01:00
Richard W.M. Jones
2cb0413049 gobject: Use TEST_FUNCTIONS framework in tests. 2017-07-10 17:03:19 +01:00
Richard W.M. Jones
707f5bcfe0 daemon: Link guestfsd with libutils.
After the previous refactoring, we are able to link the daemon to
common/utils, and also remove some of the "duplicate" functions that
the daemon carried ("duplicate" in quotes because they were often not
exact duplicates).

Also this removes the duplicate reimplementation of (most) cleanup
functions in the daemon, since those are provided by libutils now.

It also allows us in future (but not in this commit) to move utility
functions from the daemon into libutils.
2017-07-10 17:01:59 +01:00
Richard W.M. Jones
e6c89f9631 utils: Rename ‘guestfs-internal-frontend.h’ to ‘guestfs-utils.h’.
The reason it's not just ‘utils.h’ is because Pino is worried that we
might pick up /usr/include/utils.h from a rogue library.
2017-07-10 17:01:59 +01:00
Richard W.M. Jones
8be72935dc mllib, v2v: Split out OCaml utils bindings ‘common/mlutils’.
Create a module ‘C_utils’ containing functions like ‘drive_name’ and
‘shell_unquote’ which come from the C utilities.

The new directory ‘common/mlutils’ also contains the ‘Unix_utils’
wrappers around POSIX functions missing from the OCaml stdlib.
2017-07-10 17:01:59 +01:00
Richard W.M. Jones
5efebd8c7e utils: Split out structs cleanups and printing into common/structs.
These won't be used by the daemon, so interferes with us using
common/utils in the daemon, so they are moved to a different library.
2017-07-10 17:01:59 +01:00
Richard W.M. Jones
78587cc3c6 common/utils: cleanups: Add CLEANUP_CLOSE function.
This is present in the daemon, but the function could be used
throughout the code.
2017-07-10 17:01:59 +01:00
Richard W.M. Jones
b2469a6d96 common/utils: Refactor stdlib, gnulib and libxml2 cleanup functions.
This refactoring change just moves the cleanup functions around in the
common/utils directory.

libxml2 cleanups are moved to a separate object file, so that we can
still link to libutils even if the main program is not using libxml2
anywhere.  Similarly gnulib cleanups.

cleanup.c is renamed to cleanups.c.

A new header file cleanups.h is introduced which will replace
guestfs-internal-frontend-cleanups.h (fully replaced in a later commit).
2017-07-10 17:01:59 +01:00
Richard W.M. Jones
7489d22843 common/utils: Move ‘uefi.c’ to ‘lib/’.
This was only used inside the library, so move it there.
2017-07-10 17:01:59 +01:00
Richard W.M. Jones
add53125a4 common/mlstdutils: Implement ‘Char.mem’, ‘String.span’ and ‘String.cspan’.
Char.mem tells you if a byte is a member of a string.

String.span and String.cspan are like the C functions strspn and
strcspn.
2017-07-10 17:01:59 +01:00
Richard W.M. Jones
b31a076717 common/mlstdutils: Implement complete set of byte swapping functions.
This implements all of:

 val int_of_le16 : string -> int64
 val le16_of_int : int64 -> string
 val int_of_be16 : string -> int64
 val be16_of_int : int64 -> string
 val int_of_le32 : string -> int64
 val le32_of_int : int64 -> string
 val int_of_be32 : string -> int64
 val be32_of_int : int64 -> string
 val int_of_le64 : string -> int64
 val le64_of_int : int64 -> string
 val int_of_be64 : string -> int64
 val be64_of_int : int64 -> string

and tests.
2017-07-10 17:01:59 +01:00
Richard W.M. Jones
61d4891ef4 mllib: Split ‘Common_utils’ into ‘Std_utils’ + ‘Common_utils’.
The new module ‘Std_utils’ contains only functions which are pure
OCaml and depend only on the OCaml stdlib.  Therefore these functions
may be used by the generator.

The new module is moved to ‘common/mlstdutils’.

This also removes the "<stdlib>" hack, and the code which copied the
library around.

Also ‘Guestfs_config’, ‘Libdir’ and ‘StringMap’ modules are moved
since these are essentially the same.

The bulk of this change is just updating files which use
‘open Common_utils’ to add ‘open Std_utils’ where necessary.
2017-07-10 17:01:59 +01:00
Richard W.M. Jones
989292c146 mllib: Move Xml (libxml2) OCaml bindings to common/mlxml.
The ‘Xml’ module is a self-contained library of bindings for libxml2,
with no other dependencies.

Move it to a separate ‘common/mlxml’ directory.

This is not pure refactoring.  For unclear reasons, the previous
version of ‘Xml.parse_file’ read the whole file into memory and then
called ‘xmlReadMemory’.  This was quite inefficient, and unnecessary
because we could use ‘xmlReadFile’ to read and parse the file
efficiently.  Changing the code to use ‘xmlReadFile’ also removes the
unnecessary dependency on ‘Common_utils.read_whole_file’.
2017-07-10 17:01:59 +01:00
Richard W.M. Jones
9254c8f152 mllib: Move Progress OCaml bindings to common/mlprogress.
The ‘Progress’ module is a self-contained library with the only
dependencies being:

 - the C ‘progress’ implementation

Move it to a separate ‘common/mlprogress’ directory.

This change is pure code refactoring.
2017-07-10 17:01:59 +01:00
Richard W.M. Jones
746a87cbf8 mllib: Move Visit OCaml bindings to common/mlvisit.
The ‘Visit’ module is a self-contained library with the only
dependencies being:

 - the C ‘visit’ implementation

 - the guestfs OCaml bindings

Move it to a separate ‘common/mlvisit’ directory.

This change is not entirely refactoring.  Two other fixes are made:

 - remove unsafe use of CLEANUP_FREE from a function which could
   raise an OCaml exception (cleanup handlers would not be called
   correctly if the exception is thrown)

 - don't link directly to common/visit/visit.c, but instead use
   the library (common/visit/libvisit.la)
2017-07-10 17:01:59 +01:00
Pino Toscano
28c375701d builder: templates: pass empty proxy to d-i when not set
When there is no proxy set, pass an empty string to the Debian
Installer.  This way, the installer will not ask for a proxy.
2017-07-10 17:56:13 +02:00
Pino Toscano
941545bde6 builder: templates: save NVRAM before removing guest
When installing guests that need NVRAM variables, the cleanup of the
guest with `virsh undefine` will remove that file too, which is not what
we want.  Instead, compress the NVRAM file right before the cleanup,
to ensure we have it.

Also, fix the filename for it, removing the double "-nvram" suffixes.
2017-07-10 17:56:13 +02:00
Pino Toscano
a67346b2fe builder: templates: improve debian.preseed
- set the mirror to deb.debian.org, which is the official redirector, so
  generated images will use the closest mirror depending on their
  location
- automake the task selection, using the choice we want
- do a full upgrade of the distro, so the template is already up-to-date
- install grub on the default device, which should also be the only one
  in the automated installation
2017-07-10 17:56:13 +02:00
Pino Toscano
eb830e89dc builder: templates: generalize debian location
Add an helper function to translate our architecture to the Debian
naming, and use it to get the location for all the architectures.
2017-07-10 17:56:13 +02:00
Pino Toscano
2ff6938935 builder: templates: update Debian preseed from Stretch
Update our debian.preseed file from a Stretch example file, leaving all
the customization done already.
2017-07-10 17:56:13 +02:00
Richard W.M. Jones
4cea914d24 builder: make-template: Combine both os_variant_of_os functions into one.
Cosmetic only change, no functional change.
2017-07-10 16:49:32 +01:00
Richard W.M. Jones
77d25587b8 v2v: docs: VDSM location of virt-v2v log file.
See this bug for background information:
https://bugzilla.redhat.com/show_bug.cgi?id=1350465

Thanks: Tomáš Golembiovský, Pino Toscano
2017-07-07 17:17:54 +01:00
Richard W.M. Jones
d96209ef07 lib: libvirt: Pass copyonread flag through to the libvirt XML (RHBZ#1466563).
We were dropping the add_drive copyonread flag when using the libvirt
backend.  This resulted in significant performance degradation (2x-3x
slower) when running virt-v2v against VMware servers.

Thanks: Kun Wei.
2017-07-01 11:40:12 +01:00
Richard W.M. Jones
38bf2a0f97 v2v: Allow -i libvirtxml to open network disks over http or https.
Currently -i libvirtxml mode only works for local files or NBD disks.
The purpose of NBD is to support virt-p2v.

This change adds support for network disks over http or https, ie:

    <disk type='network' device='disk'>
      <driver name='qemu' type='raw'/>
      <source protocol="http" name="/scratch/disk.img">
        <host name="server.example.com" port="80"/>
      </source>
      <target dev='hda' bus='ide'/>
    </disk>

This is just for testing.  It's especially useful for exercising curl
support in qemu without requiring VMware to be available.
2017-06-29 16:01:27 +01:00
Pavel Butsykin
40fcb3e4d2 launch: add support for autodetection of appliance image format
This feature allows you to use different image formats for the fixed
appliance. The raw format is used by default.

Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
2017-06-29 12:13:12 +01:00
Richard W.M. Jones
dd4e95c636 builder: Add debian-9 template. 2017-06-27 10:04:45 +01:00
Richard W.M. Jones
669739a16c builder: make-template: Remove trailing \n in Debian index-fragment.
Caused the following error when running make-template:

  syntax error at line 22: syntax error
  virt-index-validate: ‘debian-9.index-fragment’ could not be validated, see errors above
2017-06-27 10:04:45 +01:00
Richard W.M. Jones
0e7c0877be builder: Support Debian 9 ("Stretch") in make-template. 2017-06-27 10:04:45 +01:00
Richard W.M. Jones
cfab7e122b configure: Fix the release date so that it's impossible to forget about.
Add a RELEASES file which contains the release date for each version
of libguestfs.  When a new version is released, the configure script
checks that the date has not been omitted from the file.

This also fixes the release date for version 1.37.16 which I omitted
from commit 9455f21237.
2017-06-23 15:02:19 +01:00
Richard W.M. Jones
dc6bf1d847 m4: Add utimbuf.m4 to gitignore.
Updates commit 01a6d88660.
2017-06-22 19:14:02 +01:00
Richard W.M. Jones
01a6d88660 Update gnulib to latest. 2017-06-22 15:19:44 +01:00
Richard W.M. Jones
fbb0cd8582 builder: Allow large variable length arrays.
Gnulib added: -Wvla-larger-than=4031, get rid.
2017-06-22 15:19:44 +01:00
Richard W.M. Jones
d5467855e5 build: Force -Wformat-truncation=1.
Gnulib changed the default to -Wformat-truncation=2, but GCC 7 gives a
bunch of completely incorrect warnings.  Change it back.
2017-06-22 15:19:44 +01:00
Richard W.M. Jones
b8600a2a1c build: Force -Wimplicit-fallthrough=4.
New gnulib uses ‘-Wimplicit-fallthrough=5’ which warns (and hence
errors) on every switch statement with an implicit fallthrough.

We could use the new GCC attribute here:

  #ifndef FALLTHROUGH
  # if __GNUC__ < 7
  #  define FALLTHROUGH ((void) 0)
  # else
  #  define FALLTHROUGH __attribute__ ((__fallthrough__))
  # endif
  #endif

but instead this changes the level to 4 which allows us to use
/*FALLTHROUGH*/ comments (which we are already using) to mark cases
where we expect fallthrough.
2017-06-22 15:19:44 +01:00
Richard W.M. Jones
f861c13855 maintainer: Unset LC_ALL before running Python script to list bugs.
Gnulib installs two files: ‘GNUmakefile’ and ‘maint.mk’.  The first
one runs the second one, and the second one sets LC_ALL=C universally.

However this breaks the ‘bugzilla’ script (or Python) because some
bugs contain non-ASCII characters in their Summary.  The script prints
this error:

  Traceback (most recent call last):
    File "/usr/bin/bugzilla", line 1117, in <module>
      main()
    File "/usr/bin/bugzilla", line 1112, in main
      _format_output(bz, opt, buglist)
    File "/usr/bin/bugzilla", line 702, in _format_output
      print(format_field_re.sub(bug_field, opt.outputformat))
  UnicodeEncodeError: 'ascii' codec can't encode characters in position 108-109: ordinal not in range(128)

The simplest fix for this is to unset LC_ALL before running the
external script, so that the normal locale settings are used.
2017-06-22 14:32:26 +01:00
Richard W.M. Jones
d98b381ef6 v2v: Document vdsm-compat-option in machine-readable output.
Thanks: Ming Xie
2017-06-22 11:52:02 +01:00
Richard W.M. Jones
9455f21237 Version 1.37.16. 2017-06-21 22:43:37 +01:00
Richard W.M. Jones
13cc6faedb maintainer: New layout of libguestfs website. 2017-06-21 22:23:12 +01:00
Richard W.M. Jones
7e29760d28 Version 1.37.15. 2017-06-21 21:56:11 +01:00
Richard W.M. Jones
68a88a6b0e mllib: Handle empty files correctly in read_first_line_from_file.
The OCaml function ‘input_line’ throws an End_of_file exception if the
end of the file is read before any other input, ie. if the file here
is zero length.  Return an empty string instead.

This can produce peculiar errors such as:

$ virt-customize ... --root-password file:/dev/null
libguestfs: uncaught OCaml exception in getopt callback: End_of_file
2017-06-21 18:14:18 +01:00
Richard W.M. Jones
9fdc495602 appliance/init: Allow daemon stack traces to be captured by gdb.
This fragment, not enabled by default, allows stack traces to be
captured and displayed by gdb in case the daemon crashes.
2017-06-21 16:12:09 +01:00
Pino Toscano
1ca2a8b7ba resize: make sure the input disk is read-only
Fixes commit 8a2b0738d1.
2017-06-21 16:34:05 +02:00
Pino Toscano
713243b3cb python: PEP 8: remove extra spaces in example lines
Remove (before opening round bracket) whitespaces in the documentation
of the Python binding, according to the PEP 8 specification.

This is just code reformatting, with no behaviour changes; no content
changed beside whitespaces, so "git diff -w" gives an empty diff.
2017-06-21 13:46:58 +02:00
Pino Toscano
dec7a267d8 dib: use Common_utils.run_commands
Use the new helper for spawning parallel commands, and redirecting their
stdout to file.
2017-06-20 15:10:48 +01:00
Pino Toscano
4f02613b73 mllib: add new Common_utils.run_commands
Mostly modelled after a snippet implemented in dib, it is an helper
function to run multiple commands in parallel, waiting for all of them
at once, and returning all their exit codes.  It is possible to pass
custom descriptors for collecting stdout and stderr of each command.

Common_utils.run_command is adapted to use few helper methods used by
run_commands, so all the existing code using it keeps working; in
addition, it gets labelled parameters for stdout and stderr FDs.

Add a simple unit tests for them.
2017-06-20 15:10:48 +01:00
Richard W.M. Jones
19498b199d gitignore: Remove a few unused patterns from this file. 2017-06-19 14:50:18 +01:00
Richard W.M. Jones
db8fdfd8d6 lib: direct, uml: Refactor unblocking SIGTERM code.
A small refactoring of
commit 1f1cd11cf0.
2017-06-13 08:49:05 +01:00
Richard W.M. Jones
92995c5564 lib: Move close_file_descriptors into guestfs-internal.h.
This macro is only used by the library, so move it to
lib/guestfs-internal.h.
2017-06-13 08:42:29 +01:00
Richard W.M. Jones
8a98fe91b8 daemon: lvm: Pass --yes option to force pvresize (RHBZ#1460577).
LVM2 >= 2.02.171 requires the ‘--yes’ option to force pvresize to work
in various circumstances, eg. reducing the size of an existing PV.

Pass this flag unconditionally.

Note this does NOT break earlier versions which just ignore this flag.
2017-06-12 13:24:26 +01:00
Richard W.M. Jones
1f1cd11cf0 lib: direct, uml: Unblock SIGTERM in the hypervisor and recovery processes (RHBZ#1460338).
If SIGTERM is blocked in the main program, then it ends up still being
blocked in the subprocess after we fork.  This means that we cannot
kill qemu by sending SIGTERM to it.  This commit fixes the problem by
unblocking SIGTERM unconditionally after fork.

Thanks: wtfuzz on IRC for reporting and analysis.
2017-06-12 13:24:26 +01:00
Richard W.M. Jones
5856323e6f lib: create: Allow any [[:alnum:]]+ string as a backingfmt parameter (RHBZ#1459979).
If you use the libguestfs tools which open disk images read-only
(eg. virt-df), with formats such as 'vdi', then you will see an error:

  error: invalid value for backingformat parameter 'vdi'

This is because opening a disk image read-only will try to create a
qcow2 file with the original image as a backing file.  However the
list of permitted backing formats was very restrictive and did not
include 'vdi' (nor many other uncommon formats).

Instead of using a whitelist for backing formats, just validate that
the string is alphanumeric and short.

Thanks: Mike Goodwin for reporting the bug.
2017-06-09 12:57:03 +01:00
Richard W.M. Jones
0b8556695f daemon: ldm: Use CLEANUP_FREE on list of static strings.
This likely causes a double-free in the ‘ldmtool_scan_devices’ API.
2017-06-09 12:57:03 +01:00
Richard W.M. Jones
4e05ad9e1c docs: Document common/qemuopts subdirectory. 2017-06-08 19:18:06 +01:00
Richard W.M. Jones
ab1620b8d0 builder: Add cirros-0.3.5. 2017-06-04 09:39:39 +01:00
Richard W.M. Jones
d606edfba4 builder: templates: Ensure a stable sort when creating index file. 2017-06-04 09:39:39 +01:00
Richard W.M. Jones
3ca0110adc builder: Fix Unicode quotes in index file.
Fixes commit 126ef5d082.
2017-06-04 09:39:23 +01:00
Pino Toscano
76eeb0afc9 v2v: tell v2v the real root device to mkinitrd
Complementary fix of commit 2d25872df3.
On SLES 11 SP4 with kdump enabled mkinitrd calls mkdumprd which calls
mkinitrd, but mkdumprd doesn't have any clue of the root device.

Call mkinitrd with rootdev environment variable to tell them all
what device to use as root.

Tested-By: Cédric Bosdonnat <cbosdonnat@suse.com>
2017-06-02 14:59:21 +01:00
Richard W.M. Jones
8c89299d8a mllib: Export which in "stdlib mode".
As with the previous commit, this was already being compiled in, but
not exported, so there's no substantive change here.
2017-06-01 09:07:05 +01:00
Richard W.M. Jones
5e49e3ff53 mllib: Export prog, quiet, trace, verbose in "stdlib mode".
These were already included in the .ml implementation file, but just
weren't being exported in the interface, so there's no real change
here.  It just allows these functions to be used.
2017-06-01 09:07:05 +01:00
Pino Toscano
2c41f001de btrfs_replace: fix position of subcommand options
btrfs-progs 4.11 is more strict with option parsing, so subcommand
options must appear now before the subcommand arguments.
2017-05-30 13:15:55 +02:00
Pino Toscano
7e6c16f1e7 v2v: add crypto support (RHBZ#1451665)
Make use of the additional command line arguments, and API needed to
decrypt LUKS partitions.  This extends to v2v the work done in other
OCaml tools with commit 6b26a0cce4,
since it seems to be working fine after a basic testing.

Related to: RHBZ#1362649
2017-05-22 11:31:45 +02:00
Richard W.M. Jones
ccbcb40e70 Version 1.37.14. 2017-05-18 22:34:12 +01:00
Richard W.M. Jones
a5bd493e3f lib: Add VIRTIO_DEVICE_NAME macro to handle virtio-mmio vs CCW vs virtio-PCI.
Also move the macro into lib/launch-direct.c, since it is not used
anywhere else (libvirt handles the differences in the libvirt
backend).
2017-05-18 19:02:01 +01:00
Richard W.M. Jones
c77837e6f2 s390x: tests: 9p: Use virtio-9p-ccw as the 9p device in this test. 2017-05-18 19:02:01 +01:00
Richard W.M. Jones
93af83de85 s390x: tests: regressions: Skip IDE tests on S/390.
IDE interface is not supported.
2017-05-18 19:02:01 +01:00
Richard W.M. Jones
ddde6f9e2f s390x: launch: direct: Use virtio-*-ccw on this architecture.
PCI devices don't exist/work.  You would see errors such as:

qemu-system-s390x: -device virtio-rng-pci,rng=rng0: MSI-X support is mandatory in the S390 architecture
2017-05-18 19:02:01 +01:00
Richard W.M. Jones
fa6bc0fd83 init: Add comment that we should consider using /proc/consoles.
Although we can't use it at the moment because it is incorrect
on at least s390x (RHBZ#1351968).
2017-05-18 19:02:01 +01:00
Richard W.M. Jones
5fc76d6d10 s390x: appliance: Use /dev/ttysclp0 for serial console. 2017-05-18 19:02:01 +01:00
Richard W.M. Jones
ade2652bda s390x: launch: direct: Use sclp as serial console on this architecture.
The same change to the direct backend as made to the libvirt backend
in the previous commit.
2017-05-18 19:02:01 +01:00
Richard W.M. Jones
6328f33236 s390x: launch: libvirt: Use <console> device sclp for appliance debug messages (RHBZ#1376547).
Thanks: Cole Robinson, Dan Horak, Thomas Huth.
2017-05-18 19:02:01 +01:00
Pino Toscano
2d25872df3 v2v: linux: pass the root device when using SUSE's mkinitrd
mkinitrd in SLE guests < 12 tries to get the root device by scanning the
fstab: this will fail, since v2v already remapped the devices from
hd*/sd* to vd* in the guest (including in its fstab).

Since we know what is the root device in the appliance, pass it to
mkinitrd directly, so it does not have to do guesswork.

Thanks to: Cédric Bosdonnat, for reporting the issue, and testing
the fix.
2017-05-15 14:41:03 +02:00
Pino Toscano
00bf11cba8 python: PEP 8: add empty line
Small update for commit 45e046dac9.

This is just formatting, no behaviour changes.
2017-05-15 14:31:56 +02:00
Matteo Cafasso
401c445636 python: check return value of Python object functions (RHBZ#1406906)
Verify the returned values of Python Object constructor functions
are not NULL before adding them to a collection.

This is particularly relevant when constructing Unicode strings in
Python 3 as they will return NULL if non UTF-8 characters are present.

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2017-05-15 14:20:31 +02:00
Pino Toscano
4ce26d8f21 appliance: update yara packages on openSUSE
Add the package for the yara library as available on openSUSE Leap 42.2.
'yara' is left there for now.

Updates commit 2e24129da3.
2017-05-12 17:13:55 +02:00
Pino Toscano
5cbedebdb0 daemon: lvm: use 'yes' as boolean for lvm2
It looks like older versions of lvm2 (recent enough to have selectors)
do not recognize '1' (and '0') as boolean values.  Switch to 'yes',
which seems to be supported.

Updates commit 7367945647.
2017-05-12 17:03:01 +02:00
Pino Toscano
3c0b7710c1 python: improve few exceptions thrown on error
Make use of functions and types that fit more, and that do the same job:
- use PyErr_NoMemory() on malloc failure
- use PyErr_SetFromErrno when setting an exception from an errno
- throw TypeError if not getting a list when required
2017-05-11 14:35:42 +02:00
Pino Toscano
f3f99a09ea python: use right func when PyString_FromStringAndSize is not there
Fixes commit 9d25b4e564.

Thanks to: Matteo Cafasso
2017-05-09 17:47:32 +02:00
Pino Toscano
9d25b4e564 python: add simple wrappers for PyObject<->string functions
The current need for #ifdef's based on the presence of
PyString_FromString makes both the OCaml code of the generator, and the
generated C code a mess to read.

Hence, add three simple wrappers to make both the OCaml, and C code more
readable, and easier to tweak in the future.

This should be just refactoring, with no actual behaviour changes.

Thanks to: Matteo Cafasso
2017-05-09 16:45:31 +02:00
Richard W.M. Jones
613c6fb900 Version 1.37.13. 2017-05-08 14:08:12 +01:00
Richard W.M. Jones
0e63e59bf5 v2v: -i ova: Prefer pigz or pxz for uncompressing OVA files (RHBZ#1448739).
If the parallel tools pigz or pxz are available, prefer them for
uncompressing gz- and xz-compressed OVA files respectively.  If not
available then gzip or xz are used as normal.
2017-05-08 11:14:47 +01:00
Richard W.M. Jones
5e55a9cd4e v2v: -i ova: Refactor constructing zcat command. 2017-05-08 11:14:47 +01:00
Richard W.M. Jones
d2f2c3f4b2 v2v: -i ova: Refactor untar function. 2017-05-08 11:14:46 +01:00
Richard W.M. Jones
34b047e879 v2v: -o qemu: Reimplement qemu command line using common/qemuopts. 2017-05-08 11:14:46 +01:00
Richard W.M. Jones
0071a6e146 launch: direct: Reimplement command line handling using qemuopts library. 2017-05-08 11:14:46 +01:00
Richard W.M. Jones
bb5ffd7497 configure: Drop --with-qemu-options / QEMU_OPTIONS.
In its current form this is very hard to implement because it requires
us to "unparse" the options, including removing any shell quoting.

It wasn't implemented at all for the libvirt backend.

Also contrary to the documentation, the configure script did not use
these options for testing, but constructed its own set of qemu test
options.
2017-05-08 11:14:46 +01:00
Richard W.M. Jones
581c4bcc1d common: Add a simple mini-library for handling qemu command and config files. 2017-05-08 11:14:46 +01:00
Richard W.M. Jones
b4728fd004 generator: Annotate returned strings which are devices or mountables.
Previously the generator did not change any string returned from the
daemon.  Thus guestfs_list_devices (for example) might return internal
device names like /dev/vda (if virtio-blk was in use).

This changes calls to the daemon so that returned strings are
annotated as plain strings, devices or mountables:

    old               --->     new
  RString "uuid"             RString (RPlainString "uuid")
  RString "device"           RString (RDevice "device")
  RString "fs"               RString (RMountable "fs")

For hash tables, keys and values must be annotated separately.  For
example a hash table of mountables (keys) -> plain strings (values)
would be annotated like this:

    old               --->     new
  RHashtable "fses"          RHashtable (RMountable, RPlainString, "fses")

The daemon calls reverse_device_name_translation (currently a no-op)
for devices and mountables.

Note that this has no effect for calls which are handled on the
library side.

(cherry picked from commit 6b77cc196ecb8d7e1d73592ef65a189a7412c97c)
2017-05-08 11:14:45 +01:00
Richard W.M. Jones
8a545c0b1e daemon: Move device_name_translation function to its own file.
Just code motion.

(cherry picked from commit c75d873568e95fb7845c6e3913347c4bf267f4e9)
2017-05-08 11:14:45 +01:00
Richard W.M. Jones
9013a93d0e lib: Remove internal details of device name translation from API docs.
Remove much of the text detailing how device name translation
happened.  Since we removed support for virtio-blk
(commit 9e0294f88f) and deprecated the
‘iface’ parameter, only /dev/sdX device names should be visible
through the public APIs, both in parameters and in return values from
calls like guestfs_list_devices and guestfs_list_partitions.

Note the above is in fact not true for the UML backend, but UML is
broken in the kernel and in any case this will be fixed later.

(cherry picked from commit 2727e589db216bf0731385966889a4f66dbfe225)
2017-05-08 11:14:45 +01:00
Richard W.M. Jones
04f757a708 launch: Error if you try to launch with too many drives.
In particular the virt-rescue --scratch option makes it very easy to
add huge numbers of drives.  Since the per-backend max_disks limit was
never checked anywhere you could get peculiar failures.  Now you'll
get a clear error message:

$ virt-rescue --scratch=256
libguestfs: error: too many drives have been added, the current backend only supports 255 drives
2017-05-08 11:14:45 +01:00
Richard W.M. Jones
6c0d520842 v2v: -i ova: Rearrange functions.
No change, just move one function.
2017-05-08 10:02:23 +01:00
Pavel Butsykin
a9e6fdefc3 appliance: search all types of appliances for each path separately
This patch changes appliance search using paths with multiple directories. Now
all appliance checks will be done separately for each directory. For example
if the path LIBGUESTFS_PATH=/a:/b:/c, then all applainces are searched first in
/a, then in /b and then in /c. It allows to flexibly configure the libguestfs
to interact with different appliances.

Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
2017-05-05 14:12:03 +01:00
Pino Toscano
ca0436a44a perl: remove 900-introspection.t from MANIFEST
Fixes commit b06cc25a58.
2017-05-04 16:53:09 +02:00
Pavel Butsykin
0f79400c7f build: add ./configure --with-guestfs-path option
Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
2017-05-04 13:24:39 +01:00
Pino Toscano
b06cc25a58 perl: drop %guestfs_introspection stuff
It is not something standard, and actually unused by libguestfs itself.
Possibly going to be used by the old virt-v2v (which was in Perl), but
never used for that either.
2017-05-04 10:51:29 +02:00
Pino Toscano
bf1d1d3685 inspector: validate resulting XML files
Run xmllint to validate the XML output files of virt-inspector, so the
schema is checked against actual output of virt-inspector.
2017-05-04 09:42:19 +02:00
Richard W.M. Jones
8c9a4bc84f common/options: Change drv struct to store drive index instead of device name.
The device name is only used by guestfish (when using the -N option to
prepare drives).  We constructed the device name very naively,
basically ‘sprintf ("/dev/sd%c", next_drive)’.

This stores the device index instead, and only constructs the device
name in guestfish.  Also the device name is constructed properly using
guestfs_int_drive_name so it can cope with #drives > 26.

As a side effect of this change we can remove the extra parameter of
the add_drives macro.

Thanks: Pino Toscano
2017-05-03 19:32:37 +01:00
Richard W.M. Jones
b168147834 generator: Don't permit certain String/stringt combinations.
After the previous commit it become possible to construct various
"impossible" argument types, such as lists of FileIn strings.  This
commit prevents these from happening.
2017-05-03 19:26:18 +01:00
Richard W.M. Jones
30411ef623 generator: Simplify the handling of string parameters.
Previously we had lots of types like String, Device, StringList,
DeviceList, etc. where Device was just a String with magical
properties (but only inside the daemon), and DeviceList was just a
list of Device strings.

Replace these with some simple top-level types:

  String
  StringList

and move the magic into a subtype.

The change is mechanical, for example:

    old                     --->    new
  FileIn "filename"               String (FileIn, "filename")
  DeviceList "devices"            StringList (Device, "devices")

Handling BufferIn is sufficiently different from a plain String
throughout all the bindings that it still uses a top-level type.
(Compare with FileIn/FileOut where the only difference is in the
protocol, but the bindings can uniformly treat it as a plain String.)

There is no semantic change, and the generated files are identical
except for a minor change in the (deprecated) Perl
%guestfs_introspection table.
2017-05-03 19:26:18 +01:00
Pavel Butsykin
a76e9040b2 v2v: bootloaders: search grub config for all distributions
This patch improves the search of grub config on EFI partition. This
means that the config will be found not only for rhel but also for
many other distributions.  Tests were performed on the following
distributions: centos, fedora, ubuntu, suse. In all cases, the config
path was /boot/efi/EFI/*distname*/grub.cfg

The main purpose of the patch is to improve support for converting of
vm with UEFI for most distributions. Unfortunately this patch does not
solve the problem for all distributions, for example Debian does not
store grub config on the EFI partition, therefore for such
distributions another solution is necessary.

Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
2017-05-03 10:54:29 +01:00
Matteo Cafasso
f3d3136a17 yara_scan: added API tests
Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2017-05-02 13:42:29 +01:00
Matteo Cafasso
e7a0face42 New API: yara_scan
The yara_scan API parses the file generated by the daemon counterpart
function and returns the list of yara_detection structs to the user.

It writes the daemon's command output on a temporary file and parses it,
deserialising the XDR formatted yara_detection structs.

It returns to the caller the list of yara_detection structs generated by
the internal_yara_scan command.

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2017-05-02 13:34:43 +01:00
Matteo Cafasso
d00dc913aa New API: internal_yara_scan
The internal_yara_scan runs the Yara engine with the previously loaded
rules against the given file.

For each rule matching against the scanned file, a struct containing
the file name and the rule identifier is returned.

The gathered list of yara_detection structs is serialised into XDR format
and written to a file.

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2017-05-02 13:34:42 +01:00
Matteo Cafasso
09bab5d38c New API: yara_destroy
The yara_destroy API allows to claim resources back via the removal of
the previously loaded Yara rules.

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2017-05-02 13:34:42 +01:00
Matteo Cafasso
27f175b717 New API: yara_load
The yara_load API allows to load a set of Yara rules contained within a
file on the host.

Rules can be in binary format, as when compiled with yarac command, or
in source code format. In the latter case, the rules will be first
compiled and then loaded.

Subsequent calls of the yara_load API will result in the discard of the
previously loaded rules.

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2017-05-02 13:34:42 +01:00
Matteo Cafasso
2e24129da3 appliance: add yara dependency
libyara3 on Debian/Ubuntu
yara on SUSE/RedHat

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2017-05-02 13:01:11 +01:00
Matteo Cafasso
29af0500c2 daemon: expose file upload logic
Allows other modules to use the same logic for uploading files.

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2017-05-02 13:01:11 +01:00
Richard W.M. Jones
d0344f3522 v2v: -o rhv: Add Windows 2016 Server type in OVF output (RHBZ#1447202).
Thanks: Kun Wei

See also:
d233325d7b
2017-05-02 10:59:33 +01:00
Pavel Butsykin
f885fd227c appliance: more reliable check for the supermin appliance
At least two control files (packages and base.tar.gz) are necessary for the
supermin appliance.

Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
2017-04-28 19:21:17 +01:00
Pino Toscano
c657c93753 v2v: -o glance: factorize common properties
Many of the properties for disks are the same for all of them, so
collect them only once, instead of doing that for every disk.

Should be just code motion, with no behaviour change.
2017-04-28 10:17:18 +02:00
Pino Toscano
7409c9d9d3 v2v: -o glance: add property for UEFI firmware (RHBZ#1445659)
When converting a guest with UEFI firmware, set the also
hw_firmware_type=uefi property for all the disks of the guest, so Nova
can properly boot the guest.
2017-04-28 10:17:17 +02:00
Pino Toscano
79c5acc13d appliance: add cdrkit-cdrtools-compat on openSUSE
It looks like isoinfo is in that package since openSUSE Leap 42.1, so
make sure to include it to not break the isoinfo* APIs.
2017-04-26 12:05:43 +02:00
Richard W.M. Jones
311eb4c7e1 Version 1.37.12. 2017-04-25 22:52:47 +01:00
Richard W.M. Jones
965d253c74 generator: python: Omit unused parameter names in match cases. 2017-04-25 13:08:32 +01:00
Richard W.M. Jones
9243910ea2 generator: perl: Omit unused parameter names in match cases. 2017-04-25 13:08:32 +01:00
Richard W.M. Jones
5a1257a886 daemon: Use CLEANUP_* functions to avoid an explicit free in stub functions. 2017-04-25 12:50:02 +01:00
Matteo Cafasso
ffbf1b5605 daemon: ignore unused return value in upload function
Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2017-04-25 09:33:26 +01:00
Richard W.M. Jones
99813d1195 daemon: stubs.h is generated, so should be listed in generator_built.
Fixes commit 20f190617a.
2017-04-21 15:20:18 +01:00
Richard W.M. Jones
ca12aaa90c generator: daemon: Move *RESOLVE* macros to an ordinary header file.
It's clumsy to define these in the generator, as they are essentially
just static text.
2017-04-21 15:20:17 +01:00
Richard W.M. Jones
3f3dfe68de generator: daemon: Replace ‘cancel_stmt’ with ‘is_filein’ flag.
In every instance where we used the ‘cancel_stmt’ parameter of
these macros:

  ABS_PATH
  NEED_ROOT

the value was only ever ‘cancel_receive ()’ or empty.  We only use
‘cancel_receive’ for FileIn functions, so replace it with a simple
flag for whether the current function is a FileIn function.

This also removes some incorrect comments about macros that cannot be
used with FileIn functions when in fact they can.
2017-04-21 15:20:17 +01:00
Richard W.M. Jones
5200e51719 generator: daemon: Remove fail_stmt parameter from *RESOLVE* macros.
As a simple consequence of the previous commit, every instance of the
‘fail_stmt’ parameter to one of the following macros:

  RESOLVE_DEVICE
  RESOLVE_MOUNTABLE
  REQUIRE_ROOT_OR_RESOLVE_DEVICE
  REQUIRE_ROOT_OR_RESOLVE_MOUNTABLE

is now ‘return’ and therefore we can replace it in the macro and drop
the parameter completely.
2017-04-21 15:20:17 +01:00
Richard W.M. Jones
671b1d10a0 generator: daemon: Remove done label.
As a simple consequence of the previous commit, the ‘done’ label can
be removed, and any instance of ‘goto done’ can be replaced by
‘return’.
2017-04-21 15:20:17 +01:00
Richard W.M. Jones
378cb6f818 generator: daemon: Use a cleanup function to free XDR args struct.
Previously stubs were generated like this:

  void
  fn_stub (XDR *xdr_in)
  {
    struct guestfs_fn_args args;
    ...
    // on error paths, ‘goto done’
    ...
  done:
    xdr_free ((xdrproc_t) xdr_guestfs_fn_args, (char *) &args);
  }

This replaces the call to xdr_free with a generated cleanup function.
2017-04-21 15:20:17 +01:00
Richard W.M. Jones
b2cd4367b1 generator: daemon: Get rid of useless done_no_free label.
The generated code had:

    ...
  done_no_free:
    return;
  }

There was no possible code between the label and the return statement,
so both the label and the return statement are redundant.  The
instances of ‘goto done_no_free’ can simply be replaced by ‘return’.

The only small complication is that there is a label just before this
which contains some optional code.  So we might have ended up with
generated code looking like:

  done:
    // if there was no optional code, this would be empty
  }

which provokes a parse error in C.  Therefore I had to add a semicolon
after the ‘done:’ label.  This will be removed in a subsequent commit,
so it's just to make the current commit bisectable.
2017-04-21 15:20:16 +01:00
Richard W.M. Jones
99ac577a5b tests: Replace test-max-disks with several tests.
Replace the monolithic 'test-max-disks.pl' script with a test program
written in C.  The program is completely equivalent to the old script,
except for the enhancement that it is able to detect if disks are
added to the appliance in the wrong order.

The tests themselves are split out into some shell scripts:

 - test-27-disks: Fully tests 27 disks.
   This is the minimum supported configuration for all backends.

 - test-255-disks: Fully tests 255 disks.
   This is the most disks that libguestfs up to 1.36 supported.

 - test-add-lots-of-disks: Add ‘a lot’ of disks and exit (without
   any further testing).  This is meant to try to exercise > 255
   disk case but without being as slow as a test of the max number
   of disks (which takes ages, even for as few as 4000 disks).

 - test-max-disks: Test the maximum possible number of disks.
   The maximum depends on several factors, notably which backend
   is in use, and the limit on the number of open files.

   ‘test-max-disks’ is a slow test.
2017-04-21 15:20:16 +01:00
Richard W.M. Jones
8b68d00977 daemon: Add an assertion to suppress a warning with GCC.
swap.c: In function 'do_mkswap_U':
swap.c:62:9: error: argument 1 null where non-null expected [-Werror=nonnull]
     if (strlen (label) > SWAP_LABEL_MAX) {
         ^~~~~~~~~~~~~~
2017-04-20 14:38:08 +01:00
Richard W.M. Jones
2de5e317ad daemon: Remove use of fixed-size stack buffers.
GCC 7 complains that the fixed size buffers are not large enough
(at least in theory) when using ‘-O3 -mtune=broadwell’.
2017-04-20 14:38:08 +01:00
Richard W.M. Jones
9e0294f88f lib: direct: Remove support for virtio-blk as the default.
virtio-scsi has been supported in qemu since 2012, and it is superior
in every respect to virtio-blk.  There's no reason to still be using
virtio-blk.

virtio-scsi support was initially added in 2012
(commit 0c0a7d0d86).

You can still use virtio-blk using the (deprecated) iface parameter,
but don't do that in new code.
2017-04-20 14:38:08 +01:00
Richard W.M. Jones
067d442cdc lib: Reimplement is_zero.
As suggested by Eric Blake.
2017-04-20 14:38:07 +01:00
Richard W.M. Jones
c0fdeb36c7 daemon: Move the useful 'is_zero' function into common code.
This is largely a simple refactoring, but it combines another
definition of this function from virt-builder which had a slightly
different prototype.
2017-04-19 17:30:58 +01:00
Richard W.M. Jones
7eb26f03b9 lib: libvirt: Document virtio-scsi controller/bus/target/unit fields.
This adds comments documenting what the fields correspond to in qemu,
and the range of each field.
2017-04-19 10:59:39 +01:00
Richard W.M. Jones
661fa752bb v2v: ovf: Use push_back instead of append.
Microscopically more efficient.

Updates commit dac5fc53ac.
2017-04-15 12:31:08 +01:00
Tomáš Golembiovský
31f1fe7bd2 v2v: ovf: store CPU model for oVirt
If CPU model is available store it in OVF for oVirt. This affects
-o rhev and -o vdsm.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2017-04-14 11:09:20 +01:00
Pavel Butsykin
684aa26115 daemon: add udev_settle_file to is_root_device
It fixes a fail with ENOENT when device is not yet present after system boot.

Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
2017-04-14 11:08:07 +01:00
Pavel Butsykin
93664d38d2 daemon: run 'udevadm settle' with --exit-if-exists option
Add udev_settle_file() to run 'udevadm settle' with --exit-if-exists option. It
will slightly reduce the waiting-time for pending events if we need to wait
for events related to a particular device/file.

Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>

RWMJ:
 - Use local variable for MAX_ARGS.
 - Use commandv instead of commandrv, fix checking of return code.
2017-04-14 11:07:58 +01:00
Richard W.M. Jones
bf547aac70 Version 1.37.11. 2017-04-13 17:08:17 +01:00
Richard W.M. Jones
d8e1c4bb47 v2v: windows: Install both legacy and modern virtio keys in the registry (RHBZ#1431579).
Thanks: Kun Wei (for finding the bug)
Thanks: Ladi Prosek (for diagnosing the problem and proposing the fix)
2017-04-13 13:27:05 +01:00
Richard W.M. Jones
9e0781f096 mllib: Bind %identity C primitive to Common_utils.identity. 2017-04-13 10:13:34 +01:00
Richard W.M. Jones
c509abef43 v2v: -o rhv: Document how to test RHV conversions without RHV. 2017-04-13 10:13:33 +01:00
Richard W.M. Jones
24a6c5b57c v2v: -o rhv: Quote parameter to rm -rf.
This was safe before, the change just prevents accidental errors.
2017-04-13 10:13:33 +01:00
Richard W.M. Jones
ec61873d39 v2v: tests: Fix -i vmx test so it is more stable.
When running under valgrind, the process takes a fraction of a second
to start up, changing the "Opening the guest" timestamp, which broke
the test.

Fixes commit ca40078cdd.
2017-04-12 08:32:58 +01:00
Richard W.M. Jones
ac894baf75 Version 1.37.10. 2017-04-11 23:41:51 +01:00
Pino Toscano
56c4387b38 builder: various improvements to the documentation
- convert the Fedora 20 examples to Fedora 25
- convert the yum examples to dnf
- convert the Debian 7 examples to Debian 8
- mention that --core updates all the installed packages, not "core"
  ones
- convert i386 to i686 for the Fedora 32bit examples
- mention that autogenerated root passwords are printed on stdout
- mention --get-kernel is deprecated in favour of virt-get-kernel
- update URL to the Puppet installation documentation
- edit the repository index documentation to make it clearer
  non-compressed templates are supported
- remove old wrong paragraph about customization specified in command
  line not processed in the same order
- use --install instead of --run-command '$pkgmgr install ...'
- other minor changes
2017-04-11 22:54:52 +01:00
Richard W.M. Jones
ca40078cdd v2v: Implement -i vmx to read VMware vmx files directly (RHBZ#1441197).
This is a mostly complete implementation of a VMX parser and input
class for virt-v2v.  It parses the name, memory size, CPU topology,
firmware, video, sound, hard disks, removable disks and network
interfaces from the VMX file.  It only omits support for floppies and
SCSI CD-ROMs.

The input class is split into two major parts: a generic VMX file
parser (Parse_vmx), and the Input_vmx module which translates the VMX
tree into the source device model.

This also contains tests.  There are simple unit tests of the
Parse_vmx module, and also some more complete parsing tests taken from
real guests.
2017-04-11 22:39:38 +01:00
Richard W.M. Jones
ef261d69ed mllib: Add Char.hexdigit function.
Same as the function defined in fish/fish.c.
2017-04-11 21:50:05 +01:00
Richard W.M. Jones
bb846887de ocaml: Add Bytes.sub_string function to Bytes compat module.
This is only used when OCaml < 4.02 (eg. RHEL 7).  For more recent
versions the real Bytes.sub_string function is used instead.
2017-04-11 21:50:05 +01:00
Tomáš Golembiovský
dac5fc53ac v2v: ovf: Add virtio-rng and memory balloon device
This affects -o rhv and -o vdsm.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2017-04-11 21:50:05 +01:00
Richard W.M. Jones
aa16d5ca8e v2v: -o qemu: Add a comment about ICH9 audio device.
Just a comment.
2017-04-11 14:54:07 +01:00
Richard W.M. Jones
e562f52c95 v2v: -o qemu: Fix creation of ICH6 sound device.
Fixes commit f6ece2c01a.
2017-04-11 12:17:34 +01:00
Richard W.M. Jones
1a3fa37ae1 v2v: -o qemu: Use 'commas' function for qemu comma-separated parameters.
This actually makes no difference, but is "more correct" because the
commas function handles quoting correctly.

Fixes commit d6e59ddfcd.
2017-04-07 21:02:04 +01:00
Richard W.M. Jones
c104ec517b Version 1.37.9. 2017-04-06 16:38:18 +01:00
Richard W.M. Jones
069eb3d3df builder: Allow GnuPG v2 or v1 to be used (RHBZ#1438939).
All of the GPG commands we run are compatible with either v1 or v2, so
this simply involves looking for either gpg2 or gpg binaries at
runtime.
2017-04-06 16:29:45 +01:00
Richard W.M. Jones
543b7433e2 v2v: windows: Prefer virtio-win ISO over directory (RHBZ#1438794).
The exploded tree has many missing drivers (eg. virtio-rng).
The ISO contains the complete set, so prefer it.
2017-04-06 16:29:45 +01:00
Richard W.M. Jones
d6e59ddfcd v2v: -o qemu: Add virtio-rng, balloon and pvpanic to output (RHBZ#1438794). 2017-04-06 16:29:45 +01:00
Richard W.M. Jones
0a0586936a v2v: -o glance: Add virtio-rng to output properties (RHBZ#1438794).
Only virtio-rng is supported at the time.
2017-04-06 16:29:45 +01:00
Richard W.M. Jones
2db46a4114 v2v: -o libvirt: Add virtio-rng, balloon and pvpanic to output XML (RHBZ#1438794).
When outputting libvirt XML, create virtio-rng, a memory balloon
device, and a pvpanic device, if the guest supports it.

Thanks: Daniel Berrangé for advice on memballoon
2017-04-06 16:29:44 +01:00
Richard W.M. Jones
3e0ff263a5 v2v: Extend guestcaps to record drivers for virtio-rng, balloon and pvpanic.
Extend the guestcaps structure so it records whether a guest supports
(or drivers were added) for virtio-rng, the virtio memory balloon, and
the ISA pvpanic device.
2017-04-06 16:29:44 +01:00
Richard W.M. Jones
f5ce03c4da v2v: linux: Print best kernel in debug output.
After sorting kernels to find the best one, print the best kernel if
verbose is enabled.
2017-04-06 16:29:44 +01:00
Richard W.M. Jones
e6c9c4f69f v2v: linux: Replace 'ki_supports_virtio' field.
Previously the kernel_info field 'ki_supports_virtio' really meant
that the kernel supports virtio-net.  That was used as a proxy to mean
the kernel supports virtio in general.

This change splits the field so we explicitly test for both virtio-blk
and virtio-net drivers, and store the results as separate fields.

The patch is straightforward, except for the change to the
'rebuild_initrd' function.  Instead of making the module list
conditional on whether virtio-net is available and using the old
(probably wrong) fallback if it happens to be unavailable, this now
tries to enable the common virtio kernel modules (just the ones needed
for virtio-blk and virtio-net to work).  The fallback is only used if
none of the common virtio modules can be found.

This also adds a print_kernel_info function (as the
string_of_kernel_info function was unwieldy) and exports it from the
module.
2017-04-06 16:29:44 +01:00
Richard W.M. Jones
413ebec039 v2v: linux: Fix Xen PV-only detection.
We want to detect if a Linux kernel is Xen PV only ("PV-only").  Such
a kernel will not boot on KVM, and if a guest has only PV-only
kernels, it will not be able to boot at all on the target.

Our previous test was wrong.  It tested whether the xennet.ko module
exists.  This module was renamed in more recent kernels (to
xen-netfront.ko), so it happened to not detect modern kernels as
PV-only, but this was by chance.

Modern kernel images can be compiled with Xen PV guest support.  The
same image can boot on baremetal, KVM, Xen PV or Xen HVM.  Testing if
the xennet (or xen-netfront) module exists is irrelevant to this.

This test, which is based on ideas from Laszlo Ersek and

  https://wiki.xen.org/wiki/Xen_Project_Software_Overview#Guest_Types

uses the kernel config test CONFIG_X86_XEN || CONFIG_X86_64_XEN to
determine PV-only kernels.

Note that these CONFIG flags were never upstream, and existed only in
Linux kernels forked by Xen ("XenLinux").  By the time Xen guest
support was added upstream, it was implemented using pvops support, so
a single image could boot on Xen and non-Xen as described above, and
these flags were no longer used.

Updates commit 7eb219d193.

Thanks: Laszlo Ersek.
2017-04-06 16:29:44 +01:00
Richard W.M. Jones
95f1e83baf v2v: linux: Don't return virtio flag from configure_kernel function.
This is pure refactoring, no change to functionality.
2017-04-06 11:07:30 +01:00
Richard W.M. Jones
27a7214074 v2v: Rename OVF module to Create_ovf.
It's not a general OVF module at all.  It only creates OVF,
and only for RHV.
2017-04-06 10:28:38 +01:00
Richard W.M. Jones
ee206d7ba8 Use Unicode single quotes ‘’ in place of short single quoted strings throughout.
Only in end-user messages and documentation.  This change was done
mostly mechanically using the Perl script attached below.

I also changed don't -> don’t etc and made some other simple fixes.

See also: https://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html

----------
 #!/usr/bin/perl -w

use strict;
use Locale::PO;

my $re = qr{'([-\w%.,=?*/]+)'};

my %files = ();

foreach my $filename ("po/libguestfs.pot", "po-docs/libguestfs-docs.pot") {
    my $poref = Locale::PO->load_file_asarray($filename);

    foreach my $po (@$poref) {
        if ($po->msgid =~ $re) {
            my @refs = split /\s+/, $po->reference;
            foreach my $ref (@refs) {
                my ($file, $lineno) = split /:/, $ref, 2;
                $file =~ s{^\.\./}{};
                if (exists $files{$file}) {
                    push @{$files{$file}}, $lineno;
                } else {
                    $files{$file} = [$lineno];
                }
            }
        }
    }
}

foreach my $file (sort keys %files) {
    unless (-w $file) {
        warn "warning: $file is probably generated\n"; # have to edit generator
        next;
    }
    my @lines = sort { $a <=> $b } @{$files{$file}};

    #print "editing $file at lines ", join (", ", @lines), " ...\n";
    open FILE, "<$file" or die "$file: $!";
    my @all = ();
    push @all, $_ while <FILE>;
    close FILE;

    my $ext = $file;
    $ext =~ s/^.*\.//;

    foreach (@lines) {
        # Don't mess with verbatim sections in POD files.
        next if $ext eq "pod" && $all[$_-1] =~ m/^ /;

        unless ($all[$_-1] =~ $re) {
            # this can happen for multi-line strings, have to edit it
            # by hand
            warn "warning: $file:$_ does not contain expected content\n";
            next;
        }
        $all[$_-1] =~ s/$re/‘$1’/g;
    }

    rename "$file", "$file.bak";
    open FILE, ">$file" or die "$file: $!";
    print FILE $_ for @all;
    close FILE;
    my $mode = (stat ("$file.bak"))[2];
    chmod ($mode & 0777, "$file");
}
2017-04-04 18:47:37 +01:00
Pavel Butsykin
cc162b49e6 v2v: windows convert: fix virtio block driver installation for w10/w2k16
This patch fixes the problem of the first boot after installation virtio block
drivers on Windows 10 / Server 2016. The problem is related to the change in
the behavior of Windows-Kernel-Pnp. To fix we need to add a field "Version" to
HKLM/SYSTEM/DriverDatabase/DriverPackages/drv_inf_label then Windows-Kernel-Pnp
will be able to correctly install the virtio block driver.

Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
2017-04-03 18:21:43 +01:00
Richard W.M. Jones
604be8ced8 po: Fix charset=CHARSET -> charset=utf-8 in pot file. 2017-03-31 11:47:34 +01:00
Richard W.M. Jones
8c58b62f9d Replace possessive ASCII apostrophe ('s) with Unicode apostrophe (’s).
Only replaced in end-user messages and documentation, not in code,
comments, or anything else that's not end-user visible.

See: https://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html
2017-03-31 10:38:04 +01:00
Richard W.M. Jones
126ef5d082 Use Unicode single quotes ‘’ in place of `' in strings throughout.
See: https://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html
2017-03-31 10:38:04 +01:00
Richard W.M. Jones
ee9af92963 perl: Add =encoding to Sys::Guestfs man page.
Otherwise the man page cannot contain any non-7-bit-ASCII characters.

The test error seen was:

Failed test 'POD test for blib/lib/Sys/Guestfs.pm'
at /usr/share/perl5/vendor_perl/Test/Pod.pm line 187.
Wide character in print at /usr/share/perl5/vendor_perl/Test2/Formatter/TAP.pm line 112.
blib/lib/Sys/Guestfs.pm (1811): Non-ASCII character seen before =encoding in 'caller’s'. Assuming UTF-8
Looks like you failed 1 test of 1.
2017-03-31 10:37:29 +01:00
Richard W.M. Jones
e0385c6902 docs: Fix documentation for btrfs_group_limit API. 2017-03-31 09:14:00 +01:00
Richard W.M. Jones
707c60ccb3 v2v: utils: Remove another reference to kraxel's OVMF repo.
Updates commit 889386f8c6.
2017-03-30 22:12:49 +01:00
Richard W.M. Jones
fcaae71696 Version 1.37.8. 2017-03-30 21:40:58 +01:00
Richard W.M. Jones
b417c877f4 p2v: tests: Fix fake scp command so it can handle multiple local files.
Fixes commit d178deeeb8.
2017-03-30 19:34:29 +01:00
Richard W.M. Jones
38e7a1e038 p2v: Fix list of files in documentation. 2017-03-30 15:42:39 +01:00
Richard W.M. Jones
d178deeeb8 p2v: Run fewer 'scp' commands.
Each scp command takes a considerable amount of time -- several
seconds -- because it must set up, authenticate and tear down a new
connection.  Avoid this by combining several copies into a single
command.

We still have to use two scp commands because we want to check that
some files are copied and ignore failures in a second set of
informational files.
2017-03-30 15:42:39 +01:00
Richard W.M. Jones
7cae10f0c1 p2v, v2v: Ensure the full version is always available in several places.
Ensure the full version of virt-v2v and virt-p2v is available in the
conversion log file, the only log file that we reliably get from users
and customers.  "Full version" means the major, minor, release and
extra fields.  The extra field is especially important as it contains
the downstream package release in Fedora, RHEL etc.

This change saves the virt-p2v version as a comment in the
physical.xml file, which is included in full in the conversion log (by
virt-v2v).

It also ensures that the initial virt-v2v debug message contains the
full version number including the 'extra' field.

  $ cat virt-v2v-conversion-log.txt
  virt-v2v: libguestfs 1.37.7local,libvirt (x86_64)
  ...
  <!-- virt-p2v 1.37.7local,libvirt -->

It also adds 'p2v-version' and 'v2v-version' files in the virt-p2v
debug directory.  These are strictly superfluous but could be useful
for end users.

  $ cat p2v-version
  virt-p2v 1.37.7local,libvirt
  $ cat v2v-version
  virt-v2v 1.37.7local,libvirt
2017-03-30 15:42:39 +01:00
Pino Toscano
e5e8b01f18 p2v: use standard license type in about dialog
GtkAboutDialog in GTK+ 3 can be configured with few standard licenses,
including GPL2+.  Thus, just set that property, so the about dialog will
show its own license text, and there is no need for our custom one.
2017-03-30 16:29:45 +02:00
Pino Toscano
5810e03023 p2v: move the license text to gui.c
It is used only for the about dialog, and this way it will be easier
to disable.
2017-03-30 16:29:45 +02:00
Richard W.M. Jones
86a166458c p2v: Rebuild dependencies.* files if config.status changes.
If you switch from ./configure --with-gtk=2 to =3 (or vice versa) the
dependencies files don't get rebuilt.  As a result the wrong Gtk
libraries can be included in the ISO and virt-p2v won't run.
2017-03-30 12:29:05 +01:00
Richard W.M. Jones
8ee74dcc47 docs: security: Document new CVEs in PCRE which may affect inspection. 2017-03-30 12:29:05 +01:00
Pino Toscano
c85eb443db mllib: cast integer pointers to intptr_t as intermediate step
This make sure there is no mismatch between the size of the integer
value that Int64_val returns, and the size of the guestfs_h pointer.

This should fix the warning on 32bit environments (and thus build, when
--enable-werror is enabled).
2017-03-29 18:54:49 +02:00
Pino Toscano
12c4cc7a6b automake2junit.ml: escape text in message of <skipped>
Escape XML characters in the logs to use as message for <skipped>, so
special characters such as &, ", and < do not make the whole XML
invalid.
2017-03-29 15:57:40 +02:00
Richard W.M. Jones
5faa917972 v2v: In --help output, note that --compressed only applies to -of qcow2.
Just a minor documentation change.
2017-03-27 17:41:32 +01:00
Richard W.M. Jones
aa7b7e26c3 rescue: Don't document --suggest option in --help output.
Also fix the docs test to ignore it.

Updates/fixes commit 33d2ae7961.
2017-03-25 23:35:11 +00:00
Richard W.M. Jones
5a4b72122b dist: Add AUTHORS to EXTRA_DIST and remove from dist-hook.
It's a normal file now and can be distributed in the usual way.

Fixes commit 34755dd86a.
2017-03-25 18:30:28 +00:00
Richard W.M. Jones
34755dd86a generator, p2v: Generate AUTHORS and p2v/about-authors.c from a single place.
This also improves the "Credits" box in virt-p2v.  With Gtk >= 3.4
this can now show all contributors organized by the nature of their
contribution.
2017-03-25 14:04:44 +00:00
Richard W.M. Jones
9287e8954d docs: hacking: Document 'make maintainer-*' targets. 2017-03-25 12:11:48 +00:00
Richard W.M. Jones
ea13da21ea docs: hacking: Fix the headings.
Just grouping things more logically.
2017-03-25 12:03:52 +00:00
Richard W.M. Jones
267569f7ad rescue: docs: Note that you can run virt-rescue on disks too. 2017-03-24 22:52:02 +00:00
Richard W.M. Jones
c38b48409e rescue: docs: It is no longer necessary to mount filesystems by hand.
Fix the manual page to reflect the new -i option.

Fixes commit 33d2ae7961.
2017-03-24 22:51:06 +00:00
Richard W.M. Jones
00375a6b4a Version 1.37.7. 2017-03-24 14:58:32 +00:00
Richard W.M. Jones
374899b6d9 p2v: Use lscpu instead of libvirt to get CPU information.
Don't get the CPU information from libvirt, because including libvirt
and all dependencies in the virt-p2v ISO bloats everything.

Instead get most of the information we need from the util-linux
program 'lscpu'.

Unfortunately the CPU model cannot be retrieved.

Example output:

  $ ./run virt-p2v --cmdline="p2v.dump_config_and_exit"
  [...]
  cpu vendor . . .   Intel
  cpu sockets  . .   2
  cpu cores  . . .   8
  cpu threads  . .   1
  flags  . . . . .   acpi apic pae

This updates commit 963d6c3be7.
2017-03-24 11:22:48 +00:00
Richard W.M. Jones
3d70900bac p2v: Move code to generate physical XML to a separate file.
This is pure refactoring, except that I have removed the definition
xmlBufferDetach since that function is not used.
2017-03-24 11:22:48 +00:00
Richard W.M. Jones
fd9bdab9f8 p2v: Calculate offset of the Real Time Clock from UTC.
Calculate the offset of the physical host's Real Time Clock (RTC) from
UTC and pass this to virt-v2v through the libvirt XML description of
the physical machine.

The libvirt XML is modified to add one of the following:

(no <clock/> element)

 - if the RTC could not be read or there was some other time
   calculation error.

<clock offset='utc' />

 - if the RTC is the same as UTC.

<clock offset='localtime' />

 - if the RTC is in local time.

   It's not possible to distinguish between UTC and localtime in
   timezones that lie along the Greenwich Meridian (obviously
   including the UK), when daylight savings time is not in effect.  In
   that case, UTC is chosen.

   Necessarily in timezones that use DST, this depends on when
   virt-p2v is run, so in the unusual case where a physical machine is
   switched off for a long time and then booted directly into virt-p2v
   when DST has changed, the calculation can be wrong.

<clock offset='variable' basis='utc' adjustment='<seconds>' />

 - if the RTC is some other offset to UTC, other than equal to UTC or
   localtime.
2017-03-24 11:22:48 +00:00
Richard W.M. Jones
0782da088b tests: v2v: -i ova: Fix test for reordered XML.
Commit 8e617b792f reversed the order in
which the <features> and <os> sections appear in the XML.
2017-03-24 11:22:48 +00:00
Pino Toscano
439b9189f0 inspect: get a more common size icon for ALT Linux guests (RHBZ#1433937)
A 64px icon does not exists everywhere, so just use a 48px one.

Updates commit bc54e0d605 and
commit 9928296c1c.

Thanks to: Xiang Hua Chen.
2017-03-24 11:04:14 +01:00
Richard W.M. Jones
5acd69ed6c bash: Implement tab completion for virt-win-reg (RHBZ#1367738).
This only implements long and short options.

Thanks: Ming Xie.
2017-03-24 09:47:59 +00:00
Richard W.M. Jones
7cf85ace19 v2v: xen: Require direct backend when doing Xen conversions over SSH.
Unfortunately libvirt has another bug related to the qemu
ssh driver, as described here:

  https://bugzilla.redhat.com/show_bug.cgi?id=1434651#c3

(The libvirt bug is https://bugzilla.redhat.com/1140166)

Until this bug is fixed we have to require the direct backend to be
used for xen+ssh conversions.

This partially reverts commit ecbf093850.
2017-03-23 08:48:39 +00:00
Pino Toscano
46d5a26ddc inspect: improve detection of Mageia install discs
Check for a "product.id" file in an architecture-specific subdirectory
of the main partition, and use its data to improve the data on the
media.

Only Mageia as distribution name is recognized there, since most
probably this file will not be available on other distros.
2017-03-23 09:18:07 +01:00
Pino Toscano
47b3314be2 dib: implement IMAGE_ELEMENT_YAML
Export a new environment variable for extra-data.d scripts, that
contains a YAML representation of the elements in use.

This is a new addition in d-i-b 2.0.
2017-03-23 09:18:07 +01:00
Pino Toscano
b7f8dcbc65 dib: require a Python interpreter
d-i-b 2.0 is written in Python, and thus it passes the information about
the interpreter used for it (sys.executable) to the scripts that need
it; this mechanism replaces the old discovery of what is the default
Python interpreter in the system.

Since we are not Python-based, look for 'python' and use it as default
interpreter, with the --python command line option to set a different
one.

The only place where it is used so far are extra-data.d scripts; in case
it will be used also in other out-of-chroot phases, a different solution
will be needed.
2017-03-23 09:18:07 +01:00
Pino Toscano
301d621a0b dib: extract get_required_tool out of require_tool
Extract from require_tool an helper function to search for the tool, and
return the found path (instead of ignoring it).
2017-03-22 18:11:12 +01:00
Pino Toscano
ddbe66624c dib: export IMAGE_BLOCK_DEVICE_WITHOUT_PART
New environment variable exported by d-i-b 2.0.
2017-03-22 18:11:11 +01:00
Pino Toscano
f27f475cb2 dib: implement get_image_element_array stuff
Output the get_image_element_array function like d-i-b does, together
with the eval stuff needed to make it work.

get_image_element_array is basically a bash array, with the keys are the
used elements, and the values are the paths of each element; it is a new
addition in d-i-b 2.0.

This is used so far only for the extra-data.d phase.
2017-03-22 18:11:11 +01:00
Richard W.M. Jones
2f25d23ac8 bash: Add a bash completion script for virt-v2v-copy-to-local (RHBZ#1367738).
Thanks: Ming Xie
2017-03-22 15:53:37 +00:00
Richard W.M. Jones
9d6b1ec288 p2v: gui: Change mnemonics so 's' is not used twice (RHBZ#1379289).
Change mnemonics so 's' is not used twice:

  Start Conversion: 's' -> 'c'
  Output Connection: 'c' -> 'o'
  Output Storage: continues to use 's'

Thanks: Ming Xie.
2017-03-22 15:48:48 +00:00
Richard W.M. Jones
cecf1ea135 p2v: Allow setting QEMU_OPTIONS when testing qemu in a VM.
Also document both QEMU and QEMU_OPTIONS in guestfs-hacking(1).
2017-03-21 14:54:57 +00:00
Richard W.M. Jones
07cb3591b7 daemon: selinux: Add setfiles -v flag when verbose.
This shows which files are being relabelled.  Also only use -q
(suppress non-error output) when we are not verbose.
2017-03-21 14:54:48 +00:00
Richard W.M. Jones
fc0abf2354 daemon: selinux: Add setfiles -m option to suppress extra excludes (RHBZ#1433577). 2017-03-20 16:55:20 +00:00
Richard W.M. Jones
84d791cda1 v2v: inspect source: Don't tell people twice to run virt-v2v -v -x (RHBZ#1167623).
There were two related bugs in the virt-v2v error messages when source
inspection failed.

Firstly it would print the message about running 'virt-v2v -v -x' twice:

  virt-v2v: error: inspection could not detect the source guest (or physical
  machine).

  Assuming that you are running virt-v2v/virt-p2v on a source which is
  supported (and not, for example, a blank disk), then this should not
  happen.  You should run 'virt-v2v -v -x ... >& log' and attach the complete
  log to a new bug report (see http://libguestfs.org).

  No root device found in this operating system image.

  If reporting bugs, run virt-v2v with debugging enabled and include the
  complete output:

    virt-v2v -v -x [...]

And secondly it would tell you to run virt-v2v -v -x even if you were
running with verbose messages.

Further fix for https://bugzilla.redhat.com/show_bug.cgi?id=1167623
which updates commit ab7197476d.

Thanks: Kun Wei.
2017-03-20 15:50:45 +00:00
Pino Toscano
bc54e0d605 inspect: get a better icon for ALT Linux guests (RHBZ#1433937)
Use a 64px icon which is in the menu-icons-default package, hopefully
part of the default installation of any flavour.

Updates commit 9928296c1c.

Thanks to: Xiang Hua Chen.
2017-03-20 13:50:25 +01:00
Richard W.M. Jones
f0c2a7d36f Version 1.37.6. 2017-03-20 11:04:51 +00:00
Richard W.M. Jones
0b5e3b1196 customize: slow-tests: Test Fedora 25 instead of Fedora 24.
Just an update so we're testing the latest available version of Fedora.
2017-03-20 10:51:25 +00:00
Pino Toscano
fdd3dd7a7f p2v: virt-p2v-make-disk: prevent daemons to run on Debian
On Debian systems, usually daemons are run automatically after their
installations; since we are upgrading the template, and installing
packages such as openssh, network-manager, etc, this may cause few
daemon to stay running during the virt-builder execution, causing it to
fail when shutting down (since e.g. /sysroot/dev would be in use).

As workaround, use a temporary policy-rc.d policy layer [1]: give an
error code so no daemon is ever started at any point of package upgrades
and installation.  The script is removed at the very end of the
building, so the final image will spawn daemons just fine when booted.

[1] https://people.debian.org/~hmh/invokerc.d-policyrc.d-specification.txt
2017-03-20 10:20:21 +01:00
Pino Toscano
99818be410 p2v: virt-p2v-make-disk: fix systemd paths
Usually systemd is configured with prefix=/, so units are in
/lib/systemd.  On a system with UsrMove, such as Fedora/RHEL7, /lib is
a symlink to /usr/lib, so both /lib/systemd and /usr/lib/systemd work;
OTOH, on non-UsrMove systems, such as Debian, the two paths are
different locations, and thus trying to edit system files as
/usr/lib/systemd/etc will fail.

As solution, just reference /lib/systemd for systemd files.
2017-03-20 10:20:21 +01:00
Pino Toscano
6913630004 p2v: remove network-manager-applet Debian dependency
On Debian, network-manager-gnome contains nm-applet, which is what
launch-virt-p2v spawns.  network-manager-gnome is already in the list of
packages for Debian, while network-manager-applet does not exist.
2017-03-20 10:20:21 +01:00
Pino Toscano
80029641b4 p2v: fix Gtk dependencies on Debian
On Debian, the names of the packages containing the Gtk 2 and 3
libraries have different patterns, and thus just the name will not work
for Gtk 3.

Apply a bit of m4 to use a different package name on Gtk 2 and other
versions.  It can be easily adapted to new models in future Gtk 4+,
should the naming pattern change from Gtk 3.
2017-03-20 10:20:20 +01:00
Pino Toscano
12bfb3c631 btrfs_filesystem_show: work with another old btrfs version
An old version of btrfs-progs (3.17 in this case) has a different
version string, so adapt our filtering to include this line as well.

Related to/updates commit 839ae5bcd5.
2017-03-20 10:20:20 +01:00
Richard W.M. Jones
15b00a4d1c Version 1.37.5. 2017-03-18 22:20:25 +00:00
Richard W.M. Jones
2e93f72297 tests: Add further valgrind suppressions for glib and gtk3. 2017-03-18 21:45:41 +00:00
Richard W.M. Jones
e7d11b68ea Version 1.37.4. 2017-03-18 12:13:50 +00:00
Richard W.M. Jones
b73e3913ce p2v: Duplicate CPU vendor and model strings when copying config struct.
Fixes commit 963d6c3be7.
2017-03-18 11:21:49 +00:00
Richard W.M. Jones
73e0fe9f37 v2v: -i ova: Fix tests.
Fixes commit 7f940c3e3a.
2017-03-18 11:17:13 +00:00
Richard W.M. Jones
327caa1f08 test-data: Use another name for boot and root MD devices.
mdadm 4.0 no longer lets you create devices called literally "boot" or
"root", giving a very obscure error message:

https://bugzilla.redhat.com/show_bug.cgi?id=1433575

Work around this by calling them something else.
2017-03-18 10:24:12 +00:00
Richard W.M. Jones
b6adf66628 Version 1.37.3. 2017-03-17 15:22:42 +00:00
Richard W.M. Jones
589261d99f v2v: Add new test-v2v-print-source.* files to EXTRA_DIST.
Fixes commit 12a3b735f9.
2017-03-17 15:20:57 +00:00
Pino Toscano
df29936cf8 p2v: un-duplicate common dependencies
Move all the dependencies with the same name in all the distributions to
a single list at the end.

There should be no change to the package list used to build the p2v ISO.
2017-03-17 14:36:59 +00:00
Richard W.M. Jones
b32578a536 v2v: -i libvirt: If <vcpu> is missing, calculate it from CPU topology. 2017-03-17 11:24:30 +00:00
Richard W.M. Jones
7f940c3e3a v2v: Pass CPU vendor, model and topology from source to target.
Where supported, pass the source CPU vendor, model and topology to the
target hypervisor.

-i ova: We can get just cores per socket via a proprietary VMware
extension to OVF.

-i libvirt, virt-p2v: We can get all of these fields from the libvirt
XML.

-o libvirt, -o local: We can preserve all of the information in the
target XML.

-o rhv/vdsm: We can only pass through the topology, since neither
oVirt Engine nor the OVF format supports CPU vendor or model.
Topology uses an extension of OVF which is not part of the standard.

-o qemu: We preserve the topology only because versions of qemu vary
widely in their support for CPU models.

-o glance: Only the topology is preserved since that is all that
Glance currently supports.

Thanks: Pino Toscano.
2017-03-17 11:23:50 +00:00
Richard W.M. Jones
c5fe98dde4 v2v: -o glance: Build properties list imperatively.
No change, just refactoring.
2017-03-17 11:12:34 +00:00
Richard W.M. Jones
8e617b792f v2v: -o libvirt: Refactor creation of XML body.
Just refactoring, no change in semantics.
2017-03-17 11:08:23 +00:00
Richard W.M. Jones
12a3b735f9 tests: v2v: Rearrange test-v2v-print-source.
This rearranges the input files for the test of virt-v2v
--print-source, but does not change its semantics.
2017-03-17 11:08:22 +00:00
Richard W.M. Jones
963d6c3be7 p2v: Pass host CPU details to virt-v2v.
In the fake <domain type='physical'> libvirt XML that we create to
describe the physical host, we did not accurately pass any information
about the host CPU except the number of cores (<vcpu/>).

This commit extracts detailed information about the vendor, model and
topology of the host CPU and adds that to the libvirt XML for
virt-v2v.  Conveniently we can use libvirt capabilities to get this
information without needing to parse /proc/cpuinfo or similar
techniques.

The libvirt XML looks like this:

  <domain type="physical">
  ...
    <cpu match="minimum">
      <vendor>Intel</vendor>
      <model fallback="allow">Broadwell</model>
      <topology sockets="1" cores="2" threads="2"/>
    </cpu>
  ...
    <features>
      <acpi/>
      <apic/>
      <pae/>
    </features>
2017-03-17 11:08:22 +00:00
Richard W.M. Jones
a73f459904 p2v: Enable check-valgrind in this directory.
A couple of valgrind suppressions are required to work around memory
leaks in Gtk.
2017-03-17 11:08:22 +00:00
Richard W.M. Jones
9170513c8a p2v: Free config struct before exit.
Memory leak found by valgrind.
2017-03-17 11:08:22 +00:00
Richard W.M. Jones
9bba13b9cf p2v: Add awk as a dependency.
The code to parse /proc/cpuinfo runs awk, but it was not included as a
specific dependency so the parsing code might silently fail.
2017-03-16 19:15:23 +00:00
Richard W.M. Jones
c0a8afb3e6 lib: direct: Don't ever use -no-kvm-pit-reinjection.
On qemu 1.1.2:

  qemu-system-x86_64: -no-kvm-pit-reinjection: invalid option

Thanks: John Sucaet.
2017-03-16 19:15:23 +00:00
Pino Toscano
ece9c35e58 dib: avoid using Unix.O_CLOEXEC
It looks like Unix.O_CLOEXEC does not exist in OCaml < 4, so resort to
manually using Unix.set_close_on_exec on the filedesc after opening it.

Thanks to: John Sucaet and Richard W.M. Jones.
2017-03-16 18:01:37 +01:00
Pino Toscano
509adede7b generator: open Common_utils where needed
This makes it possible to use the operators from Common_utils that do
not exist in older OCaml versions (e.g. < 4.00).

Thanks to: John Sucaet.
2017-03-15 16:45:41 +01:00
Pino Toscano
2f22f2c469 v2v: linux: accept 'scd' devices in fstab
Avoid warnings for another kind of SCSI CD-ROMs in fstab, like it is
done already for other CD devices.
2017-03-15 11:07:43 +01:00
Pino Toscano
da4757fd15 v2v: bootloaders: look for device.map also in /boot/grub (Grub2)
On Debian-based systems, Grub2 is in /boot/grub (as already known after
commit 03b9f2b967), so make sure
device.map is changed even in this situation.
2017-03-14 14:43:53 +01:00
Pino Toscano
4e5f011508 v2v: OVF: add Debian and Ubuntu osinfo variants
Unfortunately, there are very few osinfo types available for Debian and
Ubuntu, so make sure to use them only when the version is enough, and
use the higher version available also for any following version.
2017-03-14 14:40:08 +01:00
Yann E. MORIN
0d023e7f3d configure: fix check for attribute cleanup
In cross-compilation, it is not possible to run tests, so the configure
aborts when checking for attribute cleanup.

The comment above the test hints at why we would need to do an actual
run test rather than a compile test: gcc only warns on unrecognised
attributes.

But warnings can be turned into error with -Werror.

Change the AC_RUN_IFELSE into an AC_COMPILE_IFELSE test that runs with
-Werror set. Save the CFLAGS before adding -Werror, and restore them
after the test.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
2017-03-14 10:08:05 +00:00
Richard W.M. Jones
b8817417b8 Version 1.37.2. 2017-03-13 18:11:28 +00:00
Richard W.M. Jones
ebb0d32395 v2v: Add a root test for access to root-only-readable OVAs (RHBZ#1430680). 2017-03-13 15:01:12 +00:00
Richard W.M. Jones
80d3e05483 tests: Add infrastructure for running certain tests as root.
'[sudo] make check-root' is analogous to 'make check-slow'.
2017-03-13 15:01:12 +00:00
Richard W.M. Jones
542eb560bd v2v: chmod original OVA file if running as root (RHBZ#1430680).
In the case where we are going to read the disk directly from the OVA
file (partial = true), we will create a qcow2 image backed by the OVA.
If running as root, libvirt will run qemu as a non-root user (because
of no qemu:///session support for root, which is a libvirt bug).  qemu
will not be able to read the backing file and thus will fail.

To work around this problem, chmod the backing (OVA) file.

This isn't a complete fix since (eg) the OVA might be located in a
directory which isn't accessible by root, but there's only so much we
can do here until libvirt is fixed.

Thanks: Kun Wei.
2017-03-13 15:01:12 +00:00
Richard W.M. Jones
91b5fb3641 v2v: -i ova: Use full path for backing file.
Works around a libvirt bug:
https://bugzilla.redhat.com/show_bug.cgi?id=1431652
2017-03-13 15:01:12 +00:00
Richard W.M. Jones
f34636700a v2v: -i ova: Factor out the OVF parsing into a separate module.
Mixing the XML parsing with the other functions of this module made it
very hard to understand.  Splitting the XML parsing into another
module simplifies the flow considerably.

This is just code refactoring and should not affect the semantics.
2017-03-13 15:01:12 +00:00
Richard W.M. Jones
57949e6853 v2v: -i ova: Hoist utility functions to the top of the file.
These functions obscure the true flow of the code, so hoist
them out of the source () method to the top of the file.

No change, just refactoring.
2017-03-13 15:01:12 +00:00
Pino Toscano
b197546839 v2v: support no socket for <listen type='socket'>
Support also a "socket" listen type with no explicitly specified socket
(which will be generated by libvirt).

Updates commit a4adf48915.

Related to: RHBZ#1378022
2017-03-13 14:34:58 +01:00
Richard W.M. Jones
5da5718084 mllib: Add a binding for realpath(3).
This is a copy of the supermin binding:

https://github.com/libguestfs/supermin/tree/master/src realpath*
2017-03-13 13:21:53 +00:00
Pino Toscano
e48c17b10d appliance: run systemd-tmpfiles also for /var/run
Commit a6330e9d3a enabled /run for
systemd-tmpfiles: while this works fine in most of the cases, there are
few tmpfiles configurations that still references /var/run instead of
/run.  As result, include also /var/run in the systemd-tmpfiles
execution.
2017-03-13 08:53:49 +01:00
Pino Toscano
31fb6e2041 daemon: fix memory leak in xfs implementation of vfs_minimum_size
Use the proper cleanup handler for deleting the guestfs_int_xfsinfo
struct (so the string fields are deleted too).

Fixes commit f5caa421d1.
2017-03-13 08:53:49 +01:00
Pino Toscano
32f0f9b032 daemon: generate cleanup handlers for structs
This way it is possible to cleanup properly structs in the daemon, when
using them within other daemon functions.
2017-03-13 08:53:49 +01:00
Richard W.M. Jones
e3782a3611 v2v: Refactor some command line error messages.
This change (mostly) has no effect, except I changed the content of
two error messages to make them consistent with the others.
2017-03-10 14:13:50 +00:00
Richard W.M. Jones
09b0613787 v2v: -o null: Force output format to be raw sparse.
When converting and throwing away the output (-o null), the input
format should not really matter.  However it does currently matter for
a couple of reasons:

(1) If the input is not raw or qcow2, then you'll get the error below
because virt-v2v wants to write the same output format as input format
but only allows raw or qcow2 as output formats:

  virt-v2v: error: output format should be 'raw' or 'qcow2'.

(2) If you use -o null -oa preallocated then a non-sparse temporary
disk is created before being deleted, but that just wastes disk space
for no reason.

Therefore this change

(i) prevents '-o null -oa preallocated' from being specified on the
command line,

(ii) prevents '-o null -of <anything>',

(iii) forces the output (temporary file) to be raw sparse.
2017-03-10 14:13:50 +00:00
Richard W.M. Jones
9bde152644 v2v: -i ova: Avoid long line in file.
Just a whitespace change.
2017-03-10 14:13:50 +00:00
Pino Toscano
de7d6df4be v2v: fix skip check in test-v2v-o-libvirt.sh
This test needs windows.img, not fedora.img.  This way, the test is
properly skipped when NTFS support is not available.

Fixes commit a1b3d8d04b.
2017-03-08 13:13:36 +01:00
Pino Toscano
ba52e0a217 dib: actually generate SHA256 checksums (RHBZ#1430184)
diskimage-builder generates MD5, and SHA256 checksums when using
--checksum, so stick to that list for compatibility reasons.
2017-03-08 09:45:08 +01:00
Richard W.M. Jones
0cd83760f8 Version 1.37.1. 2017-03-07 15:37:15 +00:00
Richard W.M. Jones
1ac8a9e40b v2v: Add new OVA tests to EXTRA_DIST.
Updates commit a1843b9d72.
2017-03-07 15:36:38 +00:00
Richard W.M. Jones
dd680e1f81 appliance: Add libtirpc, optionally used by the daemon.
Fixes commit 4bbb1f7490.
2017-03-07 14:47:01 +00:00
Richard W.M. Jones
4bbb1f7490 lib: Prefer tirpc for XDR, and rationalise how we search for alternatives.
glibc in Fedora is currently configured with `--enable-obsolete-rpc',
so I guess we can see which way the wind is blowing.

(1) This changes our configure script to prefer libtirpc if it is
available.

If libtirpc is _not_ available then:

(a) Headers must be located in <rpc/xdr.h>, or the user must supply
the right CFLAGS.

(b) XDR functions must be located in one of -lportablexdr, -lrpc,
-lxdr, -lnsl or no library at all (ie. -lc), and the user must set
LDFLAGS if needed.

(2) We no longer add these paths automatically to $(CFLAGS)/$(LIBS).
Any part of libguestfs which needs <rpc/*.h> or the xdr_* functions
must use $(RPC_CFLAGS)/$(RPC_LIBS) explicitly.

(3) Previously Mac OS X had a workaround for the broken 64 bit support
in the supplied rpcgen.  This workaround "activates" all the time if
you use tirpc, so breaking Linux after the above changes.  tirpc is
supported on OS X, so I think it's just better to use that rather than
the broken rpcgen.  For that reason I removed the workaround
completely.

Thanks: Roy Keene
2017-03-07 12:54:17 +00:00
Richard W.M. Jones
5ea17e97e4 rescue: Move --suggest code to separate file.
Just code motion.
2017-03-07 12:47:52 +00:00
Richard W.M. Jones
3637c42f4e rescue: Implement escape sequences.
This implements a few useful escape sequences:

><rescue> ^]?
virt-rescue escape sequences:
 ^] ? - print this message
 ^] h - print this message
 ^] q - quit virt-rescue
 ^] s - sync the filesystems
 ^] u - unmount filesystems
 ^] x - quit virt-rescue
 ^] z - suspend virt-rescue
to pass the escape key through to the rescue shell, type it twice

^]i

root device: /dev/sda3
  product name: Fedora 25 (Twenty Five)
  type: linux
  distro: fedora

^]z
[3]+  Stopped                 ./run virt-rescue --scratch
$ fg

><rescue> ^]u

unmounting filesystems ...
[   21.158558] XFS (sda3): Unmounting Filesystem
2017-03-07 12:47:52 +00:00
Richard W.M. Jones
33d2ae7961 rescue: Implement -m and -i options.
`virt-rescue -a disk -i' does the right thing.

`-m' was previously an alternate form of `--memsize'.  By sniffing the
parameter we can make `-m MB' continue to work, while also allowing
`-m' to be used as a short form for the `--mount' option.

This also removes most of the description of `--suggest' from the man
page, since it is no longer needed.
2017-03-07 12:47:52 +00:00
Richard W.M. Jones
32d6080144 rescue: Modify virt-rescue so it doesn't use direct mode (RHBZ#1152819, RHBZ#1171654).
Instead of using "direct mode" (which was basically a quick hack),
virt-rescue now launches the appliance with a running daemon.

The daemon doesn't do much -- there is still a bash shell which the
user interacts with.  The daemon is there simply to provide the
initial GUESTFS_LAUNCH_FLAG message and to handle shutdown a bit more
gracefully.

To interact with the shell, and replacing direct mode, virt-rescue now
prints out log messages (the output of the shell), and sends input
typed by the user directly to the console socket.  This uses the
guestfs_internal_get_console_socket API added previously.  Most of the
complexity behind this is hidden in virt-rescue.

This fully fixes the handling of ^C (RHBZ#1152819).  Also there were
earlier reports that full screen commands like 'vim' didn't work well,
(RHBZ#1171654), but in this version vim appears to work fine, albeit
only using 80x24 of the screen because of the serial console.
2017-03-07 12:47:52 +00:00
Richard W.M. Jones
8af9acd4e3 lib: Return EPIPE for "appliance closed the connection unexpectedly". 2017-03-07 12:47:51 +00:00
Richard W.M. Jones
8c73e9aa4e appliance: Fix job control in virt-rescue.
See comment and link to busybox FAQ for explanation.
2017-03-07 12:47:51 +00:00
Richard W.M. Jones
84c9f98c2e New API: internal-get-console-socket to support virt-rescue.
This API intended for use by virt-rescue only gets the file descriptor
of the console socket.
2017-03-07 12:47:51 +00:00
Richard W.M. Jones
26948d5cb1 generator: Deprecate direct mode (guestfs_set_direct, guestfs_get_direct). 2017-03-07 12:47:51 +00:00
Richard W.M. Jones
a1843b9d72 v2v: Add extra tests for malformed OVA files.
Test:
 - Bad SHA1 sum
 - Bad SHA256 sum
 - Invalid lines in manifest (x2)
 - Good checksum and manifest

These tests were originally written by Tomáš Golembiovský.  All I have
done is to integrate them into the virt-v2v test suite.
2017-03-07 12:47:51 +00:00
Richard W.M. Jones
9f447837ae docs: Document vulnerabilities in icoutils wrestool affecting libguestfs. 2017-03-07 10:50:49 +00:00
Richard W.M. Jones
a05e0fc0e8 v2v: -o local: Check that UEFI firmware is installed before conversion (RHBZ#1429506).
Avoids a lengthy conversion followed by failure if we discover at the
end that OVMF is not installed.

This also changes the order of the methods in -o libvirt and -o qemu
so that it matches the order in the class interface, and also
logically makes more sense.

Thanks: Christopher Brown
2017-03-07 10:34:29 +00:00
Richard W.M. Jones
c6d8d68a46 v2v: Fix typo in previous commit (RHBZ#1374232).
Fixes commit 25772a8123.
2017-03-06 16:07:04 +00:00
Richard W.M. Jones
25772a8123 v2v: Fix invalid regexp in file_contexts file (RHBZ#1374232).
Instead of just documenting this bug, fix it in the file_contexts
file.

Replaces commit ad3c8fe7f4.
2017-03-06 15:56:45 +00:00
Pino Toscano
5dd261ce5c v2v, p2v: rename rhvm network to ovirtmgmt (RHBZ#1429491)
Since RHV 3.6.10, the default network name is 'ovirtmgmt' instead of
'rhvm'.

This is just a documentation change.
2017-03-06 16:05:56 +01:00
Pino Toscano
5036ec67d5 p2v: fix possible close(-1) issue
Make sure the error handler (i.e. the code after the 'cleanup' label)
does not attempt to call close(-1), in case 'sockfd' is not initialized
yet.
2017-03-06 15:04:25 +01:00
Pino Toscano
0507daf7e6 p2v: check more return values
Check for the (rare) failures of open(/dev/null), and setsockopt.
2017-03-06 15:04:25 +01:00
Pino Toscano
d36940992e lib: qemu: improve handling of FILE*
Create own blocks for all the parts dealing with FILE*: this way there
is no need to recycle the same FILE* variable for all the operations,
and have each block its own variable automatically cleaned up.

This also fixes a potential undefined behaviour on error: POSIX says
that after a call fclose(), a FILE* cannot be used anymore, not even
on fclose() failure. The previous behaviour for fclose == -1 was to jump
to the error label, which would then try to call fclose() again (since
the FILE* pointer was still non-null).
2017-03-06 15:04:25 +01:00
Pino Toscano
18ee68ad12 java: use cleanup handlers for structs (lists) as return values
Filling some of their fields may cause the flow to skip to throw the
"out of memory" exception, and return immediately.  To avoid leaking the
struct, or struct list, from the C implementation, use a cleanup handler
so there is no need to manually clean it up.
2017-03-06 15:04:24 +01:00
Pino Toscano
c5fa352087 daemon: btrfs: check end_stringsbuf return values everywhere
Make sure to check the return value of end_stringsbuf everywhere, as
that would generate invalid string lists.
2017-03-06 15:04:24 +01:00
Pino Toscano
61a6f7e2d0 tail: check the return value pf guestfs_set_pgroup
It is done when creating the handle, so do it also when duplicating the
handle.
2017-03-06 15:04:24 +01:00
Richard W.M. Jones
e5474df1ac Use gnulib set_cloexec_flag in a few places. 2017-03-06 10:52:35 +00:00
Richard W.M. Jones
58d6becc8a Use gnulib set_nonblocking_flag function instead of fcntl.
The previous code:

  fcntl (fd, F_SETFL, O_NONBLOCK)

was technically incorrect, because it would have reset any
other flags on the file descriptor.

Thanks: Eric Blake
2017-03-06 10:52:35 +00:00
Pino Toscano
c6543875ae java: do not try to malloc 0 elements in get_all_event_callbacks
In case there are no event handlers registered with the handle,
get_all_event_callbacks will count 0 elements, trying to malloc a buffer
of that size.  POSIX says that this can result in either a null pointer,
or an unusable pointer.

Short-circuit get_all_event_callbacks to allocate nothing when there are
no events, making sure to use its results only when there were events.
2017-03-06 09:02:03 +01:00
Pino Toscano
4fc85f27c4 ruby: do not try to malloc 0 elements in get_all_event_callbacks
In case there are no event handlers registered with the handle,
get_all_event_callbacks will count 0 elements, trying to malloc a buffer
of that size.  POSIX says that this can result in either a null pointer,
or an unusable pointer.

Short-circuit get_all_event_callbacks to allocate nothing when there are
no events, making sure to use its results only when there were events.
2017-03-06 09:02:02 +01:00
Pino Toscano
b890fd2900 python: do not try to malloc 0 elements in get_all_event_callbacks
In case there are no event handlers registered with the handle,
get_all_event_callbacks will count 0 elements, trying to malloc a buffer
of that size.  POSIX says that this can result in either a null pointer,
or an unusable pointer.

Short-circuit get_all_event_callbacks to allocate nothing when there are
no events, making sure to use its results only when there were events.
2017-03-06 09:02:02 +01:00
Pino Toscano
64e1101631 ocaml: do not try to malloc 0 elements in get_all_event_callbacks
In case there are no event handlers registered with the handle,
get_all_event_callbacks will count 0 elements, trying to malloc a buffer
of that size.  POSIX says that this can result in either a null pointer,
or an unusable pointer.

Short-circuit get_all_event_callbacks to allocate nothing when there are
no events, making sure to use its results only when there were events.
2017-03-06 09:02:02 +01:00
Richard W.M. Jones
7527312784 generator: ocaml: Don't link to undocumented methods.
As for the previous commit, don't link to a method if it's not
exported by the OCaml bindings.
2017-03-03 16:56:52 +00:00
Richard W.M. Jones
41040182ae generator: java: Don't link to undocumented methods.
We aren't generating Java bindings for internal and other undocumented
methods, and therefore providing {@link #...}  for deprecated methods
replaced by internal methods doesn't work.  The easiest way is just to
check for this and turn such links into plain text.
2017-03-03 16:56:52 +00:00
Richard W.M. Jones
994a8f6a71 generator: Add a function to find an action by name.
Fairly simple refactoring.
2017-03-03 16:56:52 +00:00
Richard W.M. Jones
67ce5342c2 generator: Allow actions to be deprecated with no replacement.
There is precisely one such function at the moment
(guestfs_wait_ready).
2017-03-03 16:56:52 +00:00
Pino Toscano
df6cd83872 tail: pass the right path for Windows guests
Call windows_path with the actual path to resolve, instead of a null
pointer ('filename' is still null at that point), so Windows paths can
be properly resolved.
2017-03-03 16:36:27 +01:00
Pino Toscano
be82ba38df fish: fully init the msghdr buffers
This way no fields (msg_flags in particular) remain uninitialized.
2017-03-03 16:36:27 +01:00
Pino Toscano
bd55fa553f java: fix possible memory leak on error
Use CLEANUP_FREE to properly dispose the temporary array used for
StringList, DeviceList, FilenameList, and OStringList parameters: this
way, an early return (jumping to the ret_error label) will not forget
cleaning them up.
2017-03-03 16:36:27 +01:00
Pino Toscano
099ce1d490 edit: fix small memory leak on error
If guestfs_int_random_string fails, make sure to free the buffer
allocated as return string.
2017-03-03 16:36:26 +01:00
Pino Toscano
9aef2c7e3a daemon: tsk: properly use GUESTFS_MAX_CHUNK_SIZE
Pass to fread the size of the buffer allocated, so it can be filled
completely. This is even faster than reading only 4/8 bytes each
iteration.
2017-03-03 16:36:26 +01:00
Pino Toscano
c9df2d44cd java: fix invalid memory access for FBuffer in struct lists
When convering FBuffer fields of structs in each element of the return
list, make sure to allocate enough buffer to hold also the trailing null
character.
2017-03-03 16:36:26 +01:00
Pino Toscano
eeacc86a10 java: link libguestfs_jni against libutils
The JNI library uses CLEANUP_FREE macros, whose functions are built in
the internal libutils.  Currently, trying to use functions that use
CLEANUP_FREE variables will cause the java execution to stop with a
symbol lookup error (for guestfs_int_cleanup_free).
2017-03-03 16:36:26 +01:00
Richard W.M. Jones
843d61c2d4 erlang: Rename 'message' to something less generic.
It's not possible to define an action which takes a parameter called
'message' because the Erlang bindings use that as the name of an
internal variable.  Solve this by renaming the Erlang internal
variable.

Fixes commit 84763d7fca.
2017-03-03 15:03:49 +00:00
Richard W.M. Jones
da6ea89371 generator: Move some deprecated functions to actions_core_deprecated.ml.
Fixes commit 97773d2bbe.
2017-03-03 15:03:48 +00:00
Richard W.M. Jones
7a26804569 Use AC_HEADER_MAJOR to find definitions of major, minor, makedev.
Note this requires either the following fix in autoconf:

http://git.savannah.gnu.org/cgit/autoconf.git/commit/?id=e17a30e98

OR gnulib sys_types module plus gnulib
commit a512e041120e9012e69afa2f5c3adc196ec4999a (any gnulib more
recent than Sep 2016) which corrects the AC_HEADER_MAJOR macro in a
similar way.
2017-03-03 11:32:37 +00:00
Dawid Zamirski
4fd6c3ad6e parted: add more udev_settle calls.
add udev_settle calls to print_partition_table and
sgdisk_info_extract_field because the inspect-os calls
guestfs_part_get_parttype and guestfs_part_get_gpt_guid for all
parition devices found and this causes intermittent with opening block
devices that are certainly present yet RESOLVE_DEVICE macro would fail
wiht ENOENT.
2017-03-03 10:24:48 +00:00
Richard W.M. Jones
9fbdea695b ruby: Simplify and fix regression test.
This test failed on ppc64le with:

  Failure:
    </wrong argument type Fixnum \(expected Array\)/> was expected to be =~
    <"wrong argument type Integer (expected Array)">.

In addition the test generated a warning:

  tc_800_rhbz507346.rb:29: warning: ambiguous first argument; put parentheses or a space even after `/' operator

This commit fixes both of these and also makes it simpler and faster
by not bothering to launch the appliance.

Fixes commit 227b1eea90.
2017-03-01 15:07:00 +00:00
Richard W.M. Jones
0f99537cb6 sysprep: Remove DHCP_HOSTNAME= from ifcfg-* files (RHBZ#1427529). 2017-02-28 20:56:38 +00:00
Richard W.M. Jones
c4106d34cb python: Fix python sdist.
Fixes commit d45986d21b.
2017-02-28 20:56:38 +00:00
Richard W.M. Jones
cc79d0c0c6 Version 1.37.0. 2017-02-28 09:53:42 +00:00
Richard W.M. Jones
6213bd0448 Version 1.36.0. 2017-02-28 09:18:05 +00:00
Richard W.M. Jones
97fb893878 docs: Finalize release notes for libguestfs 1.36 release. 2017-02-27 23:10:25 +00:00
Richard W.M. Jones
d2b56f08f0 lib: Require libmagic.
If libmagic isn't installed then the guestfs_file_architecture API
doesn't work.  This means that inspection will always return
<arch>unknown</arch> for every guest.  This subtly breaks a few
features.  In particular it was reported that the
virt-builder/virt-customize --install option did not work because the
"unknown" architecture of the guest was not compatible with the host.

libmagic is a small, widely available C library, so the easiest fix is
just to make it mandatory.

Reported by: Solarix on IRC
2017-02-27 12:16:07 +00:00
Richard W.M. Jones
f6ece2c01a v2v: -o qemu: Refactor generation of the qemu shell script.
This change refactors how the qemu shell script is generated, making
it a bit less likely that we'll get the quoting wrong.  Parameters are
now added to a list, unquoted, and all quoting is done when printing
out the list.

Checked by running virt-v2v -o qemu before and after the change and
manually comparing the output (which is not identical, but still
correct).
2017-02-26 13:31:12 +00:00
Richard W.M. Jones
5982b9f7de v2v: -o rhv: Remove unused exported function.
In fact mount_and_check_storage_domain is not used by -o vdsm, and
hasn't been used since commit 889e555168.
2017-02-25 20:32:30 +00:00
Richard W.M. Jones
073a5cd976 v2v: Various whitespace or other very minor cleanups. 2017-02-25 20:20:05 +00:00
Richard W.M. Jones
eb4357b767 v2v: Move libvirt XML output code into a new module.
Just code motion.

Analogous to commit 512e5fd858.
2017-02-25 20:20:05 +00:00
Richard W.M. Jones
012577e0a4 v2v: Fix comment so it refers to new parse_libvirt_xml.ml file.
Fixes commit 512e5fd858.
2017-02-25 19:59:54 +00:00
Richard W.M. Jones
50f544d971 tests: regressions: Move another test to use $TEST_FUNCTIONS.
Omitted from commit a1b3d8d04b.
2017-02-25 17:12:29 +00:00
Richard W.M. Jones
512e5fd858 v2v: Move libvirt XML parsing code into a new module.
Just code motion.
2017-02-25 12:57:49 +00:00
Richard W.M. Jones
2a29cf90fa v2v: -i libvirtxml: Modify get_drive_slot calls.
Just a small refactoring to make the function safer to use.
2017-02-25 12:39:14 +00:00
Richard W.M. Jones
124e7bfd15 v2v: -i libvirt: Move comments.
Just whitespace changes.
2017-02-25 12:29:35 +00:00
Richard W.M. Jones
d4d526c109 v2v: Fix incorrect skips in tests.
Fixes commit a1b3d8d04b.
2017-02-24 20:59:17 +00:00
Richard W.M. Jones
b105f81783 mllib: Move VIRT_TOOLS_DATA_DIR calculation to common code.
Share the computation of $VIRT_TOOLS_DATA_DIR in a single place.
Use of 'lazy' ensures it is computed at most once.
2017-02-24 20:43:41 +00:00
Richard W.M. Jones
6070f70e54 docs: release notes: add-domain now supports libvirt secrets.
Thanks: Pino Toscano
2017-02-24 17:37:55 +00:00
Richard W.M. Jones
a117382828 docs: Update release notes for libguestfs 1.36 release. 2017-02-24 16:58:57 +00:00
Richard W.M. Jones
e53ee5befa docs: Test release on aarch64, ppc64 and ppc64le.
Before a stable release, we will now test on aarch64, ppc64
and ppc64le.
2017-02-24 16:09:53 +00:00
Pino Toscano
f27d19485c v2v: document Convert_linux as more generic
Make the documentation in Convert_linux more generic than just
Enterprise distros using RPM.  Also, rename the name of the module from
"enterprise-linux" to simply "linux".
2017-02-24 16:59:06 +01:00
Pino Toscano
b927172f85 v2v: document Debian/Ubuntu support 2017-02-24 15:52:28 +01:00
Richard W.M. Jones
814786334e Version 1.35.28. 2017-02-24 13:08:50 +00:00
Richard W.M. Jones
ba1e9f8bfc docs: Begin updating release notes for libguestfs 1.36. 2017-02-24 13:08:37 +00:00
Pino Toscano
8066b34b60 inspect: read more fields for RPM packages
In particular, read the URL, and both the summary and the description.
2017-02-24 14:01:31 +01:00
Pino Toscano
ca997dce6c inspect: read more fields for Debian packages
In particular, read the URL, the source name, and both the summary and
the description.  For the long description, add a small system to read
continuation lines.

Adapt the expected result of virt-inspector for Debian and Ubuntu phony
guests, so test-virt-inspector.sh still passes.
2017-02-24 14:01:31 +01:00
Pino Toscano
a920c94870 inspect: add source and summary to internal add_application
This way source and summary can be specified for any package read from
the guest.
2017-02-24 14:01:31 +01:00
Richard W.M. Jones
8e6f6305c2 po-docs: Fix mistranslated message in Ukrainian file.
A message was translated without the trailing \n.  As it was in a
verbatim section of POD, I actually reverted the whole translation.

The error was:

  ./uk.po:53533: 'msgid' and 'msgstr' entries do not both end with '\n'
  msgfmt: found 1 fatal error

In fact po4a (or whatever calls msgfmt) seems to ignore the error and
continues which is another problem.

Fixes commit 794b6a1acf.
2017-02-24 12:54:06 +00:00
Richard W.M. Jones
1e2555c1b8 po-docs: Add cs to lingas_not_translated.
Commit 794b6a1acf added cs.po, but
because this wasn't also added to lingas_not_translated the file was
not included in EXTRA_DIST or processed properly.

Fixes commit 794b6a1acf.
2017-02-24 12:53:42 +00:00
Richard W.M. Jones
7d0ed596c2 po-docs: ja: Fix internal link L</...> which was translated.
Compiling po-docs/ja/guestfish.pod failed with:

  Pod input around line 277: L<> starts or ends with whitespace
  Pod input around line 362: L<> starts or ends with whitespace

I reverted the part of the L</...> link which had been translated.

The fix isn't quite correct -- headings *can* be translated, and the
corresponding internal links should be translated too.  However
pod2man has problems dealing with such links and in any case the
partial translation was not correct, so revert to the English version
of the link.

Updates commit 794b6a1acf.
2017-02-24 12:36:45 +00:00
Richard W.M. Jones
57d17ca301 mllib: visit: Initialize CAMLlocal-allocated value.
Somewhere between OCaml 4.01 and OCaml 4.04, <caml/memory.h> changed
the way that CAMLlocalX() values on the stack are initialized.  In
OCaml 4.01:

  #define CAMLlocal1(x) \
    value x = 0; \
    CAMLxparam1 (x)

but in OCaml 4.04:

  #define CAMLlocal1(x) \
    value x = Val_unit; \
    CAMLxparam1 (x)

The code in mllib/visit-c.c assumed that the value would be
initialized to Val_unit, and used a check (exn != Val_unit) to see if
the value had been updated.  This failed badly (with a segfault) on
OCaml 4.01 in Debian 8.

Resolve this by always initializing CAMLlocalX() values before use.
2017-02-24 04:59:57 -05:00
Richard W.M. Jones
8b950deb26 v2v: Add a utility function for testing if the backend is libvirt.
This also fixes one of the places where we checked this so it now
recognizes both "libvirt" and "libvirt:...".
2017-02-24 09:05:30 +00:00
Richard W.M. Jones
ad9e9c98b5 v2v: Rename Domainxml -> Libvirt_utils.
The name 'Domainxml' made no sense.
2017-02-24 09:05:30 +00:00
Richard W.M. Jones
94f44b9983 v2v: ova: Move libvirt version test to input_ova.ml.
Updates commit 90521da5d4.
2017-02-24 09:05:30 +00:00
Richard W.M. Jones
df2006b275 v2v: -i libvirt: Fix test for "json:" backing file support.
Thanks: Tomáš Golembiovský for pointing out the error and
showing how to fix it.
2017-02-23 15:42:15 +00:00
Tomáš Golembiovský
560a3682c6 v2v: tests: restore disabled OVA test
We are redy to restore the disabled test. The relevant libvirt fixes
should be available in 3.1.0.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2017-02-23 15:42:15 +00:00
Tomáš Golembiovský
90521da5d4 v2v: ova: check libvirt version before OVA import
Libvirt < 3.1.0 lacks enough support for json: pseudo-URLs. Notably it
does not allow use of "raw" driver that we need.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2017-02-23 15:42:15 +00:00
Tomáš Golembiovský
2dbf6bd7b7 v2v: ova: fix generated JSON for libvirt support
We have to be explicit about the drivers in backing file JSON in order
for libvirt to work.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2017-02-23 15:07:54 +00:00
Richard W.M. Jones
794b6a1acf Update translations from Zanata. 2017-02-23 15:07:46 +00:00
Richard W.M. Jones
45e046dac9 tests: Disable some tests so they don't break when ./configure --without-libvirt 2017-02-23 13:59:38 +00:00
Richard W.M. Jones
a7bd499244 tests: regressions: Ignore SIGPIPE in test.
The test tests/regressions/rhbz914931.c works by causing the daemon to
segfault while writing to it.

For reasons unknown, when configured --without-libvirt, this causes
the test to fail receiving SIGPIPE (exit code 141).  We can prevent
this by installing a signal handler to ignore SIGPIPE, so the signal
is converted to EPIPE which the code handles properly.
2017-02-23 13:59:22 +00:00
Richard W.M. Jones
c72be578c1 debian: Old qemu-img does not support -f raw -o preallocation=off
The old version of qemu-img available in Debian 8 doesn't support the
preallocation option for raw format.  However this doesn't matter
because the default is preallocation=off (ie. sparse) for old and new
versions of qemu-img so we can just omit this parameter.

Fixes commit 53317e3f07
and commit fa83b47876
and commit 74ded0dbc1.
2017-02-23 13:52:25 +00:00
Richard W.M. Jones
bf7aab615b v2v: Fix incorrect test skip.
The test should be skipped *if* uml, not unless uml.

Fixes commit a1b3d8d04b.
2017-02-23 12:52:13 +00:00
Richard W.M. Jones
e53418558a v2v: windows: Only warn on RHEV-APT if requested, install VMDP unconditionally.
Slightly change the logic for installing RHEV-APT and VMDP:

- Only warn on failure to install RHEV-APT if the output hypervisor
  requested it.  Otherwise the warning is pointless because RHEV-APT
  can't be used anyway.

- Make the warning clearer and actionable.

- Try to install VMDP unconditionally (rather than only if RHEV-APT
  failed).  It is always useful for SuSE hosts.  However don't warn if
  it's not available.
2017-02-23 09:25:49 +00:00
Richard W.M. Jones
83488cb6f3 v2v: windows: Simplify installing pnp_wait.exe.
Updates commit 09eb831e8d.
2017-02-23 09:18:28 +00:00
Richard W.M. Jones
cf85da5b7e v2v: Add fake test-data/fake-virt-tools/pnp_wait.exe for testing.
Analogous to commit f5c9357c8e.
2017-02-23 09:10:15 +00:00
Richard W.M. Jones
7a4234088b Version 1.35.27. 2017-02-22 22:15:53 +00:00
Richard W.M. Jones
990241f023 v2v: windows: Only try to install rhev-apt if the target is RHV (RHBZ#1161019).
Thanks: Tingting Zheng
2017-02-22 22:15:21 +00:00
Richard W.M. Jones
f5c9357c8e v2v: Add fake test-data/fake-virt-tools/vmdp.exe for testing. 2017-02-22 21:16:07 +00:00
Richard W.M. Jones
c280df7a4d v2v: windows: Simplify installing rhev-apt.exe or vmdp.exe.
This just simplifies the code and should make no functional
difference.

Updates commit c466d4cb92.
2017-02-22 21:16:07 +00:00
Richard W.M. Jones
4b465468b1 v2v: Pass output object into the conversion module.
Previously the Convert_linux conversion module depended on one feature
of the output module (#keep_serial_console).  This was extracted in an
ad-hoc way from the output module and passed as an extra parameter to
the conversion module.

Instead of doing it this way, just pass the output module into the
conversion module, so it can call output#keep_serial_console itself.

This is just a simplification of the existing code, but otherwise adds
no new features.
2017-02-22 21:16:01 +00:00
Pino Toscano
00bac2e5da inspect: ignore /dev/cdN devices in /etc/fstab
Non-Linux Unix guests may have static devices for CDs, so make sure to
skip them when reading /etc/fstab.  This is the same as done for
/dev/fdN devices, i.e. floppy devices.
2017-02-22 18:57:33 +01:00
Richard W.M. Jones
24d2150047 v2v: vCenter: Remove proxy environment variables (RHBZ#1354507).
Currently imports from vCenter sometimes obey proxy environment
variables (eg. $http_proxy) and sometimes don't.  The initial libvirt
connection to fetch metadata never uses the proxy, but because the
subsequent conversion and copying uses libcurl, it will pick up on
proxy environment variables.

This makes no sense, and in any case vCenter is really slow as it is
without putting another device into the data path.  Therefore ensure
that libcurl does not see any proxy environment variables by unsetting
them.
2017-02-22 15:28:40 +00:00
Richard W.M. Jones
592c960c15 mllib: Add unsetenv(3) binding to Unix_utils.
Missing from the OCaml stdlib.  This implementation is the same as the
one in Jane St's Core, except we don't bother to throw an exception on
error.
2017-02-22 15:28:40 +00:00
Richard W.M. Jones
4b6a482bc8 mllib: Combine small Unix library call bindings into Unix_utils module.
Concatenate six small modules containing Unix/POSIX library call
bindings into a single module called Unix_utils.

The previous modules and the library functions bound were:

 - Dev_t:   makedev(3), major(3), minor(3)
 - Exit:    _exit(2)
 - Fnmatch: fnmatch(3)
 - Fsync:   sync(2)
 - Mkdtemp: mkdtemp(3)
 - StatVFS: statvfs(2)
2017-02-22 14:55:12 +00:00
Richard W.M. Jones
6130411a59 Version 1.35.26. 2017-02-21 20:07:43 +00:00
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. 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. 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
Richard W.M. Jones
e9deb6fab4 Version 1.35.23. 2017-02-10 22:54:04 +00:00
Richard W.M. Jones
fa83b47876 test-data: Use ./run script to run 'guestfish disk-create'.
Commit 74ded0dbc1 changes existing calls
to truncate to run 'guestfisk disk-create' instead.  However this
fails if guestfish has not been installed.  By using the ./run script,
we can use the just-built guestfish instead.

Fixes commit 74ded0dbc1.
2017-02-10 22:41:55 +00:00
Richard W.M. Jones
74660366f6 Version 1.35.22. 2017-02-10 13:38:34 +00:00
Richard W.M. Jones
c99cf0caad v2v: Add result of qemu-img offset/size test to debug output.
Updates commit 3fc9520069.
2017-02-10 13:38:34 +00:00
Richard W.M. Jones
430604ef37 v2v: Fix quoting in external qemu-img command.
Fixes commit 3fc9520069.
2017-02-10 13:38:34 +00:00
Richard W.M. Jones
3a8e2babed contrib: Sort patches into alphabetical order and add to EXTRA_DIST.
We also have to use AM_INIT_AUTOMAKE(tar-pax), since otherwise
automake uses some ancient tar format that doesn't support a filename
this long.  (See: https://noiselabs.io/2010/02/27/tar-file-name-is-too-long-max-99/
for a clear explanation)

Fixes commit b702ec19e8.
2017-02-10 13:08:03 +00:00
Richard W.M. Jones
0a8f95a222 v2v: ova: Further fix test cases.
Updates commit 7461a8fab1.
Fixes and partly reverts commit 8f91d3a9b0.
2017-02-10 12:56:08 +00:00
Richard W.M. Jones
2c340682b5 daemon: selinux: Document cases where setfiles takes a long time to run.
Just adding a comment pointed back to the bug.
2017-02-10 10:14:15 +00:00
Richard W.M. Jones
b702ec19e8 contrib: p2v: Add scripts to build and test virt-p2v ISOs with RHEL 5, 6.
This adds a contrib script which can be used to build the virt-p2v ISO
on top of RHEL 5 or RHEL 6, i686 (32 bit) or x86-64 (64 bit) base.

There is also a script for testing the ISOs produced this way.
2017-02-09 17:52:45 +00:00
Richard W.M. Jones
4ab07a9949 builder: templates: Call sync after running virt-install.
I don't think this will really make any difference.  However there is
some puzzling disk corruption in the recently built RHEL 5 & 6 i686
images, and I want to make absolutely sure they are not caused by an
unsynchronized disk image.
2017-02-09 17:52:45 +00:00
Richard W.M. Jones
eeb3f42d1f builder: templates: Add 32 bit (i386) templates for RHEL 5 and 6. 2017-02-09 13:54:46 +00:00
Richard W.M. Jones
d74ed7b122 p2v: Fix RHEL URLs in kickstart.
Also make the repo directives use the --proxy flag if specified and
supported.
2017-02-09 13:54:46 +00:00
Richard W.M. Jones
3e7e6d95c1 p2v: Fix virt-p2v-make-kickstart when run from local directory.
It was looking for the binary in p2v/virt-p2v/virt-p2v.xz.  This fix
makes it look for the correct path p2v/virt-p2v.xz.
2017-02-08 17:44:47 +00:00
Richard W.M. Jones
3fc9520069 v2v: ova: Don't rely on qemu-img version, test "offset" and "size" features.
See:

https://www.redhat.com/archives/libguestfs/2017-February/msg00064.html
2017-02-08 12:47:17 +00:00
Richard W.M. Jones
a1bc37d673 p2v: Document sources of ssh/session timeout problems. 2017-02-08 12:47:17 +00:00
Richard W.M. Jones
2f97cd5517 p2v: Send ping packets every 5 minutes to sshd.
Also drop the connection if no response at all has been received after
30 minutes.

This action should prevent firewall timeouts from causing virt-p2v to
fail (see this thread:
https://www.redhat.com/archives/libguestfs/2017-February/msg00010.html).

Thanks: Tomáš Golembiovský
2017-02-08 12:47:17 +00:00
Richard W.M. Jones
27b64f8227 p2v: Use the ADD_ARG macro to simplify ssh/scp parameters.
No functional change.
2017-02-08 12:47:17 +00:00
Richard W.M. Jones
0de08f6527 daemon: Allow ADD_ARG macro to be used everywhere.
This is a simple macro with no dependencies.  Allow it to be used from
any program.
2017-02-08 12:47:17 +00:00
Richard W.M. Jones
4983084b8c resize: tests: Remove comment.
Doesn't look like we'll handle extended partitions any time
soon, so remove comment.
2017-02-08 12:04:23 +00:00
Richard W.M. Jones
23878acbbd builder: tests: Disable valgrind for test with multi-line parameters.
Breaks libtool, see:
https://bugzilla.redhat.com/show_bug.cgi?id=1420301

This updates commit 736a8465a6.
2017-02-08 11:58:34 +00:00
Richard W.M. Jones
736a8465a6 valgrind: Add libtool to the @VG@ macro.
There were still a few places where we were testing bash rather than
the intended program.  Add `libtool --mode=execute' to the beginning
of the @VG@ macro to try to get around this.
2017-02-08 10:30:58 +00:00
Richard W.M. Jones
6ec23eeac0 Version 1.35.21. 2017-02-07 22:01:07 +00:00
Richard W.M. Jones
0276b3e246 v2v: ova: Add various test data files to EXTRA_DIST.
Fixes commit 8f91d3a9b0.
2017-02-07 21:54:33 +00:00
Richard W.M. Jones
f73ac1fc9c v2v: Skip one test because virt-v2v -i ova can break with libvirt backend.
See:
https://www.redhat.com/archives/libguestfs/2017-February/msg00101.html
2017-02-07 21:13:57 +00:00
Richard W.M. Jones
74ded0dbc1 RHEL 5: tests: Don't use 'truncate' command.
The coreutils 'truncate' command does not exist in RHEL 5.  Replace
use of this command in tests with the guestfish 'disk-create' command.
2017-02-07 18:51:53 +00:00
Richard W.M. Jones
7461a8fab1 v2v: ova: Normalize the output in test case.
Fixes commit 8f91d3a9b0.
2017-02-07 18:51:52 +00:00
Richard W.M. Jones
fa6016af19 p2v: Use socket activation with qemu-nbd and nbdkit.
If supported, use socket activation to pass a pre-opened listening
socket to the NBD server.  This means we can guarantee to choose an
unused port even if there are multiple instances of virt-p2v running
(ie. when testing) or if there are unexpected services running on the
same machine.

This change applies to both NBD servers, since both now (or will
shortly) support this feature.
2017-02-07 15:57:04 +00:00
Richard W.M. Jones
2e0c33a7b9 p2v: Don't hard code "localhost" (NBD listening address) everywhere.
No functional change.
2017-02-07 15:57:04 +00:00
Richard W.M. Jones
4dd4a9b1a6 p2v: Move nbd_local_port to nbd.c.
In preparation for using socket activation, move the nbd_local_port
global inside nbd.c and make it private.

This is largely code motion.  However I rearranged the order in which
the ssh data connection and the NBD server are started up.  Previously
the ssh connection was made first, and the NBD server was then
started.  Now the NBD server starts first.  This happens so that nbd.c
can choose the local port, and when we implement socket activation it
will allow nbd.c to open the socket and choose a free port too.
2017-02-07 15:57:04 +00:00
Richard W.M. Jones
cdd8dc4145 p2v: Clean up ugly implementation of --nbd option.
The previous implementation was pretty ugly.  This reimplements things
a bit more cleanly.
2017-02-07 15:57:04 +00:00
Richard W.M. Jones
d9ab95ec16 p2v: Move NBD-related functions into a separate file.
This is almost pure code motion, but I changed the name and prototype
of the function 'wait_nbd' to make its purpose clearer, and to remove
the unnecessary timeout setting (which is hard-coded).
2017-02-07 15:57:04 +00:00
Pino Toscano
8a2b0738d1 resize: support non-local output disks (RHBZ#1404182)
Parse the output disk as URI, and use all its attributes just like
it is done for the input disk.  The only change is that the fsync of the
output disk is limited now for local URIs only, since it will not work
with remote protocols.
2017-02-06 16:36:29 +01:00
Richard W.M. Jones
10a5567dc7 lib: g->program is now never the empty string.
The getprogname module either sets g->program to a string derived from
argv[0] or fails at compile time.

Fixes commit eea210dbf7.
2017-02-06 12:22:49 +00:00
Pino Toscano
c1bd2c3e74 dib: add tgz output format
Implement the "tgz" output format, i.e. "tar" compressed as gzip.

This was implemented in diskimage-builder upstream as
commit da41ee6012b064aa6901c871a1104a3a3933117e.
2017-02-06 10:09:59 +01:00
Pino Toscano
91646e0bb6 dib: clarify "output:" lines in --machine-readable documentation 2017-02-06 10:09:59 +01:00
Pino Toscano
35f29deacc dib: refactor output formats handling
Implement a system similar to the operations in virt-sysprep, so each
output format has its own file and attributes (such as command line
arguments).

The result is that there is no more need to spread everywhere the job
required by each output format, such as checking for tools, or hooking
at the right point.
2017-02-06 10:09:58 +01:00
Pino Toscano
00ecda5d9c dib: pass custom mkfs options after the filesystem type
Make sure they are handled as options for the actual mkfs driver,
instead of mkfs itself.  Also, improve the documentation of
--mkfs-options accordingly.

This was fixed in diskimage-builder upstream as
commit 5e2330d89c6c0e55b270464abea7e99a4d3246ad.
2017-02-06 10:09:58 +01:00
Pino Toscano
380fd71dc8 dib: add --checksum
Add a new option to create files with the MD5 and SHA512 checksums of
all the disk image types produced.

This was implemented in diskimage-builder upstream as
commit 2ea5feca5c4b64867ac327736edfb20408f8840e and
commit 22952b7ea0543bb4f446752976d1d8ba232b021a.
2017-02-06 10:09:58 +01:00
Pino Toscano
bc06d59855 dib: clear up "already provided" message
Improve the error message that is shown when trying to selecting an
element, and another element provides it.

This was implemented in diskimage-builder upstream as
commit 452f7b8d5aaa6e85e3b01b970cd9cbc842b34b86.
2017-02-06 10:09:58 +01:00
Pino Toscano
ab0cf0012f fuse: use the configured program name
When initializing FUSE, use the program name as set (either
automatically or manually) in the guestfs handle.
2017-02-06 10:09:58 +01:00
Richard W.M. Jones
5657d4726d v2v: Use failwithf instead of failwith (sprintf ...) 2017-02-04 15:50:26 +00:00
Richard W.M. Jones
a11040d9cd v2v: Use failwith/failwithf instead of raise (Failure ...)
Minor refactoring of ommit d3c93e3320.
2017-02-04 15:47:43 +00:00
Tomáš Golembiovský
8f91d3a9b0 v2v: ova: don't extract files from OVA if it's not needed
We don't have to always extract all files from the OVA archive. The OVA,
as defined in the standard, is plain tar. We can work directly over the
tar archive if we use correct 'offset' and 'size' options when defining
the backing file for QEMU. This puts much lower requirement on available
disk space.

Since the virt-v2v behaviour for OVA input now depends on QEMU version
available this affects some of the tests. Expected result of the
affected also has to depend on the QEMU used thus such tests will have
two *.expected files.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2017-02-04 15:13:29 +00:00
Tomáš Golembiovský
d3c93e3320 v2v: add function find_file_in_tar to utils
The function looks up file in tar archive and returns a tuple containing
which at byte it starts and how long the file is.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2017-02-04 15:13:29 +00:00
Tomáš Golembiovský
3839b0be5b v2v: add function qemu_img_version to utils
The function returns version of qemu-img as a tuple (major, minor), or
the value (0,9) in case there was an error detecting the version.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2017-02-04 15:13:29 +00:00
Tomáš Golembiovský
e9eb3a79da mllib: add subdirectory function to common_utils
Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2017-02-04 15:13:29 +00:00
Richard W.M. Jones
152657178d generator: Move failwithf to mllib.
A useful function.  This is just code motion.
2017-02-04 15:13:29 +00:00
Richard W.M. Jones
2b5173712b v2v: Further increase memory allocated to the appliance (RHBZ#1418283).
In commit 08f82f2e3d we increased the
memory size to 800MB (on x86) so that the semodule command would work.

However it has been discovered that another SELinux command takes
large amounts of RAM (setfiles during the SELinux relabel step).
Therefore increase the memory size again, this time to 2000MB.
2017-02-02 09:36:56 +00:00
Richard W.M. Jones
d5383ca066 docs: Document that virt-p2v can use qemu-nbd or nbdkit.
Fixes commit 4af9081e0d.
2017-02-01 12:24:21 +00:00
Richard W.M. Jones
889386f8c6 uefi: Remove references to kraxel's old edk2 builds.
As noted in the source code, these were due to be removed at
the end of 2016.
2017-01-31 19:26:07 +00:00
Tomáš Golembiovský
c465e794b2 v2v: ova: don't detect compressed disks, read the OVF instead
The information whether the disk is gzip compressed or not is stored
in the OVF. There is no reason to do the detection.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2017-01-31 12:01:12 +00:00
Richard W.M. Jones
2e5033349a configure: Fix release date of 1.35.20.
Fixes commit 7b6b9d9bea.
2017-01-31 11:01:26 +00:00
Richard W.M. Jones
d5752538bf common/miniexpect: Add README and miniexpect.pod from upstream. 2017-01-29 18:12:43 +00:00
Richard W.M. Jones
e79a2af219 generator: Make 'main.ml' clearer.
- Make module name explicit, so it's more obvious which module a
  function is defined in.

- Group lines of code by feature.

- Capitalize some module names properly.

Just code motion, no functional change.
2017-01-29 17:32:22 +00:00
Richard W.M. Jones
c9a51b2fd2 po: Really ignore perl/lib/Sys/Guestfs.c (RHBZ#1417444).
Incorrect grep expression meant this file was not being ignored
before.

Thanks: Marius Cirsta
2017-01-29 13:34:03 +00:00
Richard W.M. Jones
48d4117789 fish: Handle changed type of 'len' parameter in gperf 3.1 (RHBZ#1416941).
Commit 004de6cf45 was not sufficient to
solve this problem.  We are also using gperf in guestfish.  Rewrite
the code in the same way to avoid having to prototype the hash
function.
2017-01-28 13:23:40 +00:00
Richard W.M. Jones
7b6b9d9bea Version 1.35.20. 2017-01-27 13:02:36 +00:00
Richard W.M. Jones
4733cb6cea p2v: Add a test for virt-p2v with nbdkit. 2017-01-27 09:42:01 +00:00
Richard W.M. Jones
4af9081e0d p2v: Allow nbdkit as an alternative NBD server to qemu-nbd.
Add code in virt-p2v so that it can use nbdkit (with the file plugin)
as an alternative to qemu-nbd.

This is controlled through the virt-p2v --nbd command line option,
allowing you to select which server (out of qemu-nbd or nbdkit) you
prefer (with a fallback).  The default is: --nbd=qemu-nbd,nbdkit so
qemu-nbd will be used preferentially.
2017-01-27 09:42:01 +00:00
Richard W.M. Jones
57d1e55374 p2v: In non-ISO environment, don't use hard-coded port 50123.
When testing virt-p2v (eg. on the host machine) this prevents us from
testing two instances of virt-p2v at the same time because both will
try to use the same port.
2017-01-27 09:42:01 +00:00
Richard W.M. Jones
535e6f5ebb tests/mount-local, tests/parallel: Use srandom (time (NULL) + getpid ()).
If two instances of the test start at exactly the same time, they
would have the same random number seed.
2017-01-27 09:42:01 +00:00
Richard W.M. Jones
5d607f752b common/edit: Don't use random() function.
Generate the random filename using our utility function
guestfs_int_random_string.  This also means that we will not need to
call srandom() in guestfish or virt-edit.
2017-01-27 09:42:01 +00:00
Richard W.M. Jones
004de6cf45 errnostring: Handle changed type of 'len' parameter in gperf 3.1 (RHBZ#1416941).
The prototype of the hash function changed in gperf 3.1:

* The 'len' parameter of the hash function and of the lookup function is now
  of type 'size_t' instead of 'unsigned int'. This makes it safe to call these
  functions with strings of length > 4 GB, on 64-bit machines.

This commit moves the guestfs_int_string_to_errno function into the
third (functions) section of the gperf file so it is able to use the
lookup function without needing a prototype.

Thanks: Marius Cirsta
2017-01-27 09:36:50 +00:00
Richard W.M. Jones
00a2b689b3 Revert "errnostring: Handle changed type of 'len' parameter in gperf 3.1 (RHBZ#1416941)."
This reverts commit 3a2b89a09e.
2017-01-27 09:31:40 +00:00
Richard W.M. Jones
3a2b89a09e errnostring: Handle changed type of 'len' parameter in gperf 3.1 (RHBZ#1416941).
The prototype of the hash function changed in gperf 3.1:

* The 'len' parameter of the hash function and of the lookup function is now
  of type 'size_t' instead of 'unsigned int'. This makes it safe to call these
  functions with strings of length > 4 GB, on 64-bit machines.

This change tries to detect the required type in ./configure

Thanks: Marius Cirsta
2017-01-26 22:07:23 +00:00
Richard W.M. Jones
8ee97b8859 p2v: Move miniexpect library to common/miniexpect.
No change, just code motion.
2017-01-26 15:05:47 +00:00
Richard W.M. Jones
db48870cf3 df: Move framework for processing domains in parallel to common/parallel.
Just code motion.
2017-01-26 15:05:47 +00:00
Richard W.M. Jones
a8c5739fd2 fish: Move edit, progress, windows under common/
Three more pieces of common code are moved under the common/
subdirectory.  This is just code motion.

Note that windows.[ch] wasn't even being used by guestfish.  That code
was only used in other virt tools.
2017-01-26 15:05:47 +00:00
Richard W.M. Jones
a9199a46b1 fish: Move fishcommon library to common/options.
This is mostly code motion but:

(1) I had to remove the compile-time COMPILING_GUESTFISH and
COMPILING_VIRT_RESCUE macros and replace them with runtime constants
and checks.

(2) I moved the fish/config.c file into this library.
2017-01-26 15:05:47 +00:00
Richard W.M. Jones
779bc1de23 cat: Move visit library to new directory common/visit.
Just code motion.
2017-01-26 15:05:46 +00:00
Richard W.M. Jones
f161c9ea57 Rename src/ to lib/ 2017-01-26 15:05:46 +00:00
Richard W.M. Jones
b53cec584d lib: Move utilities to new directory common/utils.
Just code motion.

This commit makes it clearer what is a utility and what is part of the
library.  It also makes it clear that we should rename:

  guestfs-internal-frontend.h -> utils.h
  guestfs-internal-frontend-cleanups.h -> cleanups.h (?)

but this commit does not make that change.
2017-01-26 15:05:46 +00:00
Richard W.M. Jones
88c0ce2397 lib: Share common protocol and errnostring libraries with the library and daemon.
This commit, which is just code motion, moves the common XDR protocol
code (libprotocol) and the common errno handling (liberrnostring) into
libraries which are each built once and shared between the library and
daemon.
2017-01-26 15:05:46 +00:00
Richard W.M. Jones
e285566369 gobject: Avoid multiply defined CLEANFILES.
The error is:

gobject/docs/gtk-doc.make:52: warning: CLEANFILES multiply defined in condition TRUE ...
gobject/docs/Makefile.am:95:   'gobject/docs/gtk-doc.make' included from here
common-rules.mk:28: ... 'CLEANFILES' previously defined here
gobject/docs/Makefile.am:18:   'subdir-rules.mk' included from here
subdir-rules.mk:20:   'common-rules.mk' included from here
2017-01-26 15:05:46 +00:00
Richard W.M. Jones
84254bf739 p2v: Don't inhibit D-Bus support for modern systems.
Fixes commit c526afbe95.
2017-01-26 14:39:03 +00:00
Richard W.M. Jones
c90baa812a p2v: gtk: Update docs/C_SOURCE_FILES.
Updates commit 17cc502d9b.
2017-01-25 12:30:25 +00:00
Pino Toscano
571269bf72 p2v: log also environment on conversion server
Save the content of the environment on the conversion server, so it is
one additional help when debugging failed conversions.
2017-01-23 09:44:32 +01:00
Richard W.M. Jones
718ce7964c RHEL 5: p2v: Ignore garbage when decoding base64 sections in kickstart.
RHEL 5 base64 utility requires this flag to ignore newlines in input.
2017-01-21 13:54:02 +00:00
Richard W.M. Jones
ae160215ca RHEL 5: p2v: Workarounds for limited partial match support in ancient PCRE.
In the ancient version of PCRE in RHEL 5, partial match support does
not support /.*/, returning PCRE_ERROR_BADPARTIAL.  However the
equivalent regular expression /(?:.)*/ works fine, so use that
instead.
2017-01-21 10:24:40 +00:00
Richard W.M. Jones
17cc502d9b p2v: gtk: Move Gtk compat macros into separate files.
Just code motion.
2017-01-21 09:56:21 +00:00
Richard W.M. Jones
9ceb0cca05 p2v: Include file and line number in internal errors. 2017-01-21 09:46:04 +00:00
Richard W.M. Jones
a77ef0e7c8 RHEL 5: p2v: Compile GUI for ancient Gtk 2.10.
RHEL 5 has ancient Gtk 2.10 which lacks several functions and whole
features we need (eg the spinner).  Add various macros and function
definitions to work around this.
2017-01-21 09:46:04 +00:00
Richard W.M. Jones
c526afbe95 RHEL 5: p2v: Don't compile inhibit support if dbus doesn't support FD passing.
Since RHEL 5 doesn't have systemd, inhibit isn't supported anyway, so
compiling it out is no problem.
2017-01-21 09:46:04 +00:00
Richard W.M. Jones
035d839601 RHEL 5: p2v: Skip partial match checking when PCRE_INFO_OKPARTIAL is not defined.
This test is only a sanity check, so skip it when pcre doesn't define
this symbol.
2017-01-21 09:46:04 +00:00
Richard W.M. Jones
4f102b6832 p2v: Document lscpu, lspci, lsscsi, lsusb files.
Updates commit 5f0bcc3057.
2017-01-20 13:48:56 +00:00
Richard W.M. Jones
5f0bcc3057 p2v: Add more debugging information: lscpu, lspci, lsscsi, lsusb.
Dump extra information from the source physical machine to help with
debugging.
2017-01-20 09:51:31 +00:00
Richard W.M. Jones
1aefcbcc9b daemon: Add comment explaining why we remove 'p' character.
No code change, just a comment.

Updates commit 6fd2ddb350.
2017-01-19 12:06:25 +00:00
Pino Toscano
5b02e7e6df daemon: Return MD partitions in guestfs_list_partitions (RHBZ#1414510). 2017-01-19 12:03:55 +00:00
Pino Toscano
6fd2ddb350 daemon: Fix part-to-dev when the partition name includes p<N>.
If the device name ends with a number, Linux uses partition names of
the form <device>p<N>.  Handle this case by knocking off the 'p'
character.
2017-01-19 11:00:21 +00:00
Richard W.M. Jones
5c350db94d tests: Add unit tests for guestfs_canonical_device_name. 2017-01-19 09:16:52 +00:00
Richard W.M. Jones
4fa7df3ed7 canonical_device_name: Don't rewrite /dev/mdX as /dev/sdX (RHBZ#1414682).
The guestfs_canonical_device_name API was rewriting /dev/mdX as
/dev/sdX.  This is wrong since (eg) /dev/sd0 is not a device name, so
if you pass the canonicalized name back to the API it will fail.
virt-v2v was one tool doing this.
2017-01-19 09:15:16 +00:00
Richard W.M. Jones
4a9af91e36 aarch64: launch: direct: Use virtio-pci devices.
qemu-system-aarch64 -M virt now supports virtio-pci devices.  These
are considerably faster than virtio-mmio so use them by default.
2017-01-18 14:26:46 +00:00
Richard W.M. Jones
faff6f23ff lib: uefi: Don't call access(NULL) if no UEFI debug file exists.
Bug found by valgrind on aarch64:

==21350== Syscall param faccessat(pathname) points to unaddressable byte(s)
==21350==    at 0x4F05274: access (access.c:29)
==21350==    by 0x4954DC3: guestfs_int_get_uefi (appliance-uefi.c:90)
==21350==    by 0x49752D7: launch_libvirt (launch-libvirt.c:413)
==21350==    by 0x496FD83: guestfs_impl_launch (launch.c:98)
==21350==    by 0x4902003: guestfs_launch (actions-3.c:145)
[...]
==21350==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
2017-01-18 14:26:46 +00:00
Richard W.M. Jones
d45986d21b lib: Use a common function to validate strings. 2017-01-18 13:35:25 +00:00
Richard W.M. Jones
e035d848f7 mllib: Avoid OCaml local roots corruption.
Because we used 'return' directly, the effect of the CAMLparam0()
macro was not undone, resulting in local roots corruption when the
visit callback throws an exception.

The visit_tests unit test picked this up, but the corruption was only
seen on aarch64.

Fixes commit 4a62e52111.
2017-01-18 10:25:02 +00:00
Richard W.M. Jones
3a160fe16b lib: Add missing <unistd.h> to appliance-uefi.c.
appliance-uefi.c: In function 'guestfs_int_get_uefi':
appliance-uefi.c:67:9: error: implicit declaration of function 'access' [-Werror=implicit-function-declaration]
     if (access (codefile, R_OK) == 0 && access (varsfile, R_OK) == 0) {
         ^~~~~~
appliance-uefi.c:67:5: error: nested extern declaration of 'access' [-Werror=nested-externs]
     if (access (codefile, R_OK) == 0 && access (varsfile, R_OK) == 0) {
     ^~
appliance-uefi.c:67:27: error: 'R_OK' undeclared (first use in this function)
     if (access (codefile, R_OK) == 0 && access (varsfile, R_OK) == 0) {
                           ^~~~
appliance-uefi.c:67:27: note: each undeclared identifier is reported only once for each function it appears in
cc1: all warnings being treated as errors

Fixes commit dd519e8a8e.
2017-01-17 08:58:00 +00:00
Cédric Bosdonnat
b9f510328a builder: extract Yajl helper functions to yajl.ml
Extract the yajl object_get_* helpers in the Yajl module since this
could be useful for any Yajl user code.
2017-01-05 09:25:11 +01:00
Tomáš Golembiovský
c96bcb4e24 tests: rename guestfs-hashsums.sh to test-utils.sh
Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2017-01-04 10:41:48 +01:00
Tomáš Golembiovský
8644ea7242 v2v: ova: move the untar function
Move the untar function so it can be used later in the code.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2017-01-04 10:41:48 +01:00
Tomáš Golembiovský
347e4b1648 mllib: compute checksum of file inside tar
Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2017-01-04 10:41:48 +01:00
Pino Toscano
e86b36a31c appliance: add ldmtools/libldm packages on more distros (RHBZ#1409023)
Add them also for Debian and Mageia, where libldm is shipped, and
adjust the comment on the RedHat line.
2017-01-03 17:41:16 +01:00
Pino Toscano
55bf7de97c Update copyright dates for 2017
Run the following command over the source:

  perl -pi.bak -e 's/(20[01][0-9])-2016/$1-2017/g' `git ls-files`

(Thanks Rich for the perl snippet, as used in past years.)
2017-01-03 16:48:21 +01:00
Richard W.M. Jones
dd519e8a8e lib: Move some appliance functions around.
Move some appliance functions out of src/appliance.c and src/launch.c
into separate files.

No functional change, just code movement.
2016-12-24 16:00:07 +00:00
Richard W.M. Jones
61d26f85fc Version 1.35.19. 2016-12-23 22:56:15 +00:00
Richard W.M. Jones
f7bd9bd37f launch: Validate $TERM before passing it through to the kernel command line.
Make sure it is reasonable before we pass it through to the kernel
command line.  I don't believe this is exploitable, but it might cause
obscure bugs.
2016-12-23 21:53:10 +00:00
Richard W.M. Jones
f94cfde5e7 launch: Rationalize how we construct the Linux kernel command line.
This is just code refactoring.
2016-12-23 21:53:10 +00:00
Richard W.M. Jones
764fd3fcc6 appliance: Disable EDD (edd=off) (RHBZ#1404287).
EDD (https://en.wikipedia.org/wiki/Enhanced_Disk_Drive) is a BIOS INT 13h
subcall for communicating the extended size of the boot disk over 8GB
to the OS.  Since libguestfs doesn't use a boot disk, and the
appliance disk is limited to 4GB, and we use virtio-scsi, this is all
useless.

EDD is also broken currently on RHEL 7.3, see:
https://bugzilla.redhat.com/show_bug.cgi?id=1404287

Also the EDD probing takes significant extra time (about 80ms on my
laptop), and using edd=off reduces this time although doesn't entirely
eliminate it.
2016-12-18 20:13:55 +00:00
Pino Toscano
331517d9a3 sysprep: remove anaconda's /root/original-ks.cfg
Remove one more leftover file from anaconda.

Related to: RHBZ#1401320.
Thanks to: Marko Myllynen.
2016-12-15 09:37:01 +01:00
Richard W.M. Jones
adb6a85bf9 Version 1.35.18. 2016-12-14 18:16:16 +00:00
Richard W.M. Jones
b460c50bf5 sysprep: Add new test to EXTRA_DIST.
Fixes commit 3cb43460d3.
2016-12-14 18:14:26 +00:00
Richard W.M. Jones
d131d2af92 sysprep: Add common pod_of_list function to new module 'Utils'. 2016-12-14 17:23:11 +00:00
Richard W.M. Jones
d12636dadd sysprep: Add new operation for removing /etc/passwd- and other backup files (RHBZ#1401320). 2016-12-14 17:15:29 +00:00
Richard W.M. Jones
3cb43460d3 sysprep: Add a new operation to remove editor backup files (RHBZ#1401320).
Remove editor backup files such as *~ and *.bak wherever
they occur within the guest filesystem.

This also includes a test.
2016-12-14 17:15:29 +00:00
Richard W.M. Jones
ca0ce0c2ec mllib: Add a function to test if a guest is "unix-like".
This is not a precise replacement, since we now allow SSH key
injection into Minix, but that is probably correct anyway.
2016-12-14 17:15:29 +00:00
Richard W.M. Jones
2dd2d5cc64 mllib: Add a binding for fnmatch(3) in glibc or gnulib.
This is taken from supermin.
2016-12-14 17:15:29 +00:00
Richard W.M. Jones
4a62e52111 mllib: Add a binding for visit function in cat/visit.c. 2016-12-14 17:15:29 +00:00
Richard W.M. Jones
f87ec46558 v2v: Add a comment about why virt-v2v needs the network.
Only to run unconfigure_vmware ().
2016-12-14 16:52:29 +00:00
Pino Toscano
401e58cba8 tests: drop expected-failing btrfs_subvolume_show test
One of the tests for btrfs_subvolume_show tries to invoke it on the
toplevel subvolume, expecting its failure (since btrfs-progs used to not
be able to list that).  However, since v4.8.3 btrfs-progs can do that
(even if the data returned for that subvolume is limited/incomplete),
and thus this test fails because the API does not fail anymore.

Since we can consider that functionality working (for some kind of it),
then drop this test.
2016-12-14 17:09:32 +01:00
Pino Toscano
7bd6a73f00 libvirt: fix reading secret by usage type
Use the right variable to determine the usage type of a secret.

Fixes commit a94d551345.
2016-12-14 11:09:37 +01:00
Matteo Cafasso
46669d17c5 lib: use guestfs_int_make_temp_path to generate temporary files
Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2016-12-13 18:10:44 +00:00
Matteo Cafasso
774b00e862 lib: generic function for temporary path generation
Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2016-12-13 18:10:44 +00:00
Pino Toscano
3ed0a7a57d v2v: tests: avoid '..' in member names for tar
Very recent versions of tar (most probably as a consequence of
CVE-2016-6321) may refuse archive members with '..', like the relative
paths to upper level directories.

Since these are just tests, simply copy the files in the temporary
directories where tar (or zip as well) is run, so all the files are in
the same directory.
2016-12-13 09:16:29 +01:00
Pino Toscano
99834b85b2 perl: fix memory leak in RStruct actions
The return value struct was freed using a simple free() instead of the
own cleanup function of each struct: this meant dynamically allocated
values (such as strings) were leaked.

Use the proper cleanup functions instead.
2016-12-13 09:16:29 +01:00
Pino Toscano
9089b9eaa2 java: fix memory leak in RStruct actions
The return value struct was freed using a simple free() instead of the
own cleanup function of each struct: this meant dynamically allocated
values (such as strings) were leaked.

Use the proper cleanup functions instead.
2016-12-13 09:16:29 +01:00
Richard W.M. Jones
25ed84c64d builder: Fixed CentOS 7.3 image.
The previous one had apparent filesystem corruption.

Fixes commit b16627d679.
2016-12-12 22:14:47 +00:00
Richard W.M. Jones
b16627d679 builder: Add CentOS 7.3 template.
Release notice:
https://lists.centos.org/pipermail/centos-announce/2016-December/022172.html
2016-12-12 20:14:20 +00:00
Richard W.M. Jones
a200c4c32b Version 1.35.17. 2016-12-11 18:30:46 +00:00
Richard W.M. Jones
8f32e5d67e builder: Fix copying of virt-builder index.asc etc to website.
The definition of BUILDFILES was accidentally removed, resulting
in the error:

  cp  /home/rjones/d/websites/libguestfs/download/builder/
  cp: missing destination file operand after '/home/rjones/d/websites/libguestfs/download/builder/'

Fixes commit 65a0570385.
2016-12-11 18:23:11 +00:00
Richard W.M. Jones
89ea624571 Version 1.35.16. 2016-12-10 16:31:17 +00:00
Richard W.M. Jones
2e7aecd1ad builder: Don't try to translate make-template.ml.
It fails with:

  File "../builder/templates/make-template.ml", line 1, characters 0-1:
  Parse error: [a_LIDENT] expected after "#" (in [implem])
  End_of_file
  An error occurs while processing.

In any case this doesn't matter because this file should not be
translated.

Fixes commit a1ea9a2599.
2016-12-10 16:20:34 +00:00
Richard W.M. Jones
a1ea9a2599 Version 1.35.15. 2016-12-10 15:45:19 +00:00
Richard W.M. Jones
f070774e2c v2v: Fix POTFILES-ml.
Fixes commit 222535fa12.
2016-12-10 15:37:33 +00:00
Richard W.M. Jones
546fd23504 builder: Add website/download/builder/* files to EXTRA_DIST.
Fixes commit 65a0570385.
2016-12-10 15:37:29 +00:00
Pino Toscano
f2435c7ab4 inspect: improve canonical_mountpoint implementation
Use a simplier version using a loop, skipping multiple '/' at once,
reducing the amount of memmove and strlen needed.

Updates commit 865d070ddc.
2016-12-09 13:52:00 +01:00
Richard W.M. Jones
24d14e1d26 v2v: Fix ambiguous and probably incorrect pattern match (warning 57).
See:
http://caml.inria.fr/pub/docs/manual-ocaml/comp.html#ss%3Awarn57

I believe the code as written previously was incorrect.  However we
are lucky because if neither clause matches then it will fall through
to displaying an error message, allowing the user to correct the
problem.
2016-12-09 11:28:02 +00:00
Richard W.M. Jones
c540676f5e Remove most instances of OCaml warning 52.
See:
http://caml.inria.fr/pub/docs/manual-ocaml/comp.html#s:comp-warnings
2016-12-09 09:31:25 +00:00
Richard W.M. Jones
63ff96ccda customize: Remove Customize_utils module.
After the previous commit this module is empty, so remove it.
2016-12-09 09:31:25 +00:00
Richard W.M. Jones
07fb30b161 mllib: Add quote function to Common_utils module.
Remove multiple places where we let quote = Filename.quote
2016-12-09 09:31:25 +00:00
Richard W.M. Jones
2cc348448a generator: Share Common_utils code.
For a very long time we have maintained two sets of utility functions,
in mllib/common_utils.ml and generator/utils.ml.  This changes things
so that the same set of utility functions can be shared with both
directories.

It's not possible to use common_utils.ml directly in the generator
because it provides several functions that use modules outside the
OCaml stdlib.  Therefore we add some lightweight post-processing which
extracts the functions using only the stdlib:

  (*<stdlib>*)
  ...
  (*</stdlib>*)

and creates generator/common_utils.ml and generator/common_utils.mli
from that.  The effect is we only need to write utility functions
once.

As with other tools, we still have generator-specific utility
functions in generator/utils.ml.

Also in this change:

 - Use String.uppercase_ascii and String.lowercase_ascii in place
   of deprecated String.uppercase/String.lowercase.

 - Implement String.capitalize_ascii to replace deprecated
   String.capitalize.

 - Move isspace, isdigit, isxdigit functions to Char module.
2016-12-09 09:31:25 +00:00
Richard W.M. Jones
865d070ddc inspect: fstab: Canonicalize paths appearing in fstab.
For example, converts "///usr//local//" -> "/usr/local".
2016-12-07 14:54:24 +00:00
Richard W.M. Jones
222535fa12 v2v: Rename RHEV to RHV throughout.
You can now use -o rhv (-o rhev is supported for compatibility).
2016-12-07 14:12:28 +00:00
Richard W.M. Jones
bdaeeb4e60 v2v: -o vdsm: Add --vdsm-compat flag. -o rhev: Drop support for RHV < 4.1 (RHBZ#1400205).
Support for RHEV with RHEL 6 nodes required us to output the old style
qcow2 compat=0.10 images.  Since RHEV 3.6 GA, RHEL 6 has not been
supported as a RHEV node type.  Since RHV 4.1, compat=1.1 is
supported.  (Support for compat=1.1 is uncertain in RHV 4.0 even on
RHEL 7 nodes.)

There are significant downsides to using qcow2 compat=0.10 instead of
the modern default (compat=1.1).

Therefore this patch does two things:

For -o rhev, it drops support for compat=0.10 completely.  You must
use RHV 4.1.

For -o vdsm, it adds an interim flag (--vdsm-compat=0.10 or
--vdsm-compat=1.1) which controls the compat level of the qcow2 output
file.  VDSM should use --vdsm-compat=1.1 when it is known that modern
qemu is available.  We can make this the default later when all RHV
instances have moved to 4.1.

It also adds:

  vdsm-compat-option

to the `virt-v2v --machine-readable' output to indicate that this flag
can be used.

Thanks: Yaniv Kaul, Michal Skrivanek.
2016-12-07 14:12:28 +00:00
Pino Toscano
1d86b37689 inspect: gather info from /usr filesystems as well (RHBZ#1401474)
Flag the filesystems for Linux /usr properly as USR role, and detect
some data out of it, like the distro information from an os-release
(if present), and the architecture (since the binaries used for our
architecture check will be available there only).

Later on, collect the results in a way similar to what is done for
CoreOS: for each non-CoreOS root, try to find its /usr filesystem, and
if found then merge what is missing from root; in the last case, also
override the distro inspection data (version, product name) if available
in /usr.
2016-12-07 14:23:11 +01:00
Pino Toscano
dad35e55fa inspect: fix existance check of /dev/mapper devices
When checking for the existance of /dev/mapper devices found in the
fstab of a filesystem, using guestfs_exists means they are checked as
files in the guest, while they really appear as devices on the
appliance. Instead, try the lvm name resolution anyway, and ignore them
when they are reported as missing.

Thanks to: Richard W.M. Jones.

Fixes commit 96b6504b09.
2016-12-07 14:23:11 +01:00
Pino Toscano
e21b055f3e resize: shrink/expand swap partitions
Handle the swap partition on their own, rebuilding them using the
existing UUID and label.
2016-12-07 14:20:35 +01:00
Pino Toscano
aad24f4d56 daemon: allow to change the labels of swap partitions 2016-12-07 14:20:31 +01:00
Pino Toscano
a94d551345 libvirt: read secrets of disks (RHBZ#1392798)
Read also the secrets associated to disks (<secret> tag within <auth>),
so qemu can properly open them later on.
2016-12-07 13:48:47 +01:00
Pino Toscano
bef838202b libvirt: un-duplicate XPath code
Move the checks for empty xmlXPathObjectPtr, and for extracting the
result string out of it, to a new helper functions.

This is just code motion, there should be no behaviour changes.
2016-12-07 13:38:29 +01:00
Pino Toscano
e77e1ef95e inspect: mark CoreOS /usr partitions with own USR role
Add a new inspect role for "/usr" partitions, and use that to mark the
/usr partition in CoreOS: this additional role allows to ease its lookup
later on, when merging its results into those of the root.
2016-12-06 18:11:44 +01:00
Pino Toscano
0c4edcecba inspect: change is_root flag into enum
Introduce a new enum to classify the role of a filesystem, if available.
This will help later on when doing operations on non-root filesystems,
like detecting particular mountpoints such as /usr.

The new enum has only "root" as known role, which replaces the is_root
flag.
2016-12-06 18:11:44 +01:00
Pino Toscano
b01416121f appliance: mount also /dev/pts
Tools could require the use of pseudo-terminals, so make sure we have
/dev/pts available in the appliance.  The "command" API already
bind-mounts it when running commands, so this is the only bit needed.
2016-12-06 18:11:44 +01:00
Richard W.M. Jones
601e05508b builder: Refactor command line parsing in make-template script.
This refactors command line parsing into a parse_cmdline function.
The function uses the Arg module to parse the command line instead of
ad hoc parsing.

This also enforces use of the ./run script to run the program, since
otherwise you can end up with mixed versions of the OCaml bindings and
the C library.

This updates commit 65a0570385.
2016-12-02 17:04:05 +00:00
Pino Toscano
8462b1ea32 environment: fix error message for LIBGUESTFS_DEBUG failure
Properly mention LIBGUESTFS_DEBUG as environment variable when it
cannot be parsed as boolean.
2016-12-01 16:01:57 +01:00
Richard W.M. Jones
c2f5330447 v2v: Remove bogus backslash in test. 2016-12-01 12:48:57 +00:00
Cédric Bosdonnat
cd78fa4c88 packagelist: add initviocons package on SUSE
initviocons package provides tools to resize the terminal. Having it
in the appliance will allow SUSE users to have proper line wrapping
in their terminal when using virt-rescue.
2016-11-30 17:06:06 +00:00
Richard W.M. Jones
e4b73d67f2 builder: Update Fedora 25 and RHEL 7.3 ppc64 and ppc64le images.
Rebuild these images with the new make-template.ml script.  This fixes
the lack of virtio-scsi driver and broken initramfs.

These images all use LVM because without that both Fedora and RHEL put
the root filesystem on an extended partition (/dev/sda5) which
virt-resize cannot handle.

(Note the RHEL images are not public.)
2016-11-30 14:21:13 +00:00
Richard W.M. Jones
7a9f9b7cdc builder: ppc64: Enable virtio-scsi in templates.
Workaround for dracut bug RHBZ#1396217.
2016-11-30 14:21:13 +00:00
Richard W.M. Jones
65a0570385 builder: Rearrange how template-building scripts work.
Create a new directory (builder/template).  Integrate all of the
scripts into a single program, so that templates are generated more
consistently.

This also changes how the index file is generated.  The script now
generates the index file fragment and saves it under version control,
and then generates the final index file by concatenating these.
(Previously the index was written by hand which was tedious and
error-prone.)

The new script also saves the generated kickstart under version
control so it can be referenced later.
2016-11-30 14:20:20 +00:00
Richard W.M. Jones
06dc0e52eb Revert "builder: ppc64, ppc64le: Force add virtio-scsi driver."
It turns out that adding the virtio-scsi driver does not help
to fix the dracut problem.

This partially reverts commit f766c84c39,
keeping the change to index.
2016-11-24 18:46:26 +00:00
Richard W.M. Jones
f766c84c39 builder: ppc64, ppc64le: Force add virtio-scsi driver.
Works around dracut bug RHBZ#1396217.

Also update new Fedora ppc64 & ppc64le images.
2016-11-24 17:25:33 +00:00
Richard W.M. Jones
0cd54ff45b builder: Add Fedora 25 templates. 2016-11-24 10:35:45 +00:00
Richard W.M. Jones
bad1059bc4 fish: Fix small typos in virt-copy-in and virt-copy-out man pages (RHBZ#1398070).
Thanks: Xianghua Chen
2016-11-24 09:53:10 +00:00
Richard W.M. Jones
0ae56ad711 builder: fedora-armv7l: Increase RAM for installation.
In Fedora 25 the guest runs out of RAM when loading the
Anaconda initramfs.
2016-11-24 09:52:17 +00:00
Richard W.M. Jones
f45d9d3cd2 builder: fedora-ppc64le: Require POWER8 CPU.
This is the same as commit 4919f4f740
for Fedora.
2016-11-23 22:01:57 +00:00
Richard W.M. Jones
6c50cfd464 builder: fedora-aarch64: Add --arch flag.
This is the same thing as
commit 4a5605e7be, but for Fedora.
2016-11-23 21:57:02 +00:00
Richard W.M. Jones
4919f4f740 builder: ppc64le: Require POWER8 CPU.
RHEL 7.3 requires POWER8 instructions.
2016-11-17 14:51:10 +00:00
Richard W.M. Jones
4a5605e7be builder: aarch64: Add --arch flag.
This allows us to cross-build the image from x86_64 which is
more convenient than doing it on aarch64 host.
2016-11-17 14:51:10 +00:00
Richard W.M. Jones
c08788ef1b filearch: Add s390 and s390x detection and tests.
Unfortunately I was unable to build s390 binaries since multilib was
dropped in Fedora 24 on s390x.  Going from the source of the 'file'
command it seems as if it prints "32-bit" (the architecture is really
31 bit).
2016-11-13 18:32:21 +00:00
Richard W.M. Jones
6d805f3b33 docs: Fix man pages references to incorrect section numbers. 2016-11-13 18:32:21 +00:00
Richard W.M. Jones
fc73cdc014 Fix HACKING file in top level directory. 2016-11-13 18:28:38 +00:00
Richard W.M. Jones
cf0967542f installcheck: p2v: Make virt-p2v binary executable after uncompressing it.
Fixes commit 4152388530
and commit face52f62e.
2016-11-10 11:39:43 +00:00
Matteo Cafasso
5d36f5ae82 upload: improve file write callback
As noted by Pino in another patch, the logic passes the first member of
the struct which happens to be the right address to the callback
function.

This will break the callback if order of the members of the struct will
change.

As the callback is using the entire struct, better to pass the pointer
to the struct itself.

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2016-11-09 21:09:24 +00:00
Richard W.M. Jones
4152388530 installcheck: p2v: Fix tests of virt-p2v.
Fixes commit face52f62e.
2016-11-09 17:54:52 +00:00
Pino Toscano
086be00aca v2v: add "colours-option" to machine readable sample output (RHBZ#1390876) 2016-11-02 11:00:39 +01:00
Pino Toscano
49dd176974 builder: distribute fedora-s390x.sh
Followup of commit c25a898710.
2016-11-02 11:00:39 +01:00
Richard W.M. Jones
0acdc83736 v2v: glance: Set hw_video_model property to qxl|cirrus (RHBZ#1374651).
Thanks: Vladik Romanovsky, Ming Xie.
2016-11-01 17:24:19 +00:00
Pino Toscano
1c51773b09 v2v: update again URL with glance metadata
Finally got the (hopefully stable) right URL for them.
2016-11-01 18:15:25 +01:00
Richard W.M. Jones
c25a898710 builder: Add script for starting Fedora/s390x.
However it does not currently work because of a bug in libvirt:

https://bugzilla.redhat.com/show_bug.cgi?id=1376547
2016-11-01 11:50:22 +00:00
Richard W.M. Jones
c7ce5e47fa handle: Improve error messaging if XDG_RUNTIME_DIR path does not exist.
If an environment variable such as XDG_RUNTIME_DIR or one of the
tmpdirs or cachedir is set to a non-existent directory, improve the
error message that the user will see so that (where possible) it
includes the environment variable or API call.

This is still not bullet-proof because it's hard to display the
environment variable if it is LIBGUESTFS_TMPDIR or
LIBGUESTFS_CACHEDIR, but the main problem is with XDG_RUNTIME_DIR
(because of systemd bugs).

Thanks: Hilko Bengen for identifying the bug.
2016-11-01 10:20:28 +00:00
Pino Toscano
a8b206234c docs: fix link to guestfs-golang(3) 2016-10-31 13:08:40 +01:00
Hilko Bengen
eecb1d8177 run.in: Quote contents of @VAR@ substitutions 2016-10-27 21:35:57 +02:00
Richard W.M. Jones
d411cd6127 Version 1.35.14. 2016-10-25 22:53:15 +01:00
Richard W.M. Jones
e73763de1f docs: Ignore ruby/ext/guestfs/extconf.h
Updates commit bd21993d77.
2016-10-25 22:30:30 +01:00
Richard W.M. Jones
67cc867da8 docs: Ignore php/extension/config.h.
Updates commit bd21993d77.
2016-10-25 21:59:19 +01:00
Richard W.M. Jones
7d85796466 Version 1.35.13. 2016-10-25 21:43:32 +01:00
Richard W.M. Jones
4f3269ac23 docs: Ignore java/com_redhat_et_libguestfs_GuestFS.h
Updates commit bd21993d77.
2016-10-25 21:37:37 +01:00
Richard W.M. Jones
d76d916501 Version 1.35.12. 2016-10-25 21:19:18 +01:00
Richard W.M. Jones
0875989384 docs: Ignore more generated headers.
Updates commit bd21993d77.
2016-10-25 21:12:56 +01:00
Richard W.M. Jones
959ed964b8 Version 1.35.11. 2016-10-25 20:49:21 +01:00
Richard W.M. Jones
7855c8e4a8 docs: Ignore errnostring.h files too.
Updates commit bd21993d77.
2016-10-25 20:42:40 +01:00
Richard W.M. Jones
f68388eec5 Version 1.35.10. 2016-10-25 20:02:59 +01:00
Richard W.M. Jones
bd21993d77 docs: Remove builder/index-parse.h from documented files.
Breaks things when building from clean.
2016-10-25 19:14:06 +01:00
Richard W.M. Jones
0e1f8c4de7 p2v: Add dbus dependency to dependencies.m4.
Probably not necessary since dbus is part of most base distros, but
added for completeness.

Fixes commit 54979e8842.
2016-10-25 19:05:15 +01:00
Richard W.M. Jones
851f1771bc docs: Document some more internal library structs. 2016-10-25 15:47:39 +01:00
Richard W.M. Jones
4d535c7038 docs: internal: Allow headers and structs to be documented.
This makes a number of small changes to how the internal documentation
is generated and what can be documented.

Header files are now permitted to contain internal documentation.
This works in the same wasy as .c files.

Also documentation can be added for structs as well as functions.

This commit also adds documentation to some header files and structs,
and fixes a few places which contained broken header documentation.
2016-10-25 13:38:01 +01:00
Richard W.M. Jones
8823247bd5 docs: building: Document additional deps needed to build from git.
Also document the gettext (C library) dependency which was missing.
2016-10-25 11:57:47 +01:00
Richard W.M. Jones
54979e8842 p2v: Inhibit power saving during the conversion.
We do this by sending an Inhibit() message to logind and receiving a
file descriptor back, which we hold open until the conversion
completes (or fails).  This is described here:
https://www.freedesktop.org/wiki/Software/systemd/inhibit/

This adds an additional optional dependency on DBus since we use DBus
to call the Inhibit() method.

Reported-by: Chris Cowley.
2016-10-25 10:54:31 +01:00
Pino Toscano
75fbe4511e builder: consolidate handling of temporary files/dirs
Create a single temporary directory for all the files created during the
virt-builder run (except big disk images, which already use the
libguestfs cache directory).  A single directory means there is no need
to manually schedule all the temporary files and directories for removal
when the application quits.
2016-10-25 10:15:04 +02:00
Pino Toscano
0a5954f4f7 mllib: curl: add optional tmpdir parameter
Add a new optional parameter for the Curl ADT, so temporary files can be
created in a specified directory (which is supposed to be temporary, and
disposed only when the application quits).
2016-10-25 10:15:04 +02:00
Richard W.M. Jones
79e9c87d56 customize: Check SLOW flag is set before running password tests.
Fixes commit 2f57eb181f.

Thanks: Pino Toscano for finding the bug and suggesting the fix.
2016-10-24 15:56:57 +01:00
Pino Toscano
ab8007ecda inspect: map "sled" in /etc/os-release as "sles" distro
Map SLED as "sles" when parsing /etc/os-release, just like it is done
already when using /etc/SuSE-release.

Thanks to Cédric Bosdonnat for testing.
2016-10-21 16:53:12 +02:00
Richard W.M. Jones
7822d4dccb FAQ: Document how to switch kernel and qemu. 2016-10-21 12:30:56 +01:00
Richard W.M. Jones
1d5cd15e3a Version 1.35.9. 2016-10-20 18:27:02 +01:00
Richard W.M. Jones
2f57eb181f customize: Test that the --root-password parameter works.
Add a slow test to ensure that the --root-password option
doesn't regress.
2016-10-20 13:50:50 +01:00
Richard W.M. Jones
05f201a6e6 builder: Add test that a serial console is set up for guest templates we supply. 2016-10-19 14:50:36 +01:00
Richard W.M. Jones
a01c828f0c builder: Add virt-builder --notes for enabling serial console.
On debian-8 and ubuntu-16.04.
2016-10-19 14:50:36 +01:00
Richard W.M. Jones
fc35cfe361 builder: Allow test-virt-builder-planner to be skipped. 2016-10-19 12:19:44 +01:00
Richard W.M. Jones
8d19c1a08f customize, v2v: Use script name instead of $0 in test-*-<guestname>.sh scripts.
$0 is set to the name of the test script, eg. test-settings.sh, and in
bash there is no way to change that.

Create a new environment variable, $script, which is set to the name
of the wrapper script (eg. test-settings-fedora-24.sh).

This should give more accurate error messages.
2016-10-19 12:19:43 +01:00
Richard W.M. Jones
d61e9df151 Add a test for virt-tail. 2016-10-12 13:49:46 +01:00
Richard W.M. Jones
8b076d87a1 New tool: virt-tail.
This follows (tails) a log file within a guest, rather like
the regular 'tail -f' command.  For example:

  virt-tail -d guest /var/log/messages
2016-10-12 13:49:46 +01:00
Richard W.M. Jones
19332919a2 p2v: Fix virt-p2v-make-kickstart for new location of virt-p2v.xz.
Fixes commit face52f62e.
2016-10-12 13:49:46 +01:00
Richard W.M. Jones
bb782a9dd5 Version 1.35.8. 2016-10-11 19:05:22 +01:00
Richard W.M. Jones
d6c42a6c58 valgrind: Don't use "nested" run scripts.
When TESTS_ENVIRONMENT already uses 'run', the VG variable
doesn't also need to use 'run'.

The specific problem is that if the command contains newlines
then double invocations of the 'run' script fails (in libtool).
ie the following command failed causing errors in check-valgrind:

  $VG virt-builder phony-fedora \
      -v --no-cache --no-check-signature $no_network \
  ...
      --write '/etc/append4:line1
  ' \
  ...
2016-10-11 18:08:49 +01:00
Richard W.M. Jones
9bcdffc2bb Version 1.35.7. 2016-10-11 14:19:08 +01:00
Richard W.M. Jones
4c8fc40d66 p2v: Fix EXTRA_DIST.
Fixes commit face52f62e.
2016-10-11 14:17:06 +01:00
Richard W.M. Jones
face52f62e p2v: Compress virt-p2v binary and store it in $libdir/virt-p2v (RHBZ#1382275).
Currently 'make install' installs the virt-p2v binary in
/usr/libexec/virt-p2v on the host.  It is never supposed to be run
from there, even by another program, so use of /usr/libexec is
incorrect.  It is only supposed to be copied into USB keys / ISOs /
etc created by virt-p2v-make-* scripts.

The other problem with shipping a "naked" binary on the host is that
packages built from that get all the dependencies of virt-p2v, for
example Gtk.  This is unnecessary just for running the command line
scripts mentioned above.

This changes the Makefile and scripts so that the binary is stored
compressed in $libdir/virt-p2v/virt-p2v.xz.  It is compressed to avoid
exposing the dependencies.  It is stored under $libdir since the
binary is still architecture-dependent.

A further change is that when we copy the binary into the virt-p2v
ISO, it is now installed in /usr/bin instead of /usr/libexec.  (And
note that we always use /usr/bin, not $bindir, since this path should
not need to be affected by the configuration of libguestfs).
2016-10-11 13:43:12 +01:00
Tomáš Golembiovský
2bed3e4801 appliance: add/remove some packages for Arch Linux
Added:
- cdrtools: added as alternative to cdrkit
- multipath-tools: contains kpartx (in AUR)

Removed:
- ntfsprogs: the package is no longer available, it has been completely
  replaced by ntfs-3g (already in packagelist.in)
- zfs-fuse: no longer in AUR

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2016-10-11 13:17:25 +01:00
Richard W.M. Jones
d9b2a16c71 v2v: ova: Make OVA directory public readable to work around libvirt bug (RHBZ#1375157).
Only do this if running as root and if the backend is set
to libvirt.
2016-10-11 10:48:24 +01:00
Richard W.M. Jones
9ab8b1bebd launch: libvirt: Remove unused USB and memballoon devices.
Thanks: Laine Stump.

See also:
https://www.redhat.com/archives/libvir-list/2016-October/msg00246.html
2016-10-11 10:39:02 +01:00
Tomáš Golembiovský
d0c86f287d v2v: test Debian/Ubuntu conversion
Enable testing of Debian and Ubuntu guest conversion.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2016-10-07 16:54:58 +02:00
Pino Toscano
162fe71b8d v2v: linux: enable conversion of Debian guests
A basic conversion of Debian-based guests works now; it needs more
thorough testing for all the operations done with different sources.
2016-10-07 14:55:51 +02:00
Tomáš Golembiovský
52a8202635 v2v: ova: support SHA256 hashes in manifest
The OVF standard allows the use of SHA256 hashes in the manifest file.
Adding support for this.

One of the tests was updated to put SHA256 into manifest file.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2016-10-07 14:33:48 +02:00
Tomáš Golembiovský
6b7ea3c681 v2v: ova: fix checking of the manifest file
The regular expression for parsing the manifest line was wrong. There is
a mandatory space between '=' and the hash.

Another problem was that only the first line of the manifest file was
actually processed.

Also added some debugging info and warning to catch problems with
parsing.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2016-10-07 14:33:44 +02:00
Pino Toscano
b9f6eb5132 po: manually update POTFILES-ml
Followup/fix of commit 5681db5ed8 and
commit 7a09db5e48.
2016-10-06 09:22:51 +02:00
Pino Toscano
be8ad60b8e v2v: linux: try to fix removal of VMware tools
Try to improve the way packages of VMware tools are removed from
YUM-based guests:

- when filtering the package itself from its providers, do a stricter
  check so either the provide is the unversioned package, or it is
  exactly its own name

- if the package has no other providers, then going further will cause
  the invocation of 'yum install' with no packages, and thus the package
  itself will not be added to the list of packages to be removed; to
  overcome this issue, just mark the package as "to be removed" in that
  case

Related to: RHBZ#1155150
2016-10-04 14:45:18 +02:00
Pino Toscano
664842763c v2v: linux kernels: remove unused parameter
Remove an unused paramter of the internal check_config function.

Followup of commit 7eb219d193.
2016-10-04 09:40:54 +02:00
Richard W.M. Jones
ca4a679400 appliance: Add ExFAT packages.
Thanks: Miles Wolbe
2016-10-03 14:06:15 +01:00
Pino Toscano
7eb219d193 v2v: linux: check also kernel config for modules
When checking whether a kernel supports virtio or it is Xen-based, it is
assumed that the feature has the kernel module for it; this will fail if
the feature is built-in in the kernel, misrepresenting it.

The solution is to check the kernel configuration whether the feature
is built-in, in case there is no module available.

This fixes the virtio detection on Ubuntu kernels, where virtio is
built in and not as module.
2016-10-03 14:33:20 +02:00
Pino Toscano
52b63e6b33 v2v: linux kernels: detect config file
Add a simple detection for the config file of each kernel, so that can
be used later to get more information on what a kernel provides.
2016-10-03 14:33:20 +02:00
Pino Toscano
19b7495d46 v2v: bootloaders: improve detection of Grub2 default method
Detect only once which method must be used to get and set the default
Grub2 kernel in the guest: this avoids the same checks in list_kernels
and set_default_kernel.

Also, add a "no method" option as well: Debian/Ubuntu guests do not have
neither grubby nor Perl's Bootloader::Tools, so there is no way to know
what is the default kernel, nor to change it.  In this case, add a
warning about this situation.
2016-10-03 14:33:20 +02:00
Pino Toscano
d3736eb0a3 v2v: linux kernels: set type of 'g'
Make sure the type checker can detect the real type of 'g', even when
adding more code using it in detect_kernels.
2016-10-03 10:47:18 +02:00
Pino Toscano
b548c41951 v2v: -i ova: use Checksums
Make use of the Checksums module to ease the verification of the SHA1
checksums in manifests.
2016-10-03 10:41:26 +02:00
Pino Toscano
484c64c29f mllib: add SHA1 support in Checksums
This way Checksums can be used in v2v.
2016-10-03 10:41:26 +02:00
Pino Toscano
a58dff49c5 mllib, builder: add and use Checksums.of_string
Add a simple way to turn a combination of checksum type and value into a
csum_t.  Use it in builder, even if still constrained.
2016-10-03 10:41:26 +02:00
Pino Toscano
7a09db5e48 mllib: move Checksums from builder
Move the Checksums module from virt-builder mostly as it is; the only
change is that on checksum mismatch an exception is raised rather than
invoking "error" directly: this way users of verify_checksum &
verify_checksums can do their own handling of the situation.
2016-10-03 10:41:26 +02:00
Richard W.M. Jones
5681db5ed8 customize: Add --append-line.
This appends a single line to a file, with some cleverness
involving guessing the right line endings to use.

Also adds a test.
2016-10-01 13:08:32 +01:00
Richard W.M. Jones
a31f657db0 daemon: Choose /usr/sbin first for the daemon (debian bug 838995).
Debian is also doing a UsrMove/UsrMerge:
https://wiki.debian.org/UsrMerge

However it is not finalized that Debian will actually make this
change.

Since some Debian systems have /sbin as a symlink and other have /sbin
as a real directory, and we should avoid choosing a symlinked
directory for the daemon, the easiest fix is simply to probe /usr/sbin
before /sbin since under all scenarios (and Fedora too) /usr/sbin is a
real directory.

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=838995
2016-09-28 11:06:09 +01:00
Pino Toscano
7f236d2201 p2v: add mnemonics to labels and buttons (RHBZ#1379289)
Set mnemonics for all the labels with a text entry or combo box next to
them, and for all the buttons, and check boxes.
2016-09-26 16:04:10 +02:00
Pino Toscano
e3f681e1b8 tools: build common fish sources in a static library
Create a new libfishcommon convenience static library to build just once
(instead of 12 times!) the majority of the guestfish sources used in the
rest of the C tools (mostly for command line stuff, inspection, and
mount).

The notable exceptions not using libfishcommon are guestfish itself, and
virt-rescue: both need to build at least one of the common sources using
additional CPPFLAGS.
2016-09-26 14:16:44 +02:00
Pino Toscano
23ca442f63 fish, inspector: get rid of COMPILING_VIRT_INSPECTOR
All the define was doing in options.h was masking the declaration of
inspect_mount_root, which was always built-in in inspect.c (because of
the unconditional #define there) anyway.

Since this is common code used by all the C tools, try to avoid extra
knobs which add different code paths for no benefit.
2016-09-26 11:45:07 +02:00
Pino Toscano
284c6e1078 build: remove extra libconfig linkage
Some of the C tools were building also config.c as part of the shared
sources from guestfish, and thus bringing a dependency on libconfig.
Since none of them actually read the libguestfs configuration at all,
then exclude fish/config.c from their build, and stop linking to
libconfig.
2016-09-26 11:13:17 +02:00
Pino Toscano
f057086b60 dib: use remove_duplicates instead of own code
Use a common function to remove duplicates in an unsorted list.

Just refactoring, with no behaviour change.
2016-09-23 17:43:07 +02:00
Pino Toscano
d7551ec39b mllib: move remove_duplicates from v2v
Simple code motion.
2016-09-23 17:40:09 +02:00
Richard W.M. Jones
b5d57baf3d Version 1.35.6. 2016-09-23 10:33:20 +01:00
Tomáš Golembiovský
967280566d v2v: linux: correctly reconfigure the initrd on Debian
Using update-initramfs is the native way of updating initrd on Debian
based systems.

To add some modules to the image we can list them in file
/etc/initramfs-tools/modules.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2016-09-22 18:41:16 +02:00
Pino Toscano
4c3968f262 libvirt: read disk paths from pools (RHBZ#1366049)
A disk of type 'volume' is stored as
  <source pool='pool_name' volume='volume_name'/>
and its real location is inside the 'volume_name', as 'pool_name': in
this case, query libvirt for the actual path of the specified volume in
the specified pool.

Adjust the code so that:
- for_each_disk gets the virConnectPtr, needed to do operations with
  libvirt
- when extracting the disk filename depending on the type, the code
  snippet doing it can directly set 'filename', without setting an XPath
  result variable

Only file-based volumes are supported for now; more types can be added
(with proper testing) later on.
2016-09-22 17:36:09 +02:00
Richard W.M. Jones
a4adf48915 v2v: Support <listen type='socket'> and <listen type='none'> (RHBZ#1378022).
Since libvirt 2.0.0, these two new <listen/> types have been
supported: https://libvirt.org/formatdomain.html#elementsGraphics

This change just copies that configuration over from the source to the
destination if the destination is also libvirt.

Since we previously used 'LNone' to mean "no parseable <listen/>
element" I also had to change previous uses of 'LNone' to 'LNoListen',
so we can use 'LNone' to mean "<listen type='none'>".

Thanks: Ming Xie.
2016-09-21 14:03:23 +01:00
Matteo Cafasso
79fdc9ad47 find_inode: added API tests
NTFS file system always has the MFT file at inode 0. This reliable
information helps testing the API.

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2016-09-19 19:53:07 +02:00
Matteo Cafasso
9eb21ca54a New API: find_inode
Library's counterpart of the daemon's internal_find_inode command.

It writes the daemon's command output on a temporary file and parses it,
deserialising the XDR formatted tsk_dirent structs.

It returns to the caller the list of tsk_dirent structs generated by the
internal_find_inode command.

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2016-09-19 19:53:07 +02:00
Matteo Cafasso
eccce186a3 New API: internal_find_inode
The internal_find_inode command searches all entries referring to the
given inode and returns a tsk_dirent structure for each of them.

The command is able to retrieve information regarding deleted
or unaccessible files where other commands such as stat or find
would fail.

The gathered list of tsk_dirent structs is serialised into XDR format
and written to a file by the appliance.

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2016-09-19 19:53:07 +02:00
Matteo Cafasso
76a2bdd0f1 lib: logic refactoring
Code changes in preparation for new APIs.

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2016-09-19 19:53:07 +02:00
Pino Toscano
6b26a0cce4 OCaml tools: add crypto support (RHBZ#1362649)
Make use of the additional command line arguments, and API needed to
decrypt LUKS partitions.

This affects only virt-customize, virt-get-kernel, virt-sparsify, and
virt-sysprep, as they are the main OCaml tools interacting with
user-provided images.
2016-09-19 19:49:51 +02:00
Pino Toscano
5281e08802 mllib: expose disk decrypt functionalities
Expose via Common_utils the C functions & variables (part of guestfish)
that handle decryption of LUKS partitions, and the additional command
line arguments to tune the way they work.  This way it will be easy to
provide (basic) crypto support also in OCaml-based tools.

Related to: RHBZ#1362649
2016-09-19 19:49:51 +02:00
Pino Toscano
0920b805fd fish: move disk decryption helpers in own file
This way it is easier to use them outside the rest of the code in
guestfish for inspection & mount.

Just code motion, no behaviour changes.
2016-09-19 14:48:19 +02:00
Richard W.M. Jones
21a201051d p2v: Add C<...> around XTerm button string.
Thanks: Pino Toscano.

Fixes commit 2e9d058881.
2016-09-19 12:54:13 +01:00
Richard W.M. Jones
2e9d058881 p2v: Update virt-p2v docs to describe XTerm button (RHBZ#1377081).
Thanks: Tingting Zheng.

Fixes commit bf434bdb35.
2016-09-19 12:32:31 +01:00
Matteo Cafasso
a1b5bbfced daemon: refactor tsk code
Refactor logic in preparation for new APIs.

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2016-09-19 11:12:48 +02:00
Matteo Cafasso
011f29f506 filesystem_walk: fixed root inode listing
With the current implementation, the root inode of the given partition
is ignored.

The root inode is now reported. Its name will be a single dot '.'
reproducing the TSK API.

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2016-09-19 11:12:42 +02:00
Richard W.M. Jones
59999f055b filearch: Return 'i386' instead of 'i486' (as documented).
And some incidental code refactoring.
2016-09-15 16:07:57 +01:00
Richard W.M. Jones
7907abcdc0 filearch: Add architectures missing from the documentation.
Updates commit 68d9b04735
and commit 33d2b4a734.
2016-09-15 16:07:57 +01:00
Richard W.M. Jones
536338ee93 filearch: Sort architectures into alphabetical order in documentation. 2016-09-15 16:07:57 +01:00
Tomáš Golembiovský
85327319ad v2v: linux: detect name of grub2-mkconfig
On Debian family of OSes Grub2 tools are prefixed with 'grub-', not with
'grub2-'. We have to detect the correct name of the tool to use it.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2016-09-15 16:21:43 +02:00
Richard W.M. Jones
c3bbd129ab Add riscv64 test binaries, and new tests of guestfs_file_architecture. 2016-09-15 15:19:11 +01:00
Richard W.M. Jones
68d9b04735 filearch: Add RISC-V architecture. 2016-09-15 15:19:11 +01:00
Pino Toscano
775e9cbd2a v2v: -o libvirt: always write pool names (RHBZ#1141631)
When creating the XML for the new guest, always put the name of the pool
containing the disks, even when -os specified a pool UUID: libvirt does
not handle pool UUIDs for storage, but only names.
2016-09-15 13:46:25 +02:00
Pino Toscano
f4ca4de207 v2v: -o glance: log glance client version in verbose mode
When running in verbose mode for debugging, run `glance --version` to
print the version of the glance client.  This helps when dealing with
failures, or making its output actionable.
2016-09-14 09:59:12 +02:00
Pino Toscano
04fe77c519 v2v: -i libvirtxml: tweak warning message
Use a placeholder for the type of disk, so the message becomes exactly
like another warning message used already in this function.
2016-09-14 09:56:04 +02:00
Pino Toscano
1497a9f722 v2v: -o glance: set all properties during creation (RHBZ#1374405)
The glance client v1.0.0 defaults to the Image v2 API: this means that
an image can be referenced only by its UUID, and not anymore by the name
as well (which does not need to be unique).  This caused our glance
invocation to set the properties for the newly created image to fail,
since we are using the name as identifier.

Instead of first creating the image and then setting all the properties
for it, set all the properties when creating the image: other than being
simpler, it also avoid parsing the output of the 'glance image-create'
command for the UUID ('id') of the image.
2016-09-13 16:31:27 +02:00
Richard W.M. Jones
5714439d94 perl: Guestfs.c file is not translatable, don't include it in po/POTFILES.
Reported by Nikos Skalkotos
https://aur.archlinux.org/packages/libguestfs/
2016-09-13 15:27:29 +01:00
Richard W.M. Jones
65e1c66bb9 Version 1.35.5. 2016-09-09 17:46:23 +01:00
Richard W.M. Jones
089f54b0d3 v2v: linux: Use /etc/modprobe.conf.local if it exists.
On SUSE (only) there is /etc/modprobe.conf which is generated from a
/usr/share file.  Local changes are meant to be added to
/etc/modprobe.conf.local.
2016-09-09 17:07:34 +01:00
Richard W.M. Jones
0e1b1ccfb2 v2v: linux: Avoid recursive functions.
Just code motion.
2016-09-09 17:07:34 +01:00
Richard W.M. Jones
15661d8760 v2v: linux: Don't use duck typing in interface of Linux_kernels.
On reflection we want the precise bootloaders type, not some other
object that happens to implement a #list_kernels method.

Fixes commit 2d7fa1db6a.
2016-09-09 17:07:34 +01:00
Richard W.M. Jones
2d7fa1db6a v2v: linux: Move kernel detection to a separate module.
Create a new module [Linux_kernels] which does all kernel detection,
and also provides a place to define the kernel_info data structure.

This is essentially just code motion.
2016-09-09 16:59:28 +01:00
Richard W.M. Jones
171bc5374e v2v: utils: Move external functions together.
Just a small code movement.
2016-09-09 16:09:39 +01:00
Richard W.M. Jones
b7a8247b5a v2v: Move xpath* functions to new module Xpath_helpers.
Just code motion.
2016-09-09 16:09:39 +01:00
Richard W.M. Jones
1ec78f34d8 v2v: Split up 'amend_source' function.
Just code motion.
2016-09-09 16:09:39 +01:00
Richard W.M. Jones
98619f9c26 v2v: -i ova: Derive the name from the OVA filename.
If the guest has no <Name> element in the OVF, previously we chose
"default" as the name.  This changes that so it uses a name derived
from the basename of the OVA file instead.

For example:

  virt-v2v -i ova /path/to/myguest.ova [...]

would use "myguest" as the name (assuming no <Name> was present).

Modifies the behaviour of
commit 1ae4252c93.
2016-09-09 16:09:39 +01:00
Richard W.M. Jones
312379c8a6 v2v: -i disk: Move code that creates name from disk to separate module.
Simple code motion.
2016-09-09 16:09:39 +01:00
Pino Toscano
8335af37fa tests: do not assume '.' is in Perl's @INC
Upstream Perl is going to remove '.' from @INC (the include path for
modules) by default for the next major release (= 5.26) [1], as measure
to fix security issues.  Debian already started backporting the fixes
for this [2], thus behaving this way in current Sid installations.

Since the affected Perl sources are only the local daemon testing
scripts, a simple fix is to force the 'requires' for the local
captive-daemon.pm module to start from the current directory: this way
there is no need to manually augment @INC, and only our local module is
loaded automatically.

[1] https://rt.perl.org/Public/Bug/Display.html?id=127810
[2] https://lists.debian.org/debian-devel-announce/2016/08/msg00013.html
2016-09-09 14:42:05 +02:00
Richard W.M. Jones
839fe4997b daemon: Use reply_with_error instead of *_perror for setfiles command.
Fixes commit 9d205f1c28.
2016-09-09 08:59:46 +01:00
Shahar Havivi
1ae4252c93 virt-v2v: Support for ova exported from AWS (RHBZ#1371843).
1. AWS the name tag is not mandatory - using default as a name
2. AWD doesn't prefix 'ovf:' as prefix to disk path

There is an open bug for oVirt:
https://bugzilla.redhat.com/show_bug.cgi?id=1371843

Signed-off-by: Shahar Havivi <shaharh@redhat.com>
2016-09-08 10:24:56 +01:00
Pino Toscano
12c605f8fa daemon: drop program_name definition
It was previously needed by the 'error' module of gnulib; recent
versions are able to get the name of the current program on their own.
2016-09-08 09:57:15 +02:00
Pino Toscano
eea210dbf7 Use the getprogname gnulib module
Make use of the recently added 'getprogname' module in gnulib: replace
our guestfs_int_program_name with the getprogname() provided by the
module, since it does the same thing, and in a portable way.
As consequence of the above, use gnulib in a couple of tests that use
getprogname().

Since guestfs_int_program_name is gone, drop the configure checks
associated with it.
2016-09-08 09:57:15 +02:00
Pino Toscano
1f65143a42 Update gnulib to latest 2016-09-08 09:57:14 +02:00
Pino Toscano
03032e2419 tests: make test-noexec-stack.pl work in non-English locales
Set C as language when running the script, as the output of readelf is
parsed: this way the parsing works also when the system locale is not
English.
2016-09-08 09:57:14 +02:00
Richard W.M. Jones
be737c9574 Version 1.35.4. 2016-09-02 23:32:01 +01:00
Richard W.M. Jones
c4b7b5d615 erlang: Split up large Erlang extension into smaller C files.
Reduce build times in this directory from about 10s to about 2s.
2016-09-02 23:14:08 +01:00
Richard W.M. Jones
76eee79a65 java: Split up large Java extension into smaller C files. 2016-09-02 23:14:08 +01:00
Richard W.M. Jones
63db9ae81f python: Split up large Python extension into smaller C files.
Reduces build time in this directory from 11s to 3s.
2016-09-02 23:14:08 +01:00
Richard W.M. Jones
d95f1d7102 build: Check generated files are included in the tarball.
When running 'make maintainer-check-extra-dist', check also that all
generated files are included in the tarball.  This is done so that end
users will not need OCaml to compile from tarball releases.
2016-09-02 23:14:08 +01:00
Richard W.M. Jones
20aa0f6496 ruby: Split up large Ruby extension into smaller C files. 2016-09-02 23:14:08 +01:00
Richard W.M. Jones
20f190617a daemon: Split up very large daemon/stubs.c file. 2016-09-02 23:14:08 +01:00
Richard W.M. Jones
a749b5d93a fish: Split up the very large fish/cmds.c file.
Make parallel compiles faster in this directory (about 8s down to 3s).
2016-09-02 23:14:08 +01:00
Richard W.M. Jones
4730f4a918 generator: Generalize the code used to split actions across files.
Previously we used an awkward hack to split up the large src/actions.c
into smaller files (which can benefit from being compiled in
parallel).  This commit generalizes that code, so that we pass a
subsetted actions list to certain generator functions.

The output of the generator is identical after this commit and the
previous commit, except for the UUID encoded into tests/c-api/tests.c
since that is derived from the MD5 hash of generator/actions.ml.
2016-09-02 23:14:08 +01:00
Richard W.M. Jones
f8978239e3 generator: Move all actions into a single list and add filter functions.
This mostly mechanical change moves all of the libguestfs API
lists of functions into a struct in the Actions module.

It also adds filter functions to be used elsewhere to get
subsets of these functions.

Original code         Replacement

all_functions         actions

daemon_functions      actions |> daemon_functions
non_daemon_functions  actions |> non_daemon_functions
external_functions    actions |> external_functions
internal_functions    actions |> internal_functions
documented_functions  actions |> documented_functions
fish_functions        actions |> fish_functions

*_functions_sorted    ... replacement as above ... |> sort
2016-09-02 23:14:08 +01:00
Richard W.M. Jones
71a95becbd generator: Add |> (revapply) operator for compat with OCaml < 4.01. 2016-09-02 23:14:08 +01:00
Richard W.M. Jones
13e47b1218 customize: Add a slow test of --hostname and --timezone settings.
Run these in real guests to ensure they really work.
2016-09-02 23:14:08 +01:00
Richard W.M. Jones
cbb70f1dee customize: Update "unassigned-hostname" etc in Debian/Ubuntu /etc/hosts (RHBZ#1372269).
Commit ab2df2e659 attempted to rewrite
/etc/hosts if it contained the old hostname.

However this wasn't done reliably for a couple of reasons:

(1) Certain Debian/Ubuntu /etc/hostname contains
"localhost.localdomain" but still has "unassigned-hostname" or
"unassigned-hostname.unassigned-domain" in /etc/hosts.

(2) Even if (1) doesn't apply, you still need to split out the
hostname and domainname parts and deal with them separately.
2016-09-02 23:14:08 +01:00
Pino Toscano
e6d9c1b328 build: improve distro check
Use /etc/os-release as first option, translating the distro name to the
current identifier used.  The other options (the release files) are left
as following checks, avoiding them if any matches.
2016-09-02 16:26:38 +02:00
Richard W.M. Jones
56e566af38 v2v: Don't remove Processor and Intelppm nodes (RHBZ#1372668).
Don't remove the Processor and Intelppm nodes since that just breaks
the device driver.

The only remaining node being removed by the original code was
"rhelscsi" (the xenpv-win driver).  I changed this so that instead of
deleting the whole node, it simply disables that driver.  If you look
at RHBZ#737600, it's not even clear that deleting nodes was the right
fix for anything.  I also renamed the function.

Reviewed-by: Roman Kagan <rkagan@virtuozzo.com>
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
2016-09-02 14:01:49 +01:00
Richard W.M. Jones
97cbddac12 build: In silent rules, differentiate between .cmi and ocamlc.
Although we happen to use 'ocamlc' to compile .mli files to .cmi,
it is used in a different mode from bytecode compilation.
2016-09-02 12:40:12 +01:00
Roman Kagan
09eb831e8d v2v:windows: prevent conflicts with PnP on firstboot
When put on new virtual hardware Windows will start driver installation
for newly discovered devices.

The problem is that it happens asynchronously and concurrently with
other activities, in particular, the firstboot scripts.  This may result
in conflicts (because a firstboot script may want to install or
uninstall a driver, etc.) and eventually in the system left in
inconsistent state.

In order to prevent it, add another firstboot script which calls a
special utility, pnp_wait, whose sole purpose is to wait until all
PnP-related activities are finished.  (It does so via a WinAPI call
which isn't available from a script so it has to be a compiled .exe.
The source code for it can be found in the corresponding directory in
https://github.com/rwmjones/rhsrvany).  This firstboot script is put
first, so that other firstboot scripts do not have to worry about
interactions with PnP manager any more.

One caveat is that on Windows XP and Windows 2003 the PnP manager always
fires the "Found New Hardware" wizard, which doesn't allow PnP to make
any progress until the user closes it.  As a result, this firstboot
script would never finish.

To work it around, follow the Microsoft KB
(https://support.microsoft.com/en-us/kb/938596) and set up a registry
key to make the the PnP manager not fire the wizard; the key is restored
to its initial state upon PnP completion.  Unfortunately this only works
on systems having the mentioned update installed; otherwise the user
will have to interact with the UI.

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
Reviewed-by: "Richard W.M. Jones" <rjones@redhat.com>
2016-09-01 11:46:13 +03:00
Roman Kagan
5eb9ea489e v2v:windows: factor out getting CurrentControlSet
It will be used in new code in a followup patch.

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
Reviewed-by: "Richard W.M. Jones" <rjones@redhat.com>
2016-09-01 11:46:12 +03:00
Richard W.M. Jones
ed607984ad Version 1.35.3. 2016-09-01 08:51:06 +01:00
Richard W.M. Jones
2efd8d0b1d v2v: Use a random pool name in the test to avoid conflicts.
If multiple tests (eg. from different branches) are running in
parallel, they will attempt to use and delete the same temporary pool.
Use a random pool name to avoid this.
2016-09-01 08:41:06 +01:00
Richard W.M. Jones
0797427807 valgrind: Add suppression for another --run-libc-freeres=no non-leak. 2016-08-31 23:16:48 +01:00
Richard W.M. Jones
6e547abe43 lib: Fix incorrect example in comment. 2016-08-31 19:36:34 +01:00
Richard W.M. Jones
092ef3234d v2v: xml: Fix misleading error message.
Other functions, such as ``-i ova'', also call Xml.parse_memory.
Therefore the error is not always from XML generated by libvirt, the
XML might be generated from other sources too.

Thanks: Ming Xie.
2016-08-31 11:24:44 +01:00
Richard W.M. Jones
8f6103d87d Version 1.35.2. 2016-08-30 23:04:57 +01:00
Pino Toscano
57c327538e Include <sys/sysmacros.h> for major()/minor()
GNU libc pulls them implicitly from <sys/types.h>, but it will not do
that at some point in the future.  Hence, include <sys/sysmacros.h>
explicitly.
2016-08-29 18:13:57 +02:00
Pino Toscano
f14dd26d36 tests: add rhbz1370424.xml to EXTRA_DIST
Fixes commit 98aa78f288.
2016-08-29 10:18:00 +02:00
Richard W.M. Jones
823ecfef39 v2v: Use separate scripts for the slow tests of real guests.
Following the same style used for the firstboot tests in the
customize/ subdirectory, use a separate test script for each real
guest that we test.  This has two advantages: (a) the tests run in
parallel (and are thus faster) and (b) automake "knows" about each
test and reports the results separately.
2016-08-27 14:07:48 +01:00
Richard W.M. Jones
58c1f7f7e6 customize: Add a slow test that firstboot works on a variety of real guests. 2016-08-27 13:53:14 +01:00
Richard W.M. Jones
c2d21340db customize: Fix firstboot scripts on Debian 6 & 7 (RHBZ#1019388). 2016-08-27 12:59:14 +01:00
Richard W.M. Jones
2e2a0264ae lib: Remove some unnecessary translation of debugging messages. 2016-08-27 12:59:14 +01:00
Richard W.M. Jones
98aa78f288 tests: Add a regression test for RHBZ#1370424.
Regression test for previous commit which just tests that
guestfs_add_domain doesn't assert-fail on guests with no port
attribute.
2016-08-27 12:59:14 +01:00
Richard W.M. Jones
9e7b564fc1 lib: Don't assert fail if port is missing in XML (RHBZ#1370424).
Thanks: Xiaodai Wang
2016-08-27 12:59:14 +01:00
Richard W.M. Jones
43e078abc0 v2v: Use unitless methods for methods which don't change the internal state.
Methods in OCaml which don't take any parameters don't require the
dummy unit arg, ie writing:

  method foo = ...

is fine.  The reason you might need the unit arg is if you need to
create a closure from the method without calling it, for example if
you need to use the method in a callback.

In lablgtk2 the convention is to use unitless methods if either: the
method shouldn't be used as a callback; or: (conceptually) the method
doesn't change the object's internal state.  Let's do that here.
2016-08-26 15:54:04 +01:00
Pino Toscano
7882fb7247 v2v: linux: adapt initrd name for Debian
The name of the initrd image on Debian-based systems is different from
what used on Fedora/RHEL/SUSE and derived; set a different regexp to
avoid making the current regexp even more complex.
2016-08-26 15:22:54 +02:00
Pino Toscano
bb3da3b074 v2v: linux: check the kernel package name for Debian
On Debian-based systems, the kernel packages are named like
"linux-image-$kver", so check for them.
2016-08-26 15:21:34 +02:00
Pino Toscano
03b9f2b967 v2v: add /boot/grub/grub.cfg as Grub2 config
This is the location of the Grub2 configuration in Debian-based systems.
2016-08-26 15:21:34 +02:00
Pino Toscano
bfa2f140d2 v2v: linux: identify Debian-based distros as `Debian_family
Identify these distributions, so it is possible to add specific code
for them.

This does not allow them as supported distributions, yet.
2016-08-26 15:21:34 +02:00
Pino Toscano
0dc0e78340 v2v: add basic support for the "deb" package manager
Implement the 'remove', 'file_list_of_package', and 'file_owner' methods
of the Linux module for the "deb" package manager (dpkg basically, on
Debian and derived distributions).

Also allow it for the main conversion code.
2016-08-26 15:21:34 +02:00
Pino Toscano
dc9e6c39f7 v2v: refactor Linux.remove
Move the actual job in an helper function, so the common bits (like the
check of the size of 'packages' and the reload of Augeas) can be done
for all the package manager implementations.

This should be code motion with no behaviour change.
2016-08-26 15:21:34 +02:00
Richard W.M. Jones
7141afd190 v2v: Use our definitions of iteri and mapi.
OCaml 3.12 (in Debian Wheezy) did not have these functions.
2016-08-26 12:52:27 +01:00
Richard W.M. Jones
bde35ca809 v2v: Small fix to POD documentation for old perl/POD.
Old perl/POD from Debian Wheezy has a bug where <name>NAME</name>
gives the error:

 Unknown E content in E</name>

even though this is in a verbatim section.  Fudge the documentation to
avoid this.
2016-08-26 12:52:27 +01:00
Richard W.M. Jones
619905ac5d builder: Rename cmdline 'ops' field.
In OCaml 3.12, type inference was not as smart and could not use local
information to disambiguate same-named fields in different structures.
The easiest fix for this is just to rename the field so it doesn't
have the same name as a field in the Customize_cmdline.ops struct.
2016-08-26 12:52:27 +01:00
Richard W.M. Jones
2c69865a70 build: Check for minimum version of libvirt in the configure script.
In Debian Wheezy with libvirt 0.9.12.3, HAVE_LIBVIRT was defined, but
HAVE_LIBVIRT_BACKEND was undefined, so src/libvirt-auth.c failed to
compile.

It's easy, and better, to check the minimum version in the configure
script.
2016-08-26 12:15:08 +01:00
Richard W.M. Jones
79e2d44365 docs: Fix release notes, Citrix Xen -> SUSE Xen.
I got the wrong end of the stick.  Cédric tested SUSE Xen,
not Citrix (upstream) Xen.
2016-08-26 10:04:19 +01:00
Richard W.M. Jones
ffa28d8722 Revert "v2v: Citrix Xen has been tested, adapt the documentation"
This reverts commit 68ba0609c7.
2016-08-26 10:04:19 +01:00
Pino Toscano
6f2090099e v2v: factor out bootloader handling
Create an object hierarchy to represent different bootloaders for Linux
guests, moving the separate handling of grub1 and grub2 in different
classes: this isolates the code for each type of bootloader together,
instead of scattering it all around.

This is mostly code refactoring, with no actual behaviour change.
2016-08-26 10:13:33 +02:00
Richard W.M. Jones
5802c7750e mllib: Add String.map function for OCaml < 4.00.0.
String.map was added in OCaml 4.00.0.  However we use this function
to implement String.lowercase_ascii etc.

Therefore include a definition of the function for older versions of
OCaml.  (Debian Wheezy has OCaml 3.12.1.)
2016-08-25 22:44:15 +01:00
Richard W.M. Jones
76c0a67d30 build: Add common CLEANFILES and DISTCLEANFILES to common-rules.mk.
By adding common CLEANFILES and DISTCLEANFILES variables to
common-rules.mk, we can remove these from most other Makefiles, and
also clean files more consistently.

Note that bin_PROGRAMS are already cleaned by 'make clean', so I
removed cases where these were unnecessarily added to CLEANFILES.
2016-08-25 16:54:34 +01:00
Richard W.M. Jones
c39d5e89c3 java: Don't try to set -source 1.5 in options.
There was some code in configure.ac dating back to 2009
(commit b9014d6a0d) which attempted to
add the javac option `-source 1.5'.  I don't think this code ever
worked.

However, if -source 1.5 is added, then you get this warning:

warning: [options] bootstrap class path not set in conjunction with -source 1.5
warning: [options] source value 1.5 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.

and that's very hard to reliably fix because you have to know somehow
a magic path.  For more details, see:

https://blogs.oracle.com/darcy/entry/bootclasspath_older_source
https://blogs.oracle.com/darcy/entry/how_to_cross_compile_for

Anyway, remove the voodoo from configure.ac.

As a side effect, this allows you to set the EXTRA_JAVAC_FLAGS
environment variable before ./configure with any extra javac flags
that you want.
2016-08-25 16:54:34 +01:00
Richard W.M. Jones
473a753382 bash completion: Add a simple test that the 'complete' command is not missing. 2016-08-25 16:54:34 +01:00
Pino Toscano
035533d67a v2v: linux: handle UEFI path for Grub1 (RHBZ#1152369)
Add also /boot/efi/EFI/redhat/grub.conf as configuration of Grub 1;
since the "grub" lens of Augeas does not handle this path, add a
transformation so Augeas can parse it.
2016-08-25 15:22:23 +02:00
Pino Toscano
cf5915aee3 New API: aug_transform
Expose the aug_transform API through the library, so it's possible to
add/remove Augeas transformations to handle files in custom places using
existing lenses.
2016-08-25 15:22:23 +02:00
Richard W.M. Jones
50a3abb95f bash completion: Add missing bash completion scripts (RHBZ#1367738).
Add new scripts for:

- guestunmount
- virt-copy-in
- virt-copy-out
- virt-customize
- virt-dib
- virt-diff
- virt-get-kernel
- virt-p2v-make-disk
- virt-p2v-make-kickstart
- virt-p2v-make-kiwi
- virt-tar-in
- virt-tar-out

Also combine the separate virt-resize script into the general script
virt-alignment-scan.  There wasn't really any reason to have separate
scripts.
2016-08-25 13:51:33 +01:00
Richard W.M. Jones
6a5b08065c bash completions: Add tip for how to run bash completions locally to README. 2016-08-25 13:51:33 +01:00
Richard W.M. Jones
4df8a099ab p2v: Implement --short-options and --long-options in virt-p2v-make-* scripts. 2016-08-25 13:51:33 +01:00
Richard W.M. Jones
2af8d07af6 fuse: Implement --long-options and --short-options in guestunmount. 2016-08-25 13:51:33 +01:00
Richard W.M. Jones
c795d50af3 fish: Move display_*_options functions to a separate file.
By moving these two functions out of the common options parsing code,
it means we don't need to depend on all the other machinery of options
parsing, such as the global variables ("verbose"), libconfig, etc.
2016-08-25 12:52:42 +01:00
Richard W.M. Jones
738c3bf4fd inspection: Fix parsing of btrfs subvolumes in /etc/fstab.
The code to parse btrfs subvol entries in /etc/fstab failed if the
entry had more than one comma-separated option, for example:

/dev/sda4 /home btrfs rw,user,subvol=foo 0 0

This commit fixes that code to use Augeas correctly.

Fixes commit 7ba0e10501.

Reported by: Zhongfu Li
https://bugs.launchpad.net/ubuntu/+source/libguestfs/+bug/1615337
2016-08-25 11:08:15 +01:00
Richard W.M. Jones
ecbf093850 v2v: Allow libvirt >= 2.1.0 to be used for Xen and vCenter conversions.
Libvirt >= 2.1.0 now allows you to open files which have a "json:"
QEMU pseudo-URL as backingfile, whereas previously it would fail hard
in this case (RHBZ#1134878).

When virt-v2v performs conversions from Xen (over SSH) or vCenter
(over HTTPS) it uses these pseudo-URLs as backingfiles.  We had to
tell people to use LIBGUESTFS_BACKEND=direct to avoid libvirt in this
situation.

This commit narrows the check so it will now only print the error if
libvirt < 2.1.0 and LIBGUESTFS_BACKEND=direct is not set.  Also the
error is modified to tell users they can either upgrade libvirt or set
LIBGUESTFS_BACKEND=direct to work around the problem.

Note there is not an easy way apart from checking the version number
of libvirt to tell if the json pseudo-URL is supported.

As a side-effect, this commit also prints the libvirt version number
in debugging output when virt-v2v starts up, which is sometimes useful
information for narrowing down bugs (it is in fact already printed by
libguestfs, so this is duplicate information, but it's a bit easier to
find when it's at the top of the debug).

Thanks: Peter Krempa.
2016-08-25 09:02:01 +01:00
Richard W.M. Jones
6502a7b831 v2v: Separate out machine="q35" and <smm> properties.
This is a simple refactoring of
commit 913dd8a087.
2016-08-23 17:23:10 +01:00
Pino Toscano
e7e446c926 mllib: do not assume $PATH is set
Make 'which' gracefully handle the case where $PATH is not set
(it will raise Executable_not_found, but that is the expected thing to
do).

Related to RHBZ#1367839.
2016-08-23 16:11:30 +02:00
Richard W.M. Jones
c711b51709 aarch64: uefi: Fix the build on aarch64.
Fixes commit 0c396650b0.
2016-08-18 16:13:12 +01:00
Richard W.M. Jones
913dd8a087 v2v: Use OVMF secure boot file (RHBZ#1367615).
From RHEL 7.3, Red Hat have decided to only compile the secure boot
version of OVMF on x86-64, with flags -D SECURE_BOOT_ENABLE -D SMM_REQUIRE.

The filename has also changed to reflect this - it is now
/usr/share/OVMF/OVMF_CODE.secboot.fd.  The old file
/usr/share/OVMF/OVMF_CODE.fd is no longer shipped.

However switching to using this variant of OVMF for UEFI guests is not
just a matter of changing the filename.  The new OVMF variant won't
run unless we also change:

 - The qemu machine model, from the default ("pc" ==
   "pc-i440fx-rhel7.3.0" or later) to Q35 ("q35" == "pc-q35-rhel7.3.0"
   or later).

 - Add <smm> under <features>.

 - Set <loader ... secure="yes">.

NB: On RHEL the changes requires qemu-kvm-rhev.  It is no longer
possible to convert UEFI guests using the basic qemu-kvm.

Thanks: Laszlo Ersek, Ming Xie.
2016-08-18 14:48:51 +01:00
Richard W.M. Jones
0c396650b0 Generate the lists of UEFI firmware paths.
Previously we had a list of UEFI paths in src/uefi.c, which was
accessed in virt-v2v using a private (guestfs_int_*) API and some C
binding code.  This was clumsy and required the paths to be replicated
in the virt-v2v unit tests.

Instead just generate the list of paths from the generator, creating
src/uefi.c and v2v/uefi.ml with the same content.

Remove the C bindings and the virt-v2v unit tests associated with UEFI
paths.
2016-08-18 14:48:51 +01:00
Pino Toscano
17a9712126 v2v: linux: simplify RPM database cleaning
Iterate on the array directly, instead of converting it to a list to do
the same; also, avoid a temporary variable for it.
2016-08-18 14:00:43 +02:00
Pino Toscano
5991ce1c2a build: add silent rules for jar 2016-08-18 13:00:27 +02:00
Richard W.M. Jones
c5a06ae1ad v2v: test-harness: Print the full path of the virt-v2v binary under test. 2016-08-17 17:13:41 +01:00
Richard W.M. Jones
5c03a2ca8b v2v: OVMF is now fully open source, fix the man page. 2016-08-17 14:36:51 +01:00
Richard W.M. Jones
326200c433 Version 1.35.1. 2016-08-16 15:06:17 +01:00
Richard W.M. Jones
dd22e376c4 v2v: Add -o discard option when fstrimming.
This *may* be required by some filesystems in order for fstrim to
work.  I'm not actually sure if this is true, but it's what
virt-sparsify --in-place does, and that utility has been tested a lot
more in regards to trimming.
2016-08-16 13:22:25 +01:00
Richard W.M. Jones
66816e1133 v2v: Make fstrim warning clearer (RHBZ#1366456).
This reverts the change made for RHBZ#1168144.  The warning is now
always displayed.

It would be nice to make the warning actionable, but there is not a
lot that end users can do since fstrim is such a complex topic
interacting with all filesystem and storage layers.
2016-08-16 13:22:25 +01:00
Richard W.M. Jones
d33e28c988 p2v: Fix s/is/are/ in GUI message.
I reordered the 'and' clause to make it sound a bit more natural.

Thanks: Junqin Zhou.
2016-08-16 13:22:25 +01:00
Tomáš Golembiovský
7eab864c21 v2v: linux: accept 'sr' devices in fstab
Do not print warning for 'sr' devices when converting fstab. Not all
systems create the /dev/cdrom symlink for SCSI CD-ROM devices. Moreover,
on systems with multiple CD-ROMs, having entries for /dev/sr* devices
may be inevitable.

RWMJ: Use String.is_prefix instead of String.find, to more accurately
match on the device name.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
2016-08-11 09:00:33 +01:00
Tomáš Golembiovský
68ba0609c7 v2v: Citrix Xen has been tested, adapt the documentation
Conversion from Citrix Xen has now been tested and should work. Remove
the comment about it from the documentation.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2016-08-11 08:58:30 +01:00
Matteo Cafasso
42bccd78b8 sleuthkit code cleanup
Small cosmetic changes.

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2016-08-08 22:25:04 +01:00
Pino Toscano
8a9c747ff6 sparsify, v2v: use Common_utils.absolute_path
Use the common function for ensuring a path is absolute; it should not
change the behaviour at all.
2016-08-08 17:25:40 +02:00
Pino Toscano
98dea4978d v2v: disk: strip only common extension (RHBZ#1365005)
In disk input mode, to determine the guest name strip the extension from
the filename only if it's a very well extension for disk images.
2016-08-08 17:21:03 +02:00
Richard W.M. Jones
48e4012d03 website: Get rid of some quite old branches.
RHEL 7.3 will have 1.32.6, so we should encourage people to move to at
least that version for recent features.

Fixes commit f4e4a668ae.
2016-08-08 13:57:17 +01:00
Richard W.M. Jones
2c3b829bd8 Version 1.35.0. 2016-08-08 13:46:24 +01:00
Richard W.M. Jones
4c84033d8c Version 1.34.0. 2016-08-08 12:49:58 +01:00
Richard W.M. Jones
f4e4a668ae Update website for 1.34 release. 2016-08-08 12:37:25 +01:00
Richard W.M. Jones
4ad5652c99 Update release notes.
Also remove "draft" logo since these are close to being finalized
for the 1.34 release.
2016-08-08 12:31:15 +01:00
Tomáš Golembiovský
4ddc0add85 v2v: fix regex replacement in grub2_update_console
The replacement string was wrong. There are only two match groups in the
regular expression, not three.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2016-08-08 11:00:15 +02:00
Tomáš Golembiovský
56e5cf14e9 v2v: do not hide the error, rather report it
The Invalid_argument exception is there to catch unexpected situation
when rpm returns no output. Such situation should be reported rather
then hidden.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2016-08-05 18:09:10 +02:00
Pino Toscano
34c7215a2f ruby: ignore -Wshift-overflow warnings
There seems to be a -Wshift-overflow bug in a Ruby 2.3 header, so
add a GCC diagnostic override to avoid build failures with
--enable-werror.
2016-08-05 18:09:10 +02:00
Richard W.M. Jones
71de3d49a3 sparsify: Add a regression test for RHBZ#1364347.
Add a regression test for the previous commit.
2016-08-05 15:10:50 +01:00
Richard W.M. Jones
4d5335a56d sparsify: Warn instead of error if a filesystem cannot be fstrimmed (RHBZ#1364347).
Thanks:  Xianghua Chen
2016-08-05 15:10:50 +01:00
Richard W.M. Jones
116a41d048 daemon: fstrim: Turn "discard operation is not supported" into ENOTSUP.
Because we run the external fstrim command we don't have access to the
kernel errno when it fails.  However in the case where it prints this
specific error message, turn that into errno ENOTSUP.
2016-08-05 15:10:50 +01:00
Richard W.M. Jones
97b6b4a4eb sparsify: Exit with error code 3 if fstrim is not supported by the appliance.
This replaces the indirect exception catching from
commit 931aec5b88 with a direct feature
test.

Fixes commit 931aec5b88.
2016-08-05 12:16:54 +01:00
Richard W.M. Jones
7de25f7d71 build: Line up "OCAMLOPT" with other silent rules.
Tidies up commit 0b94c4d3bb.
2016-08-05 10:37:46 +01:00
Richard W.M. Jones
a11a7ebbc3 build: Add silent rules for podwrapper.
Also quietens the podwrapper script itself, as there is no reason to
print 'wrote <output>' for each output file.
2016-08-04 23:33:58 +01:00
Richard W.M. Jones
320b053178 Version 1.33.49. 2016-08-04 22:34:42 +01:00
Pino Toscano
0b94c4d3bb build: add simple custom silent rules for automake
Add makefile variables to enable silent rules for simple command
invocations, such as ocamlc, ocamlopt, javac, and erlc.

This reduces the log output when building with silent rules, still
showing the full command lines otherwise.
2016-08-04 16:18:33 +02:00
Pino Toscano
5630e0eb05 dib: add --drive-format
Allow to specify the format of the helper drive, to avoid relying on the
format autodetection.  This is the same approach used also in all the
other tools.
2016-08-04 14:43:21 +02:00
Pino Toscano
6e198634ac firstboot: make SysV symlinks as relative on Debian
Turn the rc.d symlinks for the guestfs-firstboot service as relative,
instead of absolute paths: the result is the same (the service works the
same), and this way is more coherent with symlinks created by
update-rc.d.
2016-08-04 13:53:31 +02:00
Pino Toscano
d394e01c2b firstboot: rename systemd and sysvinit
Currently we install a systemd service named firstboot.service and a
SysV service named virt-sysprep-firstboot.  On systems where systemd is
the init system and runs with the SysV compatibility, the different
names make systemd handle them as different services, and thus trying to
run the firstboot script runner twice.

Rename both the systemd service and the SysV one to guestfs-firstboot:
the new name is less generic, and allows the systemd service to be
shadowed by the SysV service (and thus running just once).

Also cleanup the old services: the old SysV service can be removed
directly, since its former name had "virt-sysprep" in it, and so there
could not be much room for confusion and conflict.  Regarding the old
systemd service: to avoid leaving it behind, a simple cleanup strategy
is in place, checking the content of the old firstboot.service to really
ensure we are removing one of our versions of this file.
2016-08-04 13:44:03 +02:00
Pino Toscano
1d32637c64 dib: export FS_TYPE for elements
Export FS_TYPE for the elements, so they can know what is the filesystem
created.

This was implemented in diskimage-builder upstream as
commit be521bdec6233530cc952be246a66f1957b0dd58.
2016-08-04 12:16:35 +02:00
Pino Toscano
8ad870e563 dib: add docker output format
Implement the "docker" output format, to import an image into docker.

This was implemented in diskimage-builder upstream as
commit 1187f9d5df6d6eddba478ac75d3834391480755f and
commit edc06a20e57bdf0a9a03949b54395008d73520dc.
2016-08-04 12:16:35 +02:00
Richard W.M. Jones
d14a8f500c Version 1.33.48. 2016-08-04 10:00:06 +01:00
Richard W.M. Jones
9d387b5eeb po: Update POTFILES. 2016-08-04 09:52:07 +01:00
Richard W.M. Jones
9fc0418db5 mllib: _exit should return 'a
Fixes commit 0dfa96c043.
2016-08-04 09:27:43 +01:00
Richard W.M. Jones
bdfce1995b Version 1.33.47. 2016-08-03 16:43:54 +01:00
Pino Toscano
d12be6625a dib: rework run of extra-data.d hooks (RHBZ#1362354)
Instead of running them before lanching the appliance with the disks and
then uploading the result after root.d hooks run, mount the root in the
local temporary directory using FUSE and then run the hooks on the
guest.  Other than being closer to what diskimage-builder does, it also
avoids issues with the extra-data.d scripts assuming to find things
already, and we don't error out while trying to unpack files on the
guest.

Since virt-dib requires FUSE now, build it only if FUSE is supported.
2016-08-03 16:48:11 +02:00
Pino Toscano
5077c02046 mllib: move _exit from v2v as Exit module
Move the OCaml binding to C _exit to an own module.

Just code motion, adapting v2v in the process.
2016-08-03 15:01:59 +02:00
Pino Toscano
2cb053d3fe mllib: check for executable existance in run_command (RHBZ#1362357)
run_command uses Unix.create_process which forks a child process, and
executes execve: the latter fails when the executable does not exist,
triggering the exit which, in older OCaml versions [1], also runs the
at_exit handlers.

Since there is not much that can be done to avoid this on the OCaml
side, to keep run_command working also in older OCaml version then
manually search for the existance of the given executable, exiting with
code 127 (as a shell does) in this case.

[1] http://caml.inria.fr/mantis/view.php?id=7209
2016-08-03 10:07:04 +02:00
Pino Toscano
398b940ea4 mllib: move which and its exception from dib
Rename it from "tool" to "executable" in the process, but otherwise
it is just code motion (with minimal adjustments in dib).
2016-08-03 10:07:04 +02:00
Richard W.M. Jones
c8c181e8d9 launch: libvirt: Autodetect backing format for readonly drive overlays (RHBZ#1354335).
If the user doesn't specify a format (ie. they want autodetection),
and the drive is set to read-only, previously we created a qcow2
overlay to protect the drive but didn't set the backing_fmt field.
However libvirt disabled this so now libvirt doesn't work at all on
qcow2 files that have no backing_fmt field set.

We must therefore do autodetection in libguestfs and use that to set
the backing_fmt field.

We were already doing autodetection in the non-readonly case, so this
commit refactors that code into a new function
("get_source_format_or_autodetect") and uses it on the readonly path
too.
2016-08-02 20:33:57 +01:00
Richard W.M. Jones
3b9cc56a45 v2v: linux: Ignore unused string return value of 'file_owner'.
Because we didn't give the type of 'g' there wasn't sufficient
information for the type checker to pick up this problem.  By
specifying the real type of 'g' in a type annotation, that reveals the
problem.

Thanks: Pino Toscano, Nyoxi on IRC.
2016-08-02 12:11:32 +01:00
Tomáš Golembiovský
75d3c5d3c9 v2v: fixed file_owner function
What was happening in file_owner function did not match the description
in the comment. When a path is owned by multiple packages the returned
string was in fact a concatenation of the names of all packages that own
it. E.g. for `Linux.is_file_owned g inspect "/etc"` the returned value
was "filesystemyum" (i.e. "filesystem" + "yum").

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2016-08-01 15:37:39 +02:00
Richard W.M. Jones
1d3f075502 v2v: xml: Rename internal xpath_new_context function.
This change is not necessary, but is consistent with the naming scheme
of the rest of the code in this file.
2016-07-31 17:20:08 +01:00
Richard W.M. Jones
9e0022cea8 v2v: xml: Link to libxml2 website.
No change, just finessing the documentation.
2016-07-31 17:04:16 +01:00
Pino Toscano
19b0ae6c65 lvm: do not pass --cache to vgscan
This breaks lvm setups with no lvmetad, and it seems to not be needed
even with lvmetad.

Reverts parts of commit 2c4f154b91.
2016-07-29 17:21:25 +02:00
Pino Toscano
12c05d5c36 osinfo: fix reading of shared osinfo DB
$OSINFO_SYSTEM_DIR (or its /usr/share/osinfo fallback) represents the
top-level directory of the osinfo data, while we need to read the "os"
subdirectory of it.

Fixes commit c2ae46a9eb.
2016-07-29 11:36:37 +02:00
Richard W.M. Jones
fa2949b7a5 docs: In API overview, add note that you should free returned values. 2016-07-29 09:09:17 +01:00
Pino Toscano
11a359c76c osinfo: do not assume every media is an installer
The osinfo has an "installer" attribute in <media>, which defaults to
true, and there are few entries which are marked as not.
2016-07-28 15:53:26 +02:00
Pino Toscano
bfedfb6e3c osinfo: simplify reading of attributes from <media>
Directly query the attributes in the media node, instead of using an
XPath expression to read it.

Saves ~10ms when parsing the libosinfo DB on a Fedora 24 installation
(other than making the code easier).
2016-07-28 15:32:31 +02:00
Pino Toscano
38ef48cde5 utils: add new CLEANUP_XMLFREE cleanup, to call xmlFree()
Small cleanup helper to dispose xmlChar* buffers.
2016-07-28 15:30:49 +02:00
Pino Toscano
2ed76e6f17 build: improve Gtk check
Check the presence of Gtk properly depending on the value of --with-gtk:
if a specific version is chosen, then let PKG_CHECK_MODULES fail if that
version if not found, otherwise fallback from gtk3 to gtk2 to no gtk.

Also move few common AC_SUBST in a single place.
2016-07-28 10:56:58 +02:00
Richard W.M. Jones
108509ec19 docs: hacking: Add a section describing the build system. 2016-07-27 19:02:49 +01:00
Richard W.M. Jones
7561d1bcae docs: hacking: Improve documentation on how OCaml programs are built. 2016-07-27 19:02:27 +01:00
Richard W.M. Jones
c008dd15a7 Version 1.33.46. 2016-07-27 15:09:18 +01:00
Pino Toscano
0a808d986a builder: fix EOF check with flex >= 2.6.1
It looks like flex 2.6.1 changed [1] the return code for EOF in
yyinput.  Therefore, use the right value depending on the version of
flex which generates the lexer.

[1] f863c9490e
2016-07-27 15:24:29 +02:00
Pino Toscano
a6330e9d3a appliance: run systemd-tmpfiles also for /run
Setup the volatile /run in the appliance also with the tmpfiles
configurations available.  In particular, setting up correctly the lvm
bits allow lvmetad to run.
2016-07-26 18:24:40 +02:00
Pino Toscano
7367945647 daemon: lvm: improve filter for LVs with activationskip flag set
Commit 2e16e3e993 added lv_active=active
as additional condition when listing LVs, to ignore those with the
activationskip flag set.  OTOH, this check is too broad, and matches
also other kind of LVs.

Change the condition to lv_skip_activation!=1, so matching precisely
what was meant, and only that.

Related to: RHBZ#1306666
2016-07-26 18:24:39 +02:00
Pino Toscano
2c4f154b91 daemon: lvm-filter: start lvmetad better
Currently lvmetad is started in init, and thus using the system
(= appliance) configuration of lvm.  Later on, in the daemon, a local
copy of the lvm configuration is setup, and set it for use using the
LVM_SYSTEM_DIR environment variable: this means only the programmes
executed by the daemon will use the local lvm configuration, and not
lvmetad.

Thus manually start lvmetad from the daemon, right after having setup
the local lvm configuration, and still without failing if it cannot be
executed.

Additionally, since lvmetad now respects the right configuration, make
sure to update its cache when rescanning the VGs by passing --cache to
vgscan.
2016-07-26 18:24:31 +02:00
Pino Toscano
5ce19cec4c daemon: lvm-filter: set also global_filter
When editing the lvm configuration to set the LVM filter, edit the
'global_filter' key in addition to 'filter': the latter is not used when
lvmetad is running, when only the former works.
2016-07-26 16:58:53 +02:00
Pino Toscano
ca1f8efd29 daemon: lvm: change the separator character to '\r'
Commit b91b39e06a changed the separator to
':', although this creates parsing issues when there are fields with
colons (for example lv_tags=imgbased:pool).

Change once more the separator, but this time using a non-printable
character such as '\r': while it will produce uglier debug logs, this
should greatly reduce the possibilities of conflicts with texts of
metadata.
2016-07-26 14:46:49 +02:00
Pino Toscano
1b8e6c7880 osinfo: map "sled" as "sles"
The "sles" distribution string in libguestfs represents both SLES and
SLED, so map the osinfo descriptions of "sled" distributions as "sles".
2016-07-26 11:55:31 +02:00
Pino Toscano
9dc3aa3786 osinfo: parse also single-digit version numbers
Switch to guestfs_int_version_from_x_y_or_x to parse version numbers --
although, restrict the parsing to what could look like a valid version
number, to discard quickly version strings like "unknown".

This makes sure that Debian, Fedora, Mageia, and SLED ISOs have the
right version number.
2016-07-26 11:55:31 +02:00
Pino Toscano
c2ae46a9eb osinfo: revamp db reading (RHBZ#1359652)
More recent versions of libosinfo switched the internal directory with
the XML files of OSes to a different layout (still with the same XML
format), causing libguestfs to not read them anymore.  Furthermore, the
internal directory is going to disappear soon, replaced by a public
osinfo database [1].

Revamp the way libguestfs reads the data: first try the upcoming osinfo
layout, falling back to the current libosinfo layout (which is the same
as osinfo), and then to the old flat layout.

[1] https://gitlab.com/libosinfo/libosinfo/blob/master/docs/database-layout.txt
2016-07-26 11:54:31 +02:00
Richard W.M. Jones
d5a8f82887 Use 'const' for stack integers where possible.
May improve optimization possibilities in a few cases.
2016-07-26 10:43:45 +01:00
Pino Toscano
4e391aad67 po: fix markups in Japanese translation
Avoid extra spaces in L<>, they cause the POD to be invalid.
2016-07-26 10:29:45 +02:00
Pino Toscano
91d17dfe7b po: fix placeholder in Ukrainian translation
__SOMETHING__ strings are placeholders which must be left as-is.
2016-07-26 10:29:00 +02:00
Pino Toscano
7b90ff3fc8 Limit GCC 6 pragmas.
-Wnull-dereference and -Wshift-overflow are new warnings in GCC 6, so do
not try to disable them with pragmas on older GCC versions.

Fixes commit a8e15ea924.
2016-07-25 19:45:03 +02:00
Richard W.M. Jones
5363502a38 Update gnulib to latest.
As a side effect this enables the -Wnull-dereference &
-Wshift-overflow warnings.
2016-07-24 12:18:10 +01:00
Richard W.M. Jones
a8e15ea924 daemon: Ignore -Wnull-dereference & -Wshift-overflow warnings.
One -Wnull-dereference warning is real: we deliberately cause a
segfault in one of the tests.

There is a -Wshift-overflow bug in a Gtk 2 header.

The others are the result of shortcomings in GCC.

In all cases we have to add GCC diagnostic overrides to ignore
the warnings when compiling with ./configure --enable-werror.
2016-07-24 10:55:52 +01:00
Richard W.M. Jones
d0e263248d Update translations from Zanata. 2016-07-23 23:26:16 +01:00
Richard W.M. Jones
5fe8149e00 df: Fix uninitialized variable when compiled without libvirt. 2016-07-23 23:08:42 +01:00
Richard W.M. Jones
1fac79e869 Version 1.33.45. 2016-07-22 17:34:50 +01:00
Pino Toscano
8e57268dd4 static const char *str -> static const char str[]
Make all the static constant strings as char arrays, so they can be
fully stored in read-only memory.
2016-07-22 13:16:02 +02:00
Richard W.M. Jones
8689bfa437 p2v: Remove dead code from virt-p2v kickstart.
Including some code which looks like it is disabling SELinux, but is
in fact commented out -- see previous commit.
2016-07-21 22:36:07 +01:00
Richard W.M. Jones
fcce1f694e Revert "p2v: Disable SELinux in virt-p2v-make-disk."
The commit claimed that SELinux was disabled in the
virt-p2v-make-kickstart script, and so this was just making things
consistent.  However this is not true.  SELinux *is* enabled in the
kickstart version.  There is some code to disable it, but it is
commented out (admittedly it's hard to tell because the code is buried
in a multi-line sed expression).

The commit message also claimed (this time correctly) that the
'--selinux-relabel' step caused an extra reboot each time virt-p2v is
run from the ISO.  However we have recently fixed this so it can
usually do the relabelling during the build, not at boot time, so this
is no longer a problem.

This reverts commit 25ffcc7d43.
2016-07-21 22:34:58 +01:00
Richard W.M. Jones
74b13550db Update release notes. 2016-07-21 21:17:14 +01:00
Pino Toscano
bb842b415e customize: use --noconfirm when installing Arch Linux packages
Otherwise the installation will fail right away, since pacman by default
asks for confirmation of the operation.
2016-07-21 13:53:27 +02:00
Pino Toscano
a5176e6014 customize: password: use SHA-512 on Void Linux and Arch Linux
They are rolling distributions, so we can assume they have a glibc
version greater than 2.7 (cca Oct 2007).
2016-07-21 13:53:27 +02:00
Richard W.M. Jones
5e65da07fa podcheck: Check tool --help output.
For OCaml tools this does essentially nothing useful because the
--help output is automatically generated from the options, and so
cannot be wrong.  However for C tools this is a useful check.

It would be nice to generate C tools --help output, but there isn't
enough information in the getopt data to do that.

This commit also includes fixes to the --help output for a few tools.
2016-07-21 12:45:15 +01:00
Matteo Cafasso
a77c6aac81 Added download_blocks API test
The test shows how the function can be used to retrieve deleted data
from a disk partition.

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2016-07-20 15:26:50 +02:00
Matteo Cafasso
007ef02e7d New API: download_blocks
This function allows to download file system data units (blocks) from
the given partition.

The API can be used to detect data hidden within filesystem bad blocks
or slack space.

Moreover for filesystems such as Ext3 and Ext4, this function is the
only way to retrieve deleted files. An example is given in the function
tests.

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2016-07-20 15:26:50 +02:00
Pino Toscano
5996080f7c v2v: make virsh command quiet if v2v is quiet (RHBZ#1358142)
Pass -q to virsh if virt-v2v was run with -q, to reduce its output in
quiet mode.

Unfortunately this does not currently work in virsh as it should, see
RHBZ#1358179, so only after that bug is fixed this change can actually
take effect.
2016-07-20 13:40:12 +02:00
Richard W.M. Jones
fb1e9267fe mllib, customize: Don't add -g option to ocamlmklib command line.
ocamlmklib -g does not work in OCaml 4.01.0.  It does work (and is
desirable) in OCaml 4.02.2.  However since we would like to support
back to OCaml 3.11, we cannot use it.
2016-07-20 12:24:10 +01:00
Pino Toscano
08a7c5c47b daemon: mkfs: allow setting labels for f2fs filesystems
Pass -L $LABEL to set the label of a f2fs filesystem when creating it.
2016-07-20 10:17:04 +02:00
Pino Toscano
52d4e566cc appliance: add f2fs-tools to the appliance
Helper tools for f2fs filesystems.
2016-07-20 10:17:04 +02:00
Richard W.M. Jones
8d518c37cd customize: Fix the test.
In libguestfs 1.33.43 we managed to release a completely
non-functional virt-customize binary (it ran without error but did
nothing at all, whatever command line arguments you gave it).

Improve the test so this cannot happen again.
2016-07-19 19:01:54 +01:00
Pino Toscano
326f37d547 tests: check documented tool options also for inspector and p2v
This includes the additional tests, and the few needed fixes.

Followup of commit 08e27451a6.
2016-07-19 15:21:27 +02:00
Richard W.M. Jones
093f1ee546 Version 1.33.44. 2016-07-19 14:05:24 +01:00
Richard W.M. Jones
08e27451a6 tests: Add script to check documented tool options match actual options.
podcheck.pl is run as part of the tests to perform various checks on
the documentation and the tool.

Currently we check only that the documented options matches the
options that the tool implements and vice versa.  This commit would
also allow us (in future) to check --help, --long-options,
--short-options, --version output.

This commit includes scripts to run the tests and various fixes to the
manual pages to ensure that the tests pass.
2016-07-19 13:06:14 +01:00
Richard W.M. Jones
1fa3bf14e5 builder: Fix rhel-ppc64le guestroot to match reality. 2016-07-19 13:06:14 +01:00
Richard W.M. Jones
8886f2951d fish, format, fuse: Remove bogus short options.
For guestfish, guestmount, remove '?' from short options.  Currently
those tools don't process -?, so I believe these are erroneous:

  $ guestfish -\?
  Try `guestfish --help' for more information.

For virt-format, the -c, -d and -q options are removed.  These options
just give errors because they appear in the short options list but not
in the case statement.
2016-07-19 12:32:09 +01:00
Richard W.M. Jones
d03e8f461e builder: Fix URL for RHEL 7.2 ppc64le images. 2016-07-19 12:32:08 +01:00
Richard W.M. Jones
faf41e7fbb mllib: tests: Add tests to EXTRA_DIST.
Fixes commit 41a1b8a5ca.
2016-07-18 18:50:02 +01:00
Pino Toscano
34cdb1145e builder: improve the handling of list formats
Store them directly in List_entries, an adding helper function to
convert from string.

Also use Getopt.Symbol for them, so there is no need to manually reject
invalid formats.
2016-07-18 18:21:41 +02:00
Pino Toscano
99797a3d2f mllib: Getopt: add Getopt.Symbol
Introduce a new type of option to allow a value out of a fixed choice,
much like Arg.Symbol.
2016-07-18 18:20:57 +02:00
Richard W.M. Jones
41a1b8a5ca mllib: tests: Add tests of the new Getopt module. 2016-07-18 17:05:42 +01:00
Richard W.M. Jones
ba2cf9a2eb mllib: Use L"..." and S '...' for long and short options.
There is also an M"..." variant which acts the same way as
L but handles the annoying virt-v2v two letter options.
2016-07-18 17:01:22 +01:00
Richard W.M. Jones
4ac1744db4 mllib: getopt: Further fix int parsing.
Don't allow suffixes on integers, and fix the bounds to match the
definitions of Min_long and Max_long in <caml/mlvalues.h>.

Fixes commit 66b54bfefe.
2016-07-18 16:50:18 +01:00
Richard W.M. Jones
bef2d2f30e rescue: Implement virt-rescue -w option.
Documented, but never implemented.
2016-07-18 16:50:18 +01:00
Richard W.M. Jones
7352071dbf diff: Implement virt-diff --long-options.
The code was only partially implemented so the option did
not function.
2016-07-18 16:01:05 +01:00
Pino Toscano
b7e7fe396d mllib: Getopt: point to man page as additional help
On error, point also to the man page of the current tool in addition to
'$TOOL --help'.
2016-07-18 15:35:25 +02:00
Richard W.M. Jones
c2fda2c1f2 build: Factor out definition of BEST and OCAMLLINKFLAGS.
No change, just refactoring.
2016-07-18 14:11:22 +01:00
Richard W.M. Jones
2c6bfccb06 build: Fix dependencies on mllib and customize.
Binaries should be rebuilt if mllib.cma/mllib.cmxa or
customize.cma/customize.cmxa change.

Fixes commit 1e2877c6f4.
2016-07-18 14:10:28 +01:00
Richard W.M. Jones
fde0b73597 customize: Build virt-customize properly.
Fixes commit 6a0fe553b9.
2016-07-18 13:54:23 +01:00
Pino Toscano
66b54bfefe mllib: Getopt: fix integer parsing
Since we are using gnulib already, make use of xstrtol to parse the
integer arguments to avoid extra suffixes, etc.

Fixes commit 0f7bf8f714.
2016-07-18 10:58:14 +02:00
Richard W.M. Jones
4920ff57c9 Version 1.33.43. 2016-07-14 15:44:03 +01:00
Richard W.M. Jones
3bf9420f94 builder: Add new centos-aarch64.sh script to EXTRA_DIST.
Fixes commit c168638ae7.
2016-07-14 15:40:42 +01:00
Richard W.M. Jones
6a0fe553b9 customize: Build a customize.cma/customize.cmxa library.
Instead of linking with individual objects, which is very tedious,
build a proper library and link virt-builder, virt-customize and
virt-sysprep to it.

This makes the binaries a tiny bit smaller because .cmxa/.a files
allow unused code to be removed by the linker, whereas explicitly
linking .cmx/.o files does not.
2016-07-14 15:40:42 +01:00
Richard W.M. Jones
1e2877c6f4 mllib: Build a mllib.cma/mllib.cmxa library.
Instead of linking with individual objects, which is very tedious,
build a proper library and link the other tools with it.

This doesn't make the resulting binaries any larger.
2016-07-14 15:28:10 +01:00
Richard W.M. Jones
fc11490484 v2v: linux: Use new SELinux_relabel module to relabel Linux guests. 2016-07-14 15:28:10 +01:00
Richard W.M. Jones
35bac3a650 lib: Deprecate old SELinux APIs, rewrite SELinux documentation (RHBZ#1152825).
Also turns the --selinux option of guestfish, guestmount and
virt-rescue into a no-op -- it didn't work before so this is
effectively no change.
2016-07-14 15:28:10 +01:00
Richard W.M. Jones
b6e92b1100 builder: Use virt-sysprep --selinux-relabel when preparing templates.
Don't need to be clever now.
2016-07-14 15:28:10 +01:00
Richard W.M. Jones
f3c69fe60b customize: Add module for doing SELinux relabel of filesystem (RHBZ#554829, RHBZ#983969, RHBZ#1089100).
This implements the --selinux-relabel option for virt-customize,
virt-builder and virt-sysprep.  There is no need to autorelabel
functionality now.

Thanks: Stephen Smalley
2016-07-14 15:28:10 +01:00
Richard W.M. Jones
6ec75f8cfe tests: Add a test of the setfiles API. 2016-07-14 15:28:10 +01:00
Richard W.M. Jones
9d205f1c28 New API: selinux_relabel - SELinux relabel parts of the filesystem. 2016-07-14 15:28:10 +01:00
Pino Toscano
fd60be9509 appliance: touch /etc/fstab when enabling the network (RHBZ#1224795)
Sadly, the dhclient-script shipped as part of isc-dhcp-client in Ubuntu
unconditionally reads from /etc/fstab without checking for its
existence.  Since no package holds /etc/fstab, this file will not exist
in the appliance, cause dhclient to fail (actually keep looping calling
the failing dhclient-script) when the network is requested.

As a workaround, touch /etc/fstab just before enabling the network: if
that file exists nothing changes, while an empty file will be available
in the other case, making at least dhclient-script in Ubuntu working.
2016-07-14 14:09:18 +02:00
Richard W.M. Jones
eb22e2d36e v2v: Move augeas_debug_errors (renamed debug_augeas_errors) to common code.
Since the function uses the StringMap module, I also had to
move this to mllib.

The function is renamed and the 'if verbose ()' part is moved into the
function, but apart from that, it's all just code motion.
2016-07-14 11:40:22 +01:00
Pino Toscano
412dedd029 po: fix markups in Ukrainian translation
- remove extra \n at end of msgstr (not present in its msgstr)
- fix printf format specifier
2016-07-14 11:02:36 +02:00
Pino Toscano
7a404b1110 mllib: Getopt: support hidden options
Add a dummy description value to mark an option as "hidden", so it will
not be shown in the help text.

Mark few options as hidden:
- common: --short-options, --long-options, --debug-gc
- virt-sysprep: --dump-pod, --dump-pod-options

Since --debug-gc is now really considered internal, it is no more
documented.
2016-07-14 10:58:56 +02:00
Pino Toscano
0f7bf8f714 OCaml tools: add and use a Getopt module
Add a new Getopt module to mllib, to parse command line arguments with
handlers close to the ones used with Arg, but using getopt(3) (actually
getopt_long_only) to do the real parsing.  This allow us to provide
options for OCaml tools with a syntax similar to the C tools, and use
the additional features getopt offers and Arg does not.
Getopt now handles every part of the command line handling, including
the output of short & long options.

Do a single-step conversion of Common_utils and all the OCaml tools to
the syntax of Getopt.

Move a couple of utility functions from Common_utils to Getopt, since
they fit better there (and Common_utils cannot be used in Getopt, as
the former already uses the latter).

As side-change due to the conversion, extra arguments for sysprep
operation can have more keys for the same argument.
2016-07-13 18:43:32 +02:00
Pino Toscano
cbf4bbf266 i18n: fix markups in Japanese translation
Avoid extra spaces in L<>, they cause the POD to be invalid.
2016-07-13 18:15:26 +02:00
Richard W.M. Jones
c168638ae7 builder: Add CentOS aarch64 image. 2016-07-13 12:59:52 +01:00
Richard W.M. Jones
6dc3a59e73 Upload and download files to Zanata. 2016-07-12 21:43:31 +01:00
Richard W.M. Jones
a468e8b92f p2v: Set LD_LIBRARY_PATH for "remote" virt-v2v process.
In previous commit c5f12e47e4 we changed
the PATH environment variable to run the locally built virt-v2v, not
the system-installed virt-v2v.

However this meant that we were running the locally built virt-v2v
against the system-installed libguestfs.so.0.  We also need to set
LD_LIBRARY_PATH.

Fixes commit c5f12e47e4.
2016-07-12 14:48:11 +01:00
Tomáš Golembiovský
e93d4ea320 v2v: Add support for Win2016 virtio drivers
Support virtio drivers for Windows Server 2016 once they are available.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2016-07-12 08:25:29 +01:00
Richard W.M. Jones
2c7f8e9c5f utils: Clarify why some uses of gnulib are OK and others not OK. 2016-07-11 19:11:01 +01:00
Richard W.M. Jones
56eb5f36f4 Revert "utils: Allow use of gnulib in this file."
This reverts commit 975eafe4ba.
2016-07-11 19:08:41 +01:00
Richard W.M. Jones
d272cee838 python: Don't generate calls with non-existent C optargs structures.
In the case where we are building a Python dist (which can be
distributed separately), we generated calls to non-existent optargs
structures if an API was once no-optargs but had optargs added.  A
typical error was this (library: 1.32.5, Python sdist: 1.33.42):

    guestfs-py.c: In function ‘guestfs_int_py_glob_expand’:
    guestfs-py.c:9648:40: error: storage size of ‘optargs_s’ isn’t known
       struct guestfs_glob_expand_opts_argv optargs_s;

This is a simple solution to this, although it has the possible
disadvantage that such functions will not be bound at all.
2016-07-11 18:33:05 +01:00
Richard W.M. Jones
1f650932e3 python: Add documentation to guestfs-python about using pip & virtualenvs. 2016-07-11 15:47:51 +01:00
Richard W.M. Jones
c56c6e9010 python: Fix python sdist.
Since commit 83e92b4a97, utils.c
includes "ignore-value.h".  We copy utils.c into the python sdist
tarball, but it didn't not compile because of the missing header file.
Therefore we need to copy the header in too.

Fixes commit 83e92b4a97.
2016-07-11 15:46:23 +01:00
Richard W.M. Jones
4140766460 v2v: Document ports, firewall and proxy settings used by vCenter. 2016-07-11 13:39:23 +01:00
Richard W.M. Jones
711c4c923d Version 1.33.42. 2016-07-09 09:36:58 +01:00
Maxim Perevedentsev
4e0dbf94e7 sysprep: fix btrfs subvolume processing in fs-uuids
guestfs_set_uuid wants device as argument.
Moreover, btrfstune -U is unable to set uuid for subvolumes,
only unmounted partitions are supported.

Here we skip btrfs subvolumes.
2016-07-08 13:21:42 +01:00
Maxim Perevedentsev
f90185dfdf lvm: modify guestfs_is_lv to take mountable
Calling guestfs_is_lv on btrfs subvolume throws an error.
Here we workaround it by taking Mountable instead of Device
and returning 'false' for non-device mountables.
2016-07-08 13:21:42 +01:00
Maxim Perevedentsev
d6bba9bc42 mllib: add checking for btrfs subvolume
This is needed to skip btrfs subvolumes from output
of list_filesystems where device is needed.
2016-07-08 13:21:42 +01:00
Matteo Cafasso
abf85b050e filesystem_walk: more information into tsk_dirent
Access, modification, last status change and creation time in
Unix format as for statns.

Number of links pointing to a given entry.

If the entry is a symbolic link, report the its target path.

A new flag (DIRENT_COMPRESSED 0x04) indicating whether the file is
compressed using native filesystem compression support.

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2016-07-08 12:08:17 +02:00
Richard W.M. Jones
123dc018b8 mllib: Rename unshift -> push_front, push -> push_back etc.
The C++ function names are more regular.

Updates commit 1c57c71d46.
2016-07-08 09:56:47 +01:00
Richard W.M. Jones
1a3e986b61 builder: Add Fedora 24 (aarch64) image. 2016-07-07 20:36:42 +01:00
Richard W.M. Jones
7d99c2eb84 builder: downloader: More tweaks to curl code.
No functional change.
2016-07-07 18:22:09 +01:00
Richard W.M. Jones
560156d899 v2v: Use imperative list functions to simplify DOM building code. 2016-07-07 18:13:07 +01:00
Richard W.M. Jones
6a3416361b v2v: Don't open DOM module in output_rhev and output_vdsm.
I think this is left over from before we moved the OVF code
out to its own module.
2016-07-07 18:13:07 +01:00
Richard W.M. Jones
442092a305 Replace 'xs := x :: !xs' with 'unshift x xs'.
In one case, I used prepend instead.
2016-07-07 18:13:07 +01:00
Richard W.M. Jones
e84382e9f8 builder, v2v: Use imperative list functions to simplify curl arg code.
No functional change in this commit.
2016-07-07 18:13:07 +01:00
Richard W.M. Jones
1c57c71d46 mllib: Add some imperative list manipulation functions.
This adds imperative list manipulation functions inspired by Perl.
The functions are passed list refs which get updated in place.

This allows us to replace some awkward pure functional code like:

  let xs = ys in
  let xs = if foo then xs @ zs else xs in

with:

  let xs = ref ys in
  if foo then append xs zs;
2016-07-07 18:13:07 +01:00
Richard W.M. Jones
906c05c70f builder: Use the new Curl module for passing parameters to curl.
These are now passed using a curl configuration file, which is a
little bit safer than using command lines.  virt-builder doesn't need
to pass usernames and passwords to curl, but if it ever does in future
this will be a lot safer.
2016-07-07 18:13:07 +01:00
Richard W.M. Jones
20509df94e curl: Change the API to use an abstract data type.
Change the Curl module to use an ADT to store the name of the curl
binary and the arguments.

The callers in virt-v2v are changed accordingly.

This also adds a (currently unused) ?proxy argument to allow callers
to override the proxy.  It also adds some safety arguments implicitly.
2016-07-07 18:13:07 +01:00
Richard W.M. Jones
10e096c063 v2v: Move Curl wrapper to mllib.
Just code motion, no change.
2016-07-07 18:13:07 +01:00
Richard W.M. Jones
b35819d990 v2v: changeuid: Improve error messages. 2016-07-07 18:13:07 +01:00
Pino Toscano
9fa8e07465 daemon: fix cleanup of stringsbuf usages
Declare most of the stringsbuf as CLEANUP_FREE_STRINGSBUF, so they are
freed completely on stack unwind: use take_stringsbuf() in return
places to take away from the stringsbuf its content, and remove all the
manual calls to free_stringslen (no more needed now).
This requires to not use free_stringslen anymore on failure in the
helper functions of stringsbuf, which now leave the content as-is (might
be still useful even on error).

This allows us to simplify the memory management of stringsbuf's, which
are not properly fully freed, fixing memory leaks in some error paths
(which were not calling free_stringslen).
2016-07-07 16:28:18 +02:00
Pino Toscano
6a06b87559 daemon: free the string on stringsbuf add failure
If add_string_nodup fails free the passed string instead of leaking it,
as that string would have been owned by the stringbuf.

Adapt few places to this behaviour.
2016-07-07 16:27:36 +02:00
Richard W.M. Jones
d061b67410 Version 1.33.41. 2016-07-06 14:57:06 +01:00
Richard W.M. Jones
70faafddba v2v: Fix documentation, [--in-place] -> I<--in-place>.
Fixes commit 9221ef6f79.
2016-07-06 13:05:05 +01:00
Richard W.M. Jones
9cf220e73e inspection: Find icon in Windows 7 64 bit guests (RHBZ#1352761).
We have to download the old 32 bit explorer.exe in order to find the
icons as the 64 bit version doesn't contain any icons (where are they?).
Thus prefer the 32 bit (WoW64 subsystem) directory if found.

Fixes commit 7f16c346bb.

Thanks: Xiaoyun Hu
2016-07-06 13:05:05 +01:00
Richard W.M. Jones
4e806c4bd2 inspection: Find Ubuntu logo from an alternate location (RHBZ#1352761).
The current location doesn't exist unless you've installed GNOME,
which is not so common on Ubuntu.  Unfortunately I couldn't find any
other location containing a clean, high quality logo.

This adds another low quality icon source, and also prevents any icon
being returned if the highquality flag was set (note this prevents
virt-manager from displaying an icon, but there's nothing we can do
about that, and it's no worse than the current situation).

Updates commit 1d0683964f.

Thanks: Xiaoyun Hu
2016-07-05 14:01:33 +01:00
Richard W.M. Jones
d6744dac60 p2v: Remove p2v.debug option from test command lines.
Fixes commit 0c04919f50.
2016-07-02 10:16:55 +01:00
Richard W.M. Jones
0c04919f50 p2v: Remove the Enable debugging option, -v, p2v.debug.
This is now enabled by default and cannot be changed/disabled by the
user.  The output is saved into /tmp/.../virt-v2v-conversion-log.txt
on the conversion server.
2016-07-02 10:01:09 +01:00
Pino Toscano
88be0a237f v2v: fix priority of match in configure_kernel_modules
This makes sure that in the internal configure_kernel_modules function,
for virtio or SCSI block types:
a) the warnings about leftover Xen modules are printed
b) the changes in Augeas are saved

Fixes commit ee02191483.
2016-07-01 18:13:01 +02:00
Pino Toscano
d4dfa47158 v2v: fix and implify the internal Convert_linux:discover_modpath
First check for the existence of the directory /etc/modprobe.d, in case
using a file under it; this also skips all the other checks, since they
are not needed at all.  Also /etc/modprobe.d exists on recent Linux
versions, so let's give priority to the more common methods.
When /etc/modprobe.d does not exist, check for the file to edit using a
single list of possible files, now in order of priority, where the first
find is used without checking further for the rest.

Also, make sure all the returned paths are absolute: they are used in
Augeas paths later on, so relative paths will not do anything useful.
2016-07-01 18:13:01 +02:00
Pino Toscano
026992d58d docs: fix link to csvtool
Refer to the new home of the OCaml csv module.

Thanks to: Yehuda Zimmerman.
2016-07-01 15:49:17 +02:00
Richard W.M. Jones
30b728bc3b Version 1.33.40. 2016-07-01 12:22:05 +01:00
Richard W.M. Jones
87131d8681 p2v: Send ^C to remote end to cancel the conversion.
We are now able to cancel the conversion instantly by sending ^C to
the remote virt-v2v process.

Also, this reverts:
"p2v: Poll to make Cancel Conversion button more responsive."
(commit 6da4941db7)
2016-06-30 14:38:20 +01:00
Richard W.M. Jones
fa6402a0f8 p2v: ssh: Set cooked mode on the ssh session which runs virt-v2v. 2016-06-30 14:38:20 +01:00
Richard W.M. Jones
6d9bac80b2 p2v: Use 'scp' to copy the files to remote debugging directory.
Previously we copied / creates files in the remote dir by running
complex shell commands like:

  cat > file <<'EOF'
    ## the file was copied in here
  EOF

This was a little hairy, but in particular it doesn't allow us to set
the ssh session to cooked mode (so we can send ^C to cancel a
conversion).

A cleaner way to do it is to use 'scp' to copy the files over.
2016-06-30 14:38:20 +01:00
Richard W.M. Jones
c2fab43dd6 p2v: Set an SSH error message if mexp_spawnv fails. 2016-06-30 13:53:31 +01:00
Richard W.M. Jones
9445a4da17 p2v: miniexpect: Add mexp_send_interrupt, mexp_spawnvf, mexp_spawnlf and various flags. 2016-06-29 21:21:40 +01:00
Richard W.M. Jones
3390df44d3 miniexpect: Set signals to defaults and close other file descriptors after forking. 2016-06-29 15:22:29 +01:00
Richard W.M. Jones
b15b6e69e3 p2v: Colourize kernel-conversion status messages from virt-p2v.
The messages that come "through" from virt-v2v are already colourized.
However the other messages are not.  This colourizes the ones
generated during kernel-mode conversions.

Note that because of the way journal/syslog works we have to write the
ansi_restore before the end of line, thus code like this:

 ansi_magenta (stdout);
 printf ("%s: %s", guestfs_int_program_name, data);
 ansi_restore (stdout);
 putchar ('\n');

This also adds a "Conversion finished successfully" message (in green).

Thanks: Ming Xie
2016-06-29 13:00:14 +01:00
Richard W.M. Jones
d2abfc7b48 utils: Move ansi_* functions to header guestfs-internal-frontend.h.
This is just code motion.
2016-06-29 12:49:46 +01:00
Richard W.M. Jones
3ac0aa8232 mllib: Add powerpc64 and powerpc64le to normalize_arch (RHBZ#1264835).
Add powerpc64 (ppc64) and powerpc64le (ppc64le) cases to the
normalize_arch function.  Also remove a few duplicate cases which are
already caught in the catch-all case at the end of the match.
2016-06-29 10:09:27 +01:00
Matteo Cafasso
2d65129e7e Reserve entries to tsk_dirent struct
Already implemented entries.

tsk_inode
tsk_type
tsk_size
tsk_name
tsk_flags

Easy ones to add.

tsk_atime_sec
tsk_atime_nsec
tsk_mtime_sec
tsk_mtime_nsec
tsk_ctime_sec
tsk_ctime_nsec
tsk_blksize
tsk_blocks

Further ideas.

tsk_nlink
tsk_link_name

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2016-06-28 22:09:36 +01:00
Richard W.M. Jones
b221863f22 p2v: Add more utilities to the virt-p2v ISO.
- iscsi-initiator-utils (open-iscsi), as a partial fix for RHBZ#1337052

- vi (Vim), to use as an editor inside the XTerm window.
2016-06-28 17:27:52 +01:00
Richard W.M. Jones
13307325e8 p2v: Remove trailing \n from fixed disks device box.
Fixes commit 6aba5a4944.
2016-06-28 13:38:34 +01:00
Richard W.M. Jones
cc38d62fdf p2v: Ensure messages are flushed through to the journal immediately (RHBZ#1229386).
In kernel conversion mode, we must ensure messages are flushed to the
journal as soon as they are received from virt-v2v, otherwise (now
that debugging is not the default) we won't see any messages at all
until the last moment.

Thanks: Ming Xie
2016-06-28 12:29:29 +01:00
Richard W.M. Jones
5f248dcd39 p2v: Add 'less' package to the ISO.
When running the xterm it is very useful to be able to do:

  dmesg | less
2016-06-27 15:42:30 +01:00
Richard W.M. Jones
2783f695ff p2v: Add --install option to virt-p2v-make-disk, virt-p2v-make-kickstart.
This allows you to install extra packages in the disk/ISO.  The
implementation of this option in virt-p2v-make-disk was particularly
simple and followed naturally from the previous commit.
2016-06-27 11:41:19 +01:00
Richard W.M. Jones
07137ea565 p2v: virt-p2v-make-disk passes through --no-warn-if-partition to virt-builder.
See: https://bugzilla.redhat.com/show_bug.cgi?id=1342337#c4

Thanks: Junqin Zhou
2016-06-27 11:41:19 +01:00
Pino Toscano
de5c00eebf automake2junit.ml: sanitize logs, make it more conformant
- sanitize the logs, removing terminal color codes and carriage returns
- add an empty "properties" node
- put the log for skipped tests as "message" attribute, hoping it is
  read from there
- do not blacklist the log of test-virt-rescue.pl, which should not
  cause issues now
2016-06-27 11:52:35 +02:00
Richard W.M. Jones
0b836c40f2 p2v: Fix timeout error when connecting to unresponsive ssh server (RHBZ#1350363).
If an ssh server is completely unresponsive (ie. it doesn't even send
back ICMP errors), then eventually ssh times out after ConnectTimeout
seconds [ConnectTimeout is an ssh option].

Unfortunately the miniexpect timeout (default 60 seconds) was less
than ConnectTimeout so we never saw the ssh error.  Instead we would
see the internal error:

  remote server closed the connection unexpectedly,
  waiting for: password prompt

This commit sets the ssh ConnectTimeout to an explicit value, and sets
the miniexpect timeout to be 20 seconds larger than ConnectTimeout, so
that in most cases we will see the ssh error message before miniexpect
times out.

Thanks: Ming Xie for finding and diagnosing the problem
2016-06-27 10:34:10 +01:00
Richard W.M. Jones
40448d6d0d p2v: Make the conversion dialog slightly higher.
Otherwise the information pane is smaller than its content.
2016-06-24 22:28:40 +01:00
Richard W.M. Jones
9270a27650 p2v: Display serial number of fixed disks (RHBZ#855058).
Use "lsblk -o serial" to get the serial number of each fixed disk, and
if it is available display that in the GUI.
2016-06-24 15:30:34 +01:00
Richard W.M. Jones
6aba5a4944 p2v: Combine size & model columns into the device column.
In the GUI disks block, instead of using separate "Size" and "Model"
columns, combine that information into a markup column under "Device".

To make the GUI look consistent I also had to change the removables
"Device" column to be a markup column and embolden the device name
there too.
2016-06-24 15:30:33 +01:00
Richard W.M. Jones
68ff3ffd1d p2v: Refactor into get_blockdev_size and get_blockdev_model functions.
This is just refactoring, but it reveals and fixes a bug too.  The
size_gb field was left as NULL when the --test-disk option was used.
Apparently passing NULL to gtk_list_store_set is fine, but just in
case I replaced it with "".
2016-06-24 15:30:33 +01:00
Richard W.M. Jones
5ea62c57c4 Revert "p2v: add -x option to nm-online"
This reverts commit f51c0bc837.
2016-06-24 10:51:22 +01:00
Richard W.M. Jones
95448111d2 Version 1.33.39. 2016-06-23 23:10:07 +01:00
Richard W.M. Jones
82b74ed0bd v2v: windows: Fix priority of match statement which stopped Xen/Parallels code from being uninstalled.
Fixes commit c466d4cb92.
2016-06-23 14:51:58 +01:00
Richard W.M. Jones
7c52d86de9 virt tools: Use Sys.file_exists instead of clumsy open_in/close_in hack.
No functional change.

Fixes commit c466d4cb92.
2016-06-23 14:51:48 +01:00
Richard W.M. Jones
8f8a651e59 p2v: ssh: Improve consistency of error messages. 2016-06-23 14:28:44 +01:00
Richard W.M. Jones
323c3e20a4 p2v: Make the sudo error message actionable.
Updates commit 5b6a8e0862.
2016-06-23 13:52:46 +01:00
Richard W.M. Jones
9221ef6f79 v2v: Refuse to convert if < 1GB of free space in temporary directory (RHBZ#1316479).
The error you would see is:

  virt-v2v: error: insufficient free space in the conversion server temporary
  directory /var/tmp (853.8M).

  Either free up space in that directory, or set the LIBGUESTFS_CACHEDIR
  environment variable to point to another directory with more than 1GB of
  free space.

  See also the virt-v2v(1) manual, section "Minimum free space check in the
  host".

Also adds some documentation.

Thanks: Ming Xie and Xiaodai Wang
2016-06-23 13:45:22 +01:00
Richard W.M. Jones
d8a465a14c v2v: Rename check_free_space -> check_guest_free_space. 2016-06-23 13:28:49 +01:00
Richard W.M. Jones
a7fb3d601a v2v: Move calculation of overlay directory to common code.
There is a tiny functional change in this patch, since overlay_dir is
now always evaluated once (eg. even in --inplace mode), whereas
previously it was evaluated twice but only in copying mode.
2016-06-23 13:28:48 +01:00
Richard W.M. Jones
24130d7872 sparsify: Move statvfs wrapper function to mllib.
We wish to use this function in virt-v2v too, so move it to the common
directory.

No functional change.
2016-06-23 13:28:48 +01:00
Richard W.M. Jones
5e794b8607 p2v: Set LANG=C in the remote shell so we can match on error messages.
Since commit 5b6a8e0862 we are now
matching on error messages, and therefore we must set LANG=C.
2016-06-23 11:34:00 +01:00
Richard W.M. Jones
d41cf142e1 p2v: Force bash as the remote shell.
As described in the comment, this solves a number of problems with
non-standard remote configurations.

I tested this with:

 - tcsh
 - zsh
 - ksh

and all behaved correctly.
2016-06-23 11:33:44 +01:00
Pino Toscano
5b6a8e0862 p2v: improve error message for sudo with password
Print a better error message when the non-root user on the conversion
server requires a password to use sudo, and p2v is told to use sudo.

See also RHZ#1340809.
2016-06-23 11:07:18 +02:00
Richard W.M. Jones
32cc27bb61 generator: filesystem_walk APIs added in 1.33.39 (not .37).
Updates commit 3de8abac4a and
commit 19e7a52f8f.
2016-06-23 08:30:48 +01:00
Matteo Cafasso
19e7a52f8f New API: filesystem_walk
Library's counterpart of the daemon's internal_filesystem_walk command.

It writes the daemon's command output on a temporary file and parses it,
deserialising the XDR formatted tsk_dirent structs.

It returns to the caller the list of tsk_dirent structs generated by the
internal_filesystem_walk command.

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2016-06-22 18:43:51 +01:00
Matteo Cafasso
7d8fbde4b2 lib: Added filesystem_walk command tests
The tests check whether the filesystem_walk command is able to retrieve
information regarding both existing and deleted files.

A NTFS image is used as Ext3+ filesystems deletion is more aggressive
in terms of metadata removal.

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2016-06-22 18:43:51 +01:00
Matteo Cafasso
3de8abac4a New API: internal_filesystem_walk
- generator: Added tsk_dirent struct

The tsk_dirent struct contains the information gathered via TSK APIs.

The struct contains the following fields:
 * tsk_inode: inode of a file
 * tsk_type: type of file such as for dirwalk command
 * tsk_size: file size in bytes
 * tsk_name: path relative to its disk partition
 * tsk_flags: bitfield containing extra information
 * tsk_spare[1-5]: extra space for future usage

 - configure: Added libtsk compile-time check

Ensure libtsk is available at compile time.
If not, daemon routines depending on it won't be available.

 - API: internal_filesystem_walk

The internal_filesystem_walk command walks through the FS structures
of a disk partition and returns all the files or directories
which could be found.

The command is able to retrieve information regarding deleted
or unaccessible files where other commands such as stat or find
would fail.

The gathered list of tsk_dirent structs is serialised into XDR format
and written to a file by the appliance.

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2016-06-22 18:43:51 +01:00
Matteo Cafasso
90e623d4c7 Code cleanup in daemon/sleuthkit.c
Adhere to coding standards.

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2016-06-22 18:41:19 +01:00
Matteo Cafasso
434f617bdd Improve download_inode documentation string.
The download_inode does not require the disk to be mounted
in order to work.

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2016-06-22 18:40:55 +01:00
Richard W.M. Jones
0421c5afa3 v2v: Add a regression test for floppy assignment (RHBZ#1309706). 2016-06-22 18:25:36 +01:00
Richard W.M. Jones
b9613acb94 v2v: Fix conversion of floppy removable devices (RHBZ#1309706).
The previous code treated floppy disks and CD-ROMs as the same kind of
thing, resulting in malformed libvirt XML.  You would see the
following error when importing a guest into libvirt:

  error: Failed to define domain from /tmp/v2vlibvirt063486.xml
  error: internal error: Invalid floppy device name: hdb

because we incorrectly generated this bogus libvirt XML fragment:

  <disk device='floppy' type='file'>
    <driver name='qemu' type='raw'/>
    <target dev='hdb' bus='ide'/>
  </disk>

This commit models floppy devices as a distinct type, occupying their
own bus ("/dev/fdX").  When writing to libvirt, we generate correct
XML fragments, looking like this:

  <disk device='floppy' type='file'>
    <driver name='qemu' type='raw'/>
    <target dev='fda'/>
  </disk>

Miscellaneous other changes were required in the code.  There is also
a regression test (see following commit).

Note this ignores floppy disks in '-o qemu' mode.
2016-06-22 18:25:36 +01:00
Richard W.M. Jones
044de389e7 builder: Add Fedora 24 images for x86-64, i686, armv7l.
aarch64 image isn't buildable at the moment because of
Anaconda bug RHBZ#1348980.

ppc64 & ppc64le images are not buildable because of delays updating
the Fedora mirrors.
2016-06-22 18:25:36 +01:00
Richard W.M. Jones
94e1504146 v2v: OVF: Add <BootOrder/> to the first drive.
This adds <BootOrder>1</BootOrder> to the first drive, which is
necessary to make the drive bootable (or would be necessary, if oVirt
hadn't implemented their own workaround for the OVF we were previously
generating).

https://bugzilla.redhat.com/show_bug.cgi?id=1308535#c11

This is not a full solution to the problem.  Really we should be
copying the boot order over from the source hypervisor, but that
requires extensions to libvirt as discussed here:

https://bugzilla.redhat.com/show_bug.cgi?id=1308535#c7

Thanks: Shmuel Melamud
2016-06-22 15:46:56 +01:00
Maxim Perevedentsev
6521be3aa7 ext: change e2fsck retcode processing during resize
e2fsck returns 1 in case of "file system errors corrected".
We treat it as success in normal e2fsck, but fail if e2fsck
is run by resize2fs.

Change 'manual' execution of e2fsck to dedicated function call.
2016-06-22 15:18:19 +01:00
Cédric Bosdonnat
62d23aa4f9 p2v: use yast2 lan on SUSE distros rather than NM
NetworkManager isn't provided on SLES. As yast2 lan is available on all
openSUSE / SLE distro, use it instead.
2016-06-22 13:26:13 +01:00
Richard W.M. Jones
e4e197bb86 builder: Use newly open sourced edk2 from Fedora, replacing kraxel's builds. 2016-06-22 12:47:20 +01:00
Richard W.M. Jones
27b3b2cf7d builder: Use a different mirror when building armv7l image. 2016-06-22 12:41:57 +01:00
Cédric Bosdonnat
f51c0bc837 p2v: add -x option to nm-online
On distros not running NetworkManager, use the nm-online -x parameter
to exit quickly. The network connection will be checked just after
anyway when attempting to connect to the conversion server using ssh.
2016-06-22 11:03:38 +01:00
Cédric Bosdonnat
9c0f547b02 p2v: add virt-p2v-make-kiwi to generate kiwi config
Kiwi is the tool used by openSUSE / SLES to generate many sort of
disk images. Add a virt-p2v-make-kiwi tool and his documentation to
geneate the p2v appliance kiwi configuration.
2016-06-22 11:02:44 +01:00
Cédric Bosdonnat
9507c79945 p2v: fix dependencies for SLES / openSUSE
Use the common denominator for SLES and openSUSE in the dependencies.
For example most of NetworkManager pieces and metacity aren't provided
on SLES.

ifconfig is in the net-tools-deprecated package in openSUSE Factory,
which means after openSUSE Leap 42.2. Older versions have it in the
net-tools package. Adding this complexity only to add ifconfig because
sysadmins prefer it isn't too good:  iproute2 is doing the job.
2016-06-22 10:58:45 +01:00
Richard W.M. Jones
10cbf35cbd p2v: Use a more specific password prompt regexp.
The password prompt is actually generated by the openssh client which
is under our control, so we can regexp match on the specific prompt
printed by openssh.  This also avoids mistaking any server-side
issue.net message for a password prompt (eg. if the server prints a
message like "all users must change their passwords today!")  which
would have prevented virt-p2v from logging in.
2016-06-22 10:53:37 +01:00
Richard W.M. Jones
c44ff0b789 p2v: Improve the error message when login fails (RHBZ#1348900).
This can fail because the username is wrong.  Also don't unnecessarily
reveal irrelevant implementation details in the error message, just
say the login failed.

Thanks: Juquin Zhou
2016-06-22 10:53:27 +01:00
Richard W.M. Jones
572b416468 Revert "aarch64: launch: libvirt: As a workaround, pass -cpu parameter to qemu."
Since libvirt bug https://bugzilla.redhat.com/1184411 is now fixed, we
don't need this workaround any longer.

This reverts commit 7e4b7a346a.
2016-06-21 14:20:20 +01:00
Richard W.M. Jones
c87eab35c0 p2v: Gtk 3 workaround for RHEL 7.
New enough to complain about gtk_widget_modify_font, not new enough to
have gtk_style_context.

Fixes commit ca6fea7616.
2016-06-21 14:11:57 +01:00
Richard W.M. Jones
b5725ef856 docs: internals: Fix cross-references to guestfs(3) man page. 2016-06-20 15:11:46 +01:00
Richard W.M. Jones
6da4941db7 p2v: Poll to make Cancel Conversion button more responsive.
Previously cancelling the conversion only set a flag, which was
checked when the run dialog displayed new output from virt-v2v.  When
virt-v2v was showing hundreds of debugging messages, this wasn't a
problem, but now that we are hiding those messages, cancelling the
conversion might mean a wait of seconds or minutes.

By polling (albeit infrequently) we can make the cancel button more
responsive.
2016-06-20 15:11:46 +01:00
Richard W.M. Jones
55a0ab845d p2v: Don't display libvirt XML and wrapper script on stderr.
Confusing for end users, and not necessary for debugging since those
files are saved on the conversion server.
2016-06-20 15:11:46 +01:00
Richard W.M. Jones
6f5abc9539 p2v: Display up to 50 lines of the virt-v2v conversion log on failure.
For some failures, 30 lines was not sufficient and only part of the
error was shown.  Increase the number of lines shown to 50.

This also colourizes the failure message, and prominently displays the
location of the full log.  The following message is now shown:

  *** virt-v2v command failed ***

  The full log is available on the conversion server in:
      /tmp/virt-p2v-20160620-sga9rhk7/virt-v2v-conversion-log.txt
  Only the last 50 lines are shown below.

  [followed by up to 50 lines of log]

Updates and fixes commit 7447fe2478.
2016-06-20 15:11:46 +01:00
Pino Toscano
44483e7eb3 inspect: recognize older PLD Linux versions
PLD Linux got /etc/os-release only in the recent 3.0 release; since
older versions have only /etc/pld-release, check for it to identify
the guest and get its version.
2016-06-20 14:22:16 +02:00
Richard W.M. Jones
6db1043342 Version 1.33.38. 2016-06-18 22:40:55 +01:00
Richard W.M. Jones
257f2cc6b4 p2v: Use absolute path in test.
Fixed because of change in commit 7447fe2478.
2016-06-18 21:47:21 +01:00
Richard W.M. Jones
ca6fea7616 p2v: Use a monospace font for the run dialog. 2016-06-18 21:16:54 +01:00
Richard W.M. Jones
7301c51da3 p2v: Add DejaVu Sans and Monospace fonts to the ISO.
Improves the general look of virt-p2v.
2016-06-18 21:16:54 +01:00
Richard W.M. Jones
7447fe2478 p2v: Don't display debugging messages in the run dialog.
Previously we displayed the complete output of virt-v2v in the run
dialog.  This output included all the debugging messages, and was very
long and confusing for users (especially we had false bug reports
about "errors" appearing in the debug output).

Only display stdout in the run dialog.  However make sure everything
(stdout and stderr) is still logged to the conversion log.
2016-06-18 21:16:54 +01:00
Richard W.M. Jones
514893b68b p2v: Use a wrapper script instead of long virt-v2v command lne.
Instead of constructing and directly executing a long virt-v2v command
line, build a wrapper script with the same command line and send it to
the remote server (stored in /<remote_dir>/virt-v2v-wrapper.sh).

This will make it a bit easier to construct more complex virt-v2v
wrappers.

Note this commit on its own is a simple refactoring and does not
change any functionality.
2016-06-18 21:16:54 +01:00
Richard W.M. Jones
5e8f820494 p2v: Use virt-v2v --colours option, support colour in the run dialog (RHBZ#1314244). 2016-06-18 21:16:52 +01:00
Richard W.M. Jones
b000d6bc68 virt tools: Add common --colours option.
This option (alternately spelled: --color, --colour, --colors, or
--colours) enables ANSI colour sequences output even if that would be
disabled becaues the output is not a TTY.
2016-06-18 21:15:59 +01:00
Richard W.M. Jones
5b131356e2 virt tools: Warnings are not errors, send them to stdout. 2016-06-18 21:15:59 +01:00
Richard W.M. Jones
bda1224b2b p2v: Fix size of run dialog window in Gtk 3.
Setting the size on the surrounding scrolled window works better.
2016-06-18 21:15:57 +01:00
Richard W.M. Jones
377bd8f921 p2v: Fix the rule for rebuilding windows.img.
Fixes commit 53ec66c7e2.
2016-06-18 19:56:38 +01:00
Richard W.M. Jones
fc292631da v2v: Be careful to send all debug messages to stderr.
The debug() function is already sending these to stderr, but in a few
places we were using printf.  Change those to eprintf, except for one
informational message which should have been using info().
2016-06-18 14:46:43 +01:00
Richard W.M. Jones
c5f12e47e4 p2v: Fix slow test so it runs our locally built virt-v2v.
The virt-p2v slow test tested the local virt-p2v.  However it ran
against the installed virt-v2v (and in fact would have failed if
virt-v2v was not installed).

This commit sets the environment up to run the locally built virt-v2v.

This is unfortunately quite a lot more complex than it should be.
There is no simple "set this environment variable" option in
sshd_config.
2016-06-18 11:47:13 +01:00
Richard W.M. Jones
87addfb440 p2v: test-virt-p2v-pxe.sshd_config is generated by awk, not configure. 2016-06-18 11:47:13 +01:00
Richard W.M. Jones
4f4f0f1fe9 p2v: Add a dialog confirming the user really means to cancel (RHBZ#1340464).
Thanks: Kean Li
2016-06-18 09:19:10 +01:00
Richard W.M. Jones
072cf26dc3 p2v: Disable the sudo button when the username is root. 2016-06-17 22:24:45 +01:00
Richard W.M. Jones
b0d2d697e0 p2v: Don't allow password & SSH identity URL fields to both be non-empty.
It makes no sense.  By setting one field to non-sensitive when the
other field is populated, we can avoid this happening, and also make
tabbing between the fields simpler.

As a consequence of making this change, I also got rid of the now
unnecessary explanatory text telling you to leave one field blank.
2016-06-17 21:36:31 +01:00
Richard W.M. Jones
e6a173d5d4 p2v: Hide the spinner in more cases when it is not running (RHBZ#1341564).
In particular if you hit the 'Test Connection' button when the server
name field was empty, you would still see a stopped spinner.

This updates commit 036a11f379.
2016-06-17 21:15:47 +01:00
Richard W.M. Jones
b92fe7a666 Version 1.33.37. 2016-06-17 15:13:49 +01:00
Richard W.M. Jones
02f648f656 p2v: Add various disk utilities to the virt-p2v ISO (RHBZ#855058). 2016-06-17 14:25:25 +01:00
Richard W.M. Jones
bb053d067d p2v: Fix 'run-virt-p2v-in-a-vm' so it boots the USB disk automatically.
Thanks: Stefan Hajnoczi for working out the right qemu incantation.
2016-06-17 13:24:22 +01:00
Richard W.M. Jones
762f24c1f3 p2v: In non-GUI mode, make sure the progress of virt-p2v is visible (RHBZ#1229386).
By changing the logging mode of the p2v.service unit, we can make sure
that the progress of virt-p2v is visible in non-GUI mode at the
console.

Since the output is now always shown on the console, there's no need
to print the journalctl command for following that output when the
user logs in.
2016-06-17 13:15:27 +01:00
Richard W.M. Jones
3c7c63e1dc p2v: Don't run X in non-GUI mode.
Even in non-GUI mode we were starting up the X server in the virt-p2v
ISO.  This is a waste of time and resources, so don't do it.
2016-06-17 13:15:17 +01:00
Richard W.M. Jones
784d8bd894 p2v: Tidy up long line in Makefile.am.
Just a whitespace change.
2016-06-17 13:15:17 +01:00
Richard W.M. Jones
e5fcda8a5a p2v: test-virt-p2v-pxe: Fix dependencies for rebuilding the image.
Not all dependencies were included, so some file changes (eg. to
launch-virt-p2v) would not rebuild the test image.
2016-06-17 12:25:51 +01:00
Richard W.M. Jones
896e1e191a p2v: Add run-virt-p2v-non-gui-conversion target.
This simulates doing a non-GUI conversion with virt-p2v being
downloaded over PXE.  Conveniently we already had a test that was
doing this, and this rule just runs the same test.
2016-06-17 12:15:20 +01:00
Richard W.M. Jones
8717a11012 p2v: ssh: Print ssh error if user gives invalid conversion server (RHBZ#1167916).
Instead of throwing away the ssh error and printing the generic
message "unexpected end of file waiting for password prompt", we
capture the ssh error and print it.  The user will see the ssh
diagnostic, eg. "No route to host".
2016-06-16 21:23:48 +01:00
Richard W.M. Jones
3dd3bba778 p2v: ssh: Don't send wrong password more than once (RHBZ#1227599).
For some reason I don't quite understand, in
commit fd82bb12fd if it got the password
prompt unexpectedly a second time then it would send the password
again, continually until ssh closed the connection because of too many
retries.

This obviously makes no sense.  If we get the password prompt back,
then we must have sent an incorrect password so abort the connection
and report the error at once.
2016-06-16 21:18:54 +01:00
Richard W.M. Jones
172b38014b ocaml: Use -safe-string option in OCaml >= 4.02.
In a follow up to the previous commit, enable the -safe-string option
when we detect the version of the compiler which supports this option.
2016-06-16 15:22:04 +01:00
Richard W.M. Jones
6e79a3c84d Convert source so it can be compiled with OCaml '-safe-string' option.
OCaml 4.02 introduced the 'bytes' type, a mutable string intended to
replace the existing 'string' type for those cases where the byte
array can be mutated.  In future the 'string' type will become
immutable.  This is not the default now, but it can be forced using
the '-safe-string' compile option.

This commit changes the code so that it could be compiled using
'-safe-string' (but does not actually make that change).

If we detect OCaml < 4.02, we create a dummy 'Bytes' compatibility
module ((nearly) an alias for the 'String' module).  The only
significant difference from upstream OCaml is that you must write the
'bytes' type as 'Bytes.t' in interfaces, apart from that everything
else should work.
2016-06-16 15:22:04 +01:00
Richard W.M. Jones
66856b6ba0 generator: Use common OCaml rules for building the generator too.
Updates commit a3cb12ab2c.
2016-06-16 15:22:04 +01:00
Andrea Bolognani
a2d0511904 builder: Fix description for --long option 2016-06-16 15:22:04 +01:00
Cédric Bosdonnat
cf137ef306 filesystems: don't try to get the size of btrfs subvolume
virt-filesystem -l tries to get the size of btrfs subvolumes, which
results in an error. Teach it to skip the subvolumes.
2016-06-15 17:52:48 +01:00
Richard W.M. Jones
2ecdc46114 mllib: Use Unix.F_OK instead of plain F_OK.
Removes this warning:

  File "common_utils.ml", line 826, characters 24-28:
  Warning 40: F_OK was selected from type Unix.access_permission.
  It is not visible in the current scope, and will not
  be selected if the type becomes unknown.
2016-06-14 18:55:31 +01:00
Richard W.M. Jones
bbb83aeccc generator: Remove unnecessary 'chars' function.
String.make can be used instead, and that function has been around
since at least RHEL 6 era OCaml.
2016-06-14 17:00:26 +01:00
Richard W.M. Jones
a88418621d v2v: OVF: Add new <Origin/> values for virt-p2v and HyperV.
See proposed change to oVirt: https://gerrit.ovirt.org/#/c/59147/
and RHBZ#1342398.

This enhances commit 9467777fdf.

Thanks: Shahar Havivi
2016-06-14 16:40:06 +01:00
Richard W.M. Jones
c9bfe1ee9b v2v: OVF: Add a comment about what happens for unknown <Origin/>. 2016-06-14 13:13:23 +01:00
Richard W.M. Jones
669e25049e sysprep: Add --network to enable the network (RHBZ#1345813).
In commit ae6f726ecc we started to use
the virt-customize code to replace various virt-sysprep operations.
This had the effect of adding many more possible operations to
virt-sysprep, but some of them (specifically --install) did not work
unless the appliance network is enabled.  It was not enabled in
virt-sysprep, so these operations never worked.

This change does NOT enable the network by default.  However it adds a
--network flag which may be used in conjunction with --install etc to
make those commands work.

In addition we now emit a warning for certain customize operations if
they fail and if the network is not enabled.  It will print:

  [   4.5] Installing packages: tcpdump
  Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again
  Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os&infra=stock error was

  virt-sysprep: warning: the command may have failed because the network is
  disabled.  Try either removing '--no-network' or adding '--network' on the
  command line.

  virt-sysprep: error: yum -y install 'tcpdump': command exited with an error

(If the network is already enabled, or if the command is successful,
then the warning is not printed.)

Thanks: Xianghua Chen
2016-06-13 15:39:34 +01:00
Richard W.M. Jones
0b5c6174b8 customize: Give an error if --truncate-recursive path does not exist (RHBZ#1345809).
You will now see an error such as:

$ virt-customize -a centos-6.img --truncate-recursive /home/foo
[   0.0] Examining the guest ...
[  16.5] Setting a random seed
[  16.5] Recursively truncating: /home/foo
virt-customize: error: libguestfs error: find0: /home/foo: No such file or
directory

Thanks: Xianghua Chen
2016-06-13 15:17:46 +01:00
Richard W.M. Jones
07c34fa65f customize: Use C<> around parameter name in documentation.
Fixes commit a084758e83
and commit 7e8ed7cb21.
2016-06-13 15:17:46 +01:00
Richard W.M. Jones
e6adcae770 Version 1.33.36. 2016-06-13 10:46:31 +01:00
Richard W.M. Jones
dba54ec0a2 v2v: Fix get_firmware_bootable_device.
Commit 82df768514 breaks the regression
test for RHBZ#1232192 because g#part_list can return an error when
called on a completely blank disk.

By rewriting and simplifying the code using higher-order functions we
can avoid the need for the double-nested imperative loop and calling
g#part_list at all.

Fixes commit 82df768514.
2016-06-13 10:21:14 +01:00
Richard W.M. Jones
08f82f2e3d v2v: Allocate extra RAM to the appliance during conversion.
The 'semodule' command, called by the guest tools uninstaller, will
run out of memory with the default of 500MB
(https://bugzilla.redhat.com/426775).

Allocate a large amount of RAM, that will be at least 800MB, but scale
correspondingly on other architectures like ppc64 that have larger
memory requirements.

Thanks: Pavel Butsykin
2016-06-13 09:03:13 +01:00
Richard W.M. Jones
736cc8f8a9 mllib: Document open_guestfs identifier parameter.
Just a documentation fix.
2016-06-13 08:55:02 +01:00
Richard W.M. Jones
a3cb12ab2c ocaml: Move identical rules for building OCaml objects to common file. 2016-06-13 08:51:46 +01:00
Richard W.M. Jones
0321797c7a v2v: XML: Fold some over-long lines of code.
Just whitespace, no functional changes.
2016-06-12 22:08:09 +01:00
Richard W.M. Jones
ec63594b67 v2v: XML: Rename internal types.
This is a mostly mechanical renaming of the internal pointer types
used in the libxml2 bindings.  Also I have added a longer comment to
make the system clearer.
2016-06-12 22:08:03 +01:00
Pavel Butsykin
22190afce9 v2v: remove the 'graphicsmodedisabled' entry in ESP BCD
Guest tools for Windows in Parallels / Virtuozzo Server 6 contain a
paravirtualized video driver, which wants to take full control of the video
mode. To avoid excessive video mode switches in UEFI VMs it executes
"bcdedit /set {current} graphicsmodedisabled true".

When such a VM is imported into a QEMU/KVM-based hypervisor, the
standard video drivers in Windows do not set the video mode as they
expect it to have already been configured by the bootloader.  As a result,
the VM runs with black screen.

So patch the BCD store (which is a Windows registry hive with a special
structure, located on the EFI system partition) to clear this setting.

Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
2016-06-12 18:24:45 +01:00
Pavel Butsykin
82df768514 v2v: fill the list of the EFI system partitions
Store the list of EFI system partitions on the inspect object in order  to be
able to tune their contents later in the process.

Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
2016-06-12 18:24:45 +01:00
Richard W.M. Jones
3719d75098 docs: hacking: Small updates to virt-p2v code documentation.
Use Unicode box-drawing characters instead of ASCII art.

Reference virt-p2v manual for how virt-p2v works.
2016-06-12 18:24:45 +01:00
Richard W.M. Jones
09eeb04578 docs: hacking: Document how OCaml programs are compiled and linked. 2016-06-12 18:24:45 +01:00
Richard W.M. Jones
b8f1ea3fff v2v: DOM: Make 'doc' and 'element' types distinct.
No functional change, just enforces the distinct type for callers.
2016-06-12 18:24:45 +01:00
Pavel Butsykin
4d09ce2251 v2v: linux: uninstall Parallels tools
Guest tools for Linux in Parallels / Virtuozzo Server 6 come with a script
that can be used to uninstall them.

Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
2016-06-11 21:36:11 +01:00
Richard W.M. Jones
4df28a433a v2v: Whitespace change in DOM. 2016-06-10 22:24:38 +01:00
Richard W.M. Jones
9467777fdf v2v: OVF: Set <Origin/> field correctly based on source hypervisor.
https://bugzilla.redhat.com/show_bug.cgi?id=1342398#c6
2016-06-10 22:16:08 +01:00
Richard W.M. Jones
4ed70d558a ruby: tests: Give each test class and method a unique name.
'tc_410_close_event.rb' was not being run.  You could prove this by
simply inserting "exit 1" into that test.

The reason is unclear, but by renaming every class and method in the
tests to be unique, this ensures the tests are run.
2016-06-10 14:25:38 +01:00
Richard W.M. Jones
4d6899ee91 ruby: Print exceptions thrown by event callbacks. 2016-06-10 14:25:38 +01:00
Pino Toscano
35fa141522 get-kernel: use "auto" as real autodetection marker (RHBZ#1341984) 2016-06-08 16:12:49 +02:00
Richard W.M. Jones
0e0a350c02 p2v: Print full curl error when failing to fetch SSH identify URL (RHBZ#1343423). 2016-06-07 14:50:47 +01:00
Richard W.M. Jones
3064c85372 p2v: Add note about 403 Forbidden errors when serving id_rsa file (RHBZ#1343414). 2016-06-07 14:32:26 +01:00
Richard W.M. Jones
6425a8824b customize: Add --uninstall operation (RHBZ#1343375). 2016-06-07 12:19:24 +01:00
Richard W.M. Jones
a3ca5182d4 docs: hacking: Describe which order to look at directories.
When browsing the source code.
2016-06-06 15:50:27 +01:00
Roman Kagan
613a7e0884 v2v:windows: prevent Parallels drivers from loading at boot
Parallels proprietary hypervisor uses RDPMC as the hypercall
instruction.  As this instruction is supported since early P6 family,
the drivers didn't even bother to check for the presence of the
corresponding feature in CPUID.

In QEMU/KVM, however, this instruction triggers #GP unless the VM is run
with PMU (performance monitoring unit) enabled, which is often not the
case (due to its impact on perfromance and migratability).

So, to prevent crashes upon conversion, stop respective drivers from
loading by disabling the corresponding services.  Note that the services
are being disabled ("Start" value set to 4) rather than their node
removed, to avoid confusing the uninstaller which is scheduled to run
from a firstboot script.

In addition, prl_strg (storage filter driver) is unlinked from the
storage subsystem following the DelReg directive from its .inf file,
otherwise Windows crashes with BSOD 0x7b due to missing dependency of
the storage subsystem.

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
2016-06-06 15:21:26 +03:00
Richard W.M. Jones
ba5767d69e Version 1.33.35. 2016-06-06 11:50:15 +01:00
Roman Kagan
4c24531d90 v2v: copy all driver files into guest
Some virtio-win drivers contain more files than just *.{cat,inf,sys}.
They are filtered out currently, which prevents the drivers from being
installed by PnP.

Stop filtering driver files by extension, and copy all of them instead.

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
2016-06-04 17:13:51 +03:00
Richard W.M. Jones
3a231afcfa p2v: Add more authors who have worked on virt-v2v and virt-p2v.
Use this command as a starting point:

  git shortlog -s -- p2v v2v | awk -F'\t' '{print $2}' | sort -f

However note the above will include people who made only incidental
code changes, and also misses out QA team members, so the actual list
still has to be curated by hand.
2016-06-04 14:47:28 +01:00
Richard W.M. Jones
5bc56f4c6b docs: performance: Mention optimizations added in libguestfs 1.33, qemu 2.7 2016-06-04 14:41:45 +01:00
Richard W.M. Jones
2e5542a65e docs: hacking: It's the 'docs' subdirectory, not 'doc'. 2016-06-04 14:34:34 +01:00
Richard W.M. Jones
5f118f1dd2 docs: hacking: Move subdirectories list higher up in the file.
It's better to have this overview of how the code is arranged before
any details about modifying the code, since most people will be
reading code before writing.
2016-06-04 14:34:29 +01:00
Richard W.M. Jones
5d9db47033 docs: building: Document ./configure options. 2016-06-04 14:34:25 +01:00
Richard W.M. Jones
fe84ce8521 docs: building: Add a warning about running tests as root.
It's a really bad idea, don't do it.
2016-06-04 14:34:21 +01:00
Richard W.M. Jones
0e469badff docs: building: Fix link to RHEL sources.
These are now stored at centos.org, not at ftp.redhat.com.
2016-06-04 14:34:12 +01:00
Richard W.M. Jones
2eb1d849f2 docs: Remove imaginary '--enable-gcc-warnings' flag.
It doesn't actually exist.  Not sure if it did in some earlier
version, but it doesn't exist now.
2016-06-04 14:24:16 +01:00
Roman Kagan
9d920732a3 v2v: recognize Virtuozzo tools as Parallels tools
Recent updates of Virtuozzo Server 6 (fka Parallels Cloud Server 6) have
"Virtuozzo tools" instead of "Parallels tools" as their display name in
the corresponding Uninstall registry key.

Recognize those, too, and schedule their uninstallation on first boot.

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
2016-06-04 14:49:03 +03:00
Richard W.M. Jones
69e5410e62 fish: rc: Rewrite file descriptor send/receive.
On Linux 4.7.0 the old code was giving -EINVAL errors.  This rewrites
the code based on online sources, and it works on at least RHEL 7,
Linux 4.4 and 4.7.  Also checked with valgrind.
2016-06-03 21:47:04 +01:00
Richard W.M. Jones
8417eb4587 fish: rc: Fail hard if recvmsg doesn't receive a file descriptor.
Also some code reformatting.
2016-06-03 21:03:03 +01:00
Richard W.M. Jones
b2cc087e8f Version 1.33.34. 2016-06-03 14:52:18 +01:00
Richard W.M. Jones
c97ca67a5c mllib: Fix other places where Dev_t module must be linked to Common_utils.
Fixes commit df7a33768e.
2016-06-03 14:34:05 +01:00
Richard W.M. Jones
a7c4061a2e Version 1.33.33. 2016-06-03 13:05:08 +01:00
Richard W.M. Jones
f0a7c68146 v2v: Don't distribute binary v2v_unit_tests in EXTRA_DIST.
Because EXTRA_DIST included $(TESTS) this ended up distributing the
binary file v2v_unit_tests.

Unfortunately to fix this we need to list all the test scripts and
data files explicitly a second time, but there we are.
2016-06-03 13:05:07 +01:00
Richard W.M. Jones
9f3b6aa6e2 p2v: Place conversion server name and port side by side.
Just a small rearrangement of the UI.
2016-06-03 13:05:07 +01:00
Richard W.M. Jones
bf434bdb35 p2v: Add "XTerm" button which launches a terminal window. 2016-06-03 13:05:07 +01:00
Richard W.M. Jones
60d4b7f544 p2v: Add ifconfig to the ISO (RHBZ#1342447).
Suggested by Ming Xie.
2016-06-03 13:05:07 +01:00
Richard W.M. Jones
57dbad4bba p2v: Rename internal Makefile rule 'run-virt-p2v' -> 'run-virt-p2v-in-a-vm'.
Now there are two rules for running virt-p2v:

  make -C p2v run-virt-p2v-directly

  make -C p2v run-virt-p2v-in-a-vm

Updates commit f8cfdf274f.
2016-06-03 13:05:07 +01:00
Richard W.M. Jones
1507913168 p2v: Fix docs for new hot key to use when testing virt-p2v in a VM.
The QEMU hot key for choosing the boot disk has changed in qemu 2.6.0
so update the documentation to reflect this.
2016-06-03 13:05:07 +01:00
Richard W.M. Jones
57abf86676 p2v: Make run-virt-p2v rule depend on $(PHYSICAL_MACHINE).
Fixes commit f8cfdf274f.
2016-06-03 13:05:07 +01:00
Richard W.M. Jones
523a65b65f p2v: Pass special --iso flag when running in the ISO environment.
If this flag is not set (ie. we are doing local testing) then we
disable some dangerous features.  Currently this is just the "Reboot"
button, but may include other features in future.
2016-06-03 13:05:07 +01:00
Richard W.M. Jones
b2bd2beeb6 p2v: Allow virt-p2v to be built with Gtk 2 or 3.
Currently virt-p2v requires Gtk 2.  This commit changes virt-p2v so it
can be built with either Gtk 2 or 3.

By careful use of macros, this code should compile on both recent
Gtk 2 and Gtk 3.

With no other options, ./configure will now prefer Gtk 3 if it finds
it, or fall back to Gtk 2.  But you can control this by setting
'./configure --with-gtk=2|3|check|no' where the options mean:

  * --with-gtk=2 - Only test for Gtk 2
  * --with-gtk=3 - Only test for Gtk 3
  * --with-gtk=check - Check for Gtk 3 then Gtk 2 (default)
  * --with-gtk=no - Don't build virt-p2v

In the ./configure output you will see something like this:

  checking for --with-gtk option... 2
  checking for GTK... yes
  checking if we can build virt-p2v... yes, with Gtk 2
2016-06-03 13:05:07 +01:00
Richard W.M. Jones
b5ea940d52 p2v: Remove GDK thread synchronization.
Gtk 3 deprecates the GDK thread synchronization locks (functions such
as gdk_threads_enter/gdk_threads_leave), and requires that you issue
all Gtk calls in the main thread.  To do this you have to restructure
any code that calls Gtk from other threads so it is wrapped in an idle
task, and so is run from the main thread.

This commit transforms the code in this way.

I found through experimentation that libxcb crashes noisily if you
issue any X11 calls (and hence any significant Gtk calls) when the GDK
thread sychronization initializer has been removed, so if there are
any remaining calls that are missed by this patch we should find out
about them quickly.
2016-06-03 13:05:07 +01:00
Richard W.M. Jones
53ec66c7e2 p2v: Add --test-disk option for testing conversions.
Use, for example:

  ./run virt-p2v --test-disk=$(pwd)/test-data/phony-guests/windows.img

to test conversions using a file of test data instead of the real host
/dev/sda.
2016-06-03 13:05:07 +01:00
Richard W.M. Jones
7274f11ad4 builder: Warn if --output is a host partition (RHBZ#1342337).
But allow the warning to be turned off using --no-warn-if-partition.

Ming Xie tried to create a bootable USB key using
'virt-p2v-make-disk -o /dev/sdX1'.  That works, but doesn't create a
bootable key because it puts everything into the first partition.

Emit a warning if someone tries to do this to try to prevent user
error:

  virt-builder: warning: output device (/dev/sdb1) is a partition.  If you
  are writing to a USB key or external drive then you probably need to write
  to the whole device, not to a partition.  If this warning is wrong then you
  can disable it with --no-warn-if-partition
2016-06-03 13:05:07 +01:00
Richard W.M. Jones
df7a33768e mllib: Add Common_utils.is_partition function.
Returns true if the device is a host partition.

The only tedious bit of this patch is that now Common_utils depends on
Dev_t so we have to add extra objects every time something links with
Common_utils.
2016-06-03 13:05:07 +01:00
Richard W.M. Jones
dd2ce98d24 mllib: Add bindings for makedev(3), major(3) and minor(3). 2016-06-03 13:05:07 +01:00
Richard W.M. Jones
6358633bf2 p2v: Add --verbose option to virt-p2v-make-{disk,kickstart}.
For virt-p2v-make-kickstart this doesn't do very much.  But for
virt-p2v-make-disk it enables verbose mode in virt-builder which is
extremely useful for debugging problems.

Thanks: Ming Xie.
2016-06-02 14:16:38 +01:00
Richard W.M. Jones
036a11f379 p2v: Hide the spinner when it is not running (RHBZ#1341564).
Thanks: keanli
2016-06-01 12:05:32 +01:00
Richard W.M. Jones
2b67073432 p2v: Add missing ethtool dependency.
virt-p2v runs `ethtool --identify' command, but since the command was
not included in the ISO the command always failed.

Thanks: Ming Xie.
2016-06-01 11:54:03 +01:00
Pino Toscano
603f4f1c23 p2v: require a non-interative sudo (RHBZ#1340809)
Run sudo with -n (non-interactive), so it will fail right away when not
configured to not require a password.  This will avoid the connection to
time out.
2016-05-31 12:36:22 +02:00
Richard W.M. Jones
3e437d1671 p2v: Rebuild the virt-p2v disk image if dependencies.m4 changes.
Fixes commit f8cfdf274f.
2016-05-30 17:42:23 +01:00
Richard W.M. Jones
d3b2a5bbd2 p2v: Add xterm to the virt-p2v ISO.
You can run `xterm -display :0' at the virtual console in order to get
a shell in the graphical environment.

This is useful for debugging and doesn't have much overhead unlike
other terminals.
2016-05-30 17:42:23 +01:00
Richard W.M. Jones
af4502c95f p2v: Preserve and display the full version of p2v and v2v.
Fetch the full version from the remote virt-v2v, including the
--with-extra field, since that tells us which distro virt-v2v was
compiled for which is useful information.

Display this information in all debug output and dialogs.
2016-05-28 15:54:24 +01:00
Richard W.M. Jones
adef54ad1a p2v: Translate comments in About dialog.
Also make the translatable string more accurate.
2016-05-28 15:53:56 +01:00
Richard W.M. Jones
ffc53c318e p2v: More internal documentation. 2016-05-28 15:26:27 +01:00
Richard W.M. Jones
3c3472f3e5 p2v: Add Ming Xie (from QA team) to authors page. 2016-05-28 15:09:31 +01:00
Richard W.M. Jones
c20b06dc08 p2v/gui.c: Add internal documentation.
No functional change.
2016-05-28 14:34:58 +01:00
Richard W.M. Jones
a90343f1e9 p2v: Fix alignment issues in treeviews on right of conversion dialog (RHBZ#1340407).
Multiple cell alignment issues in the treeviews on the right of the
conversion dialog.  This particularly showed up when you had multiple
heterogeneous disks or network cards because the description cells did
not align nicely.

Thanks: Ming Xie.
2016-05-27 13:21:00 +01:00
Richard W.M. Jones
4bbdb85822 p2v: Update 'make run-virt-p2v' rule.
Use KVM, fallback to TCG.

Add more network devices so we can test the layout of that
dialog box.

Move the documentation into guestfs-hacking(1).

Updates commit f8cfdf274f.
2016-05-27 13:05:32 +01:00
Richard W.M. Jones
cb803ef37e Version 1.33.32. 2016-05-27 09:53:54 +01:00
Richard W.M. Jones
f8cfdf274f p2v: Add a 'make run-virt-p2v' rule which boots virt-p2v in a VM.
A convenience method instead of having to work out the right
qemu command line each time.
2016-05-26 19:04:34 +01:00
Richard W.M. Jones
25ffcc7d43 p2v: Disable SELinux in virt-p2v-make-disk.
The kickstart version of virt-p2v has SELinux disabled, so this is at
least consistent.  Mainly it avoids the very long relabel when the
disk boots first time.
2016-05-26 19:00:38 +01:00
Richard W.M. Jones
10b3065b89 p2v: Consolidate EXTRA_DIST and CLEANFILES into single lists.
No functional change.
2016-05-26 19:00:38 +01:00
Pino Toscano
0e1f12f2e1 osinfo: use guestfs_int_version_from_x_y to parse the os version
Make use of the common version code, and avoid a separate regexp.
2016-05-26 17:51:09 +02:00
Pino Toscano
03ce1a4e0c lib: qemu: use guestfs_int_version_from_x_y for qemu version parsing
Make use of the common version code, and avoid a separate regexp.
2016-05-26 17:51:09 +02:00
Richard W.M. Jones
7023f20830 aarch64: launch: Only pass gic-version=host when KVM is likely to be enabled.
See:
https://bugzilla.redhat.com/show_bug.cgi?id=1339977
2016-05-26 16:30:49 +01:00
Pino Toscano
ea41945e88 customize: random_seed: avoid one file checking for existing files
When the random-seed file is found, then avoid checking its existance
again.
2016-05-26 15:15:40 +02:00
Pino Toscano
0f4dfa8282 dib: pass envvars also to extra-data.d scripts
Inject the variables passed via --envvars also when running extra-data.d
scripts.  This removes the need to exporting them before running
virt-dib.
2016-05-26 15:15:39 +02:00
Richard W.M. Jones
6cc640b558 Version 1.33.31. 2016-05-26 12:55:32 +01:00
Richard W.M. Jones
e516b85bd7 v2v: Add test-v2v-i-ova-subfolders test files to EXTRA_DIST.
Fixes commit 9de9300e8b.
2016-05-26 12:54:08 +01:00
Richard W.M. Jones
55e5150106 todo: Use query-qmp-schema. 2016-05-26 11:36:20 +01:00
Richard W.M. Jones
0c49869366 Revert "utils/boot-analysis: Make seabios optional in timeline."
The loss of SeaBIOS messages was actually caused by a bug in my code,
not a change in the boot process.

This reverts commit 6fa24e768a.
2016-05-25 13:42:21 +01:00
Richard W.M. Jones
6fa24e768a utils/boot-analysis: Make seabios optional in timeline. 2016-05-24 22:05:42 +01:00
Pino Toscano
9928296c1c inspect: get icon of ALT Linux guests
The icon is part of a documentation package, although it's the best hit
so far...
2016-05-24 18:49:53 +02:00
Pino Toscano
77ad2e1f18 customize: add support for the xbps package manager 2016-05-24 18:14:38 +02:00
Pino Toscano
5d1dfe89cd inspect: support the xbps package manager and its format
Associate the Void Linux distribution with it.
2016-05-24 17:54:47 +02:00
Pino Toscano
0251c0fcaa inspect: recognize the Void Linux distribution
Since Void Linux provides only an /etc/os-release with no VERSION_ID
field, then special-case it to avoid that the os-release parsing ignore
it.

This provides basic distro identification, and icon.
2016-05-24 17:54:47 +02:00
Pino Toscano
c0534db2cb inspect: allow single-number version in DISTRIB_RELEASE of lsb-release
When parsing lsb-release, allow a version number in the format "X" other
than "X.Y" for the DISTRIB_RELEASE key.

This fixes version parsing in Mageia 4 guests.
2016-05-24 15:32:43 +02:00
Pino Toscano
c605765c95 mllib: add a new run_command helper
Add a simple helper to run a command from a sequence of arguments,
without using a shell: this should help reducing the amount of quoting
ineeded, since arguments are passed straight as such.

Make use of it in the places currently using shell_command, and which
don't assume they can run anything (so no shell redirections, `env`,
etc).
2016-05-24 11:26:48 +02:00
Pino Toscano
d58b2437e4 mllib: move stringify_args from dib
Move the make_dib_args helper function to Common_utils as
stringify_args, so it can be used also within Common_utils itself.

This is mostly code motion.
2016-05-24 11:16:11 +02:00
Pino Toscano
f06b7dbe45 v2v: use common debug function where possible
Followup of commit 063af7f987.
2016-05-24 11:10:50 +02:00
Pino Toscano
a52ee88f88 mllib: add an helper shell_command
Add a simple shell_command, which is mostly a wrapper around
Sys.command but with logging of the command run.
2016-05-24 11:10:42 +02:00
Pino Toscano
3dad36dab2 mllib: make external_command echo the command executed
Add an optional parameter to disable this behaviour, so the Curl module
in v2v won't print user-sensible data (like passwords).
2016-05-24 11:10:15 +02:00
Cédric Bosdonnat
9de9300e8b v2v: handle subfolders in ova files
Some ova files like those produced by SUSE Studio have their ovf, mf
and other files inside a folder rather than at the root of the
tarball. Consider the paths relative to the ovf and mf files to cover
this case too.
2016-05-24 09:19:48 +01:00
Cédric Bosdonnat
c466d4cb92 v2v: add support for SUSE VMDP drivers
To add this support, two things are needed:
 * make the existing code searches for either the viostor
   or the SUSE VMDP (Virtual Machine Driver Pack) files.

 * add a firstboot script setting up VMDP.

Note that 2 firstboot scripts are intentionally added for the VMDP
setup. This is due to windows potentially rebooting after loading the
virtio block driver. It may happen that this reboot interrupts the VMDP
setup in the firstboot script, we thus make sure the setup is run a
second time in case it needs to finish the previous run.
2016-05-24 09:19:48 +01:00
Cédric Bosdonnat
07f7bfa608 customize: fix windows firstboot script
Sync the windows firstboot script with its linux brother. Also change
the main redirection to append to the log rather than overwriting it.
With this change, the firstboot script will resist reboots in the
executed scripts.
2016-05-24 09:19:48 +01:00
Pino Toscano
0a4aac0d08 appliance: add kpartx to the dib packages
Newer diskimage-builder versions run kpartx in root.d elements.
2016-05-23 18:20:43 +02:00
Richard W.M. Jones
50e1ae5aa0 Version 1.33.30. 2016-05-23 12:02:52 +01:00
Richard W.M. Jones
d5cd752e25 v2v: Fix unit tests for new UEFI paths.
Fixes commit f755918fb5.
2016-05-23 12:00:28 +01:00
Richard W.M. Jones
063af7f987 ocaml tools: Use a common debug function.
Add a common debug function for printing debugging messages.  It only
emits the debug message when the verbose (-v) flag is used on the
command line.

It sends the output to stderr, which is flushed immediately after the
message is printed (to help with debugging unexpected crashes).  There
are good arguments for sending the debug to either stdout or stderr,
and almost all existing debug messages replaced by this change went to
stdout.  However using stderr is consistent with libguestfs's own
debug messages which also go to stderr.

I only made simple changes to code of the form 'if verbose () then
printf ...'.  There are more places which could be changed in future.
In a few places I removed gettext calls since we probably should not
translate debug messages.
2016-05-23 10:30:56 +01:00
Richard W.M. Jones
87c18474b5 customize: Turn print into warning.
It is still only emitted if we are debugging in order not to cause
unnecessary alarm.  Note this code needs a better long term fix, this
is still a hack.
2016-05-23 10:30:56 +01:00
Richard W.M. Jones
1f09537a9c umask: Use /proc/self/status instead of unnecessary path computation.
Fixes commit 2feeeb8fb4.

Thanks: Roman Kagan.
2016-05-23 10:30:52 +01:00
Richard W.M. Jones
f755918fb5 uefi: Add new locations for UEFI files on Fedora (RHBZ#1338083).
Now that UEFI is fully open source the UEFI firmware can be included
in Fedora.  However the location is slightly different from the
location that was used by kraxel's out of distro firmware.  This
commit searches for UEFI files in the new location, falling back to
the old location (until the end of this year when we will drop it
entirely).

Thanks: Cole Robinson, Gerd Hoffmann (kraxel) & Microsoft for
relicensing the FAT code.
2016-05-23 10:12:04 +01:00
Richard W.M. Jones
1d79964bf7 utils: Move UEFI firmware lists to src/uefi.c.
Just code motion, no functional change.
2016-05-23 10:12:04 +01:00
Richard W.M. Jones
607b2b9b0c v2v: Remove unused and unimplemented Linux.install function.
This function did 'assert false' and was also never called
from anywhere else.  Delete it.
2016-05-23 09:59:21 +01:00
Richard W.M. Jones
2feeeb8fb4 umask: Use /proc/<PID>/status to read umask in Linux >= 4.7.
Since Linux 4.7, the process umask is available in /proc/<pid>/status.
See:
3e42979e65

Use this value if available, else fall back to the existing codepath
for Linux <= 4.6 and other Unix.
2016-05-23 09:59:21 +01:00
Richard W.M. Jones
7855f15ad9 v2v: windows: Minor documentation fixes.
Fixes commit 19f3689e5d
and commit ee02191483.
2016-05-21 15:40:56 +01:00
Richard W.M. Jones
a11dd820c7 src/version.c: Move internal documentation before includes.
The internal documentation generator only works if the file
description comment appears before the first #include line.

Fixes commit f277087d2a.
2016-05-20 21:03:49 +01:00
Pino Toscano
23ebc3d9eb tests: disable UUID change on ext journal_dev
Newer versions of e2fsprogs refuse modifying journal devices, causing
the test #1 of get_e2uuid to fail with:

  libguestfs: error: set_e2uuid: Cannot modify a journal device.

Since the test case just needs to verify get_e2uuid runs without
failing, run it without expecting a certain UUID set earlier.

Followup of commit da4812ab6b.
2016-05-20 13:27:40 +02:00
Pino Toscano
ff0a622a6f tests: fix --format in virt-customize
Only in very recent OCaml versions (or in Fedora) the Arg module
supports the --foo=bar syntax for options with arguments.  Do not
require it yet.

Fixes commit 64bb9edd52.
2016-05-20 13:21:15 +02:00
Cédric Bosdonnat
536ef6f34a customize: change windows firstboot path
Rename the C:\Program Files\Red Hat\Firstboot folder into the more vendor
independent C:\Program Files\Guestfs\Firstboot.
2016-05-20 10:48:50 +01:00
Cédric Bosdonnat
75fe93ea74 v2v: improve initrd search
To make sure we can also find the initrd on openSUSE and SLES, we need two improvements:
 * the initrd filename may not end with '.img'
 * don't use the version + release from the RPM data, rather from the
   /lib/modules/<version>/ path as we need to find it out anyway.
2016-05-20 10:39:58 +01:00
Cédric Bosdonnat
e9082ea4d9 v2v: rename RHEL 5 Xen input section into Xen in man
In virt-v2v man page the documentation on how to use RHEL 5 Xen as
input is generic enough to fit other Xen versions.
2016-05-20 10:39:58 +01:00
Cédric Bosdonnat
25848b59e5 v2v: document SUSE's Xen as a working input hypervisor 2016-05-20 10:39:58 +01:00
Cédric Bosdonnat
ee78c06b7f customize: add support for pvvxsvc
SUSE VMDP comes with a replacement for rhsrvany.exe named pvvxsvc.exe.
Check for either one of them instead of only rhsrvany.
2016-05-20 10:39:58 +01:00
Pino Toscano
1c9e808eee fish: generate test-prep.sh with generator
Generate test-prep.sh using the generator, so the prepared disk types
tested are the same as the ones configured in prepopts.ml.
2016-05-19 19:06:00 +02:00
Pino Toscano
d5b3f558e0 tests: remove remaining relative paths to binaries
Tests are run via the ./run binary, so all the binaries in the build
directory are available via $PATH already.

Followup of commit e85a976c5a.
2016-05-19 19:06:00 +02:00
Pino Toscano
64bb9edd52 tests: specify the image format when possible
When possible, make the disk image format explicit when invoking tools
or using add-drive. This avoids warnings from qemu about the unspecified
format for the image, and also makes qemu slightly faster (skipping the
disk image probing).
Tests checking the image probing are not touched.

This changes also:
- old-style invocations of tools (`$tool $filename`) into new style
  (`$tool -a $filename`)
- add-drive-ro/add-drive-with-if guestfish commands into add/add-drive
  with explicit readonly/iface arguments

There should be no change in the tests results.
2016-05-19 19:06:00 +02:00
Pino Toscano
b5c81b3e12 customize: fix ownership when creating ~/.ssh/authorized_keys (RHBZ#1337561)
When creating ~/.ssh and ~/.ssh/authorized_keys (in case they are
missing), change their ownership to the target user.  If not, they are
owned by root.
2016-05-19 19:06:00 +02:00
Pino Toscano
59690dfc04 customize: minor function factoring in ssh_key
Turn the snippet reading user information from /etc/passwd in a slightly
more generic function, so there is no need to copy&paste for other
details.

Mostly code motion.
2016-05-19 19:06:00 +02:00
Cédric Bosdonnat
89ae53ecdd appliance: skip /etc/mtab creation is already existing
At least on openSUSE and SLES, the /etc/mtab file is already existing.
Skipping the symlink creation in init removes one error message during
the appliance boot.
2016-05-19 19:06:00 +02:00
Cédric Bosdonnat
3bf7d307b6 Update packagelist for SLES and openSUSE
SUSE Linux Entreprise Server doesn't have dhcpcd and the hivex package
is not in the default repositories. Better use dhcp-client and
libhivex0.

openSUSE needs ntfs-3g and ntfsprogs packages.
2016-05-19 19:06:00 +02:00
Cédric Bosdonnat
bba9ea9d50 v2v: also search for windows virtio drivers in symlinks
To allow saving space in the package shipping the windows virtio
drivers, we can use symlinks between the drivers folders. For example
SUSE VMDP drivers are the same for Win8.1 and Win2012r2, one folder
is a symlink to the other.

To take advantages of this, find must use the -L flag.
2016-05-19 19:06:00 +02:00
Richard W.M. Jones
54629d3d34 p2v: Run udevadm settle when virt-p2v starts up. 2016-05-19 13:22:29 +01:00
Richard W.M. Jones
1817d9a966 lib: qemu: Memoize qemu feature detection.
qemu feature detection takes about 95ms on my laptop.  The overhead is
almost all due to the time taken by the glibc link loader opening the
170+ libraries that qemu is linked to (×2 because we need to run qemu
twice).

Fixing that is seriously hard work.

Therefore memoize the results of guestfs_int_test_qemu.

This is keyed on the size and mtime of the qemu binary, so if the user
changes the qemu binary (eg. setting LIBGUESTFS_HV) we discard the
memoized result and rerun the qemu commands.  There is also a
generation number so we can bump the generation in future versions of
libguestfs to invalidate all previously cached data.

The memo is stored in the supermin cache directory (eg. /var/tmp/.guestfs-*)
in the files:

  qemu.stat     Result of 'stat(2)' of the qemu binary
  qemu.help     qemu -help output
  qemu.devices  qemu -devices ? output

Note these files are only stored when using the 'direct' backend.  For
the libvirt backend, libvirt itself memoizes this data in its own
place.
2016-05-18 18:10:10 +01:00
Richard W.M. Jones
4e36f2fa9e lib: Move qemu testing code to a new module called 'qemu.c'.
This is code motion, but I have cleaned up and formalized the
interface between this module and other parts of the library.

Also this adds documentation to the interface.
2016-05-18 18:10:10 +01:00
Richard W.M. Jones
166ac594cc launch: direct: Capture and display maxrss of qemu subprocess.
The maxrss is described in getrusage(2) as "This is the maximum
resident set size used (in kilobytes).".  This lets us find out how
much memory qemu really used, and is useful for determining if memory
minimization techniques such as DAX are having any effect.
2016-05-18 18:08:56 +01:00
Pino Toscano
9b305eae29 drives: force format=raw for /dev/null dummy drives
When creating the dummy scratch disk for a /dev/null drive, force its
format as raw if it was not specified already.  After all, raw was
already the only format allowed for this kind of drives, so it makes
sense to specify the format explicitly and avoid the autodetection in
qemu.
2016-05-18 17:33:05 +02:00
Pino Toscano
3fb35e6627 inspect: switch to version struct for os major/minor version
Use the version struct in inspect_fs to hold the version of a
filesystem, adapting the inspection code to that.

Also, move the parts of the version parsing to helper functions of the
version struct, so common bits like parsing "X.Y" or "X" version strings
is done only once.
2016-05-18 15:02:27 +02:00
Pino Toscano
f277087d2a src: start unifying version handling
Introduce a new struct version with few helper functions for it: this
allows to "atomically" represent a version number, without different
variables to be used and checked together.

Add a initialization function from a libvirt-style version number, and
apply it for the qemu and libvirt versions in the direct and libvirt
backends.
2016-05-18 14:57:44 +02:00
Richard W.M. Jones
d6ec6e06d2 Version 1.33.29. 2016-05-17 21:31:44 +01:00
Richard W.M. Jones
613fe4c089 utils: boot-analysis: Make insmod message handling a bit more robust. 2016-05-17 15:35:20 +01:00
Richard W.M. Jones
8a4dcde16a appliance: Find udevd a bit faster.
Rearrange the paths that we check for udevd so that the systemd paths
are first.  Break from the loop as soon as we find udevd.
2016-05-17 15:35:20 +01:00
Richard W.M. Jones
db1f811b29 appliance: Reenable ACPI.
Previously I disabled ACPI because it was not necessary and was slow.
However measuring it again now, I can see no significant difference in
performance, and it is necessary if we are going to use DAX.

It's also useful to keep the appliance kernel state as similar to the
ordinary state, and setting acpi=off is a massive change to the way
that the kernel boots.

Therefore, reenable it.
2016-05-16 23:18:00 +01:00
Richard W.M. Jones
aec89b62be appliance: Move code for creating supermin appliance directory to tmpdirs.c.
This is largely code motion.
2016-05-16 23:18:00 +01:00
Richard W.M. Jones
2c474923b4 src/tmpdirs.c: Add internal documentation. 2016-05-16 23:18:00 +01:00
Richard W.M. Jones
bb9893ab51 launch: direct: Simplify -machine parameter.
Use the ADD_CMDLINE_PRINTF to simplify this code.  No functional
change.
2016-05-16 19:20:22 +01:00
Richard W.M. Jones
214ec3dee7 launch: direct: Break some long source code lines.
Just cosmetic, no functional change.
2016-05-16 19:20:22 +01:00
Pino Toscano
839ae5bcd5 btrfs_filesystem_show: work with btrfs < 4.3.1
Versions older than 4.3.1 output also the version string after the
output.  Ignore such line, since it isn't relevant to what
btrfs_filesystem_show needs.
2016-05-16 14:28:26 +02:00
Richard W.M. Jones
653e374ef6 inspection: Unquote UUID=.. or LABEL=.. before passing to findfs (RHBZ#1335671).
In /etc/fstab the UUID= or LABEL= field may be quoted.  Augeas returns
the field including the quotes, and we passed this directly to
guestfs_findfs_uuid or guestfs_findfs_label.  It happens that this
works on upstream findfs, although it doesn't work in RHEL 7.2.  The
correct thing to do is to remove the quotes before passing the UUID or
label to these functions.

Thanks: Thom Carlin for reporting the bug, Karel Zak for identifying
the change in behaviour in util-linux.
2016-05-16 12:39:25 +01:00
Richard W.M. Jones
e13334a1a2 v2v: Move the shell_unquote function to src/utils.c.
This function is useful outside virt-v2v so move it into the core
utilities library.

The function has been rewritten from OCaml into C, but it should be
functionally identical.
2016-05-16 12:39:25 +01:00
Richard W.M. Jones
12fb49c5dd build: Fix missing +=.
noinst_DATA is defined earlier in the Makefile.am, so we must
use the += operator to append to the previous value.
2016-05-16 12:39:25 +01:00
Richard W.M. Jones
1b35d1d225 mllib: Update documentation for qemu_input_filename.
Don't describe internally how the function works in the
public interface documentation, since that is misleading.
2016-05-16 11:33:41 +01:00
Richard W.M. Jones
1f4a0bd90d utils: boot-analysis: Avoid overflow when comparing large doubles. 2016-05-14 19:30:12 +01:00
Richard W.M. Jones
bf80587367 utils: boot-analysis: Add magic & asserts to some structs.
I suspected data corruption (but didn't prove it).  This commit just
adds some magic numbers to the structs so we will see data corruption
quickly if it happens again.
2016-05-14 18:46:36 +01:00
Richard W.M. Jones
12d8decfa9 launch: Use tsc=reliable.
This saves about 21ms per secondary CPU when using guestfs_set_smp.
2016-05-13 15:57:39 +01:00
Richard W.M. Jones
b6f5a0cd90 utils: boot-analysis: Make handling of first kernel message more flexible.
Allows us to disable EDD completely, and still have boot-analysis work.
2016-05-13 13:30:39 +01:00
Richard W.M. Jones
634f47e6d4 appliance: Copy /etc/ld.so.cache from the host into the appliance.
Previously we were running ldconfig to create /etc/ld.so.cache.

This is required, at least on Fedora, if we need to run any binary
that uses a library with a weird path.  libiscsi (a dependency of
qemu-img, used by virt-dib) is an example of such a weird library,
since it puts its single library into /usr/lib64/iscsi for no readily
understandable reason, and drops a configuration file into
/etc/ld.so.conf.d/ so that this new directory gets picked up.

By copying the /etc/ld.so.cache from the host we get an already
configured cache which should contain every library on the host, so
there is no need to run ldconfig.
2016-05-13 13:30:39 +01:00
Richard W.M. Jones
ba8e8d277d Revert "appliance: init: run ldconfig"
Running ldconfig adds about 100ms to the boot time.  I would prefer
that we understood which libraries need ldconfig to be run, and fix
that.  We could also consider running ldconfig in parallel, but since
it might be required by just about any binary that the init script
runs it's not clear what benefit that gives.

This reverts commit 66aa98265d.
2016-05-13 13:30:39 +01:00
Pino Toscano
e3d429d37d New API: btrfs-filesystem-show (RHBZ#1164765)
Add a new API to list all the devices where a btrfs filesystem is
spanned.
2016-05-12 17:14:11 +02:00
Pino Toscano
ddcd9c2a10 builder: run/schedule a SELinux relabel if needed
If the guest uses SELinux, then make sure to run a relabel (or at least
schedule one) after the image build: this way the template is
relabelled, or at least it will do that at the next boot, without the
need for the user to ask for a relabel.

This just covers the case of building a new image with no additional
operations on it though.
2016-05-10 15:11:54 +02:00
Richard W.M. Jones
754b8f5ef3 boot-analysis: Flush out debug data after printing it.
Just makes it easier to see bugs causing the analysis stage to
hang / infinite loop.
2016-05-10 12:17:28 +01:00
Richard W.M. Jones
e4edede364 boot-analysis: Make ftrace optional in the timeline.
This allows me to test minimal kernels with ftrace disabled at
compile time.
2016-05-10 12:16:36 +01:00
Richard W.M. Jones
320b0faeaf utils: boot-analysis: Fix minor typo in string. 2016-05-09 12:19:16 +01:00
Richard W.M. Jones
a608865cac Version 1.33.28. 2016-05-09 10:10:36 +01:00
Richard W.M. Jones
999df47160 src/utils.c: Update comment. 2016-05-09 09:21:53 +01:00
Pino Toscano
873560f495 perl: use INT2PTR macro for casting back to guestfs_h * (RHBZ#1150298)
Use the right macro, which should avoid the warnings seen with Perl
headers on some architecture.
2016-05-09 10:04:15 +02:00
Richard W.M. Jones
ea71e00d1a fish: Add internal documentation to several files. 2016-05-08 20:59:36 +01:00
Richard W.M. Jones
13017c852e lib: Rename test-utils -> unit-tests. 2016-05-07 12:46:49 +01:00
Richard W.M. Jones
4910a448f4 lib: Add more unit tests.
Add unit tests for the following internal functions:

 - guestfs_int_getumask
 - guestfs_int_new_command and other src/command.c functions
 - guestfs_int_qemu_escape_param
 - guestfs_int_timeval_diff
 - guestfs_int_match, match1, match2
 - guestfs_int_add_string and other src/stringsbuf.c functions

Because we now need to use a libguestfs handle, we have to link the
unit tests to the library.  But because we also need to access the
internal functions (to test them) we need to link the test statically
to the objects making up the library.  So this requires a small change
to the linking of this test too.
2016-05-07 12:40:50 +01:00
Richard W.M. Jones
c3ff4da088 src/stringsbuf.c: Add internal documentation. 2016-05-07 12:40:50 +01:00
Richard W.M. Jones
479828ccd0 src/test-utils.c: Add internal documentation. 2016-05-07 09:31:05 +01:00
Richard W.M. Jones
0ff9b808d9 src/conn-socket.c: Add internal documentation. 2016-05-07 07:44:47 +01:00
Richard W.M. Jones
b4f440e65a src/whole-file.c: Add internal documentation. 2016-05-07 07:38:24 +01:00
Richard W.M. Jones
cad516cae5 src/command.c: Add documentation markup. 2016-05-05 22:56:43 +01:00
Richard W.M. Jones
3965c9f56e lib: Turn qemu_escape_param into a shared function.
This function appeared twice (identically).  Turn it into a single
shared function.

This also adds some documentation for the two files affected.
2016-05-05 22:38:30 +01:00
Pino Toscano
f3c278474d inspect: check also /etc/hosts for detecting Linux root (RHBZ#1203898)
Use /etc/hosts as alternative of /etc/fstab to detect whether a partition
represents the root of a Linux installation; the latter might not exist
in smaller/special installations like Docker images.
2016-05-05 22:00:47 +01:00
Pino Toscano
48116cfb4e python: use constants instead of raw values
Extend the internal libguestfsmod module with the CREATE values, so
there is no need to hardcode values in GuestFS.__init__.
2016-05-05 22:00:47 +01:00
Pino Toscano
dc02e8985f tools: improve reporting for option errors (RHBZ#1316041)
Improve the error messages produced by C-based tools in case of issues
with the command line options:
- explicitly mention to use -a/-d (and -A/-D in virt-diff)
- when extra arguments are found, mention the correct way to pass
  options to certain command line switches (like --format)
- in virt-inspector, give a cleaner error message when neither -i nor
  any -m is specified

In all the cases, keep the extra notice to use 'TOOL --help' to get more
help with it.
2016-05-05 14:25:28 +02:00
Richard W.M. Jones
cd689c9d3a Version 1.33.27. 2016-05-04 18:20:20 +01:00
Richard W.M. Jones
ff7e755f95 utils: Add README to EXTRA_DIST.
Updates commit 3b581a727c
and commit bbec1b570b.
2016-05-04 18:16:26 +01:00
Pino Toscano
43358290b3 python: PEP 8: miscellaneous coding fixes
python/guestfs.py:136:37: E712 comparison to True should be 'if cond is True:' or 'if cond:'
python/t/tests_helper.py:42:8: E713 test for membership should be 'not in'

No functional changes, as the new versions follow the suggested Python
coding style to do the same things.
2016-05-04 18:56:01 +02:00
Pino Toscano
060b724c49 python: PEP 8: avoid whitespace-only lines in docstrings
Tweak the docstring generation to avoid lines with only indentation
spaces.

No functional changes, only whitespaces removals.
2016-05-04 18:56:01 +02:00
Pino Toscano
845d518b8b python: PEP 8: miscellaneous indentation fixes
Small fixes for few remaining indentation issues.

No behaviour changes.
2016-05-04 18:56:01 +02:00
Pino Toscano
6e34396661 python: PEP 8: avoid too long lines
Reindent Python scripts to make sure lines are not longer than 80
columns.

Regarding autogenerated code (guestfs.py and bindtests.py): add an
helper function to make sure comma-separated lists are wrapped at the
wanted length.

This produces only differences in the indentation of long Python lines,
with no behaviour changes.
2016-05-04 18:56:01 +02:00
Pino Toscano
d8337077e3 python: PEP 8: break compound statements
Avoid compound statements, simply indenting their blocks.

No functional changes.
2016-05-04 18:56:01 +02:00
Pino Toscano
2c7bba6374 python: PEP 8: remove trailing semicolons
Remove extra semicolons at the end of single-statement lines.

No behaviour changes.
2016-05-04 18:56:01 +02:00
Pino Toscano
f85e18f62f python: PEP 8: adapt empty lines
Add or remove empty lines to match the needed ones around
blocks/functions/etc.

This is just formatting, no behaviour changes.
2016-05-04 18:56:01 +02:00
Pino Toscano
6105ee0c71 python: PEP 8: adapt whitespaces in lines
Add (after comma) or remove (before opening round bracket, and around
'=' in arguments) whitespaces according to the PEP 8 specification.

This is just code reformatting, with no behaviour changes; no content
changed beside whitespaces, so "git diff -w" gives an empty diff.
2016-05-04 18:56:01 +02:00
Richard W.M. Jones
839a17ff04 docs: Document CVE-2015-8869 OCaml code gen bug. 2016-05-04 17:48:44 +01:00
Richard W.M. Jones
547662d9f6 customize: Improve the error messages when package manager is unknown or unsupported.
For Windows, we now print:

$ virt-customize -a ./test-data/phony-guests/windows.img --install MSSQL
[   0.0] Examining the guest ...
[  14.2] Setting a random seed
virt-customize: warning: random seed could not be set for this type of
guest
[  14.2] Installing packages: MSSQL
virt-customize: error: cannot use '--install' because no package manager
has been detected for this guest OS.

If this guest OS is a common one with ordinary package management then this
may have been caused by a failure of libguestfs inspection.

For OSes such as Windows that lack package management, this is not
possible.  Try using one of the '--firstboot*' flags instead (described in
the manual).
2016-05-04 17:48:25 +01:00
Richard W.M. Jones
5470f059c2 inspection: Set package manager to "unknown" if parsing major version failed (RHBZ#1332025).
In cases where parsing the release file failed and so we have an
obviously incorrect major version number, don't try to infer the
package manager from the major version number.

In the bug report, parsing the /etc/redhat-release file of a CentOS
7.1 guest failed, so major version was set to 0, and the package
manager was inferred as "up2date".  virt-customize then failed with a
peculiar error:

  virt-customize: sorry, don't know how to use --install with the 'up2date' package manager

Instead this sets it to "unknown" which will cause virt-customize to
fail with:

  virt-customize: --install is not supported for this guest operating system

which is (only very slightly) better.

Problem reported by novegin on IRC.
2016-05-04 14:09:50 +01:00
Richard W.M. Jones
d25e509317 Tag versions with "v<VERSION>" instead of just the version number.
This is the normal convention used for tagging git releases.
2016-05-04 14:09:50 +01:00
Richard W.M. Jones
a2ac6b4897 docs: Fix cross-references in guestfs-security(1).
Fixes commit 15b8b6453d.
2016-05-04 14:09:50 +01:00
Richard W.M. Jones
c585a5835b p2v: Fix misleading string in error message. 2016-05-04 14:09:50 +01:00
Richard W.M. Jones
28634ecc2c docs: Link to correct building instructions from guestfs-hacking(1).
No longer in the README file.
2016-05-03 22:54:14 +01:00
Richard W.M. Jones
d899a53f2e docs: Improve the internal documentation in guestfs-hacking.
Several mostly cosmetic changes.
2016-05-03 22:50:15 +01:00
Richard W.M. Jones
a8114449fa docs: Move internal documentation to guestfs-hacking(1).
All developer documentation should go in guestfs-hacking(1) and the
"internal documentation" (ie. documentation about internal functions
and interfaces) belongs here, not in the coincidentally synonymous
guestfs-internals(1).
2016-05-03 22:50:15 +01:00
Richard W.M. Jones
bbec1b570b utils: Add a README file describing briefly the purpose of this directory.
.. and where to find the real documentation.

Updates commit 3b581a727c.
2016-05-03 22:50:15 +01:00
Richard W.M. Jones
6b48977cb7 Version 1.33.26. 2016-05-03 14:49:59 +01:00
Richard W.M. Jones
b1c945195c po: Use xgettext --from-code=utf-8
Since moving boot-benchmark-range.pl out from under a tests/
subdirectory, it is now being added to po/POTFILES.  This causes the
following error:

/usr/bin/xgettext: Non-ASCII string at utils/boot-benchmark/boot-benchmark-range.pl:205.
                   Please specify the source encoding through --from-code.

Add --from-code parameter as instructed.
2016-05-03 14:39:03 +01:00
Richard W.M. Jones
5bbf8f655d Version 1.33.25. 2016-05-03 14:13:01 +01:00
Pino Toscano
ae3224cf8a customize: remove "core" from description of --update
--update invokes a distribution update, updating all the installed
packages and not just some "core" ones.
2016-05-03 14:25:46 +02:00
Pino Toscano
e77faf7f61 mllib: add "internal" to the description of --{short,long}-options
The Arg module of OCaml does not support hiding options from the --help
output: hence, mark --short-options and --long-options as internal
options, since we need them only for the bash completion scripts.
2016-05-03 14:25:46 +02:00
Richard W.M. Jones
a3bc0e13f6 build: Don't use noinst_MANS.
Automake doesn't run noinst_MANS rules at all, likely a bug.

Use noinst_DATA instead which is always run during the build.
2016-05-03 13:21:34 +01:00
Richard W.M. Jones
98b28b15c6 utils/boot-analysis, utils/boot-benchmark: Add manual pages. 2016-05-03 13:21:34 +01:00
Richard W.M. Jones
3b581a727c utils: Move tests/qemu/ boot-analysis etc tools to new utils top level directory.
Create a new top level directory called 'utils' and move the
following programs there:

  tests/qemu/boot-analysis -> utils/boot-analysis/
  tests/qemu/boot-benchmark -> utils/boot-benchmark/
  tests/qemu/qemu-boot -> utils/qemu-boot/
  tests/qemu/qemu-speed-test -> utils/qemu-speed-test/

Also we only build the boot-analysis program on x86-64 and aarch64,
since it requires custom porting to each architecture.
2016-05-03 13:21:34 +01:00
Richard W.M. Jones
c34995c6b3 launch: Add cryptomgr.notests to the appliance command line.
Save 28ms by not running the crypto self-tests when Linux boots.
2016-05-03 13:21:34 +01:00
Pino Toscano
1f5054daa8 php: Fix the tests yet again.
Move unsetting of LIBGUESTFS_DEBUG & LIBGUESTFS_TRACE into the
php-for-tests.sh wrapper.

Fixes commit 0d69eab98f.
2016-05-03 13:21:34 +01:00
Richard W.M. Jones
915f6e299e Revert "php: Fix the tests ... again."
This reverts commit 0d69eab98f.
2016-05-03 13:21:34 +01:00
Pino Toscano
4760d80c93 appliance: move btrfs-progs as common package
Recently Debian switched to btrfs-progs, so almost all the distributions
(except openSUSE) have btrfs-progs which is then moved as common
package.
The old btrfs-tools name is left there, to support Debian Jessie and
older, and Ubuntu Xenial and older.
2016-05-03 13:03:45 +02:00
Richard W.M. Jones
51cea56d1c Version 1.33.24. 2016-04-30 17:20:39 +01:00
Richard W.M. Jones
9cd00805b0 tests/qemu: boot-analysis: Display libvirt as distinct source.
Don't display libvirt events as '[library]', but as '[libvirt]'.
2016-04-30 16:42:24 +01:00
Richard W.M. Jones
2fd05203e4 tests/qemu: boot-analysis: Dump pass data times in ms, with diffs.
When (in --verbose mode) we dump the pass data, dump the times in
milliseconds (instead of nanoseconds) so they are consistent with
other output.  Also dump the time difference from the previous event.

Useful for detailed debugging/analysis of problems.
2016-04-30 16:02:30 +01:00
Richard W.M. Jones
66447f4e29 aarch64: Use AAVMF_CODE.verbose.fd when debugging is enabled.
When we are debugging use the verbose (debug messages enabled) version
of the AAVMF (UEFI) firmware.  This is useful for diagnosing what is
causing failures to boot and what inside UEFI is causing slow booting.
2016-04-30 15:49:58 +01:00
Richard W.M. Jones
f7381470bb v2v: Add unit tests of the Utils UEFI functions. 2016-04-30 15:41:26 +01:00
Richard W.M. Jones
5253d2367b utils: Use struct for UEFI firmware.
Use an array of structs for the UEFI firmware instead of an array of
strings.

This change is hopefully just refactoring and there is no functional
difference.
2016-04-30 15:17:08 +01:00
Richard W.M. Jones
03e2d00036 appliance: Add pciutils to the appliance.
This adds the 'lspci' program, useful for debugging
appliance / qemu problems.
2016-04-30 12:49:28 +01:00
Richard W.M. Jones
d76129aa0c launch: Don't initialize all UARTs (serial ports).
This doesn't save very much time, perhaps under 1ms, but it avoids
some useless scanning.
2016-04-30 12:49:28 +01:00
Richard W.M. Jones
2b9f58f87b launch: libvirt: Add a /dev/urandom-based virtio-rng device to the appliance.
It is safe to use /dev/urandom to seed the guest.  In libvirt 1.3.4
this silly restriction has been lifted.

This restores commit b2c845333f.
See also commit 9423c16607.

Thanks: Cole Robinson for doing the libvirt implementation.
2016-04-30 12:49:28 +01:00
Richard W.M. Jones
e080e5909e launch: libvirt: Add libvirt version to the data struct.
This commit just allows us to make XML features conditional on the
libvirt version, but has no other functional change.
2016-04-30 12:49:28 +01:00
Richard W.M. Jones
29cb8d60d2 launch: Disable USB in the appliance.
Only saves a tiny amount of time, but as we don't use USB
we might as well disable it.
2016-04-30 12:49:28 +01:00
Richard W.M. Jones
1beab198b9 ocaml: Add LDFLAGS to mlguestfs.cma/mlguestfs.cmxa.
Encode the build LDFLAGS into the OCaml library.
2016-04-30 12:49:28 +01:00
Richard W.M. Jones
b2464e07de v2v: Add a slow test to ensure trimming doesn't regress (RHBZ#1264332). 2016-04-30 12:49:28 +01:00
Richard W.M. Jones
5ec42a6238 v2v: OVF: Better mapping for inspection data to vmtype.
The old mapping code was directly copied from old virt-v2v, translated
from Perl to OCaml.

The new mapping code does a few things more accurately:

 - Use the i_product_variant field (Windows InstallationType) if available.

 - Simplify rules, so there is only one special case needed for RHEL 3/4.

 - Don't assume Fedora == Desktop.

 - Don't assume all later Windows variants are server.

 - Works for Windows > 7.
2016-04-30 12:49:28 +01:00
Richard W.M. Jones
3a6636fc05 v2v: Remove the --vmtype option.
It will now print a warning but is otherwise ignored:

  virt-v2v: warning: the --vmtype option has been removed and now does
  nothing

See:

  https://www.redhat.com/archives/libguestfs/2016-April/msg00178.html
2016-04-30 12:49:28 +01:00
Richard W.M. Jones
b81e8ef162 v2v: Remove --no-trim option.
It will now print a warning but is otherwise ignored:

  virt-v2v: warning: the --no-trim option has been removed and now does
  nothing

See:

  https://www.redhat.com/archives/libguestfs/2016-April/msg00178.html
2016-04-30 12:49:28 +01:00
Richard W.M. Jones
d5c40262fa tests/qemu: boot-analysis: Port this program to aarch64 (using UEFI). 2016-04-30 12:45:54 +01:00
Richard W.M. Jones
606f158606 tests/qemu: boot-analysis: Add analysis of initcalls before entering userspace. 2016-04-28 13:35:27 +01:00
Richard W.M. Jones
63915b69f1 Version 1.33.23. 2016-04-24 19:21:34 +01:00
Richard W.M. Jones
7f572434f0 tests: Add tests/qemu/boot-benchmark-range.pl to EXTRA_DIST.
Updates commit 8299d7087a.
2016-04-24 19:21:34 +01:00
Richard W.M. Jones
90aacea2ac ja: Fix unclosed L<> which breaks POD.
Since commit b23e149774, we have been
strict about POD errors.  An error in the Japanese translation caused
"L</guestfish" (ie. an unclosed L<>) to appear in the POD.

This commit fixes the problem, but when building you may need to do:

  rm po-docs/ja/guestfish.pod
  rm po-docs/podfiles; make -C po-docs update-po

in order to update the broken po-docs/ja/guestfish.pod file.

Unfortunately I have been unable to upload this change back to the
Zanata servers because of a variety of client problems.
2016-04-24 19:21:04 +01:00
Richard W.M. Jones
314c5795b0 podwrapper: Remove output file on failure.
Otherwise we end up generated a bad output file and (in some cases)
continuing the build.

Updates commit b23e149774.
2016-04-24 15:35:10 +01:00
Richard W.M. Jones
0d69eab98f php: Fix the tests ... again.
PHP (5?) renamed the PHP_EXECUTABLE variable to TEST_PHP_EXECUTABLE.
As a result of that if you enabled debugging, the tests broke because
we no longer used our custom PHP wrapper to filter out debugging
environment variables before running the tests, so debug output was
mixed with the expected output.

This commit also updates an old comment telling you how to debug PHP
tests.
2016-04-24 15:08:12 +01:00
Richard W.M. Jones
672eff4a34 v2v: target_bus_assignment: Assign removables with slot pref first. 2016-04-24 12:07:16 +01:00
Richard W.M. Jones
c1adbe61df v2v: target_bus_assignment: Various refactorings.
No functional change.
2016-04-24 12:06:02 +01:00
Richard W.M. Jones
6193b2b273 v2v: Assert fail if we overwrite an existing disk in a bus slot.
Prevents us from accidentally "losing" a disk during conversion.  I
believe from code inspection that this assertion is always true for
the current code, so this should have no effect.
2016-04-24 11:33:28 +01:00
Richard W.M. Jones
9e3182b4c5 v2v: Move target_bus_assignment to separate module.
This is just code motion.
2016-04-24 11:31:48 +01:00
Richard W.M. Jones
c42557f5e1 v2v: Move inspect_source to separate module.
It's a large feature / function with its own set of nested functions,
so move the inspect_source function into its own module.  It also lets
us specify and document the interface explicitly.

Also: Define a root_choice type in Types module.  I turned it into a
non-polymorphic variant type for extra type safety.

This is just code motion.
2016-04-24 11:31:16 +01:00
Richard W.M. Jones
0eb8d673c1 v2v: List SOURCES_MLI in alphabetical order.
Fixes commit 01ede002db.
2016-04-23 18:03:16 +01:00
Richard W.M. Jones
ac9c31eb68 v2v: Commenting and refactoring changes.
- Add headings, further documentation to the Types module.

- Move two type definitions in Types module.  Not a functional change.

- Add more comments and clean up comments throughout v2v/v2v.ml.

- Refactor guestcaps / conversion in v2v/v2v.ml.  Not a functional
  change, just hides local variables from the rest of the code.

- In --in-place mode, change inspection message to 'Inspecting the
  source VM'.  This matches the later message 'Closing the source VM'.
2016-04-23 17:57:32 +01:00
Richard W.M. Jones
9304b70ff6 v2v: Move 'du' function to Utils module.
Just code motion.
2016-04-23 17:54:33 +01:00
Richard W.M. Jones
8299d7087a tests: Add boot-benchmark-range script.
Add a script we can use to benchmark performance across a range of
commits in another project.
2016-04-22 17:10:43 +01:00
Richard W.M. Jones
45f84601b0 tests: boot analysis: Add text to describe how to change settings. 2016-04-22 16:39:49 +01:00
Richard W.M. Jones
874ef2a04f docs: Fix use of getopt and pod2usage in make-internal-documentation.pl.
Fixes commit 04229c68d6.
2016-04-22 16:39:49 +01:00
Richard W.M. Jones
b23e149774 podwrapper: Send errors to stderr and die if any errors seen.
Enable a few POD options:

 - Don't generate an errata section in the output.

 - Send errors and warnings to stderr.

 - Die if any errors or warnings are seen while generating the outputs.
2016-04-22 09:09:10 +01:00
Richard W.M. Jones
71a4ffdd05 builder: Add Ubuntu 16.04 (Xenial) image. 2016-04-21 13:41:52 +01:00
Richard W.M. Jones
d585aca1d5 builder: ubuntu: Lock the 'builder' account that we have to add to the template. 2016-04-21 13:41:00 +01:00
Richard W.M. Jones
f56a46d0b5 builder: ubuntu: Fix URL of archive.ubuntu.com.
The archive.ubuntu.net address appears to work only intermittently.
2016-04-21 13:40:37 +01:00
Richard W.M. Jones
a1e47c4b47 tools: Reduce use of _ (wildcard) in match statements.
No functional change, just various improvements to the safety of match
statements.
2016-04-21 12:50:58 +01:00
Richard W.M. Jones
234c4091b5 sparsify: Refactor handling of checks of copying mode / --in-place.
Just refactoring, no change.
2016-04-21 12:40:18 +01:00
Richard W.M. Jones
906e2e0a96 dib: Rewrite match statement as ordinary if statement.
Just stylistic change, no functional change.
2016-04-21 12:05:01 +01:00
Richard W.M. Jones
cb0818ea86 mllib: Add documentation to Common_utils, JSON and Mkdtemp modules. 2016-04-20 23:15:51 +01:00
Richard W.M. Jones
dec30914e8 mllib: Rename uRI -> URI.
There is no difference in the OCaml module name, which remains 'URI'.
2016-04-20 22:48:37 +01:00
Pino Toscano
541d07e35f launch: direct: specify format for appliance drive
The drive used for the appliance is a raw (sparse) disk: specify that
explicitly in its -drive qemu command line options, so qemu can skip the
autodetection of its format and save a tiny bit of time.
2016-04-18 16:27:24 +02:00
Richard W.M. Jones
fb74a275c1 p2v: Allow p2v kernel options to override GUI configuration (RHBZ#1327488).
Allow kernel options such as p2v.o=libvirt to override internal
defaults, even for GUI configuration.

The main change is to split up the kernel conversion into two steps:
reading the kernel command line configuration, and performing the
conversion.  The kernel command line can then be read by the main
program and used to initialize the config structure for either kernel
conversion or GUI conversion.

A small adjustment is required in the test because p2v.pre no longer
runs before kernel command line parsing.  (The aim is to have
p2v.pre/post/fail still only run when doing a kernel conversion, not
in the GUI case.)
2016-04-18 14:48:09 +01:00
Richard W.M. Jones
f267840aa4 Version 1.33.22. 2016-04-17 09:54:47 +01:00
Richard W.M. Jones
9df3daccad valgrind: Ignore another glibc "leak".
See commit 74b604d7e6.
2016-04-17 09:49:28 +01:00
Richard W.M. Jones
0d9a9ec429 Version 1.33.21. 2016-04-16 22:42:08 +01:00
Richard W.M. Jones
0108240364 tests: Fix 'make check-slow'.
Since we started to use the parallel tests framework in automake,
'make check-slow' has been broken.  This is because parallel tests
doesn't allow you to run 'make check TESTS=...' with a set of test
scripts which do not also appear in the static list of tests in the
Makefile.am.  We would like to list and run only "fast" tests in the
Makefile.am, and have other scripts for slow tests.

The solution is to add the slow tests to Makefile.am, but condition
those tests on an environment variable SLOW=1 being set.

This commit fixes all the existing slow tests in this way, and updates
the documentation (guestfs-hacking(1)) to document how slow tests
should be written in future.
2016-04-16 20:40:49 +01:00
Richard W.M. Jones
90f6267606 v2v: Also check Fedora 23, RHEL 7.2 conversions in check-slow. 2016-04-16 19:32:15 +01:00
Richard W.M. Jones
74b604d7e6 valgrind: Use --run-libc-freeres=no.
Valgrind has a weird hack where it invokes a glibc function called
__libc_freeres on exit.  See:

  http://valgrind.org/docs/manual/faq.html#faq.exit_errors

This is intended to free up memory that glibc won't normally free
(since glibc doesn't free everything on exit for efficiency reasons).

More importantly, valgrind runs __libc_freeres even if the process
calls _exit, resulting in this bug:

  https://bugs.kde.org/show_bug.cgi?id=361810

(either a bug in valgrind, or in glibc, or in both, depending on your
point of view).

In any case we don't want this behaviour, so disable it.

Also we have to add suppressions for new "leaks" in glibc found by
valgrind because __libc_freeres no longer runs.  In fact there is only
one such suppression needed, for TLS allocation in multithreaded
tests.
2016-04-16 18:33:21 +01:00
Richard W.M. Jones
429a098839 valgrind: Use --trace-children=no --child-silent-after-fork=yes
When we are valgrinding we don't really care about the child
processes, which might be qemu, libvirtd, etc.  So disable tracing
into children (at least, as far as is possible with valgrind, which is
not entirely disabling it, but suppressing it).
2016-04-15 17:20:52 +01:00
Richard W.M. Jones
6f4de25369 Version 1.33.20. 2016-04-14 20:31:32 +01:00
Richard W.M. Jones
1b4d8ed72e docs: Add docs/C_SOURCE_FILES to EXTRA_DIST.
Fixes commit 04229c68d6.
2016-04-14 20:30:20 +01:00
Richard W.M. Jones
e84ceeada7 dist: Make AUTHORS/BUGS/etc rules safe if the output command fails.
Also use $@ instead of target name.
2016-04-14 19:54:05 +01:00
Richard W.M. Jones
788d2dbbff dist: Split up dist-hook so we have separate rules for each generated file.
This is convenient because it allows you to do:

  rm -f docs/C_SOURCE_FILES
  make docs/C_SOURCE_FILES

if you ever wanted to recreate that file (without doing 'make dist').

Note that the rules depend on configure.ac so that the files get
updated on each new version (otherwise the files would never get
updated).
2016-04-14 19:52:36 +01:00
Richard W.M. Jones
d2921ef270 Add safe wrapper around waitpid which deals with EINTR correctly.
Thanks: Eric Blake.
2016-04-14 19:42:28 +01:00
Richard W.M. Jones
1a77e61a41 utils: Allow use of gnulib in this file.
Almost all the tools link to -lgnu, so really this is fine.

Updates commit 768ab2e01d
and commit 83e92b4a97.
2016-04-14 18:09:55 +01:00
Richard W.M. Jones
64a04a4af0 builder: pxzcat: Remove ineffective POSIX_FADV_WILLNEED.
On Linux this will load the whole file into the page cache.  However
the output file is empty and zero sized just after it is opened, so
this has no effect.  Note that the advice is not persistent, so this
really does nothing.

I considered adding the call back after the file has been written,
just before the close, but:

 - If we do a virt-resize next then we will open and read the file mostly
   sequentially, so readahead will deal with any missing pages.

 - If we do a virt-customize next then we will only access a small
   part of the disk image, so loading it all into the page cache adds
   extra work.

 - In any case, since we have just written the file it's likely to
   still be in the page cache.
2016-04-14 17:00:44 +01:00
Richard W.M. Jones
816eb7605f builder: pxzcat: Close the output file.
After uncompressing the template we didn't close the output file,
which potentially could cause writes to the output file to be lost.
2016-04-14 16:10:47 +01:00
Richard W.M. Jones
0b1196ce6c fadvise: Add guestfs_int_fadvise_normal, document Linux behaviour.
This commit adds guestfs_int_fadvise_normal, but it's not enabled
since nothing calls it.

It also documents what Linux actually does, which is a bit different
from what I thought these settings did.  Note this is for Linux 4.6.0rc3
and may change in future.

This updates commit 83e92b4a97.
2016-04-14 16:04:08 +01:00
Richard W.M. Jones
f23d6d9e68 builder: pxzcat: Add further posix_fadvise hints.
Setting POSIX_FADV_RANDOM makes no measurable difference, but at least
it's the right thing to do.

POSIX_FADV_WILLNEED makes no measurable difference either.

Moving the calls to posix_fadvise to just after the open() makes no
measurable difference, but does make the code a bit clearer.

Changing POSIX_FADV_NOREUSE on the input file descriptor to
POSIX_FADV_DONTNEED slows things down by about 10%.
2016-04-14 15:23:00 +01:00
Richard W.M. Jones
83e92b4a97 utils, builder: Add wrappers for posix_fadvise.
Add wrappers around posix_fadvise and use them in places we were
calling posix_fadvise directly before.

Also in virt-builder we were doing this (and ignoring the result):

  posix_fadvise (fd, 0, 0, POSIX_FADV_RANDOM|POSIX_FADV_DONTNEED);

However the POSIX_FADV_* flags are _not_ bitmasks!  In fact
POSIX_FADV_RANDOM|POSIX_FADV_DONTNEED == POSIX_FADV_NOREUSE so we were
giving a completely different hint from what we thought we were
giving.
2016-04-14 15:23:00 +01:00
Richard W.M. Jones
eeacb4ef60 launch: Implement a safer getumask.
The current implementation of getumask involves writing a file with
mode 0777 and then testing what mode was created by the kernel.  This
doesn't work properly if the user set a per-mount umask (or fmask/
dmask).

This alternative method was suggested by Josh Stone.  By forking, we
can use the thread-unsafe method (calling umask) and pass the result
back over a pipe.

This change also fixes another problem: mode_t is unsigned, so cannot
be used to return an error indication (ie. -1).  Return a plain int
instead.

Thanks: Josh Stone, Jiri Jaburek, Eric Blake.
2016-04-14 15:10:25 +01:00
Pino Toscano
f5821fe6b7 customize: cast value to intptr_t for pointer usage
Cast a Int64 OCaml value to intptr_t before casting it to a pointer, so
this avoids warnings about casting an int to pointer.

Fixes commit 80a13b7216.
2016-04-14 15:25:52 +02:00
Pino Toscano
3cc039bf17 docs: exclude more generated sources from C_SOURCE_FILES
Exclude more files from the documented sources in C_SOURCE_FILES:
- sources generated by XDR definitions
- sources generated by gperf
- errnostring.c (generated by the generator, and copied around from src
  to daemon during build)

Also update C_SOURCE_FILES as well, so libguestfs builds again from
scratch.
2016-04-14 13:12:31 +02:00
Roman Kagan
47aa64aec9 v2v: add support for virtio-scsi
Virtio-SCSI offers a number of advantages over virtio-blk, in
particular, it supports SCSI UNMAP (aka trim) which is crucial for
keeping the virtual drive from wasting host disk space.

This patch adds support for virtio-scsi as the virtual disk connection
type both on input and on output of v2v.

Virtio-blk remains the default, so for now virtio-scsi-based guests can
only be produced in --in-place mode.

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
Reviewed-by: "Richard W.M. Jones" <rjones@redhat.com>
2016-04-14 14:08:04 +03:00
Richard W.M. Jones
01f98a2500 docs: Convert more ordinary comments to internal documentation comments. 2016-04-13 13:47:50 +01:00
Richard W.M. Jones
63e9293b35 docs: Add internal documentation for a few virt-df functions. 2016-04-12 21:27:18 +01:00
Richard W.M. Jones
24e5b591e4 docs: Add internal documentation for a few guestfish functions. 2016-04-12 21:10:53 +01:00
Richard W.M. Jones
82aa5bd25e docs: Add internal documentation for a few daemon functions. 2016-04-12 20:59:40 +01:00
Richard W.M. Jones
4d55b046e3 docs: Add internal documentation for many core internal functions. 2016-04-12 20:19:58 +01:00
Richard W.M. Jones
5977fe9d2b docs, po: Only update C_SOURCE_FILES, POTFILES, etc when doing 'make dist'.
There's no particular reason that we have to update these files in
every 'make'.  It's slow, and it doesn't really matter if a single
file is accidentally omitted from translations on a developer's build
machine.

On the other hand generating it from 'make dist' has advantages:

 - We only do it once per release.

 - The maintainer can check the changes carefully.

 - If a developer adds some random files in their local build tree,
   these won't be picked up accidentally.

 - Changes to POTFILES etc won't leak into general commits.
2016-04-12 20:19:58 +01:00
Richard W.M. Jones
dd85d4f06d docs: Add list of C source files instead of calculating it using 'find'.
Add the real list of C source files to the Makefile, instead of trying
to calculate it.  This (will, in the next commit) fix a problem with
the build on Koji where we created a subdirectory (for python3/) but
the find command picked up files from that directory for the
documentation (and then failed).

This fixes commit 04229c68d6.
2016-04-12 20:19:58 +01:00
Richard W.M. Jones
d13f438850 docs: Ignore gnulib files when producing internal documentation.
This fixes commit 04229c68d6.
2016-04-12 15:20:18 +01:00
Richard W.M. Jones
557b6ce35c Version 1.33.19. 2016-04-12 13:52:55 +01:00
Richard W.M. Jones
04229c68d6 Add internal documentation to C files.
As in libvirt, allow internal documentation comments in C files.
These are marked using '/**' comments.  Unlike libvirt which has an
ill-defined and inconsistent markup, the markup we use is Perl POD.

These comments are added to guestfs-internals(1), but are most likely
to be read in-place.

This commit changes some existing comments in src/launch.c to
demonstrate how this can be used.
2016-04-12 13:22:00 +01:00
Roman Kagan
e07459d994 v2v: win: factor out common bits in registry patching
Refactor registry patching to share common parts between Win <= 7 and
Win >= 8.  Also branch between the two based on the presence of the
DriverDatabase subtree rather than on the OS version, which allows not
to pass the inspect handle into the functions.

OTOH make the patching functions accept the driver name and device PCI
id as arguments; this will allow to easily expand the code to support
other drivers (e.g. vioscsi) later on.

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
Reviewed-by: "Richard W.M. Jones" <rjones@redhat.com>
2016-04-12 14:14:48 +03:00
Roman Kagan
9a441b0317 v2v: win >= 8: simplify registry patching
It turned out (by trial and error) that for Windows >= 8 / 2012, even
though the PnP system uses names related to the original driver's .inf
file for certain entries under DriverDatabase registry subtree, this
doesn't have to hold for the storage driver to make it boot.

So use our own artificial names there and simplify the surrounding code.
This will also make sure the added entries don't confilct with those
generated by PnP proper once the driver is installed, and that the
entries are easy to look up in the eventual registry.

The name chosen to refer to the driver -- "guestor" -- is intentionally
different from the original "viostor" both to avoid collisions and to
naturally expand to other relevant drivers (e.g. "vioscsi") later on.

Tested on

Win 8 x32
Win 8 x64
Win 8.1 x32
Win 8.1 x64
Win 2012R2 x64
Win 10 x64

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
Reviewed-by: "Richard W.M. Jones" <rjones@redhat.com>
2016-04-12 14:14:48 +03:00
Roman Kagan
f0dce2452c v2v: win >= 8: reduce registry patch
The patch to the Windows registry allowing it to boot off a virtio-blk
drive was initially conceived by comparing the state with virtio-blk
driver properly installed, to that without.

However, we don't want to replicate the Windows PnP system; rather we
need to apply just enough edits to make the system boot, and then let
the Windows PnP manager figure out the rest.

It turned out (by trial and error) that for Windows >= 8 / 2012 the
"just enough" set includes only the service entry for the driver, and a
few entries under DriverDatabase.

Tested on

Win 8 x32
Win 8 x64
Win 8.1 x32
Win 8.1 x64
Win 2012R2 x64
Win 10 x64

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
Reviewed-by: "Richard W.M. Jones" <rjones@redhat.com>
2016-04-12 14:14:48 +03:00
Roman Kagan
1f24364367 v2v: win <= 7: reduce registry patch
The patch to the Windows registry allowing it to boot off a virtio-blk
drive was initially conceived by comparing the state with virtio-blk
driver properly installed, to that without.

However, we don't want to replicate the Windows PnP system; rather we
need to apply just enough edits to make the system boot, and then let
the Windows PnP manager figure out the rest.

It turned out that for Windows <= 7 / 2008R2 the "just enough" set
includes only the service entry for the driver, and a
CriticalDeviceDatabase entry matching the PCI id of the device and
pointing at that service entry.

While at this, also drop CriticalDeviceDatabase entries for older and
no longer relevant PCI ids of the virtio-blk device.

Tested on

Win XP SP3 x32
Win XP SP2 x64
Win 2003R2 SP2 x32
Win 2003R2 SP2 x63
Win Vista SP2 x32
Win Vista SP2 x64
Win 2008 SP2 x32
Win 2008R2 SP1 x64
Win 7 SP1 x32
Win 7 SP1 x64

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
Reviewed-by: "Richard W.M. Jones" <rjones@redhat.com>
2016-04-12 14:14:48 +03:00
Richard W.M. Jones
80a13b7216 customize/perl_edit-c.c: Don't use internal APIs.
We can now use the Guestfs.c_pointer method to access the underlying
guestfs_h *.  So no need to use internal APIs for this.
2016-04-12 10:37:12 +01:00
Richard W.M. Jones
fc4936661d v2v: Don't allow -oa option to be specified more than once on the command line. 2016-04-12 10:37:12 +01:00
Richard W.M. Jones
7bc0ea7d24 v2v: Reject duplicate -b/-n parameters on the command line (RHBZ#1325825). 2016-04-12 10:37:12 +01:00
Pino Toscano
57467ca88b php: support PHP 7
Adapt to the API changes in the newer versions of the Zend framework, in
particular regarding:
- strings handling
- resources handling (used for the guestfs_h pointer)
- iterating in hash maps
- data types for function arguments

Introduce helper macros to reduce greatly the amount of #if's all around
the generated C code.
2016-04-12 10:35:20 +02:00
Pino Toscano
4a337cd33b fish: improve formatting of help text of generated commands
In the generated description of the guestfish commands, wrap and indent
the help text, so it is a multiline string instead of a very long single
one.

This has no behaviour changes, only makes cmds.c more readable (and
easier to diff when the description of actions change).
2016-04-11 17:06:50 +02:00
Richard W.M. Jones
ea175fb244 ruby: Document that rubygem-rdoc is required for the Ruby bindings. 2016-04-09 21:18:54 +01:00
Richard W.M. Jones
ea300d8ffe docs: Refresh documentation for the ./run script. 2016-04-09 21:18:54 +01:00
Richard W.M. Jones
eb364b15eb build: ./run is documented in guestfs-building(1), not README. 2016-04-09 21:11:14 +01:00
Richard W.M. Jones
f24753ebb0 tests/qemu: boot-analysis: (Don't) set LIBVIRT_LOG_FILTERS.
Setting LIBVIRT_LOG_FILTERS is supposed to be better than setting
LIBVIRT_DEBUG, but I couldn't get it to work.

This updates commit b332d91bc9.
2016-04-06 17:49:38 +01:00
Richard W.M. Jones
b332d91bc9 tests/qemu: boot-analysis: Add support for logging libvirt events. 2016-04-06 13:06:23 +01:00
Richard W.M. Jones
0008d794cf tests/qemu: Don't leak backend variable in boot-analysis/boot-benchmark programs. 2016-04-06 10:42:21 +01:00
Richard W.M. Jones
171c84788e v2v: DOM: Add documentation for the obscure 'e' function.
No functional change, just comment.
2016-04-05 21:32:08 +01:00
Richard W.M. Jones
1dd3da54f1 v2v: Add documentation to Convert_windows and Convert_linux modules.
No functional change, just add comments / documentation.
2016-04-05 21:20:26 +01:00
Richard W.M. Jones
c8cf4dc0a1 Version 1.33.18. 2016-04-05 15:15:21 +01:00
Richard W.M. Jones
b2c845333f launch: libvirt: Disable virtio-rng in libvirt backend until we can use /dev/urandom.
This updates commit 9423c16607.
2016-04-05 15:02:20 +01:00
Cédric Bosdonnat
dc94de5bee v2v: extract controller offset discovery as a function
This function is needed for other drivers, move the code in order to
help sharing it later.
2016-04-05 13:22:46 +01:00
Richard W.M. Jones
19dc728c48 Version 1.33.17. 2016-04-05 12:09:22 +01:00
Richard W.M. Jones
91c7273899 builder: Add ubuntu-ppc64le.sh to EXTRA_DIST.
Fixes commit f756002b54.
2016-04-05 12:07:13 +01:00
Richard W.M. Jones
1ecd0b0058 Add python/t/README to EXTRA_DIST.
Fixes commit aae74c9e4e.
2016-04-05 12:06:23 +01:00
Richard W.M. Jones
a04b04c5c1 Remove .x-sc (syntax check) files from EXTRA_DIST.
Fixes commit 821db657d1.
Updates commit 017f1c6729.
2016-04-05 11:58:35 +01:00
Richard W.M. Jones
c48e04d9d2 align/scan: Remove stray comment that confuses clang-format. 2016-04-04 17:57:38 +01:00
Richard W.M. Jones
821db657d1 Further remove mention of 'make syntax-check'.
Updates commit 017f1c6729.
2016-04-04 17:57:38 +01:00
Richard W.M. Jones
fdfedcb4ef Use 'error' function for fprintf followed by exit.
Like with the previous commit, this replaces instances of:

  if (something_bad) {
    fprintf (stderr, "%s: error message\n", guestfs_int_program_name);
    exit (EXIT_FAILURE);
  }

with:

  if (something_bad)
    error (EXIT_FAILURE, 0, "error message");

(except in a few cases were errno was incorrectly being ignored, in
which case I have fixed that).

It's slightly more complex than the previous commit because we must be
careful to:

 - Remove the program name (since error(3) prints it).

 - Remove any trailing \n character from the message.

Candidates for replacement were found using:

  pcregrep --buffer-size 10M -M '\bfprintf\b.*\n.*\bexit\b' `git ls-files`
2016-04-04 17:57:38 +01:00
Richard W.M. Jones
129e4938ba Use 'error' function consistently throughout.
Wherever we had code which did:

  if (something_bad) {
    perror (...);
    exit (EXIT_FAILURE);
  }

replace this with use of the error(3) function:

  if (something_bad)
    error (EXIT_FAILURE, errno, ...);

The error(3) function is supplied by glibc, or by gnulib on platforms
which don't have it, and is much more flexible than perror(3).  Since
we already use error(3), there seems to be no downside to mandating it
everywhere.

Note there is one nasty catch with error(3): error (EXIT_SUCCESS, ...)
does *not* exit!  This is also the reason why error(3) cannot be
marked as __attribute__((noreturn)).

Because the examples can't use gnulib, I did not change them.

To search for multiline patterns of the above form, pcregrep -M turns
out to be very useful:

  pcregrep --buffer-size 10M -M '\bperror\b.*\n.*\bexit\b' `git ls-files`
2016-04-04 13:14:26 +01:00
Richard W.M. Jones
03b68d436c tests/qemu: boot-analysis: Don't force backend direct.
Current libvirt overhead is 220ms.  That didn't matter when our launch
time was 4000ms.  Now we're launching in 900ms, it really does.
2016-04-02 11:59:39 +01:00
Richard W.M. Jones
014b7c0ced tests/qemu: Standardize test info printed by boot-* tests.
It now looks like:

test version: libguestfs 1.33.16
 test passes: 5
host version: Linux moo 4.4.4-301.fc23.x86_64 #1 SMP Fri Mar 4 17:42:42 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
    host CPU: Intel(R) Core(TM) i7-5600U CPU @ 2.60GHz
     backend: direct
        qemu: /home/rjones/d/qemu/x86_64-softmmu/qemu-system-x86_64
qemu version: QEMU emulator version 2.5.90, Copyright (c) 2003-2008 Fabrice Bellard
         smp: 1
     memsize: 500
      append: guestfs_boot_analysis=1 ignore_loglevel initcall_debug
2016-04-02 11:01:30 +01:00
Richard W.M. Jones
d470480b35 tests/qemu: boot-analysis: Display all times in ms.
It was confusing to have a mix of seconds and milliseconds.  For all
upstream testing (eg. with SeaBIOS) we are discussing everything in
milliseconds, so use those exclusively.
2016-04-02 10:42:12 +01:00
Richard W.M. Jones
96ce2f9afe tests/qemu: Add boot-benchmark.
Add a new test program called 'boot-benchmark'.  This is similar to
'boot-analysis' but it simply boots and shuts down the appliance
several times in a row and measures how long it takes, calculating
mean and standard deviation.
2016-04-01 19:22:56 +01:00
Richard W.M. Jones
2e04be377a docs: Link to boot-analysis program from guestfs-performance(1). 2016-04-01 17:47:19 +01:00
Matteo Cafasso
7ecec1ee55 python: Fix bug in code generator
When a struct containing FChar fields is defined
in generator/structs.ml, the Python code generator will generate
code referencing a dirent struct instead of the correct one
thus breaking at compile time.

This bug was left unnoticed because the dirent struct is the only
one using FChar fields. Yet it prevents any other struct
from using such fields.

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2016-04-01 17:14:53 +01:00
Richard W.M. Jones
2cc8a4c1ff launch: Add a comment about why acpi=off (because it's slow). 2016-04-01 12:28:18 +01:00
Richard W.M. Jones
6c99a17dc5 launch: Only use sgabios when verbose is enabled.
The sgabios option ROM is slow.  Only use it when we're debugging.

Thanks: Paolo Bonzini.
2016-04-01 10:10:04 +01:00
Richard W.M. Jones
77e1ac5a97 launch: direct: Add a comment about use of -display none.
No functional change.
2016-04-01 10:09:42 +01:00
Richard W.M. Jones
68fc25e1d5 v2v: Document how to use 'cinder manage' for importing directly to Cinder.
Thanks: Tom Barron.
2016-03-31 14:03:56 +01:00
Richard W.M. Jones
b2f42a8dce builder: Update Fedora 23 (i686) image.
Contains a fix for RHBZ#1317843 and another dnf bug.
2016-03-31 13:43:55 +01:00
Pino Toscano
d2e81b42e7 inspect: use os-release for CoreOS
Look for /lib/os-release in the /usr partition and try to use it, if
present, before using lsb-release later on.  This should not change the
final result of the inspection, while using the os-release detection
method also for CoreOS.

Update the phony CoreOS image to use os-release instead, uploading the
version found in the current stable version.
2016-03-31 11:38:00 +02:00
Matteo Cafasso
5fd0819ebc Rename icat command in download_inode
The "icat" name comes from the employed command line tool which might be
replaced at any time with a different implementation.

The command name is a bit confusing because it's similar to "cat" but
act as "download".

download_inode is more clear and descriptive.

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2016-03-31 10:50:42 +02:00
Pino Toscano
ca4516d94c inspect: os-release: fix single-number version parsing (RHBZ#1321620)
Use the proper length modifier for asprintf, instead of a padding
modifier.  This fixes the parsing of versions in VERSION_ID which are a
single number (i.e. "X" and not "X.Y", etc).

Bug introduced with commit 32d19e3289, but
uncovered recently with the switch away from VLAs, i.e.
commit 07c496c53c.
2016-03-30 15:49:16 +02:00
Matteo Cafasso
88d5186eb4 renamed daemon/tsk.c to daemon/sleuthkit.c
In order to support the new features I am renaming the file with a better name.

The file sleuthkit.c will contain the code depending on the sleuthkit package.

The original tsk.c file will contain the logic built using libtsk
which is the sleuthkit core library.

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2016-03-30 13:02:30 +02:00
Richard W.M. Jones
c67bab9c5d builder: Update Fedora 23 image.
Contains a fix for RHBZ#1317843 and another dnf bug.
2016-03-30 11:25:00 +01:00
Pino Toscano
807433bc23 appliance: init: generate /etc/machine-id
Some of the systemd-tmpfiles snippets need the machine ID of the running
system; the current lack of this file produces warning messages during
the appliance boot like:

[/usr/lib/tmpfiles.d/systemd.conf:26] Failed to replace specifiers: /run/log/journal/%m
[/usr/lib/tmpfiles.d/systemd.conf:28] Failed to replace specifiers: /run/log/journal/%m
[/usr/lib/tmpfiles.d/systemd.conf:29] Failed to replace specifiers: /run/log/journal/%m

Thus create a new randomly-generated /etc/machine-id on boot.
2016-03-30 10:15:49 +02:00
Richard W.M. Jones
da7e22b648 boot-analysis: Add --memsize, --smp and --append options.
These options allow you to control the appliance memory size, number
of vCPUs, and extra kernel options respectively.

Note that using --smp is not usually a good idea.  Not only does it
slow down the appliance, but it tends to break the boot analysis
program because it makes runs (more) non-deterministic.
2016-03-29 12:01:42 +01:00
Richard W.M. Jones
de66981917 v2v: Don't use List.sort_uniq, add util function for this instead (RHBZ#1321338).
List.sort_uniq was added in OCaml 4.02, so this breaks compilation on
earlier versions of OCaml.

Thanks: Jean-Christophe Manciot
2016-03-25 17:13:58 +00:00
Richard W.M. Jones
f756002b54 builder: Add ubuntu ppc64le script.
Thanks: Gustavo Romero
2016-03-24 20:19:19 +00:00
Lars Kellogg-Stedman
c6512ead45 document behavior of --selinux-relabel
the description of the --selinux-relabel option suggests that it
perform an immediate relabel, when in fact it may (and probably will)
instead simply touch /.autorelabel on the image, which schedules a
relabel operation for the next time the image boots.  This can be
surprising because it results both in an extended initial boot time
*and* results in an automatic reboot (on some distributions).
2016-03-24 20:19:09 +00:00
Richard W.M. Jones
6cdd20716c Version 1.33.16. 2016-03-24 18:51:36 +00:00
Richard W.M. Jones
c3fb5deab6 rescue: Fix test to deal with new --suggest output.
Fixed commit 72fd0531ab.
2016-03-24 18:51:36 +00:00
Richard W.M. Jones
aae74c9e4e python: Add README documenting how to run a single test. 2016-03-24 14:46:42 +00:00
Richard W.M. Jones
a5507a16c6 rescue: Print chroot suggestion for Linux guests. 2016-03-24 13:56:29 +00:00
Richard W.M. Jones
72fd0531ab rescue: Suggest using recursive bind mounts.
Since /dev and other directories contain sub-mounts, suggest using
--rbind instead of --bind.  This also allows us to remove the /dev/pts
line.
2016-03-24 13:56:29 +00:00
Richard W.M. Jones
0024e5a13e python: Misspelling in tests, libirt -> libvirt. 2016-03-24 13:56:29 +00:00
Roman Kagan
db982654d1 v2v: better explain --in-place
It seems that the documentation for --in-place mode of v2v wasn't clear
enough, so try to explain it better.

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
Signed-off-by: "Richard W.M. Jones" <rjones@redhat.com>
2016-03-24 16:43:29 +03:00
Roman Kagan
fb73d8261d v2v: in-place: request caps based on source config
In in-place mode, the decisions on which interfaces to use are made and
the source VM configuration is created by the outside entity.  So in
that case v2v needs to look it up in the source configuraion, and try to
follow.

For that, the source VM configuration is used to populate requested caps
object which is then passed to the convert routine.

It's assumed that the configuration has exactly one type of storage
devices and no more than one type of network and video adapters;
anything else is rejected.

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
Signed-off-by: "Richard W.M. Jones" <rjones@redhat.com>
2016-03-24 15:07:01 +03:00
Roman Kagan
ee02191483 v2v: take requested caps into account when converting
Give the caller certain control over what kind of interface to use for
virtual disks, network and video cards upon conversion.

For that, make convert functions accept additional rcaps parameter
containing an object with optional capabilities similar to the ones
produced on output, with None indicating that the decision is left to
the convert function itself.

To facilicate review, this patch unconditionally passes rcaps with no
preferences; populating it with more sensible values is done in a
followup patch.

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
Signed-off-by: "Richard W.M. Jones" <rjones@redhat.com>
2016-03-24 15:07:01 +03:00
Roman Kagan
94c83c0165 v2v: introduce requested guestcaps type
Introduce a type to contain the guestcaps that are to be put in effect
in the converted VM: options of the block type, net type, and video.

It'll be populated by the caller and passed into convert function to
affect its choice of devices and drivers.

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
Signed-off-by: "Richard W.M. Jones" <rjones@redhat.com>
2016-03-24 15:07:01 +03:00
Roman Kagan
ad5bb4f6bd v2v: collect source network and video adapter types
Those will be useful when making decisions about what configuration to
set on output.

The data is also included in --print-source so the tests are adjusted
accordingly.

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
Signed-off-by: "Richard W.M. Jones" <rjones@redhat.com>
2016-03-24 15:07:01 +03:00
Richard W.M. Jones
0ba59db611 tests/qemu: Add program for tracing and analyzing boot times. 2016-03-23 13:25:46 +00:00
Richard W.M. Jones
cd57851019 conn: Pretend to be a serial terminal, so sgabios doesn't hang.
This tedious workaround avoids a 0.26 second pause when using sgabios
(the Serial Graphics Adapter).  It's basically a workaround for buggy
code in sgabios, but much easier than fixing the assembler.
2016-03-23 13:25:46 +00:00
Richard W.M. Jones
f36ba38886 appliance: init: Don't run hwclock command.
This command alone took 0.3 seconds which is about 10% of the current
launch time.  It appears to be unnecessary.

This reverts commit 508f1ee87e.
2016-03-23 12:58:15 +00:00
Richard W.M. Jones
705b721b42 appliance: init: Mount selinuxfs along with other special filesystems.
Move this earlier.
2016-03-23 12:58:15 +00:00
Richard W.M. Jones
cb8f69e959 appliance: init: Move cmdline parsing earlier.
Since commit bb5d30ab2a, we don't
require any external programs like grep to parse the command line.  We
only use bash intrinsics.

Therefore we can do it early (but after /proc is mounted).

This allows verbose mode to enable set -x early on, so we can trace
most things that the init script does.
2016-03-23 12:58:15 +00:00
Richard W.M. Jones
d368fa0895 appliance: When using verbose mode, 'set -x' in the appliance init script. 2016-03-23 12:58:15 +00:00
Richard W.M. Jones
9423c16607 launch: Add a virtio-rng device to the guest. 2016-03-23 12:58:15 +00:00
Richard W.M. Jones
e94e61f76f launch: Remove guestfs_int_print_timestamped_message function.
This function was kind of like debug(), except that it didn't check
the g->verbose flag and it only worked in the library (it would crash
if used after fork).

It also wasn't very useful.  The sort of boot analysis done by
[forthcoming program] tests/qemu/boot-analysis.c means that
timestamping (some) messages is even less interesting than before.

Remove it and replace calls with debug() instead.
2016-03-23 12:57:55 +00:00
Richard W.M. Jones
b7b3411976 launch: direct: Don't run qemu -version.
Dr. David Gilbert pointed out to me that the first line of the
qemu -help output includes the qemu version, so we don't need
to run qemu -version at all.

This saves about 0.04s on the launch time when using the direct
backend.
2016-03-23 12:57:55 +00:00
Richard W.M. Jones
b3e843e5b4 launch: Factor out earlyprintk from the command line.
Just code motion.

In theory we could also add earlyprintk=ttyS0,115200 on x86, but I
cannot get it to work.
2016-03-23 12:57:55 +00:00
Richard W.M. Jones
b652cc419d launch: direct: Remove dead code promising we were going to use virtio-console.
We're never going to use virtio-console since, although it is faster,
it's not available during early boot, and that is more important for
debugging.
2016-03-23 12:57:55 +00:00
Pino Toscano
bb5d30ab2a appliance: use bash features for string matching in files
Read the content of /proc/cmdline using bash features, and use its
[[ ... ]] expression to find texts in a variable.

This shaves off 5 grep invocations.
2016-03-22 22:30:59 +00:00
Pino Toscano
e2457d0773 Reduce GUESTFS_PRIVATE usage
Remove the GUESTFS_PRIVATE=1 define for some tools and tests which don't
really use any private API.
2016-03-22 22:30:59 +00:00
Pino Toscano
40017ba7f3 build: improve GUESTFS_FIND_DB_TOOL macro
- find the unversioned name just once
- add 5.3 and 5.2 as versions
- add db_$TOOL-X and db_$TOOL-X.Y as patterns (found on FreeBSD)
2016-03-22 09:45:41 +01:00
Pino Toscano
5f24d45ab5 build: check the path of true, and use it in tests
Check for the full path of true, and use it instead of hardcoding
/bin/true (which is still left as fallback).
2016-03-22 09:45:41 +01:00
Pino Toscano
76a01fe41d php: pass $(MAKE) to run-php-tests.sh
Instead of hardcoding "make" in run-php-tests.sh, pass the actual name
of make from the Makefile; the default is still "make", mostly to use
the script without having to set $MAKE.
2016-03-22 09:45:41 +01:00
Pino Toscano
39772344ad v2v: tests: use guestfs-hashsums.sh for MD5
Use the common helper for MD5 checksum, instead of assuming md5sum(1).
2016-03-22 09:45:41 +01:00
Pino Toscano
8aee5726d3 v2v: tests: isolate SHA1 calculation in an own shared function
sha1sum(1) does not exist everywhere, so wrap it in an own function so
the right implementation can be chosen on each OS.  Also, wrapping it
avoid using awk everytime.
2016-03-22 09:45:41 +01:00
Pino Toscano
41795a1c98 tests: move guestfs-md5.sh to test-data
Move it to the test-data directory, giving it a more generic name so it
can be used also for more than just md5; adjust qemu tests accordingly.

This is just code motion, no behaviour change.
2016-03-22 09:45:41 +01:00
Pino Toscano
7e970fcdb3 build: check the path of fuser, and use it in FUSE code
Check for the full path of fuser, and use it instead of hardcoding
/sbin/fuser (which is still left as fallback).
2016-03-22 09:45:41 +01:00
Richard W.M. Jones
5897b3bbad appliance: Quiet some warnings about missing files.
Try to make the appliance script as quiet as possible along
the fast path.
2016-03-18 13:18:13 +00:00
Richard W.M. Jones
23028cb30d appliance: Make it clear that the init script is a bash script.
We have used /bin/sh here since 2009.  However this is a bash
script and probably won't work well with other shells.
2016-03-18 13:18:13 +00:00
Richard W.M. Jones
ed739e71f6 appliance: Pass "quiet" option to kernel when !verbose.
The quiet option suppresses kernel messages.  On my laptop it improves
appliance boot times by about 40% (3.5s -> 2.5s).

The emulated UART is slow and has a fixed, small FIFO (16 bytes).  But
it has the advantage of being a simple ISA device which is available
very early in boot, thus enabling us to diagnose early boot problems.
So the aim is to reduce our usage of this UART on fast paths.

Of course when we are in verbose mode, we should not add this flag
because we want to see all the messages.

This change is not entirely invisible:

(1) Progress messages use the "Linux version ..." string from kernel
output in order to determine part of where we are in the boot process.
This string will no longer be detected.  We should probably use a BIOS
message or maybe drop this altogether.  I have added a comment to the
code.

(2) It is possible for programs to be listening for
GUESTFS_EVENT_APPLIANCE events, and they will see fewer messages now
(although what kernel messages programs see is never defined).
2016-03-18 13:18:13 +00:00
Pino Toscano
1df34fd8d1 inspect: improve UsrMove detection (RHBZ#1186935)
In case /usr is a symlink to /usr/bin, then we cannot rely on /usr/bin
to exist, since /usr might be in a different partition.  Thus, in case
/bin is a symlink, check it points to "usr/bin".
2016-03-17 15:28:18 +01:00
Pino Toscano
b0be4c1130 inspector: define more multichoice tags in the RELAX NG schema
Provide new <define> for the following elements: "distro",
"package_format", "package_management", and "format", adding all the
values so far possible for each.
2016-03-17 15:28:18 +01:00
Pino Toscano
9775777a55 builder: fedora: ensure images are up-to-date
Update the system at the end of the installation, so the generated image
is up-to-date.  This also removes the need to manually update dnf on
i686 and x86_64.
2016-03-17 10:39:11 +01:00
Richard W.M. Jones
a5bf0e7e64 Version 1.33.15. 2016-03-16 15:17:12 +00:00
Richard W.M. Jones
180b853658 fish: Link with LIBTINFO_LIBS.
Required on Gentoo.

Thanks: Mark Pictor
2016-03-16 15:16:39 +00:00
Richard W.M. Jones
1129cbba3d docs: Fix cross-reference to fixed appliance section.
The fixed appliance documentation moved from guestfs(3) to
guestfs-internals(1).

Thanks: Mark Pictor (mark999 on IRC)
2016-03-15 19:13:59 +00:00
Richard W.M. Jones
ffeea7995b Revert "configure: Move version and date together."
You can't use AC_SUBST before AC_INIT.  It resulted in the
RELEASE_DATE being an empty string.

This reverts commit d53fd558ae.
2016-03-09 15:05:43 +00:00
Matteo Cafasso
d314d10e1f sleuthkit availability check renamed
>From 'available icat' to 'available sleuthkit'.

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2016-03-08 21:13:10 +00:00
Cédric Bosdonnat
f0d71e148c configure: handle older version of ncurses
ncurses didn't have pkg-config files in not-that-old versions. If those
couldn't be found, then try the ncurses6-config and ncurses5-config tools.
2016-03-08 16:25:19 +01:00
Cédric Bosdonnat
1c30c23a19 fish: fix btrfs subvolumes display in error case
The list of filesystems that is printed when there was an error prints
the internal mountable string even for the btrfs subvolumes. Let's
printing a valid -m option value instead.
2016-03-08 16:25:19 +01:00
Cédric Bosdonnat
f5a9cdff2a api: add mountable_device and mountable_subvolume
These two functions allow the user to split the mountable strings
into a device and a subvolume if any. See this thread on the mailing
list for the rationale:

https://www.redhat.com/archives/libguestfs/2016-February/msg00247.html
2016-03-08 16:25:19 +01:00
Pino Toscano
43dd545e46 appliance: pick sleuthkit on all the distros
It looks like it has the same name everywhere, so move it in the common
packages section.

This updates commit 3bb65458ff.
2016-03-08 09:47:30 +01:00
Pino Toscano
d3b68d90c8 inspector: extend the OS "name" in the RELAX NG schema
Put the definition of "name" in an own <define>, and add the missing
operating systems so far known to libguestfs.
2016-03-08 09:20:47 +01:00
Pino Toscano
709e530655 inspector: add --no-applications and --no-icon
Add command line options to optionally disable the output of the
installed application, and the guest icon.

This makes the inspection slightly faster, producing a smaller XML to
parse/process in case there is no interest in these details.
2016-03-08 09:20:47 +01:00
Richard W.M. Jones
31e9be7696 Version 1.33.14. 2016-03-07 20:11:02 +00:00
Matteo Cafasso
ac0d2adf56 added icat API tests
Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2016-03-07 19:33:53 +00:00
Matteo Cafasso
acd3f235ae added icat API to retrieve deleted or inaccessible files
Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2016-03-07 19:33:53 +00:00
Matteo Cafasso
3bb65458ff added The Sleuth Kit package to the appliance
Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2016-03-07 19:33:53 +00:00
Richard W.M. Jones
07c496c53c Use less stack.
GCC has two warnings related to large stack frames.  We were already
using the -Wframe-larger-than warning, but this reduces the threshold
from 10000 to 5000 bytes.

However that warning only covers the static part of frames (not
alloca).  So this change also enables -Wstack-usage=10000 which covers
both the static and dynamic usage (alloca and variable length arrays).

Multiple changes are made throughout the code to reduce frames to fit
within these new limits.

Note that stack allocation of large strings can be a security issue.
For example, we had code like:

 size_t len = strlen (fs->windows_systemroot) + 64;
 char software[len];
 snprintf (software, len, "%s/system32/config/software",
           fs->windows_systemroot);

where fs->windows_systemroot is guest controlled.  It's not clear what
the effects might be of allowing the guest to allocate potentially
very large stack frames, but at best it allows the guest to cause
libguestfs to segfault.  It turns out we are very lucky that
fs->windows_systemroot cannot be set arbitrarily large (see checks in
is_systemroot).

This commit changes those to large heap allocations instead.
2016-03-07 17:36:24 +00:00
Pino Toscano
8ed6435f04 inspect: list applications with APK
Implement the helper function for guestfs_inspect_list_applications2 to
be able to parse the list of installed applications with the APK package
manager (used on Alpine Linux).
2016-03-07 17:25:21 +01:00
Pino Toscano
b07f8793d0 build: fix reading of the java version
Update the check for the first line (the one containing the version) to
match also the message with OpenJDK; switch to awk so it is easier to
extract the version inside the double quotes.
2016-03-07 16:17:32 +01:00
Richard W.M. Jones
a51b136584 inspect: windows: Make is_systemroot check code more robust.
We rely on this function for security to ensure the caller cannot set
windows_systemroot to a very long or bogus value.
2016-03-07 11:17:07 +00:00
Richard W.M. Jones
af4cd5347e lib: inspect: gpt_prefix is a constant string. 2016-03-07 11:16:58 +00:00
Richard W.M. Jones
7b17447ac4 lib: Minor whitespace rearrangement. 2016-03-07 11:14:21 +00:00
Richard W.M. Jones
e7666da224 lib: Fix incorrect comment in utils.
The string is not freed by the caller.  A fixed buffer is provided
by the caller.
2016-03-07 11:14:21 +00:00
Richard W.M. Jones
c30363d4af v2v: linux: Fix small typo in comment. 2016-03-06 15:50:57 +00:00
Richard W.M. Jones
d5b3aa0cca v2v: Fix incorrect calculation of lc_basename.
We should be using the lowercase path.  Prior to this patch
lc_basename was not actually lowercase.

Fixes commit f7249a0bcc.
2016-03-04 10:22:45 +00:00
Richard W.M. Jones
f33e127d87 v2v: Describe workaround for Windows >= 8 Fast Startup.
Thanks: Nisim Simsolo
2016-03-03 15:42:26 +00:00
Pino Toscano
82b0d25bb2 mllib: factor out mounting of guest root
Introduce and use a new inspect_mount_root function to mount all the
mountpoints of a root in the guest, replacing the same code doing that
in different tools.

inspect_mount_root_ro is inspect_mount_root with readonly mount option.
2016-03-03 14:52:39 +01:00
Richard W.M. Jones
d53fd558ae configure: Move version and date together.
I keep forgetting to update the date field when releasing.
2016-03-03 13:50:36 +00:00
Pino Toscano
e8408fe3c3 daemon: do not fail list-disk-labels w/o labels set
If there are no labels set for the disks, the directory with the
symlinks will not even exists, causing list-disk-labels to fail with
ENOENT.  In this situation, act as if the directory was there, but
empty.
2016-03-02 14:42:02 +01:00
Pino Toscano
4d4f16067e daemon: ntfs: switch away from asprintf_nowarn in ntfsclone-in
No custom formats (eg %Q, %R) are used.
2016-03-02 11:14:19 +01:00
Pino Toscano
acbc5dee4f make-fs: print error message on mkfs failure
This makes a bit easier to diagnose failures on mkfs, without the need
to restart the filesystem creation with verbose output (which will
produce a lot more output).
2016-03-02 11:02:08 +01:00
Pino Toscano
c9b186ae63 daemon: ntfs: fix format strings
Use PRIi64 as format string for int64_t, so it builds and works fine
also on 32bit.  Also switch from asprintf_nowarn to asprintf, since no
custom formats (eg %Q, %R) are used.
2016-03-02 10:55:14 +01:00
Pino Toscano
1d5af46a44 tests: move ntfs tests in a single directory
Move test-ntfscat.sh and test-ntfsclone.sh in a single ntfs directory,
much like the tests for other filesystems.
2016-03-01 14:20:46 +01:00
Matteo Cafasso
a7ea3b577f tests: Added test for ntfscat_i.
Test is based on file signature, it checks whether the extracted file
is the $MFT.

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2016-03-01 09:06:10 +00:00
Matteo Cafasso
61b0317c12 New API: ntfscat_i
Adding ntfscat_i command for downloading files based on their inode number.

This allows the dowload of files unaccessible otherwise from a NTFS guest disk image.

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2016-03-01 09:06:10 +00:00
Richard W.M. Jones
49dea6c79f docs: building: Document using clean-supermin-appliance rule. 2016-02-28 16:10:41 +00:00
Richard W.M. Jones
b2877dc34f appliance: Add comment and clean-supermin-appliance rule.
Add a comment to appliance/Makefile.am describing the purpose of this
directory.

Add a 'make clean-supermin-appliance' rule which forces the supermin
appliance to be reprepared from scratch.  See the discussion here:
https://www.redhat.com/archives/libguestfs/2016-February/msg00264.html
2016-02-28 15:57:51 +00:00
Richard W.M. Jones
ac76081f5a builder: Add Fedora 23 (armv7l) image. 2016-02-27 14:57:52 +00:00
Richard W.M. Jones
9ff2c3ef18 builder: armv7l: Specify virt-install --arch explicitly.
Allow us to run this script on x86_64 by specifying the --arch option
to virt-install, and removing the --cpu option.
2016-02-27 14:55:12 +00:00
Richard W.M. Jones
6b501cb6f2 builder: armv7l: Use latest available os-variant. 2016-02-27 14:55:12 +00:00
Richard W.M. Jones
fdc201a30c builder: armv7l: Use --vcpus=1 because TCG is not yet multithreaded. 2016-02-27 14:55:12 +00:00
Pino Toscano
1225bb194e java: drop empty lines at end of pod-generated text
They are converted as additional empty paragraphs but adding nothing to
the generated API documentation.  Also avoids warnings about them by
javadoc.
2016-02-26 18:36:42 +01:00
Pino Toscano
3b427b90ac doc: add info on per-function needed feature
Document which feature, if any, is needed for a function; this should
help users in properly checking feature availability when using certain
functions.
2016-02-26 18:36:42 +01:00
Richard W.M. Jones
9b1f826202 Version 1.33.13. 2016-02-26 11:45:47 +00:00
Richard W.M. Jones
660246dcbc v2v: -o libvirt: Preserve source <graphics> type (RHBZ#1312254).
Old virt-v2v changed the <graphics> to VNC if the guest was using the
Cirrus hardware and Spice if the guest used QXL.

In commit 3d1cb74b3e I got the logic
backwards, using Spice if the guest used Cirrus and VNC if the guest
used QXL, which obviously makes no sense.

In this commit, I preserve the original <graphics> type from the
source guest.  This has the advantage that the user can use the same
method to access the guest after conversion.  If the source guest had
no <graphics> element, then we force VNC (a safe choice), and if the
source guest is a local disk that we use SDL, but this should only be
used for testing.

Thanks: Xiaodai Wang for the original bug report here:
https://bugzilla.redhat.com/show_bug.cgi?id=1225789#c10
2016-02-26 10:45:21 +00:00
Richard W.M. Jones
534dfcf84e v2v: -o libvirt: Refactor video and graphics elements.
This is just a refactoring and doesn't change the meaning of the code.
2016-02-26 10:45:21 +00:00
Richard W.M. Jones
fadce8d3e7 fish: Set program name correctly for virt-{copy,tar}-{in,out} programs.
Set the (libguestfs handle) program name correctly when running
programs like virt-copy-in, so the program name is not "guestfish" but
"virt-copy-in".

Note this feature cannot be tested using the ./run script, since
libtool (buggily) resets the program name to "lt-guestfish".  However
I tested it on the installed copy and it worked there.
2016-02-26 10:45:21 +00:00
Richard W.M. Jones
7b11fb16ec perl: Don't embed API number in Sys::Guestfs.
It means you have to rerun `make -C perl clean ; make' every time you
add an API, and is useless anyway.
2016-02-26 10:45:21 +00:00
Pino Toscano
d9169fc371 listfs: ignore the default btrfs subvolume
When listing the subvolumes of a btrfs filesystem, ignore the default
subvolume: we get the content of it when mounting the whole device
(without specifying any particular subvolume), so avoid listing it
twice.
2016-02-26 11:41:47 +01:00
Pino Toscano
20efe36582 src: print contents of structs and struct lists on tracing
It eases the debugging, instead of getting just the name of the struct
returned.
2016-02-24 13:47:18 +01:00
Pino Toscano
e58e603a71 fish: use the new structs-print.c to print structs
Use of the new code to print structs, making sure the layout is the same
as before.
2016-02-24 13:47:18 +01:00
Pino Toscano
2c0d16e82e src: generate code for printing contents of structs
Extend the generator to generate a source (and the header for it) with
functions that print the content of a guestfs struct.  The code is
modelled after the code for it in fish.ml, although made a bit more
generic (destination FILE*, line separator) so it can be used also in
the library, when tracing.

This just introduces the new code and builds it as part of the helper
libutils.la.
2016-02-24 13:47:18 +01:00
Richard W.M. Jones
c0c91f96d7 daemon: btrfs: Use COMPILE_REGEXP macro to compile regular expressions. 2016-02-23 10:55:17 +00:00
Richard W.M. Jones
4752c42c21 lib: Allow the COMPILE_REGEXP macro to be used everywhere.
Since the daemon links to pcre and use regular expressions, and since
the COMPILE_REGEXP macro doesn't depend on any aspects of the
library-side code (eg. the guestfs_h handle etc), we can allow the
daemon to use the COMPILE_REGEXP macro.  Move the macro to
"guestfs-internal-all.h" to permit this.
2016-02-23 10:55:17 +00:00
Pino Toscano
b1ae32416e ruby: tests: use more asserts instead of manual checks
Make more use of assert_equal/refute_equal instead of manually checking
values and raising errors.
2016-02-23 11:50:35 +01:00
Pino Toscano
3c2bc20250 Revert "ruby: Run tests one at a time, instead of in parallel."
It seems the default behaviour of rake is to run tests sequentially, and
not in parallel (there are separate gems to achieve that behaviour).

Hence just invoke "rake test" to run all the available tests at once.

This reverts commit 8f30c3c3f8.
2016-02-23 11:50:35 +01:00
Richard W.M. Jones
ae3c051567 generator: Declare which input file(s) generate each output file. 2016-02-23 10:40:06 +00:00
Richard W.M. Jones
52b5ddf23e generator: Make the 'this file is generated' warning clearer.
Also rename the ~extra_inputs parameter as plain ~inputs.  We will use
~inputs more widely in following commit.
2016-02-23 10:40:06 +00:00
Richard W.M. Jones
9eb26a1748 generator: gobject: Remove parameters which are not used.
Revealed by adding typed interfaces in the previous commit.
2016-02-23 10:40:05 +00:00
Richard W.M. Jones
30d2a308c0 generator: Add interfaces to all modules.
Be explicit about what is exported from each module in the generator.
2016-02-23 10:40:05 +00:00
Richard W.M. Jones
b9a97718f7 tests: Use LOG_COMPILER to run valgrind. 2016-02-22 17:55:13 +00:00
Richard W.M. Jones
dd7be596f5 tests: Remove bogus use of $(VG). 2016-02-22 17:55:13 +00:00
Richard W.M. Jones
085815ce10 build: Describe how to set up check-valgrind rules correctly.
Since we enabled parallel tests, you can no longer run tests
under valgrind merely by doing:

  TESTS_ENVIRONMENT = $(top_builddir)/run --test $(VG)
  check-valgrind:
      $(MAKE) check VG="@VG@"

The reason is that the parallel tests framework doesn't run
``$(TESTS_ENVIRONMENT) <test>''.  It inserts some other processes in
between the environment and the test, so you end up valgrinding some
unrelated process (currently the 'env' program).

In run.in, remove out of date documentation for using $(VG).
In guestfs-hacking(1), document how to do it properly.
2016-02-22 17:55:13 +00:00
Pino Toscano
789d256645 python: tests: fix long/int mismatch in test090RetValues.py
Cast the value to the "int_type" representing the "long" value for
test_rint64, so the test works again with Python 3.
2016-02-22 17:13:38 +01:00
Pino Toscano
519c9bc8df python: tests: move the 'int' type in tests_helper
This way it can be used in other tests as well.

Simple code motion.
2016-02-22 16:57:57 +01:00
Pino Toscano
9776615301 python: tests: refactor to use unittest's discovery
Instead of running all the tests manually, the unittest module has a
'discovery' mode to run tests by importing them from a directory: this
requires the tests to have different filenames, since they need to be
imported as modules now (hence an empty __init__.py is added), and the
current naming does not match the convention.

Using unittest as loader/runner brings another change: tests skipped as
whole cannot be done anymore with exit(77), since they are not run but
imported: thus introduce an helper module with decorators applied to the
test classes to skip them according to the current checks.  This also
gets us nicer recordings in the unittest log.

Due to the relative imports (needed for the helper code), it is no more
possible to execute tests anymore by invoking them manually; although
it is possible to run single tests, still using unittest's runner:

  $ cd python
  python$ ../run python -m unittest discover -v t test010Load.py

This does not change anything in what the tests do/check.
2016-02-22 16:57:15 +01:00
Richard W.M. Jones
961721b64b FAQ: Link to posting about compiling libguestfs from source. 2016-02-22 10:19:42 +00:00
Richard W.M. Jones
34e7b69612 FAQ: cache=none, not cache=unsafe, prevents qemu from caching.
Thanks: kaze on IRC.
2016-02-22 09:54:10 +00:00
Richard W.M. Jones
3fa03a30b3 build: installcheck: Ensure libguestfs.so is copied.
If you ran 'make installcheck' when libguestfs-devel was not
installed, then the installcheck would fail in many places with:

  gcc: error: ../../src/.libs/libguestfs.so: No such file or directory

We should stop the installcheck script immediately if the .so file was
not found.

Also this commit ensures that src/.libs/libguestfs.so* not existing
before installcheck is not fatal.
2016-02-19 12:49:18 +00:00
Richard W.M. Jones
2e87face9e v2v: windows: Change wording of warning about basic VGA display driver (RHBZ#1309619). 2016-02-19 09:00:10 +00:00
Pino Toscano
9854ea913a gobject: ship also run-tests-retvalues
Fixes commit f7765ea6e4 and
commit 3787ebace4.
2016-02-19 09:47:37 +01:00
Richard W.M. Jones
cbf0714e07 v2v: RHEV: Treat Windows 8.1 x86 client as Windows 8 (RHBZ#1213324). 2016-02-18 14:43:33 +00:00
Richard W.M. Jones
7bf820b0d9 v2v: RHEV: Treat Windows 8.1 client as Windows 8 (RHBZ#1309580). 2016-02-18 14:41:43 +00:00
Richard W.M. Jones
5431eda3a6 v2v: Make the error message actionable when cannot find libvirt pool.
Make this error message useful and actionable by suggesting commands
that the end user can run to find available pools, etc.

I also had to extend the fixed size buffer we use for messages since
the message got truncated.
2016-02-18 14:14:19 +00:00
Richard W.M. Jones
ba839f553b v2v: OVF: In warning, display inspect.i_arch field.
See: https://bugzilla.redhat.com/show_bug.cgi?id=1213324#c11
2016-02-18 10:06:27 +00:00
Richard W.M. Jones
d87c6fd6f2 v2v: Add Windows 10 to OVF.
See https://github.com/oVirt/ovirt-engine/blob/master/packaging/conf/osinfo-defaults.properties
2016-02-18 10:00:45 +00:00
Richard W.M. Jones
6200ae7204 v2v: glance: Allow Glance backend to import multiple disks (RHBZ#1308769). 2016-02-17 18:04:32 +00:00
Richard W.M. Jones
bae3d92e88 v2v: glance: Add "OUTPUT TO GLANCE" section to the documentation. 2016-02-17 18:02:54 +00:00
Pino Toscano
3787ebace4 gobject: ship correct .js file
Fixes commit f7765ea6e4.
2016-02-17 10:26:35 +01:00
Pino Toscano
967e887e43 v2v: update URL with glance metadata 2016-02-16 14:42:44 +01:00
Pino Toscano
f7765ea6e4 Start adding return values tests for bindings
Introduce a new kind of bindings tests, 090-retvalues, to check all the
possible return values in bindings; start implementing them for
scripting languages such as GObject introspection, Perl, PHP, Python,
and Ruby, reusing existing implementations where existing.
2016-02-15 18:32:07 +01:00
Richard W.M. Jones
938f48f08a v2v: Fix CompatibleIDs for Windows > 7 conversions.
Thanks Joshua Pincus for finding the bug.

I checked back with the original W2K8R2 guest which I had used for
getting these registry entries, and there was a transcription error
with two of the CompatibleIDs.
2016-02-15 10:40:11 +00:00
Pino Toscano
2a2a540436 python: tests: use more targeted assert*() functions/checks
- use assertIsInstance, assertNotEqual, and assertIsNotNone as more
  specific checks (will produce better logging)
- use assertRaises when expecting exceptions being thrown
- when testing internal_test_rhashtable, instead of checking type and
  elements of the return values just check the return value as a whole
  (easier and already getting all the work needed by unittest)
2016-02-12 17:57:58 +01:00
Richard W.M. Jones
6629cb0d91 Version 1.33.12. 2016-02-12 15:57:51 +00:00
Richard W.M. Jones
85b1815e7b tests: Make '080' be an official test of the guestfs_version API.
Useful because it tests returning a single structure.
2016-02-12 15:41:42 +00:00
Richard W.M. Jones
b647dd8b52 python: tests: Use the 'unittest' module to run the test suite. 2016-02-12 15:32:39 +00:00
Richard W.M. Jones
2e16e3e993 daemon: lvm: Ignore LVs with the activationskip flag set (RHBZ#1306666).
When listing logical volumes, ignore the ones which don't get
activated automatically.  No /dev/VG/LV device node is created for
these ones which confuses APIs that attempt to do 'guestfs_lvs'
followed by opening the device node.  Note that 'guestfs_lvs_full' is
unaffected by this change.
2016-02-12 14:21:08 +00:00
Pino Toscano
7a598a0c02 php: restructure and expand tests
Rename the existing tests according to the naming/numbering described in
guestfs-hacking(1), and improve the current ones:
- guestfs_php_001.phpt: rename to guestfs_020_create.phpt
- guestfs_php_003.phpt: rename to guestfs_070_optargs.phpt
- guestfs_php_bindtests.phpt: rename to guestfs_090_bindtests.phpt
- guestfs_090_version.phpt: new, checks taken from the former
  guestfs_php_002.phpt
- guestfs_100_launch.phpt: new, modelled after the equivalent in e.g.
  OCaml/Perl/Python
- guestfs_php_002.phpt: remove, as what it did is now covered by
  090_version and 100_launch
2016-02-12 15:10:07 +01:00
Pino Toscano
9753986819 fish, sysprep: run FUSE-related tests only when FUSE is available
They will fail anyway in that case, so run them only when the FUSE
support is built in.
2016-02-11 18:40:04 +01:00
Richard W.M. Jones
18fa191250 v2v: Small documentation fix in permissions section.
In vCenter 5.5 at least, it's 'Sessions', not 'Session'.
2016-02-10 14:44:35 +00:00
Richard W.M. Jones
eae73a5aa9 Revert "v2v: Document that vCenter etc permissions must be set to "OK"."
On further examining the incredibly confusing VMware dialogs, I don't
believe this is true after all.

This reverts commit e76128a20b.
2016-02-10 14:43:09 +00:00
Richard W.M. Jones
e76128a20b v2v: Document that vCenter etc permissions must be set to "OK".
And that READ_ONLY access is insufficient.  I believe this is a bug in
libvirt, but it requires further investigation.  If it is resolved in
libvirt then we can update this documentation again.

Thanks: Ulhas Surse
2016-02-10 13:21:47 +00:00
Pino Toscano
2f461b7cb8 Update zanata.xml
Update the Zanata configuration based on what Zanata itself proposes as
project configuration.
2016-02-10 14:15:05 +01:00
Richard W.M. Jones
f9686217b5 docs: Add recipe for FUSE-mounting a Windows guest with drive letters.
Thanks: Pino Toscano, Hilko Bengen.
2016-02-10 11:06:07 +00:00
Richard W.M. Jones
3a9643834c docs: Alphabetize headings in guestfs-recipes(1).
No change, just reorder a section so they are in alphabetical order.
2016-02-10 10:43:09 +00:00
Roman Kagan
92ea4ed5f7 v2v: move virtio_win to windows_virtio
Now that all the stuff related to Windows virtio drivers has been moved
into a dedicated module, it makes sense to move the definition of
virtio_win there, too, and stop passing it around as a parameter.

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
2016-02-09 16:36:10 +00:00
Richard W.M. Jones
511280c076 Version 1.33.11. 2016-02-09 13:27:55 +00:00
Pino Toscano
41afeb266d tmpdirs: fix typo in variable name
On mkdtemp error, free tmppath and not tmpdir (which is CLEANUP_FREE).

Fixes commit 673a7a959c.
2016-02-09 14:18:15 +01:00
Pino Toscano
15d28b09c0 tmpdirs: centralize permissions handling
Move to lazy_make_tmpdir the logic for making world-readable (but only
for root) newly-created temporary directories, removing the non-fatal
code doing that in guestfs_impl_launch.

Followup of commit 772f649e59.
2016-02-09 14:15:06 +01:00
Pino Toscano
772f649e59 lib: fix sockdir for root
When running as root libvirt will launch qemu as qemu.qemu, which will
not be able to read inside the socket directory in case it is set as
XDG_RUNTIME_DIR under /run/user/0.

Since normal users don't need particular extra access permissions for
their sockdirs, restrict /tmp as only possible sockdir for root,
changing the permissions only for this user (and making this operation
fatal).

Fixes commit 55202a4d49 and
commit 7453952d24.
2016-02-09 11:36:23 +01:00
Richard W.M. Jones
d5c0f85c6e Version 1.33.10. 2016-02-08 17:52:29 +00:00
Pino Toscano
fcf1884932 tests: reduce sizes of scratch disks to 2 GB
1 GB should be enough to create a btrfs filesystem, even with 64K page
size; hence, make the /dev/sda and /dev/sdb test devices smaller so
there is less space taken during the test run.

Followup of commit 8ffad75e5b and
commit 9e9b648770.
2016-02-08 17:22:48 +00:00
Richard W.M. Jones
7453952d24 launch: Set sockdir mode to 0755.
https://bugzilla.redhat.com/show_bug.cgi?id=610880

Fixes commit 55202a4d49.
2016-02-08 17:20:30 +00:00
Richard W.M. Jones
7fd17fa99d launch: libvirt: Debug sockdir not tmpdir.
Fixes commit 55202a4d49.
2016-02-08 17:09:48 +00:00
Dawid Zamirski
7cb28488a6 inspect: get windows drive letters for GPT disks.
This patch updates the guestfs_inspect_get_drive_mappings API call to
also return drive letters for GPT paritions. Previously this worked
only for MBR partitions. This is achieved by matching the GPT partition
GUID with the info stored in the blob from
HKLM\SYSTEM\MountedDevices\DosDevices keys. For GPT partions this blob
contains a "DMIO:ID:" prefix followed by a 16 byte binary GUID.
2016-02-06 17:09:18 +00:00
Richard W.M. Jones
985a693251 Version 1.33.9. 2016-02-05 19:11:47 +00:00
Richard W.M. Jones
8cba70c038 lib: Stop exporting the safe_malloc, etc. functions.
As was forewarned in the comment, stop exporting these functions
outside the library.
2016-02-05 14:17:48 +00:00
Richard W.M. Jones
32cd056ff8 ruby: Stop using the safe_malloc, etc. functions. 2016-02-05 14:17:48 +00:00
Richard W.M. Jones
4b96331ad5 perl: Stop using the safe_malloc, etc. functions. 2016-02-05 14:17:48 +00:00
Richard W.M. Jones
2a48a6591f java: Stop using the safe_malloc, etc. functions. 2016-02-05 13:16:22 +00:00
Richard W.M. Jones
ae750fcfe0 python: Stop using the safe_malloc, etc. functions. 2016-02-05 13:15:59 +00:00
Richard W.M. Jones
0445284dfb ocaml: Stop using the safe_malloc, etc. functions. 2016-02-05 13:15:48 +00:00
Richard W.M. Jones
0b10465772 java: Fix documentation of @throws.
The javadoc @throws directive requires a string documenting
when the exception is thrown.
2016-02-05 13:05:30 +00:00
Richard W.M. Jones
7ac9127bf4 v2v: Move the other OVMF paths into the core library.
Refactoring change, continuing the theme from the previous commit.
2016-02-05 09:22:28 +00:00
Richard W.M. Jones
4ac6ff6b47 aarch64: Use a common table of AAVMF paths.
Previously the code had two places where an identical set of AAVMF
paths were stored.  Put this information into one place.

This is just refactoring.
2016-02-04 18:36:19 +00:00
Pino Toscano
13c3698358 customize: add globbing for --delete
Support globbing in paths passed to --delete, telling glob to not
return directories with leading slash.

This re-adds back globbing for --delete in virt-sysprep, which was
available before the integration with common code from virt-customize.
2016-02-04 11:26:20 +01:00
Pino Toscano
01f46e4e31 daemon: glob: add optarg to control trailing slash for dirs
Add a new optional bool "directoryslash" to indicate whether the caller
wants trailing slashes in names of directories, defaulting to true (the
current behaviour); this helps with interoperability with other tools
(such as rm).

Related to RHBZ#1293271.
2016-02-04 11:25:56 +01:00
Pino Toscano
14b8e67f0b sysprep, get-kernel: explicit the Guestfs parameter
Help the OCaml compiler by expliciting Guestfs.guestfs as type for 'g'
in some functions.
2016-02-04 10:22:18 +01:00
Richard W.M. Jones
fe7fceba6e v2v: Replace "=" by "_" in OVF .meta DESCRIPTION field.
The current VDSM .meta file parser is incorrect:

  https://code.engineering.redhat.com/gerrit/gitweb?p=vdsm.git;a=blob;f=vdsm/storage/fileVolume.py;h=20573bd2a3fe6909a8474bd7c53c8d0fea79091c;hb=c1289fd70edcde0a0b3bc8e37ecad1e2a5babe1a#l285

When parsing the key=value fields in the .meta file, it uses the
Python expression:

  key, value = l.split("=")

which throws an exception "ValueError: too many values to unpack" if
the value part also contains an "=" character (because split returns
an n-tuple with n > 2).  The correct way to split the string in this
situation is to use l.split("=", 1).

In commit 399e031c25 I changed the
DESCRIPTION field in .meta so that in RHEL it would look like this:

  DESCRIPTION=generated by libguestfs 1.32.2rhel=7,release=1.el7,libvirt

thus containing an "=" character in the value and throwing an
exception in VDSM.

Although this is a bug in VDSM which needs to be fixed separately,
change any occurrence of "=" in the value to "_" to avoid this
problem.

Thanks: Derrick Ornelas for helping to diagnose this bug and finding
the offending code in VDSM.
2016-02-03 21:35:48 +00:00
Richard W.M. Jones
9e9b648770 tests: btrfs: Use a 2000 MB partition for btrfs test (instead of 200 MB).
One of the mkfs-btrfs tests used two 200 MB partitions.  That isn't
enough to create a btrfs filesystem on aarch64 (with 64K page size).
Since we now have a 10 GB disk, we can make the test partition 10
times larger.
2016-02-03 17:26:34 +00:00
Richard W.M. Jones
5238c4ee0a tests: btrfs: Don't test --leafsize, and use --nodesize 64K.
In btrfs-progs 4.4, the --leafsize parameter is deprecated.  It's now
just an alias for --nodesize.

On aarch64, --nodesize 4096 does not work because it's smaller than
the page size (64K).  Luckily we can test a 64K nodesize on any
platform, so use that instead.
2016-02-03 17:26:34 +00:00
Richard W.M. Jones
8ffad75e5b tests: Increase the size of the /dev/sda and /dev/sdb test devices.
Previously these were rather small - just 500 MB.  This is too small
to create a btrfs device on aarch64 (where page size may be 64K), and
barely enough even on x86-64.  This change makes both these devices
10 GB, and adjusts a few tests so they continue to pass.
2016-02-03 17:26:34 +00:00
Richard W.M. Jones
c055f842d7 Version 1.33.8. 2016-02-03 14:02:26 +00:00
Richard W.M. Jones
f88e931866 resize: Use sparse copy for extended partitions unless --no-sparse.
Thanks: Maxim Perevedentsev
2016-02-03 13:32:35 +00:00
Pino Toscano
d3502bdc32 generator: simplify generated code for always-available features
Just refer to the dummy function directly, instead of using #define's.
2016-02-03 13:24:37 +01:00
Pino Toscano
55202a4d49 New API: get-sockdir
Introduce a new read-only API to get a path where to store temporary
sockets: this is different from tmpdir, as we need short paths for
sockets (due to sockaddr_un::sun_path), and it is either
XDG_RUNTIME_DIR if set, or /tmp; adapt guestfs_int_create_socketname
to create sockets in that location.

Furthermore, print sockdir and XDG_RUNTIME_DIR in test-tool for
debugging.
2016-02-03 13:15:29 +01:00
Pino Toscano
4f7251f896 launch: add internal helper for socket paths creation
Introduce an internal helper to create paths for sockets -- will be
useful for changing later the logic for placing sockets.
Futhermore, check that the length of sockets won't overflow the buffer
for their filenames.
2016-02-03 12:51:26 +01:00
Pino Toscano
673a7a959c lib: extract lazy tmpdir creation helper
Extract the bit of code for lazy creation of a temporary directory, so
it can be used for more directories as well.

This is just code motion, with no behaviour changes.
2016-02-03 11:07:34 +01:00
Pino Toscano
dbad317120 launch: libvirt: cleanup sockets on shutdown
Unlink the sockets in the shutdown callback, instead of right before
creating a new ones.  This makes sure we are unlinking the right
sockets.
2016-02-01 10:52:15 +01:00
Pino Toscano
e31e3ccd8f launch: libvirt: move socket path variables
Move the paths of the sockets used, from the libvirt_xml_params struct
to backend_libvirt_data; this way, they will be usable also outside the
launch callback.

Simply code motion.
2016-02-01 10:52:14 +01:00
Pino Toscano
cfedf73b3d launch: direct: cleanup daemon socket on shutdown
Unlink the daemon socket in the shutdown callback, instead of right
before creating a new one.  This makes sure we are unlinking the right
socket.
2016-02-01 10:52:14 +01:00
Pino Toscano
0f6a3b13a5 launch: direct: save the path of the daemon socket
Save the path of the socket passed to qemu for communication with
guestfsd; we will need it to clean it correctly.
2016-02-01 10:52:13 +01:00
Pino Toscano
79b2f19fe7 launch: unix: check for length of sockets
Error out early if the path to the socket will not fit into
sockaddr_un::sun_path, as we will not be able to connect to it.
2016-02-01 10:52:12 +01:00
Richard W.M. Jones
e8ce35b007 FAQ: Add answer about unsupported use of NTFS in RHEL 7.2. 2016-01-31 16:00:00 +00:00
Richard W.M. Jones
19f3689e5d v2v: Split with_hive into with_hive_readonly, with_hive_write.
I find the code slightly easier to read if we get rid of the ~write
flag, and instead split the with_hive function into two functions, one
for readonly access, and one for write access.

This is just code refactoring.
2016-01-31 14:25:30 +00:00
Richard W.M. Jones
53cc0370b2 mllib: Add 'protect' function (like try/finally).
Use the function in the virt-v2v [Windows] module.

This is just refactoring.  There is no visible change in
functionality.
2016-01-31 14:14:37 +00:00
Richard W.M. Jones
db3e2023eb mllib: Move the maybe type (like Haskell Either) to common library.
Just code motion.
2016-01-31 14:01:59 +00:00
Richard W.M. Jones
14d80452dc arm: Disable -Wcast-align warning.
Any modern system can handle unaligned memory access.  On armv7 it's
slightly slower, that's all.
2016-01-29 20:58:46 +00:00
Richard W.M. Jones
8a910136e4 v2v: windows: Remove unused code left over by previous commit.
As this code wasn't exported in the module interface, it cannot have
been used anywhere.

Fixes commit b76f271425.
2016-01-29 12:50:12 +00:00
Richard W.M. Jones
b6a7aaf0d0 v2v: Remove items from TODO which have been implemented already. 2016-01-29 12:41:02 +00:00
Richard W.M. Jones
825ff5d04d Version 1.33.7. 2016-01-29 10:26:27 +00:00
Richard W.M. Jones
b76f271425 v2v: windows: Move all virtio driver installation code to common module.
Add a common module `Windows_virtio' and move all the code related to
finding and installing Windows virtio drivers to this module.

This is just code motion and code refactoring, there is no change in
functionality.
2016-01-29 10:10:18 +00:00
Pino Toscano
0ac8894f62 inotify_add_watch: pass IN_ALL_EVENTS as mask for test
Instead of pass 0x3fffffff as mask value, pass a simplier 0xfff, which
is the value of the IN_ALL_EVENTS define.  This will still catch all
the inotify events, and avoid a EINVAL error with Linux 4.4.
2016-01-29 10:06:33 +01:00
Richard W.M. Jones
6db3c4099f v2v: windows: Update comment about device number key.
Thanks: Vadim Rozenfeld for finding the TechNet documentation
related to this key.
2016-01-29 08:56:10 +00:00
Richard W.M. Jones
b2a10de6db v2v: Add location of SUSE UEFI binaries.
Thanks: Jim Fehlig
2016-01-29 08:52:09 +00:00
Richard W.M. Jones
52e7085d18 ruby: Rename internal C functions with more consistent naming. 2016-01-28 22:06:01 +00:00
Richard W.M. Jones
f9259c7ba4 lua: Rename 'guestfs_lua_' functions to 'guestfs_int_lua_'.
Actually these are all static functions, so they don't really need the
'guestfs_' prefix at all, but using a prefix avoids any possibility of
a collision with a standard C function.

This is a mechanical refactoring.
2016-01-28 21:53:38 +00:00
Richard W.M. Jones
1a9312c743 python: Rename 'py_guestfs_' functions to 'guestfs_int_py_'.
Purely mechanical change, done by a Perl script (hah!)
2016-01-28 21:49:47 +00:00
Richard W.M. Jones
14cd9a031a java: Rename internal C function without guestfs_ prefix. 2016-01-28 21:38:18 +00:00
Richard W.M. Jones
53403fbdef ocaml, virt tools: More consistent naming for C functions.
For functions linked to virt tools, make sure the name of the function
actually matches the virt tool.  Because of the history of moving
functions across tools, some names no longer matched.

For mllib, use `guestfs_int_mllib_' prefix.

For OCaml bindings, use `guestfs_int_ocaml_' prefix.

This commit is by no means complete.  There are many other C functions
in other language bindings which could do with being more consistently
named.

There is no functional change, this is just refactoring.
2016-01-28 21:30:20 +00:00
Richard W.M. Jones
e32a14ceec docs: Remove reference to double underscore, which is no longer used in internal identifiers. 2016-01-28 21:08:01 +00:00
Richard W.M. Jones
4125181681 docs: Rework headings in guestfs-hacking(1) manual page. 2016-01-28 21:08:01 +00:00
Richard W.M. Jones
98332e8c85 docs: Move section about local* files to guestfs-building(1).
Since it is part of the instructions for building libguestfs, it goes
better in the guestfs-building(1) man page.
2016-01-28 21:08:01 +00:00
Pino Toscano
f9e8f3b2d2 lvm: support lvm2 older than 2.02.107
lvm2 2.02.107 adds the -S/--select option used in lvs to filter out only
public LVs (see RHBZ#1278878).  To make this work again with versions
of lvm2 older than that, only on old versions filter out thin layouts
and compose the resulting device strings ourselves.

The filtering done is much simplier than what "-S lv_role=public" will
do, but should be good enough for our need.
2016-01-28 15:38:25 +01:00
Richard W.M. Jones
569ad259b4 v2v: linux: Find dracut if it is located in /usr/bin.
In Fedora 23, dracut moved to /usr/bin.  However we only looked for
/sbin/dracut, so we didn't find it.  You would have seen a failure
like this:

  virt-v2v: error: unable to rebuild initrd
  (/boot/initramfs-4.2.3-300.fc23.x86_64.img) because mkinitrd or dracut was
  not found in the guest

Look for dracut in /usr/bin as well.

Thanks: Arnaud Bougeard.
2016-01-28 13:57:04 +00:00
Pino Toscano
2bccaa3047 python: stop using parens-less print in tests
print "" is no more available in Python 3, and print(...) is available
since Python 2.7; as one of the tests was using print(), use this form
everywhere so the tests can run fine with Python 3.
2016-01-28 14:45:23 +01:00
Richard W.M. Jones
a6c7b39530 v2v: windows: Don't hard code "oem1.inf" string.
Find the next free "oem%d.inf" string.

Thanks: Vadim Rozenfeld for clarifying what we should be doing
in this case.
2016-01-28 13:11:48 +00:00
Richard W.M. Jones
58ce08f36f v2v: Abbreviate a couple of comments.
No functional change.
2016-01-28 13:11:48 +00:00
Richard W.M. Jones
b12f0a809f GCC 6: Avoid warning about logical OR of "equal" expressions.
The warning (see below) is fairly useless.  This modification to the
code avoids it.

inotify.c: In function 'do_inotify_read':
inotify.c:219:32: error: logical 'or' of equal expressions [-Werror=logical-op]
       if (errno == EWOULDBLOCK || errno == EAGAIN) /* End of list. */
                                ^~
2016-01-28 12:37:33 +00:00
Richard W.M. Jones
b1b15dc77d Version 1.33.6. 2016-01-27 17:36:03 +00:00
Richard W.M. Jones
c323bb7db7 p2v: tests: Don't supply os-version in test. 2016-01-27 15:27:06 +00:00
Pino Toscano
c355b748ce actions: mark btrfs test case of vfs_minimum_size as TestRunOrUnsupported
The btrfs implementation of vfs_minimum_size requires
btrfs-progs >= 4.2, erroring with ENOTSUP otherwise; thus mark the btrfs
test case of the vfs_minimum_size tests as TestRunOrUnsupported, so it
will not cause failures if the available btrfs-progs is not enough.
2016-01-27 14:23:48 +01:00
Pino Toscano
ceefa701c6 generator: add TestRunOrUnsupported test type
Create a new TestRunOrUnsupported test type, which represents a test
sequence where a failure with ENOTSUP in the last command only marks the
test as skipped.  To be used mainly when testing features available only
with some versions of helper tools used in the appliance, for example.
2016-01-27 14:17:22 +01:00
Pino Toscano
474e3051c7 btrfs: also check return value of sysroot_path in btrfs_minimum_size
Followup of commit 79ac68030f.
2016-01-27 14:09:16 +01:00
Pino Toscano
79ac68030f btrfs: fix leak in btrfs_minimum_size
Make sure the result of sysroot_path is properly free'd.
2016-01-27 13:45:24 +01:00
Pino Toscano
fa262e2540 btrfs: fix wrapping in message in btrfs_minimum_size 2016-01-27 13:29:16 +01:00
Richard W.M. Jones
3aaa4c9419 p2v: virt-p2v-make-disk: Make os-version parameter optional.
Having to choose the os-version of the virt-p2v disk was confusing.
Users thought it had something to do with the physical machine being
converted.

In some cases, virt-p2v-make-disk can now choose a suitable os-version
for the user.  Usually it's the latest numeric version of Fedora or
Debian, depending on the host distro.  If we don't recognize the host
distro, we bail and ask the user to choose, but this is still an
improvement.
2016-01-27 11:54:09 +00:00
Richard W.M. Jones
42f8c6e3bd p2v: Use $program consistently in virt-p2v-make-disk script. 2016-01-27 11:48:17 +00:00
Richard W.M. Jones
c3ad944555 p2v: Fix typo in virt-p2v-make-disk manual page. 2016-01-27 11:38:09 +00:00
Richard W.M. Jones
683dd5cbab docs: Refresh the guestfs-testing(1) man page.
Require libguestfs >= 1.22.  Testing ancient versions isn't useful.

Add a virt-builder test section.
2016-01-26 22:18:42 +00:00
Richard W.M. Jones
09e29a70e7 docs: Fix headings in guestfs-security(1). 2016-01-26 21:49:04 +00:00
Richard W.M. Jones
e96df6e776 docs: Add security contact information. 2016-01-26 21:45:17 +00:00
Richard W.M. Jones
1b4de75cb0 docs: Refactor list of manual pages in guestfs(3). 2016-01-26 21:38:12 +00:00
Richard W.M. Jones
1b3d3a3589 customize: Remove "useless" sprintf.
Actually the OCaml compiler rewrites all printf functions at compile
time to a series of primitive string operations, so the use of sprintf
here doesn't really matter.  Still, it's a bit tidier not to use
sprintf where it's not needed.

Also this commit contains some code reformatting.

This is just refactoring.
2016-01-26 21:26:23 +00:00
Richard W.M. Jones
81ff8c5d23 p2v: User can click on an interface name to identify the physical interface.
When the user clicks on the second column of the list of network
interfaces, run 'ethtool --identify <if_name> 10', which (on supported
cards) flashes a light on the physical interface for 10 seconds,
allowing it to be identified by the operator.
2016-01-26 17:54:20 +00:00
Richard W.M. Jones
4470f0483b customize: Add support for the APK (Alpine Linux) package manager. 2016-01-26 17:54:20 +00:00
Pino Toscano
7adb8ffa61 inspect: resolve symlinks when detecting architecture
Resolve the paths of the binaries we are looking in the guest to
identify the architecture. This way we can identify also busybox-based
guests such as Alpine Linux, where all the "base" binaries in /bin are
symlinks to busybox.
2016-01-26 17:54:20 +00:00
Richard W.M. Jones
302bba4f3f Version 1.33.5. 2016-01-26 14:04:38 +00:00
Pino Toscano
5aa26e76ea daemon: fold xfs_admin stdout to stderr
Apparent newer versions of that report everything on stdout, including
error messages; since we only print something on failure, fold stdout to
stderr so we can see everything on failure.
2016-01-26 11:25:54 +01:00
Pino Toscano
1d0bd79c08 xfs_admin: do not set lazycounter in tests not checking that
This flag cannot be disabled (yet) in V5 xfs filesystems; since 2 out
of the current 3 tests of xfs_admin check other results than that flag,
avoid setting it when not needed.
2016-01-26 11:23:25 +01:00
Pino Toscano
d2a36f8cbe daemon: improve debugging for "stdout on stderr" flag
When the COMMAND_FLAG_FOLD_STDOUT_ON_STDERR flag is passed to
command*(), indicate that as stdout=e in debugging message.
2016-01-26 11:21:46 +01:00
Pino Toscano
c22dea9871 btrfs_subvolume_show: fix root/toplevel check w/ btrfs-progs >= 4.4
In trfs-progs 4.4 the error message has been changed, and our check did
not work anymore.  Yes, parsing user messages really sucks...
2016-01-25 19:53:42 +01:00
Pino Toscano
08bf961d68 actions: expand partitions for btrfs_image test
Apparently with newer btrfs-progs (seen with 4.4) 100M are not enough
for a btrfs filesystem; hence double the size of the partitions
created in the test of btrfs_image, so now 200M are enough for btrfs.
2016-01-25 19:08:14 +01:00
Richard W.M. Jones
f2e201033a p2v: Use new miniexpect methods to access the handle fields. 2016-01-24 17:01:17 +00:00
Richard W.M. Jones
38edddb8e8 p2v: Resynch miniexpect with upstream.
Upstream miniexpect commit 3df4c0d3e4192cb6bb8e9ed7126346ab6aa98043.
2016-01-24 17:01:17 +00:00
Richard W.M. Jones
86ec266f22 p2v: Handle mexp_close returning -1 correctly.
If a system call fails, this function returns -1 and sets errno.  This
case was not handled correctly.
2016-01-24 17:01:16 +00:00
Richard W.M. Jones
b564e3682b arm: Remove all DTB (device tree) code.
In commit af762e4342 (2015-03-05)
I stopped libguestfs from using the supermin -dtb parameter when
building appliances.

It has not been necessary for quite a long time to specify a DTB,
since qemu itself creates a device tree structure in the guest
(appliance) memory from the devices presented to the guest.  Qemu does
this on the fly each time the guest starts.

As I promised in the commit mentioned above I would remove this code,
and this commit does that (for libguestfs only).
2016-01-22 22:23:25 +00:00
Richard W.M. Jones
1477c95da4 launch: libvirt: Reword an SELinux debug message. 2016-01-22 21:51:18 +00:00
Richard W.M. Jones
bf469bca13 launch: libvirt: Refactor destroy_domain function.
Small rewrite of commit 7e2f2b0b24.  No
functional change.
2016-01-22 21:48:16 +00:00
Richard W.M. Jones
2b9fda2f92 docs: Tested clang, and userspace probes now work. 2016-01-22 15:44:21 +00:00
Richard W.M. Jones
e3ff6507e9 Version 1.33.4. 2016-01-22 13:16:03 +00:00
Richard W.M. Jones
e23b44e2de daemon: Link with cleanups.c.
And remove the cleanup_* functions from guestfsd.c.

This fixes commit d94860d7e8.
2016-01-22 13:08:24 +00:00
Richard W.M. Jones
2cb8e5ddb8 Minor fixes to "daemon: Split out command* functions and CLEANUP_* macros."
This updates commit d94860d7e8.

Thanks: Pino Toscano.
2016-01-22 12:52:33 +00:00
Richard W.M. Jones
ac5fe225a9 Version 1.33.3. 2016-01-22 12:42:57 +00:00
Richard W.M. Jones
d94860d7e8 daemon: Split out command* functions and CLEANUP_* macros.
This allows the command* functions and CLEANUP_* macros to be used
independently from the daemon.
2016-01-22 09:12:17 +00:00
Richard W.M. Jones
b5066c67e0 daemon: Rename daemon/command.c -> daemon/sh.c.
Simply a file rename, no other change.
2016-01-21 14:25:44 +00:00
Richard W.M. Jones
550fdefc3c p2v: Display architecture in the About dialog. 2016-01-21 13:56:13 +00:00
Richard W.M. Jones
6d25ad48e5 p2v: virt-p2v-make-disk: Allow --arch parameter to be supplied.
This allows you to build a 32 bit virt-p2v USB key, even on a 64 bit
host.

Because of problems with the Fedora build system it's unfortunately
not easy to build a 32 bit virt-p2v binary, so this patch punts on
this issue and assumes that the user can supply the binary themselves.
2016-01-21 13:55:16 +00:00
Richard W.M. Jones
d5222a3ab9 p2v: Fix paths to data files in documentation. 2016-01-21 12:39:47 +00:00
Maxim Perevedentsev
e834b7413a New API: part_expand_gpt.
This action moves second(backup) GPT header to the end of the disk.
It is usable in in-place image expanding, since free space after
second GPT header is unusable. To use additional space, we have
to move second header. This is what sgdisk -e does.

However, sgdisk -e may perform additional actions if the partition
table has unexpected params (e.g. if we call sgdisk -e /dev/sda1,
it may fix partition table thus destroying the filesystem).
To prevent such cases, we do a dry-run at first and fail if
additional actions are scheduled.
2016-01-20 17:41:13 +00:00
Roman Kagan
390c68441a convert_windows: uninstall Parallels Tools on first boot
If present, Parallels Tools may stand in the way of proper running the
windows guests in non-Parallels hypervisors, so we're better off
uninstalling them on the first boot into the new environment.

With this patch, the uninstall records for Parallels Tools are looked up
in the registry and, if found, corresponding firstboot actions are
registered, taking special care that those actions are run fully
unattended.

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
2016-01-20 17:33:24 +00:00
Richard W.M. Jones
e40acef864 Version 1.33.2. 2016-01-20 17:25:09 +00:00
Richard W.M. Jones
4a0905ac36 tests: regressions: Allow test-big-heap to work on machines with less memory.
This test would fail on machines with around 4 GB of free memory.
Adjust the test so it would now work on such machines (it will however
still fail on a machine with around 2 GB of free memory).
2016-01-20 17:05:53 +00:00
Richard W.M. Jones
ce5607895f docs: Add requirement on ncurses.
Previously missing from the requirements list.
2016-01-20 16:34:34 +00:00
Richard W.M. Jones
9310fabd26 docs: Add guestfs-building(1) man page.
This contains instructions for building libguestfs from source.
2016-01-20 13:42:38 +00:00
Richard W.M. Jones
50f838de31 p2v, v2v: Move HACKING documentation to guestfs-hacking(1) manual page. 2016-01-20 12:05:22 +00:00
Maxim Perevedentsev
dce3b4649d resize: preserve GPT disk GUID.
Changed disk GUID makes some OSes fail to boot.
To enable virt-resize to support such OSes we
have to preserve disk GUID.
2016-01-19 17:59:58 +00:00
Maxim Perevedentsev
1af51b9b02 New API: part_set_disk_guid_random.
Provides a way to set a new randomly-generated GUID to disk.
2016-01-19 17:59:58 +00:00
Maxim Perevedentsev
035936a038 New API: part_get_disk_guid and part_set_disk_guid.
Some OSes (e.g. Windows Server 2012 R2) fail to boot if the disk
GPT GUID has changed. To preserve disk guid e.g. during virt-resize,
we need a way to get/set disk GUIDs.
2016-01-19 17:59:58 +00:00
Richard W.M. Jones
7e2f2b0b24 lib: Handle slow USB devices more gracefully.
Libvirt has a fixed 15 second timeout for qemu to exit.  If qemu is
writing to a slow USB key, it can hang (in D state) for much longer
than this - many minutes usually.

The solution is to check specifically for the libvirt EBUSY error when
this happens, and retry the virDomainDestroyFlags operation
(indefinitely).

See also the description here:
https://www.redhat.com/archives/libvir-list/2016-January/msg00767.html

Similar to the following OpenStack Nova commit:
http://git.openstack.org/cgit/openstack/nova/commit/?id=3907867

Thanks: Kashyap Chamarthy and Daniel Berrange.
2016-01-19 17:59:58 +00:00
Richard W.M. Jones
c3ebc0a837 launch: libvirt: In error messages, display err->int1, don't display domain.
The err->domain field is essentially random from the point of view
of libguestfs.

The err->int1 field has some useful information in some circumstances:
it has the errno value from the failed system call.
2016-01-19 16:04:02 +00:00
Richard W.M. Jones
d029fa0507 Revert "p2v: virt-p2v-make-disk: Allow --arch parameter to be supplied."
This won't work unless we also build a 32 bit virt-p2v binary.

This reverts commit d723b352f8.
2016-01-19 16:04:02 +00:00
Pino Toscano
40b5698388 daemon: resolve paths for ll and llz
Resolve in the guest the given path, so absolute symlinks can be listed
using appliance tools without resolution errors.
Also remove the note about the possibility to escape the sysroot using
ll and llz, since realpath won't return paths outside sysroot.

Fixes part of RHBZ#1293276.
2016-01-19 09:46:20 +01:00
Richard W.M. Jones
3f376fa513 p2v: virt-p2v-make-disk: Use a more robust way to get the latest kernel version.
Fedora/i686 does not have a package called 'kernel', so the command
'rpm -q kernel' fails.  In any case the method used wasn't exactly
very robust.

The new method is based on how febootstrap used to do this.

This updates commit d723b352f8.
2016-01-18 17:44:12 +00:00
Maxim Perevedentsev
4a7b32a7e2 Add -f option to resize2fs -P in vfs_minimum_size.
Sometimes the user wants to know minimum size
for dirty (e.g. mounted) filesystems. In this case,
resize2fs -P will require calling e2fsck -f, while
"in general, it is not safe to run e2fsck on mounted filesystems".

Since resize2fs -P does not modify filesystem, we force it
to display (probably approximate) minimum size.
2016-01-18 16:49:18 +00:00
Richard W.M. Jones
d723b352f8 p2v: virt-p2v-make-disk: Allow --arch parameter to be supplied.
This allows you to easily build a 32 bit virt-p2v USB key, even on a
64 bit host.
2016-01-18 12:12:58 +00:00
Richard W.M. Jones
727ac63dea Update gnulib.
The version we picked just before 1.32 was released suffers from:

  test-mbrtowc.c:49: assertion 'ret == (size_t)(-2)' failed

on RHEL 7.  See this thread for details:

  http://comments.gmane.org/gmane.comp.lib.gnulib.bugs/35567
2016-01-14 17:05:57 +00:00
Pino Toscano
0687bb8e07 builder: allow a specific template for --list
Allow the user to specify a template in --list mode, which will be the
only result in the resulting output (instead of all the available
templates).

This makes it easier to find out the details of a specific template.
2016-01-14 12:40:31 +01:00
Pino Toscano
0a84c67bd6 builder: move os-version search in own function
Simple code motion, no behaviour changes.
2016-01-14 11:51:13 +01:00
Richard W.M. Jones
7bccd0593f tests/mountable: Allow test to be skipped. 2016-01-12 18:26:33 +00:00
Richard W.M. Jones
c1799541d3 Version 1.33.1. 2016-01-11 14:06:42 +00:00
Richard W.M. Jones
446f7794e0 podwrapper: Add --warning flag for manual pages of CLI tools (RHBZ#1293527).
This doesn't add --warning flags to the translated pages,
which is a bug to be fixed at some point.
2016-01-11 13:42:49 +00:00
Richard W.M. Jones
bb27fc1c0a podwrapper: Generate consistent WARNING sections (RHBZ#1293527). 2016-01-11 13:42:49 +00:00
Richard W.M. Jones
6fa4d983a3 podwrapper: Enforce that every manual page must have a DESCRIPTION section.
For every user command line tool (eg. guestfish or virt-cat) require
that the manual page has a DESCRIPTION section.  This doesn't apply to
non-CLI man pages (eg. guestfs-perl, guestfs-faq).
2016-01-11 13:42:49 +00:00
Richard W.M. Jones
3b8322e18c customize: Document missing command line parameters in the synopsis.
I noticed that the --attach option was not covered in the synopsis.
This commit documents all of the missing command line parameters in
the synopsis.
2016-01-11 13:42:49 +00:00
Richard W.M. Jones
b527ff0dfc build: Require qemu >= 1.3.0 and yajl.
Require qemu >= 1.3.0, the first version that supported
`qemu-img --output=json'.

This means we require yajl (for parsing the JSON output of qemu-img),
and that in turn has consequences elsewhere.
2016-01-11 13:42:49 +00:00
Richard W.M. Jones
64af88a1b7 v2v: Unquote path when removing VirtualBox Guest Additions (RHBZ#1296606). 2016-01-11 13:38:36 +00:00
Richard W.M. Jones
2e728ed0dc p2v: Break long lines when displaying virt-v2v output in GUI. 2016-01-08 13:12:01 +00:00
Richard W.M. Jones
abd41320e1 tests: Allow test-disk-create.sh to be skipped. 2016-01-06 17:05:28 +00:00
Richard W.M. Jones
980dc9deaf regressions: test-big-heap: Allow this test to be skipped. 2016-01-06 16:04:46 +00:00
Richard W.M. Jones
de94d01692 regressions: test-big-heap: Add comment about a failure of this test. 2016-01-06 16:04:23 +00:00
Richard W.M. Jones
6afde4fd34 Version 1.33.0. 2016-01-06 11:45:27 +00:00
Richard W.M. Jones
f674520651 hacking: Fix git push command for pushing stable branch.
This fixes commit 5218f54a54.
2016-01-06 11:35:34 +00:00
Richard W.M. Jones
88ba55c553 Version 1.32.0. 2016-01-06 11:34:01 +00:00
Richard W.M. Jones
bc9faf843b website: Prepare website for 1.32 release. 2016-01-06 11:30:02 +00:00
Richard W.M. Jones
5218f54a54 hacking: Document simpler way to create stable branch in git.
I will try this method for the 1.32 release.
2016-01-06 11:30:02 +00:00
Richard W.M. Jones
acde5a6f95 Finalize release notes for libguestfs 1.32. 2016-01-06 11:18:35 +00:00
Richard W.M. Jones
07d1baebae Update PO files from Zanata. 2016-01-06 11:13:27 +00:00
Richard W.M. Jones
1007b2555c daemon: Fix ext2 labels error message (RHBZ#1294956). 2016-01-04 15:33:45 +00:00
Richard W.M. Jones
307c83177c Update copyright dates for 2016.
Run the following command over the source:

  perl -pi.bak -e 's/(20[01][0-9])-2015/$1-2016/g' `git ls-files`
2016-01-02 21:19:51 +00:00
Richard W.M. Jones
9958dffc08 builder: Update Fedora 23 ppc64le image which was broken.
This updates commit d92758d8bb.
2015-12-19 21:30:50 +00:00
Richard W.M. Jones
d92758d8bb builder: Add Fedora 23 ppc64/ppc64le images. 2015-12-19 13:32:25 +00:00
Richard W.M. Jones
eed0e7a2e0 builder: Fix Fedora ppc64/ppc64le build scripts to use correct version. 2015-12-19 09:57:36 +00:00
Pino Toscano
d7753a8eb9 tests: add a couple of iSCSI-related test cases 2015-12-18 17:10:25 +01:00
Pino Toscano
079984a8b8 drives: allow authentication for iSCSI
Now that both the direct and libvirt backends handle authentication with
iSCSI correctly, we can allow this in the library.
2015-12-18 11:17:23 +01:00
Pino Toscano
b2598ce890 launch: direct: manually compose iscsi:// URIs
Move the creation of iscsi URIs away from make_uri, composing them
manually: this is needed because libxml assumes colons (':') to separate
user and password for the authority part, while with iscsi URIs the
separator is percentage ('%'), which would be percent-encoded by libxml.
2015-12-18 11:17:23 +01:00
Richard W.M. Jones
7ecad8d4f7 daemon: Improve debug information from command*.
Do some fake quoting so people don't get worried that we aren't
quoting the commands we run.  See:
https://www.redhat.com/archives/libguestfs/2015-December/msg00080.html
2015-12-17 11:27:04 +00:00
Richard W.M. Jones
6d90cf5eb2 daemon: Make command*f flags parameter unsigned.
It's a bitmask, so unsigned is the right choice.  eg. We can more
easily print it using %x.

This patch changes the size of the fd mask and the values of the
COMMAND_FLAG_* constants, but since these are internal definitions
that doesn't matter.
2015-12-17 11:15:14 +00:00
Richard W.M. Jones
346a8aa303 Version 1.31.30. 2015-12-16 13:27:16 +00:00
Richard W.M. Jones
8e5a431a59 po: Add pt_BR to list of linguas.
Commit e6f7d23782 added new po files for
pt_BR to po/ and po-docs/ (they are only very minimal).  However they
were not added to the list of linguas, so amongst other things the
files were not included in EXTRA_DIST automatically.
2015-12-16 13:27:16 +00:00
Richard W.M. Jones
cbe698b9c9 po: Fix two faults in the uk.po file.
./uk.po:1049: 'msgid' and 'msgstr' entries do not both end with '\n'
./uk.po:9638: format specifications in 'msgid' and 'msgstr' for argument 2 are not the same

This updates commit e6f7d23782.
2015-12-16 13:27:08 +00:00
Richard W.M. Jones
adfe577ee9 hacking: index.html.in is now stored in git under website/ directory. 2015-12-16 12:44:51 +00:00
Richard W.M. Jones
e44de65ec9 builder: Add CentOS 7.2 image. 2015-12-15 18:40:36 +00:00
Richard W.M. Jones
e69e9c1ece builder: website: Update comment in centos.sh script. 2015-12-15 18:20:17 +00:00
Richard W.M. Jones
43e0d25f8d fish: tests: Don't open phony fedora.img for write in parallel.
Two tests opened the phony Fedora image in parallel without the
readonly flag.  This occasionally resulted in strange errors
(especially observed in test-inspect.sh).  Add the --readonly flag to
avoid this.
2015-12-15 17:01:44 +00:00
Richard W.M. Jones
8ec4ebb952 Update release notes. 2015-12-15 16:49:30 +00:00
Richard W.M. Jones
7e8ff29710 Update gnulib to latest. 2015-12-15 16:31:50 +00:00
Richard W.M. Jones
e6f7d23782 Add latest translations pulled from Zanata. 2015-12-15 16:31:50 +00:00
Richard W.M. Jones
ddd9d479cc Update translations and send to Zanata. 2015-12-15 16:31:41 +00:00
Richard W.M. Jones
5c02ad3375 Update BUGS. 2015-12-15 16:31:34 +00:00
Pino Toscano
9c3b4f6ad8 daemon: improve internal commandrvf
- add a flag to request chroot for the process, which is done only as
  very last (before chdir) operation before exec'ing the process in the
  child: this avoids using CHROOT_IN & CHROOT_OUT around command*
  invocations, and reduces the code spent in chroot mode
- add failure checks for dup2, open, and chdir done in child, not
  proceeding to executing the process if they fail
- open /dev/null without O_CLOEXEC, so it stays available for the
  exec'ed process, and thus we don't need to provide an own fd for stdin

Followup of commit fd2f175ee7, thanks also
to the notes and hints provided by Mateusz Guzik.
2015-12-15 15:00:11 +01:00
Richard W.M. Jones
6c6c3ea675 build: Disable -Wstack-protector warning.
Fires with gcc 5.3.1 (on Fedora 23).  It's a completely useless
warning since it just tells you that a function couldn't use the stack
protector.
2015-12-14 22:38:52 +00:00
Kashyap Chamarthy
b314f6700a guestfs.pod: Update reference to libguestfs internals 2015-12-14 21:23:20 +00:00
Richard W.M. Jones
cc717138a9 customize: Capitalize the first character in --sm-credentials help text.
Prior to this commit:

$ virt-builder --help
[...]
  --sm-attach SELECTOR         Attach to a subscription-manager pool
  --sm-credentials SELECTOR    credentials for subscription-manager
  --sm-register                Register using subscription-manager

Really the generator ought to check this.
2015-12-11 15:51:21 +00:00
Pino Toscano
4be1587b33 inspect: recognize the PLD Linux distribution
Just basic identification, with name and version read from
/etc/os-release.
2015-12-10 14:06:14 +01:00
Richard W.M. Jones
545fc84775 perl: Add missing backslash in CLEANFILES rule.
This fixes commit a2edda266e.

Thanks: Jean-Christophe Manciot.
2015-12-06 16:24:32 +00:00
Richard W.M. Jones
f48361ed04 Version 1.31.29. 2015-12-05 23:45:07 +00:00
Richard W.M. Jones
0339b3d7a5 builder: Add Fedora 23 i686 image (RHBZ#1288733).
This includes the DNF fix, see
commit 59ea51d358.
2015-12-05 23:41:25 +00:00
Pino Toscano
a090a48f44 builder: create temporary images in the cachedir (RHBZ#1288201)
Temporary images can be quite big, more than the space available in
$TMPDIR when it's on a tmpfs; hence, place them in our cachedir
instead.
2015-12-04 11:06:35 +01:00
Richard W.M. Jones
5c7c4666e4 resize: Add a regression test for RHBZ#1285847. 2015-12-02 16:18:14 +00:00
Richard W.M. Jones
b3bc670c71 resize: Work around regression in sfdisk (RHBZ#1285847).
'sfdisk --part-type' used to merely set the MBR ID byte in the
partition.  However since sfdisk was rewritten, it now "helpfully"
corrupts the first sector of the partition if you change the type byte
from an ordinary partition to an extended partition.

So we need to change the order in which we sets the partition type
byte, to do it before copying the partition content.

This fixes a major regression in the way that virt-resize handles any
guest with logical partitions (specifically Ubuntu guests).
2015-12-02 16:18:14 +00:00
Richard W.M. Jones
8eb9ad0fb2 POTFILES: Escape dot in regular expression. 2015-12-02 16:18:14 +00:00
Richard W.M. Jones
59ea51d358 builder: Rebuild Fedora 23 image with new DNF (RHBZ#1280029, RHBZ#1278382).
We also need to add a small hack to the build script to ensure the
latest dnf is really included.
2015-12-01 13:03:31 +00:00
Richard W.M. Jones
4085acc67f builder: pxzcat: If write fails, display correct error message.
If uncompressing a template to a filesystem which is nearly full,
virt-builder displays an error which points to the wrong (source) file:

$ virt-builder fedora-22
[   1.2] Downloading: http://libguestfs.org/download/builder/fedora-22.xz
[   1.7] Planning how to build this image
[   1.7] Uncompressing
/home/rjones/.cache/virt-builder/fedora-22.x86_64.1: No space left on device
/home/rjones/.cache/virt-builder/fedora-22.x86_64.1: No space left on device
/home/rjones/.cache/virt-builder/fedora-22.x86_64.1: No space left on device
/home/rjones/.cache/virt-builder/fedora-22.x86_64.1: No space left on device

(The error message is usually printed once by each thread, so it is
printed several times.)

Change the error message to point to the output file, which might be a
temporary or the final file depending on the build plan:

$ virt-builder fedora-22
[   1.1] Downloading: http://libguestfs.org/download/builder/fedora-22.xz
[   1.6] Planning how to build this image
[   1.6] Uncompressing
fedora-22.img: No space left on device
fedora-22.img: No space left on device
fedora-22.img: No space left on device
fedora-22.img: No space left on device
2015-11-27 09:08:07 +00:00
Richard W.M. Jones
8120c6c903 Version 1.31.28. 2015-11-24 22:59:36 +00:00
Richard W.M. Jones
2ee2003d56 daemon: Allow --channel fd:N
In this case, the daemon has been passed an open file descriptor which
it uses directly for the channel.
2015-11-24 19:13:39 +00:00
Richard W.M. Jones
49ad09bae3 launch: direct: aarch64: Add gic-version=host to -M option.
On ARM machines with vGICv3, we need to use the extra -M
parameter gic-version=3 (or gic-version=2 for the old vGIC).

qemu can detect this feature for us if we pass gic-version=host,
so add that to the -M option.  Unfortunately we cannot detect if
qemu itself supports this parameter, but this change only affects
aarch64.

Thanks: Wei Huang
2015-11-24 18:39:52 +00:00
Richard W.M. Jones
6e15468337 builder: rhel: Fix path in rhel-aarch64.sh. 2015-11-24 15:41:56 +00:00
Pino Toscano
51362c9638 fuse: fix return value of guestunmount for unmounted paths
Exit with 3 as return value when fusermount fails, because the specified
mount point is not considered mounted for the user.  This is in line
with what the guestunmount documentation says.

Adapt the test-guestunmount-fd test to the updated return value.

Thanks to: Maxim Perevedentsev.
2015-11-24 16:28:06 +01:00
Richard W.M. Jones
e49680bdd6 fish: ps_restore is only used when HAVE_LIBREADLINE is defined.
Thanks: Keresztes Péter-Zoltán
2015-11-24 11:14:37 +00:00
Pino Toscano
fd2f175ee7 daemon: always provide stdin when running chroot commands (RHBZ#1280029)
When running commands in the mounted guest (using the "command" API, and
APIs based on it), provide the /dev/null from the appliance as open fd
for stdin.  Commands usually assume stdin is open if they didn't close
it explicitly, so this should avoid crashes or misbehavings due to that.
2015-11-20 14:55:46 +01:00
Pino Toscano
0799ac4bf4 build: disable -Winline
Older GCC versions (e.g. < 4.9) may complain about inline functions that
cannot be inlined (growing the generated code). It is not really a
problem for us, so just suppress again the warning.

Followup of commit c37c554fc5.
2015-11-20 14:54:20 +01:00
Richard W.M. Jones
37e145140b v2v: Add full stop after multi-line error message. 2015-11-20 10:27:53 +00:00
Richard W.M. Jones
6faa0bb331 v2v: Clean up the documentation for virt-v2v-copy-to-local.
Don't duplicate the instructions in two different man pages.
Put the conversion steps into virt-v2v(1) only.

This updates commit 87adc30163.
2015-11-20 09:53:35 +00:00
Richard W.M. Jones
0721b8d7f3 v2v: Fix valgrind of virt-v2v-copy-to-local.
This fixes commit 87adc30163.
2015-11-20 08:22:01 +00:00
Richard W.M. Jones
b193908514 build: Add virt-v2v-copy-to-local to installcheck.
This updates commit 87adc30163.
2015-11-19 22:53:18 +00:00
Richard W.M. Jones
9fbb956b14 Version 1.31.27. 2015-11-19 22:51:17 +00:00
Richard W.M. Jones
87adc30163 v2v: Add a new tool virt-v2v-copy-to-local.
This allows certain guests which virt-v2v cannot access to be copied
off the remote hypervisor and converted.  Essentially this just
automates the process of copying the guest's disks and adjusting the
libvirt XML.

This also adds a test of the new tool.
2015-11-19 21:51:42 +00:00
Richard W.M. Jones
05a80e6088 v2v: xml: Add a binding for XmlUnsetProp. 2015-11-19 19:17:41 +00:00
Richard W.M. Jones
7a9edee22c v2v: vcenter: Split out map_source_to_https from map_source_to_uri.
Split the map_source_to_uri function up so that we can get at just the
https://... URI.

This is almost refactoring.  It doesn't quite handle the case where we
are passed a source path from the libvirt VMware driver that doesn't
match the expected "[datastore] path" format, but probably if we hit
that case it's a bug anyway.
2015-11-19 17:20:55 +00:00
Richard W.M. Jones
2ea771e4f8 v2v: Detect conversions where the source disk has zero size (RHBZ#1283588).
If you try to convert a guest that has a zero-sized disk, it
will currently fail in a rather strange way.  Usually you will
see errors in the debug output:

  [    0.562714] sd 2:0:0:0: [sda] Read Capacity(16) failed: Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE
  [    0.563884] sd 2:0:0:0: [sda] Sense Key : Not Ready [current]
  [    0.564587] sd 2:0:0:0: [sda] Add. Sense: Logical unit not ready, manual intervention required

followed by virt-v2v failing with:

  libguestfs: trace: v2v: inspect_os = []
  virt-v2v: error: inspection could not detect the source guest (or physical
  machine).

Additionally, because of a problem with the ssh driver in qemu (or
perhaps, with sftp-server on the remote side) it is not possible to
use the ssh driver to open a block device path on the remote server.
The drive will appear as zero-sized, triggering the above error.

Therefore detect this situation, and emit an error (see below).  Also
add a section to the manual describing the workaround required for
converting RHEL 5 Xen guests which are located on block devices.

  virt-v2v: error: guest disk sda appears to be zero bytes in size.

  There could be several reasons for this:

  Check that the guest doesn't really have a zero-sized disk.  virt-v2v
  cannot convert such a guest.

  If you are converting a guest from an ssh source and the guest has a disk
  on a block device (eg. on a host partition or host LVM LV), then
  conversions of this type are not supported.  See "XEN OR SSH CONVERSIONS
  FROM BLOCK DEVICES" in the virt-v2v(1) manual for a workaround.
2015-11-19 13:56:37 +00:00
Richard W.M. Jones
9c85bbbc42 p2v: Cancel conversion if user closes the running dialog.
If the user tries to close the running dialog during a running
conversion, act as if the cancel button was pressed (cancelling the
conversion).

If the conversion has finished/been cancelled, then this closes the
dialog and exits virt-p2v, as now.

Cancelling the conversion in this way ensures that qemu-nbd and ssh
subprocesses are cleaned up.
2015-11-16 22:38:01 +00:00
Richard W.M. Jones
046a625846 p2v: Add a conversion_is_running() function.
This thread-safe function can be used to determine if the conversion
is running (maybe in another thread).
2015-11-16 22:33:59 +00:00
Richard W.M. Jones
62b8a09b36 p2v: Make cancel_conversion() properly thread safe.
Rename 'stop' variable as cancel_requested, and defend it with a
mutex.
2015-11-16 22:33:59 +00:00
Richard W.M. Jones
05d08b8d19 p2v: Tidy up in man page. 2015-11-16 21:47:36 +00:00
Richard W.M. Jones
7406c76bcf p2v: Send physical server 'dmesg' output to debug dir on conversion server.
If the virt-p2v ISO doesn't contain the correct drivers for the
hardware on the physical server, that can cause peculiar conversion
problems.  This was hard to diagnose because we could not see the
'dmesg' output from the physical server.

Upload 'dmesg' output from the physical server (more precisely: from
the virt-p2v ISO's kernel running on the physical server) to the
virt-v2v conversion server debugging directory, so that this
information is available for debugging later.

Unfortunately this involves yet another copy of the 'read_whole_file'
function.
2015-11-16 21:47:36 +00:00
Richard W.M. Jones
399e031c25 v2v: OVF: Use common generated_by string.
Instead of creating a special 'Exported by ...' string just for this
module, use the Common_utils.generated_by string.  Since the string is
just descriptive, this should make no difference.
2015-11-15 22:43:06 +00:00
Richard W.M. Jones
ab37d92ab9 v2v: Move mpstat struct into Types module.
Strangely the Types module already defined mpstat, but it was not used
and redefined in v2v.ml.  Apart from that, this change is just
refactoring.
2015-11-15 22:18:36 +00:00
Richard W.M. Jones
fa1f770498 v2v: windows: Fix a few comments. 2015-11-15 21:54:06 +00:00
Richard W.M. Jones
d2ea61bd1c v2v: Add comment. 2015-11-15 21:54:06 +00:00
Richard W.M. Jones
f3e6b3565c v2v: Move the get_node function to the Windows module.
Just refactoring - however this does make the function safer by having
it return an option type instead of throwing a [Not_found] exception.
2015-11-15 21:54:06 +00:00
Richard W.M. Jones
9ad4ce77b6 v2v: Refactor some uses of Windows.with_hive.
This changes:

  let f root = .. in
  Windows.with_hive ... f

to:

  Windows.with_hive ... ( fun root -> .. )

No functional change, just refactoring.
2015-11-15 21:54:06 +00:00
Richard W.M. Jones
40701b715c v2v: Move the with_hive function to the Windows module.
Just refactoring.
2015-11-15 21:33:32 +00:00
Richard W.M. Jones
8cb6600eee Version 1.31.26. 2015-11-13 19:14:43 +00:00
Richard W.M. Jones
9dc4717bb9 build: Remove ChangeLog from make distclean.
Adding this causes 'make dist' to fail with:

  make[1]: *** No rule to make target 'ChangeLog', needed by 'distdir'.  Stop.

This updates commit a2edda266e.
2015-11-13 19:10:35 +00:00
Richard W.M. Jones
c2d216d166 inspection: Fix detection of the kernel version of Windows ≥ 10 (RHBZ#1281578).
See the description in the bug report:

https://bugzilla.redhat.com/show_bug.cgi?id=1281578

Thanks: Richard Tollerton for alerting me to this change in the way
that Windows version numbers are stored in the Registry starting with
Windows ≥ 10.
2015-11-13 14:24:27 +00:00
Richard W.M. Jones
b91b39e06a daemon: lvm: Change the separator character to ':'.
The separator character (currently comma) was picked arbitrarily to
allow us to parse the output of commands like 'lvs' for APIs such as
'lvs-full'.  Unfortunately the choice of comma conflicts with the 'lvs
-o modules' column, since the list of modules is separated by commas,
breaking our parser.

Change the separator to another arbitrary character (colon) which
hopefully is not used by any column.

See also:
https://bugzilla.redhat.com/show_bug.cgi?id=1278878#c11
2015-11-13 11:53:12 +00:00
Richard W.M. Jones
fccd4ee5e8 daemon: lvm: Only return public LVs from guestfs_lvs API (RHBZ#1278878).
When a disk image uses LVM thinp (thin provisioning), the guestfs_lvs
API would return the thinp pools.  This confused other APIs because
thinp pools don't have corresponding /dev/VG/LV device nodes.

Filter the LVs that are returned using "lv_role=public".

Thanks: Fabian Deutsch
2015-11-13 11:53:12 +00:00
Richard W.M. Jones
c37c554fc5 build: Enable some more warnings.
After fixing some warnings (see prior commits), we can now enable
them in configure.ac.
2015-11-13 11:53:12 +00:00
Richard W.M. Jones
52e517c570 Avoid "function 'asprintf_nowarn' can never be inlined because it uses variable argument lists".
Move this to a separate translation unit and don't inline it.
2015-11-13 11:53:12 +00:00
Richard W.M. Jones
120b658ccc Avoid various "declaration of <var> shadows a previous local"
I enabled the -Wshadow warning temporarily in order to do these fixes,
but had to disable it again afterwards.  The reason is that this warns
about shadowing globals, which is sort of a good thing, but because we
have a global called "verbose" just about everywhere, and at the same
time we baked a function argument called "verbose" into several
unchangable APIs, well, we're stuck without being able to use this
warning.
2015-11-13 11:53:12 +00:00
Richard W.M. Jones
4dc53f0fba Avoid gcc warnings about infinite loop.
This seemingly redundant change avoids a gcc warning/error:

  error: cannot optimize possibly infinite loops

See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=34114#c3 and
following for an explanation.

Of course gcc is completely wrong and stupid here, because there's no
possibility on current or future hardware that an array of size
SSIZE_MAX could be allocated since it would by definition occupy at
least all addressible memory (if it was an array of bytes, which this
isn't), leaving no room for the code that is being compiled.
2015-11-13 11:53:12 +00:00
Richard W.M. Jones
573c0a26fb gobject: Ignore gobject/docs/guestfs-scan.c.
I'm not sure what/why this file has suddenly appeared.  It may
be something to do with updating gtk-doc.

Whatever - ignore it.
2015-11-13 11:53:12 +00:00
Richard W.M. Jones
4e32737c40 sparsify: Make the interface between cmdline.ml and sparsify.ml explicit.
We could go a bit further here and push the cmdline struct
into Copying.run and In_place.run.
2015-11-13 11:53:12 +00:00
Richard W.M. Jones
995ce5f648 dib: Turn a few progress messages into info messages. 2015-11-13 11:53:12 +00:00
Richard W.M. Jones
f8287387c2 dib: Make the interface between cmdline.ml and dib.ml explicit. 2015-11-13 11:53:12 +00:00
Richard W.M. Jones
a4c981e7bb builder: Make the interface between cmdline.ml and builder.ml explicit. 2015-11-13 11:53:12 +00:00
Richard W.M. Jones
6f38aff262 inspector: --xpath: Copy node to new document (RHBZ#1281577).
'virt-inspector --xpath' can segfault.

When run under valgrind, it shows this error:

==2254== Invalid free() / delete / delete[] / realloc()
==2254==    at 0x4C29D6A: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==2254==    by 0x53BA198: xmlFreeNodeList (tree.c:3690)
==2254==    by 0x53B9F65: xmlFreeDoc (tree.c:1247)
==2254==    by 0x405BFA: do_xpath (inspector.c:808)
==2254==    by 0x405BFA: main (inspector.c:250)
==2254==  Address 0x1030a037 is 311 bytes inside a block of size 1,048 alloc'd
==2254==    at 0x4C28C50: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==2254==    by 0x545DE86: xmlDictAddString.isra.0 (dict.c:270)
==2254==    by 0x545E961: xmlDictLookup (dict.c:923)
==2254==    by 0x539C6DC: xmlDetectSAX2 (parser.c:1067)
==2254==    by 0x53B0B92: xmlParseDocument (parser.c:10725)
==2254==    by 0x53B1276: xmlDoRead (parser.c:15295)
==2254==    by 0x40587D: do_xpath (inspector.c:772)
==2254==    by 0x40587D: main (inspector.c:250)

The cause appears to be that when copying the matching node(s) found
by the xpath expression, we have to copy them into the new document
(using xmlDocCopyNode instead of xmlCopyNode).

This bug has existed since this functionality was originally added in
commit d1ee71782a.
2015-11-13 11:53:12 +00:00
Richard W.M. Jones
ab48601afd inspector: Whitespace changes.
Just break up a few long source lines.
2015-11-12 22:42:45 +00:00
Richard W.M. Jones
7747723aa0 builder: Add Fedora 23 aarch64 image. 2015-11-12 18:12:04 +00:00
Richard W.M. Jones
c15b877310 builder: fedora-aarch64.sh: Switch to using Gerd's edk2. 2015-11-12 16:41:36 +00:00
Richard W.M. Jones
be1b9315ac customize, dib, resize, sysprep: Use 'may' pattern in various places. 2015-11-11 16:12:36 +00:00
Richard W.M. Jones
905d98c127 mllib, v2v: Allow open_guestfs to set the handle identifier.
Extend open_guestfs to take an optional ?identifier parameter.

Use this parameter in virt-v2v which is currently the only place where
we use the handle identifier.
2015-11-11 16:12:35 +00:00
Richard W.M. Jones
b91286c372 v2v: Use the 'may' pattern in the Changeuid module. 2015-11-11 16:12:35 +00:00
Richard W.M. Jones
9307087bb5 builder: Use the 'may' pattern in a few places. 2015-11-11 16:12:35 +00:00
Richard W.M. Jones
9a2c5b7c4d mllib: Add Common_utils 'may' function.
This higher order function encapsulates the following pattern:

  match x with
  | None -> ()
  | Some x -> f x

(replaced with: `may f x`)

This is taken from OCaml lablgtk (Gtk bindings) where this pattern is
used frequently.

See also: https://ocaml.org/learn/tutorials/labels.html
2015-11-11 16:12:35 +00:00
Richard W.M. Jones
c09be9334b v2v: Make the interface between cmdline.ml and v2v.ml explicit. 2015-11-11 14:53:18 +00:00
Richard W.M. Jones
6d46eb33bf v2v: Add --compressed option to produce compressed qcow2 files (RHBZ#1279273). 2015-11-10 13:40:34 +00:00
Pino Toscano
4cc98d8f6e OCaml tools: use open_guestfs everywhere
Instead of creating Guestfs handles and manually apply common options
(e.g. debug and trace), use the open_guestfs in Common_utils.
This also applies the common options to handles which didn't set them
before, so we can inspect also their messages if needed.
2015-11-10 11:38:40 +01:00
Pino Toscano
a7f3f48dd1 customize: allow editing symlinked files
Resolve also symlinks when checking whether a path passed to --edit is a
file: the file editing code supports symlinks anyway (properly changes
the target file, instead of overwrite the symlink with a real file), so
it is safe to allow this operation in customize/builder.
2015-11-09 18:33:52 +01:00
Pino Toscano
6e41fc5a7f customize: check for file existence with --edit (RHBZ#1275806)
Check that a path provided to --edit exists already; while the is_file
call later will fail for non-existing files, with an explicit check a
better error message can be provided.
2015-11-09 18:26:05 +01:00
Pino Toscano
78db05a05c v2v: test-v2v-i-ova-two-disks.sh: fix sha1 filename
Run sha1sum on the compressed filename (with .gz extension, after the
gzip run), and reference that file in the .mf file.
2015-11-09 16:42:32 +01:00
Pino Toscano
39a8e12d90 lib: do not manually include libvirt.h in .c files
guestfs-internal.h includes it already, so rely on that.
2015-11-09 11:38:49 +01:00
Pino Toscano
3b54869dad lib: enable the libvirt code consistently everywhere
With commit bc2b417784
HAVE_LIBVIRT_BACKEND is defined based on the libvirt version (using its
version macro), although libvirt.h is included only after that check:
because of this, variables in the guestfs_h struct after the
HAVE_LIBVIRT_BACKEND block would be used wrongly if libvirt.h was not
included before guestfs-internal.h, like in the recently added
available.c (all the other places using libvirt features in the handle
already happened to do so).

Considering guestfs-internal.h already includes libvirt.h, move its
inclusion up, right before the libvirt version check.
2015-11-09 11:29:49 +01:00
Richard W.M. Jones
cbeb127a5d todo: Remove virt-p2v --inject-ssh-identity as it has been implemented. 2015-11-08 20:36:47 +00:00
Richard W.M. Jones
3bf676be92 lib: find_or_cache_feature function can return a const pointer.
This updates commit 38598e2ba5.
2015-11-06 22:24:39 +00:00
Richard W.M. Jones
2497b4921e lib: Fix whitespace in src/available.c
This updates commit 38598e2ba5.
2015-11-06 21:38:28 +00:00
Richard W.M. Jones
dc9d14ebd3 Version 1.31.25. 2015-11-06 17:30:53 +00:00
Pino Toscano
7b74d05758 tests: rhbz1232192.sh: fix VIRT_TOOLS_DATA_DIR
Followup of commit f933a3c9c7.
2015-11-06 17:13:34 +01:00
Pino Toscano
af3511c7a9 tests: replace run-xml-to-junit.* with automake2junit.ml
Replace the custom XSLT + script to turn output from $RUN_OUTPUT_FILE
(from previous run.in versions) with a OCaml script to analyze .trs and
.log files of the automake test framework.

The final result should be the same, just with classname= for each test
set to the "path" (subdirectories) to that test.
2015-11-06 16:14:22 +01:00
Pino Toscano
18c730e7f6 build: use a custom test driver
Use a custom test driver for running the tests: based on the test-driver
provided by automake, it adds the running time of the test in each .trs
file.
2015-11-06 16:11:55 +01:00
Richard W.M. Jones
c0a781ed9a build: Drop serial_tests.
Use (implicitly) parallel tests on new enough automake.  The tests run
a bit quicker with this change.  On my laptop, I measured 27 mins down
to 18 mins.

Change the ./run function so that ./run --test no longer spools the
test output to a file.  That is not necessary when using parallel
tests, since the test harness does the same thing.

Note: This commit removes the $RUN_OUTPUT_FILE functionality.  We will
change the CI integration in a future commit so it uses the .trs and
.log files.
2015-11-06 16:11:44 +01:00
Richard W.M. Jones
7964e48b5e inspect: windows: Fail hard if we cannot detect Windows architecture (RHBZ#1278371).
The user did not have the 'file' command installed, and when they
attempted to do a v2v conversion of a Windows guest, inspection
succeeded, but the Types.i_arch field was found to contain "unknown".
virt-v2v conversion failed to locate the correct virtio drivers as a
result.

The 'file' command is required, and there's no other reason we should
not be able to detect the architecture of any Windows guest, so fail
hard in this situation.
2015-11-06 12:16:30 +00:00
Richard W.M. Jones
32368f25f1 generator: Another minor indentation fix in src/actions-*.c files. 2015-11-06 12:09:53 +00:00
Richard W.M. Jones
22c97bcb3f v2v: tests: No QXL drivers on the ISO.
There are no QXL drivers on the ISO, so don't expect the QXL driver to
be installed.

This fixes commit 8c735a84c7.
2015-11-06 09:41:47 +00:00
Richard W.M. Jones
c5237e28c5 test-data: Copy DriverVer from real *.inf files to fake *.inf files.
We want to test if virt-v2v can find drivers using the *.inf files.
For this to work, one field is important:

  [Version]
  DriverVer = 07/17/2013,6.1.0.10018

Copy the [Version] section header and DriverVer field from the real
*.inf files to our fake *.inf files, which is enough for testing.

See also:
https://www.redhat.com/archives/libguestfs/2015-October/msg00352.html

Note that the fields are case insensitive and may or may not contain
spaces.
2015-11-05 16:23:10 +00:00
Richard W.M. Jones
8c735a84c7 test-data: Make fake virtio-win ISO.
The virtio-win ISO has a different layout and superset of drivers
compared to the virtio-win RPM directory.  Previously we simply put
all the RPM files into the fake ISO.  Instead create a fake ISO which
has the same layout and (fake) drivers as the real ISO.
2015-11-05 16:23:10 +00:00
Richard W.M. Jones
b99a57a631 test-data: Add further (all fake) virtio-win driver files. 2015-11-05 16:23:10 +00:00
Richard W.M. Jones
f933a3c9c7 v2v: Move fake-virtio-win and fake-virt-tools under test-data.
There is no change, this just moves the test files.
2015-11-05 16:23:10 +00:00
Pino Toscano
38598e2ba5 actions: refactor available & feature_available
Refactor the internal_feature_available to return the result for just
one group, so it is easier to know on the library side what was the
actual error, and which group refers to; drop internal_available, as no
more needed after this.

On the library side, implement in available and feature_available the
real logic to iterate through the requested group, and error out or
return whether the groups are available. This also introduces caching
for the features, so each needs to be queried just once in each
appliance run.

The result of this is that there should be much less communication with
the daemon to know about available features; the downside is that
queries for more than one group at once, not already cached, will be
cause more queries to the daemon.
2015-11-05 16:48:58 +01:00
Pino Toscano
2e79edb4a3 actions: turn available & feature_available as non-daemon
Rename the current available and feature_available into internal daemon
functions, and provide non-daemon functions wrapping them at library
side.  This will make it possible to e.g. add caching for them.

Should be only refactoring, no actual behaviour change.
2015-11-05 16:48:58 +01:00
Richard W.M. Jones
18fbdaaf14 v2v: Improve the error when virt-v2v is run on a blank disk.
The error messages changes from:

  $ virt-v2v -i disk /tmp/blank.img -o null
  [...]
  [  14.6] Inspecting the overlay
  virt-v2v: error: no root device found in this operating system image.

to:

  $ virt-v2v -i disk /tmp/blank.img -o null
  [...]
  [  15.2] Inspecting the overlay
  virt-v2v: error: inspection could not detect the source guest (or physical
  machine).

  Assuming that you are running virt-v2v/virt-p2v on a source which is
  supported (and not, for example, a blank disk), then this should not
  happen.  You should run 'virt-v2v -v -x ... >& log' and attach the complete
  log to a new bug report (see http://libguestfs.org).

  No root device found in this operating system image.
2015-11-05 14:01:10 +00:00
Richard W.M. Jones
b20d36aa1b tests: Change more conflicting temporary output file names.
Various tests cannot be run in parallel just because they happen to
use conflicting names for temporary output files (eg. "test.out").

Change these tests to use unique temporary names, so the tests could
be run in parallel.
2015-11-05 13:48:38 +00:00
Richard W.M. Jones
8a72616bf7 test-data: phony-guests: Don't use *.tmp.* temporary files. 2015-11-05 13:46:05 +00:00
Richard W.M. Jones
458d7c09b7 v2v: Check if i_type, i_distro or i_arch contains "unknown".
That indicates that inspection failed, so we should error out early.
2015-11-05 13:46:05 +00:00
Richard W.M. Jones
fff2797578 v2v: vCenter: Document additional permission needed for conversions (RHBZ#1277274).
This updates commit 4e24338625.

Thanks: Alessandro on https://bugzilla.redhat.com/show_bug.cgi?id=1277274#c6
2015-11-05 09:03:56 +00:00
Pino Toscano
b933b17a2a actions: set features for vfs_minimum_size tests
Limit the scope of two tests of vfs_minimum_size to the features they
require (btrfs and xfs).
2015-11-05 09:46:36 +01:00
Richard W.M. Jones
c12c7d0df0 Version 1.31.24. 2015-11-04 17:45:28 +00:00
Richard W.M. Jones
8e3920a334 sparsify: Let --in-place capture ^C and shut down gracefully (RHBZ#1277122).
When virt-sparsify receives a user quit signal (eg from ^C) it
currently kills virt-sparsify and qemu instantly, meaning any mount +
fstrim in progress is uncleanly stopped.  The (minor) side effect of
this is that the guest filesystem may require a journal replay or fsck
on boot.

Let virt-sparsify capture the user quit signal and shut down
gracefully.

It is not thought that the previous behaviour could cause guest
corruption; see
https://lists.nongnu.org/archive/html/qemu-devel/2015-11/threads.html#00402
for discussion.
2015-11-04 16:24:04 +00:00
Richard W.M. Jones
4e24338625 v2v: vCenter: Document the minimum set of permissions needed for conversions (RHBZ#1277274).
Thanks: Alessandro on https://bugzilla.redhat.com/show_bug.cgi?id=1277274#c2
2015-11-04 16:24:04 +00:00
Pino Toscano
9d8ffd966a lib: include few more headers
- include <sys/un.h> for sockaddr_un, on any OS (removing the Mac OS X
  blocks)
- include <fcntl.h> for O_* flags

This commits reverts a couple of changes in these files done in
commit 3b17152ec3.
2015-11-04 14:52:29 +01:00
Pino Toscano
a13e95783d Revert "launch: add missing headers on Darwin"
This reverts commit 3ce4e95c5a.
2015-11-04 14:50:58 +01:00
Richard W.M. Jones
226848762b builder: Add fedora-23 image. 2015-11-04 13:06:11 +00:00
Margaret Lewicka
3ce4e95c5a launch: add missing headers on Darwin
Including sys/un.h for sockaddr_un and sys/fcntl.h for
O_CLOEXEC/O_NONBLOCK.
2015-11-04 12:22:28 +00:00
Richard W.M. Jones
0c879fcd15 sparsify: Don't mark virt-sparsify --in-place as "experimental".
Thanks: Gil Klein.
2015-11-04 09:47:52 +00:00
Richard W.M. Jones
9f70d71d4a builder: Document using 'qemu-img amend' for RHEL 6 compat (RHBZ#1204131). 2015-11-03 21:14:40 +00:00
Richard W.M. Jones
a2edda266e build: Make 'make clean' remove more files.
Remove man pages and other pages which 'make clean' did not remove
before.

To evaluate which pages could be removed, I did a full build and
check, and then ran 'make clean' followed by 'git clean -xdf'.  By
examining the output of the git clean command I could see which files
were being missed.

Files that are _not_ removed by make clean or make distclean:

 - generator-built files

 - Makefile, Makefile.in, .deps, .depend

 - any ./configure output files (maybe they should be?)
2015-11-03 13:53:37 +00:00
Richard W.M. Jones
6221d54445 build: Remove unused intltool-* files.
None of these files have been touched since the initial intltoolize
command (commit 29204fe10d, May 2009).
2015-11-03 12:14:10 +00:00
Richard W.M. Jones
c192d99c09 p2v: Don't present the vdsm output driver to the user (RHBZ#1277074).
Thanks: Ming Xie.
2015-11-02 23:31:32 +00:00
Richard W.M. Jones
f45c4619f5 tests: Remove fuzz testing of inspection.
It's a nice idea, but has never actually found a problem.  After using
afl to find bugs in qemu-img, it's pretty clear to me that no
successful approach could be run in the short time demanded by the
libguestfs test suite.  Afl tests run for days, weeks or even months.

A better approach may be to use a proven fuzz tester (such as afl) on
the inspection code; or to run this code for days on end on a separate
testing machine.

This reverts commit c2dcd10964.
2015-10-31 23:09:51 +00:00
Richard W.M. Jones
2c62de52b7 df: Close parenthesis in comment. 2015-10-31 22:53:14 +00:00
Richard W.M. Jones
88c506767a build: Make 'make clean' remove a few backup files. 2015-10-31 22:08:06 +00:00
Richard W.M. Jones
6190226671 website: Add guestfs-hacking, guestfs-internals, guestfs-security to website.
Also move guestfs-performance to the right place on the website.

This updates commit 2eb01004bf
and commit d07515b947
and commit 74fba6e692
and commit 15b8b6453d.
2015-10-31 17:09:29 +00:00
Richard W.M. Jones
47b095b928 website: Put website into a separate directory.
Move the random set of HTML files we build from html/ into
the website/ directory.

Also in the website/ directory, put the index.html file from
http://libguestfs.org, which was previously not under version control.
It is generated from index.html.in so we can automatically add the
current version and release date.

Also in the website/ directory, put various CSS file, images, etc.
which are required by the website and were also previously not under
version control.

Change the 'make website' rule to 'make maintainer-upload-website'.
As the name suggests, it is only useful for the maintainer, and will
fail with an error for anyone else.
2015-10-31 17:09:29 +00:00
Richard W.M. Jones
de819d17e4 Version 1.31.23. 2015-10-31 11:08:14 +00:00
Richard W.M. Jones
7dcfc9eb03 docs: Minor fix to description of 'test-data' subdirectory.
Fixes commit dc1d0880b0.
2015-10-30 23:02:54 +00:00
Richard W.M. Jones
2eb01004bf website: Copy guestfs-hacking, guestfs-internals, guestfs-security to website.
Make sure the three new man pages are copied over to the website.

This updates commit d07515b947
and commit 74fba6e692
and commit 15b8b6453d.
2015-10-30 22:49:50 +00:00
Richard W.M. Jones
877c69bef7 build: Reorder build sequence.
When I conceived commit dc1d0880b0, I
thought it would be a good idea to build test-data files, including
the phony guest images, during the 'make' phase.  Previously these
were built early in the 'make check' phase.

However this has two disadvantages: (a) We run the appliance
unnecessarily during builds.  For example, it is not necessary to
build the phony guests if we are going to do an 'installcheck'.
(b) Even if we are testing, the critical first time we run the
appliance is not in 'quickcheck' or 'tests/qemu', but some random
guest build.

Reorder the build sequence to fix this, and also a few other things.

This updates commit dc1d0880b0.
2015-10-30 22:06:18 +00:00
Richard W.M. Jones
dd5f5ffb48 test-data: Remove bogus comment.
The way we now build the blank guest images is safe to be run in
parallel.
2015-10-30 21:39:54 +00:00
Richard W.M. Jones
cd6f7f6ee0 tests/regressions: Fix rhbz1174551.sh so it works when debugging is enabled.
This test failed during release testing.  It turned out to be because
the tests are run with LIBGUESTFS_DEBUG=1 LIBGUESTFS_TRACE=1 which
causes other messages to be printed.

Updates commit b5a6f899cd.
2015-10-30 18:51:30 +00:00
Richard W.M. Jones
c078486041 Version 1.31.22. 2015-10-30 16:28:28 +00:00
Richard W.M. Jones
dc1d0880b0 tests: Move the tests/data and tests/guests directories to test-data.
Create a new top-level directory called test-data, which will carry
all the test data which is large and/or shared between multiple tests.

There are actually several new subdirectories created:

test-data/binaries: The pre-built binary and library files for random
architectures that we use to test various architecture detection
features (was part of tests/data).

test-data/blank-disks: The blank disks which are used for disk format
detection (was part of tests/data).

test-data/files: Other miscellaneous test files from tests/data that
are not included in the above.

test-data/phony-guests: The phony guests (was tests/guests).

test-data: The top-level directory builds the 'test.iso' image file
that is used for testing the C API and in miscellaneous other tests.
2015-10-30 16:07:32 +00:00
Richard W.M. Jones
7efde6589c tests/regressions: Display errors in rhbz1174551.sh.
Updates commit b5a6f899cd.
2015-10-30 15:09:37 +00:00
Richard W.M. Jones
93214205cc Version 1.31.21. 2015-10-30 10:52:30 +00:00
Richard W.M. Jones
6b2ff3377c v2v: windows: Create Windows module, and move functions around.
Create a Windows module, analogous to the Linux module we already
have.  Move utility functions related to Windows into this module.

In particular:

 - detect_antivirus function moves here, and the Detect_antivirus
   module goes away entirely

 - copy_virtio_drivers / virtio_iso_path_matches_guest_os moves here,
   and the virtio_iso_path_matches_guest_os can now be hidden

This is just refactoring, but allows us to make deeper changes to
copy_virtio_drivers.
2015-10-30 10:32:43 +00:00
Richard W.M. Jones
b00a2151ab v2v: utils: Refactor xpath_* functions.
No change, just refactoring.
2015-10-30 09:45:02 +00:00
Richard W.M. Jones
bd65e346d8 v2v: utils: Add a utils.mli file defining the interface. 2015-10-30 09:45:02 +00:00
Richard W.M. Jones
6a688c5119 v2v: utils: Remove unused function compare_app2_version_min. 2015-10-30 09:45:02 +00:00
Richard W.M. Jones
e9bd10897d v2v: utils: Comment fix. 2015-10-30 09:45:02 +00:00
Richard W.M. Jones
7f19420cfe v2v: utils: Move three utility functions to where they are used.
The three utility functions xml_quote_attr, xml_quote_pcdata and
uri_escape were only used in a single module.  Move them close to
where they are used.

This is just code refactoring.
2015-10-30 09:45:02 +00:00
Richard W.M. Jones
e7f8c064cf v2v: utils: Don't open Types module. 2015-10-30 09:45:02 +00:00
Richard W.M. Jones
0dffbb7d94 v2v: Move the open_guestfs function into Common_utils.
Removes the somewhat ugly inclusion of this function in Types.  Also
means we can use this function elsewhere.
2015-10-30 09:45:02 +00:00
Richard W.M. Jones
63952d9666 ocaml: Rename Config module as Guestfs_config.
Unfortunately Coccinelle places a Config module in the ocaml libdir,
and this confuses ocamlfind (only when Coccinelle is installed).
Since this is a private module that only libguestfs tools use
internally, just rename it from Config -> Guestfs_config.
2015-10-30 09:45:02 +00:00
Richard W.M. Jones
f4783fcc0d docs: Group guestfs(3) 'SEE ALSO' into sections. 2015-10-30 09:45:02 +00:00
Richard W.M. Jones
15b8b6453d docs: Move security documentation to guestfs-security(1). 2015-10-30 09:45:02 +00:00
Richard W.M. Jones
74fba6e692 docs: Move architecture and internals documentation to guestfs-internals(1). 2015-10-30 09:45:02 +00:00
Richard W.M. Jones
d07515b947 docs: Move 'extending libguestfs' documentation to guestfs-hacking(1).
Start to split the huge, monolithic guestfs(3) manual page.
2015-10-30 09:45:02 +00:00
Richard W.M. Jones
a87218c271 configure: Move FUSE checks to separate file.
This is moved earlier because it's now part of the C library.
2015-10-30 09:45:02 +00:00
Richard W.M. Jones
cdcd1e7c98 configure: Move misc. library checks to separate file. 2015-10-30 09:45:02 +00:00
Richard W.M. Jones
34304f5e3d configure: Move appliance checks to separate file. 2015-10-30 09:45:02 +00:00
Richard W.M. Jones
dfa9dee775 configure: Move daemon checks to separate file. 2015-10-30 09:45:02 +00:00
Richard W.M. Jones
56884b6543 configure: Move C library checks to separate file. 2015-10-30 09:45:02 +00:00
Richard W.M. Jones
4a67b4be93 configure: Move basic C compiler environment checks to separate file.
Also gnulib stuff.
2015-10-30 09:45:02 +00:00
Richard W.M. Jones
1d73d93130 configure: Move detection of external programs to a separate file.
Do this early since these tests generally don't depend on anything
else (the external program is either there or its not), and because
other things depend on some of these tests.
2015-10-30 09:45:02 +00:00
Richard W.M. Jones
671525bfdd configure: Move qemu detection to separate file. 2015-10-30 09:45:01 +00:00
Richard W.M. Jones
7adf7e26de configure: Move bash completion detection to separate file. 2015-10-30 09:45:01 +00:00
Richard W.M. Jones
3683b5f57f configure: Move Perl program / man page detection into m4/guestfs_perl.m4. 2015-10-30 09:45:01 +00:00
Richard W.M. Jones
51811c80a1 configure: Move (old, Perl) tools detection into m4/guestfs_perl.m4. 2015-10-30 09:45:01 +00:00
Richard W.M. Jones
21d41daec0 configure: Move language binding detection to separate files.
The extra files don't have to be added to EXTRA_DIST, as it appears
that autotools already knows that it has to add them.
2015-10-30 09:45:01 +00:00
Richard W.M. Jones
db5ebecd8a Revert "resize: add function find_partitions"
This reverts commit 5aa7e99cb9.
2015-10-30 09:45:01 +00:00
Richard W.M. Jones
3258695162 Revert "resize: add function calculate_target_partitions"
This reverts commit 21677c5b46.
2015-10-30 09:45:01 +00:00
Richard W.M. Jones
8ad069c402 Revert "resize: add function mbr_part_type"
This reverts commit fc34e2d16c.
2015-10-30 09:45:01 +00:00
Richard W.M. Jones
b1a7903fd1 Revert "resize: add p_mbr_p_type as member of type partition"
This reverts commit 6e989fd709.
2015-10-30 09:45:01 +00:00
Richard W.M. Jones
20ae8bd9ec v2v: windows: Don't do NTFS heads fix if i_root is not a partition (RHBZ#1276540).
The error was:

libguestfs: trace: pread_device = "NTFS    "
libguestfs: trace: part_to_dev "/dev/sda"
guestfsd: main_loop: new request, len 0x34
guestfsd: error: device name is not a partition
guestfsd: main_loop: proc 272 (part_to_dev) took 0.00 seconds
libguestfs: trace: part_to_dev = NULL (error)
virt-v2v: error: libguestfs error: part_to_dev: device name is not a
partition
2015-10-30 08:51:52 +00:00
Richard W.M. Jones
25fee09a44 builder: Add Debian 7 sparc64 image. 2015-10-27 18:18:50 +00:00
Maxim Perevedentsev
f5caa421d1 Added xfs support to vfs_minimum_size. 2015-10-27 17:25:49 +00:00
Pino Toscano
a4da3f74c9 builder: run virt-resize with --unknown-filesystems=error
This way, we can make sure that if a template needs to be expanded, the
result will have all the filesystems correctly expanded, fitting into
the new sizes of their partitions.
2015-10-27 17:49:57 +01:00
Pino Toscano
4f97f6866c resize: add --unknown-filesystems
Introduce a new option to control how virt-resize behaves when asking to
expand a filesystem, either unknown to libguestfs or that virt-resize
cannot expand. The default keeps the current behaviour, i.e. just warn.
2015-10-27 17:49:57 +01:00
Maxim Perevedentsev
858a9de297 Added btrfs support to vfs_minimum_size. 2015-10-27 14:58:42 +00:00
Pino Toscano
3734d76f1a build: look for Module::Build instead of ExtUtils::MakeMaker
Module::Build is now used for building the Perl bindings, so look for it
instead of the old module.

Followup of commit f98e0f115b.
2015-10-26 13:08:58 +01:00
Richard W.M. Jones
638761e6df Version 1.31.20. 2015-10-25 17:07:01 +00:00
Richard W.M. Jones
31c42e9c11 perl: Fix location of generator_build Guestfs.xs.
Also add MANIFEST to EXTRA_DIST.

This fixes commit f98e0f115b.
2015-10-25 17:06:06 +00:00
Richard W.M. Jones
f98e0f115b perl: Switch to using Module::Build.
Replace ExtUtils::MakeMaker with Module::Build.

'perllocal.pod' and 'bindtests.pl' are no longer incorrectly
installed.

This change also removes the following phony deps: appliance src_deps
test_images.  No other language binding needs explicit dependencies
for their tests, they just rely on the top level build order being
correct (ie. SUBDIRS in /Makefile.am).
2015-10-24 12:36:28 +01:00
Richard W.M. Jones
1c506aa960 ocaml: Allow 'make install' to be run twice.
'ocamlfind install' doesn't like to install the same package if it is
already installed.  It will give errors like:

  ocamlfind: Package guestfs is already installed

or:

  ocamlfind: Conflict with file: /usr/lib64/ocaml/guestfs/mlguestfs.cmxa

Fix this by removing the old installed files before running
'ocamlfind install'.  An alternative would be to use
'ocamlfind uninstall', but this seems more direct.
2015-10-24 12:36:28 +01:00
Richard W.M. Jones
905a9c54e6 builder: Allow 'make install' to be run twice.
The error is:

ln -s xdg/virt-builder /tmp/p/etc/virt-builder
ln: failed to create symbolic link '/etc/virt-builder/virt-builder': File exists

There is no 'LN_SF' macro, but according to the documentation at
least, it should be safe to add a '-f' flag since it will work for
both the 'ln' and 'cp' variants of the macro.
2015-10-24 12:36:18 +01:00
Maxim Perevedentsev
474f6525c8 Bugfix in number parsing in vfs_min_size. 2015-10-23 10:05:09 +01:00
Pino Toscano
a1b7540b78 v2v: -o libvirt: dump XML for libvirt if verbose
When running in verbose mode, dump the XML we created for libvirt:
this way it is easier to debug mismatches between what we want to setup
in libvirt, and what actually gets defined.
2015-10-22 14:39:03 +02:00
Pino Toscano
f56031d549 v2v: -o libvirt: fix <video> element (RHBZ#1225789)
Create the correct tags for <video> in the libvirtxml, so all the
attributes are in a <model> child of <video> instead of <video> itself.

Adapt the XML of test-v2v-i-ova to the different expected XML.
2015-10-22 14:10:16 +02:00
Pino Toscano
d8f248ffb4 po-docs: generate virt-dib and virt-get-kernel docs 2015-10-22 11:20:35 +02:00
Pino Toscano
0f04263000 build: isolate common po-docs logic
Move most of the content of either po-docs/ja/Makefile.am or
po-docs/uk/Makefile.am to po-docs/language.mk, and use it exclusively
instead of the former contents of the languange-specific Makefile.am.
This way, either adding a new documentation or enabling a new language
will not require copying over the same make code.
2015-10-22 11:13:48 +02:00
Pino Toscano
8d8fa9cf4a v2v: fix identifier
Set the "virtio_win" identifier to the right Guestfs handle.

Fixes commit f7249a0bcc.
2015-10-21 18:03:46 +02:00
Pino Toscano
6aea0e21ad v2v: use open_guestfs everywhere
Use the common open_guestfs to open Guestfs handles, so we get
debugging, tracing, and other common options set.
2015-10-21 18:03:46 +02:00
Pino Toscano
8a9d056163 v2v: move open_guestfs to Types
Move most of open_guestfs to Types, so a common function to open a
Guestfs handle is available.  Since it does not do all the things the
old open_guestfs did, the two operations have been moved to the only
place requiring them.

This function has been placed in Types and not Utils, as will be needed
by other functions in Types; Utils uses Types, so this avoids a circular
dependency.
2015-10-21 18:03:46 +02:00
Richard W.M. Jones
9ecfd8a94f p2v: Set the virt-p2v ISO timeout to 60 seconds (not 6 seconds).
Thanks: Dennis Gilmore.
2015-10-21 15:46:08 +01:00
Richard W.M. Jones
34d1b2678b p2v: Add dracut-live to the kickstart (RHBZ#1168223).
Thanks: Dennis Gilmore for working out what was missing.
2015-10-21 15:21:11 +01:00
Pino Toscano
b5a6f899cd actions: turn some params into FilenameList (RHBZ#1174551).
Use FilenameList as type for lists of file names, as used in some
listing-alike APIs.  This way we can ensure anything different than just
file names in those lists is rejected outright.

As a consequence, test-big-dirs.pl does not need to prepend the
directory name anymore before calling listing-alike APIs: previously
they didn't fail, but the returned lists contained only invalid
elements (and only their size was checked).

Furthermore, add a new regression test for it.
2015-10-21 13:00:18 +02:00
Pino Toscano
7c10cda266 generator: add a FilenameList parameter type
Mostly like StringList (so it can used in current StringList
parameters), but checking client- and daemon-side that the elements are
file names.
2015-10-21 13:00:18 +02:00
Pino Toscano
64cb0f5dad tests: use fake-virt-tools also in tests outside v2v
We have phony tools for v2v tests, introduced with
commit c1af1ba32f126b7be275bcc8cd4ea4e5af27a88e; make use of it also in
tests related to v2v outside the v2v directory.
2015-10-21 13:00:18 +02:00
Richard W.M. Jones
2b50bad568 docs: Move guestfs-release-notes(1) to docs/ subdirectory.
I have also removed the text equivalent of this file.  Originally I
added this because it was thought good to have the release notes
available in a format that doesn't require any special tools to read.
But:

 - POD files are basically text.

 - Debian tooling generates the text file in a slightly different way
   from Fedora tooling, resulting in git marking the file as being
   updated when it isn't really.

 - github can format and display POD files.
2015-10-21 11:26:16 +01:00
Richard W.M. Jones
6219e61cba Move miscellaneous documentation from examples/ to docs/.
Wasn't very logical putting these doc files in the examples directory.
2015-10-21 11:17:14 +01:00
Richard W.M. Jones
eb36df827b guestfs-performance: Add a note about Xen dom0. 2015-10-21 10:36:07 +01:00
Richard W.M. Jones
0294b1f9b2 guestfs-performance: Use lowercase in =head2 sections.
Makes it easier to read.
2015-10-21 10:35:03 +01:00
Richard W.M. Jones
a86a7d0f07 Version 1.31.19. 2015-10-20 23:53:21 +01:00
Maxim Perevedentsev
8296933ade Include resize2fs_P into vfs_minimum_size. 2015-10-20 18:26:22 +01:00
Maxim Perevedentsev
b8d4ca686b New API: vfs_minimum_size
This call provides the way to get minimum size of filesystem.
This is needed for shrinking. The return units are bytes.
2015-10-20 18:26:22 +01:00
Roman Kagan
e9b32e1bad v2v: add test for --in-place
Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
2015-10-20 18:26:22 +01:00
Roman Kagan
3c3873bc9a v2v: document --in-place
Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
2015-10-20 18:26:22 +01:00
Roman Kagan
d0069559a9 v2v: add --in-place mode
In this mode, converting of the VM configuration, setting up the
rollback path for error cases, transforming the VM storage and so on is
taken care of by a third-party toolset, and virt-v2v is only supposed to
tune up the guest OS directly inside the source VM, to enable it to boot
and run under the input hypervisor.

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
2015-10-20 18:26:22 +01:00
Pino Toscano
fe62f4727f Add a regression test for RHBZ#1011907 / RHBZ#1165785
Test case adapted from Hu Zhang's RHBZ#1242853, thanks.
2015-10-20 18:02:23 +02:00
Richard W.M. Jones
44889b7d53 Version 1.31.18. 2015-10-20 16:56:00 +01:00
Roman Kagan
fa40934aad v2v: factor out opening and populating guestfs handle
Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
2015-10-20 15:17:27 +01:00
Roman Kagan
7ad0c1eee9 v2v: factor out preserving overlays for debugging
Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
2015-10-20 15:17:27 +01:00
Roman Kagan
5c1e068e60 v2v: factor out copying of output data
Factor out copying the overlays to final disk images into a separate
function.

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
2015-10-20 15:17:27 +01:00
Roman Kagan
48345d0d83 v2v: factor out determining the guest firmware
Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
2015-10-20 15:17:27 +01:00
Roman Kagan
030c6fb63e v2v: factor out actual guest transformation
Factor out perfoming the actual convertion of the guest, which includes
determinig the appropriate guest os specific conversion module and
running its conversion routine.

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
2015-10-20 15:17:27 +01:00
Roman Kagan
5dae9ca23d v2v: factor out size checks
Factor the size checks out to separate functions.

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
2015-10-20 15:17:27 +01:00
Roman Kagan
a61f148186 v2v: factor out populating targets list
Besides, it doesn't need guestfs handle open so move this step earlier
in the process.

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
2015-10-20 14:45:41 +01:00
Roman Kagan
d59a43aa65 v2v: factor out overlay creation
Iterating over source disks and creating temporary overlays for easy
rollback fits nicely into a separate function.  In addition, determining
their size doesn't need to wait until the guestfs is launched: the size
can be obtained via disk_virtual_size() method.

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
2015-10-20 14:45:41 +01:00
Roman Kagan
3ca8c04273 v2v: factor out opening input VM
Opening the source VM and amending the properties in its internal
representation in accordance with command-line options fit nicely into
two isolated functions.

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
2015-10-20 14:45:41 +01:00
Richard W.M. Jones
754a43142c inspect: Include more information for augeas parse errors (RHBZ#1229119)
If Augeas fails to parse a file, more information is available in at
least these fields:

><fs> aug-ls /augeas/files/etc/fstab/error
/augeas/files/etc/fstab/error/char
/augeas/files/etc/fstab/error/lens
/augeas/files/etc/fstab/error/line
/augeas/files/etc/fstab/error/message
/augeas/files/etc/fstab/error/pos

Pull out some of these fields and add them to the error message.
The new error message looks like this:

  virt-v2v: error: libguestfs error: /etc/fstab:17:4: augeas parse failure:
  Iterated lens matched less than it should

This updates commit 279addeb7d.
2015-10-16 10:22:00 +01:00
Richard W.M. Jones
bc2b417784 lib: Define HAVE_LIBVIRT_BACKEND where you have too old libvirt to run the backend.
In the case where libvirt was installed, but is too old to run the
backend, the libvirt backend would be compiled out but still
referenced by the library.

Fix this by splitting the definition of HAVE_LIBVIRT (libvirt is
installed at all) and HAVE_LIBVIRT_BACKEND (libvirt is new enough to
run the libvirt backend).

Reported by: Efstratios Skleparis.
2015-10-16 10:01:36 +01:00
Pino Toscano
279addeb7d inspect: check for errors in files parsed with augeas (RHBZ#1229119)
During the inspection phase, check for errors after aug_load: if any of
the errors happened in any of the requested files, then report the error
straight away; ignoring the error means that information would be
silently lost.  For example, a malformed /etc/fstab would have caused
the inspection to not handle any of the additional mount points, giving
cryptic errors later on when trying to access files in any of the mount
points.

Now guests with invalid files such as /etc/fstab, /etc/mdadm.conf, and
/etc/sysconfig/network will cause the inspection to fail, instead of
being reported with a single mount point ('/').
2015-10-15 18:14:49 +02:00
Pino Toscano
45bb7c8bcb mllib: move is_regular_file there
Move the is_regular_file function, implemented in virt-dib and virt-v2v,
to Common_utils.
2015-10-15 16:24:25 +02:00
Richard W.M. Jones
42c60abfbd v2v: Curry Changeuid.func. 2015-10-15 14:38:29 +01:00
Richard W.M. Jones
01ede002db v2v: Rename Kvmuid module to Changeuid.
It has nothing to do with KVM.
2015-10-15 14:32:30 +01:00
Richard W.M. Jones
2587db8f18 Version 1.31.17. 2015-10-15 14:24:10 +01:00
Richard W.M. Jones
b50f341576 v2v: Add unit test for virtio_iso_path_matches_guest_os. 2015-10-15 13:23:29 +01:00
Richard W.M. Jones
6b02513bb2 v2v: Rename match_vio_path_with_os -> virtio_iso_path_matches_guest_os.
Just refactoring.  Having the function name begin with 'match' was a
bit confusing because it can look similar to a match statement.
2015-10-15 12:25:04 +01:00
Richard W.M. Jones
2cb86bc4dc lib: Add comment and regression test for case where main process has large heap.
Thanks: Dan Berrangé for identifying the problem.
2015-10-15 11:04:48 +01:00
Richard W.M. Jones
25bde98cb1 lib: info: Move common code for setting child rlimits.
This is almost just refactoring, but I also set the memory
limit to really 1 GB, and not 1×10⁹.
2015-10-15 11:04:48 +01:00
Roman Kagan
169bc884a5 v2v: drop useless forced gc
Now that virtio driver copying is localized in a single function and the
auxiliary guestfs handle doesn't leak outside of it (and thus an extra
qemu instance doesn't survive beyond that function's runtime) there's no
need in the forced GC which used to trigger closing of that handle and
termination of that qemu instance.

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
2015-10-15 11:04:48 +01:00
Roman Kagan
f7249a0bcc v2v: copy virtio drivers without guestfs handle leak
Refactor copying of virtio windows drivers into the guest so that the
matching of the drivers to the guest os flavor and copying the files
happens one next to the other in a single function, and no guestfs
handle (nor any other irrelevant info) is leaked outside.

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
2015-10-15 11:04:48 +01:00
Roman Kagan
4ff0bfc336 v2v: consolidate virtio-win file copying
Copy the appropriate driver files from the virtio-win storage into
%SYSTEMROOT%\Drivers\VirtIO once they are discovered, and stick to using
those copies later on.

This way the knowledge of where the drivers come from originally is
consolidated in one place, so the lifetime of the associated entities
becomes easier to control (to be implemented in followup patches).

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
2015-10-15 11:04:48 +01:00
Maxim Perevedentsev
a5e7823c92 New API: resize2fs_P
Added support for getting ext2/3/4 filesystem minimum size.
This is needed primarily for shrinking images.
2015-10-14 17:11:54 +01:00
Richard W.M. Jones
3bf70226f6 v2v: test harness: Suggest using make check -k. 2015-10-14 14:45:48 +01:00
Richard W.M. Jones
b486ae1631 v2v: test harness: Use I<> quoting around command line parameter. 2015-10-14 14:45:29 +01:00
Pino Toscano
753bf99f5c builder: fix conversion of double to OCaml (RHBZ#1270011).
Create the OCaml value for double using caml_copy_double, which is
the correct way, simplier, and works.
2015-10-12 16:38:50 +02:00
Richard W.M. Jones
1f23a2c3a9 Version 1.31.16. 2015-10-09 17:55:19 +01:00
Richard W.M. Jones
9090408ea1 v2v: -i libvirt: Fix comment. 2015-10-09 17:46:36 +01:00
Richard W.M. Jones
5cdff50d8a v2v: Refactor the map_source_to_uri function.
Move this function to the VCenter module.  This is easier since it
doesn't have to do dcPath calculation (see previous commit).

The readhead parameter is no longer labelled.
2015-10-09 13:21:07 +01:00
Richard W.M. Jones
ffea9f9792 v2v: Use libvirt-supplied <vmware:datacenterpath> if available.
In libvirt >= 1.2.20, the VMware libvirt driver supplies the correct
dcPath to use via <vmware:datacenterpath> in the libvirt XML.  If
libvirt passes us this element, use it.

This code still allows the user to override dcPath using the --dcPath
option on the command line, but that's mainly for safety so we can fix
any problems in virt-v2v or libvirt in the field.  As we get more
confident in libvirt and as libvirt 1.2.20 is more widely adopted, we
will be able to deprecate this parameter entirely.

Thanks: Matthias Bolte for adding the <vmware:datacenterpath> element
to libvirt in
https://libvirt.org/git/?p=libvirt.git;a=commit;h=636a99058758a0447482f3baad94de8de3ab1151
2015-10-09 13:21:07 +01:00
Richard W.M. Jones
a8c725071d v2v: Move VCenter functions to library module.
This refactors useful VCenter functions out of the large
'input_libvirt_vcenter_https.ml' file.
2015-10-09 13:21:07 +01:00
Richard W.M. Jones
d4431886c7 v2v: Move curl functions to library module.
This refactors the curl functions used to talk to vCenter into a
library module.
2015-10-09 13:21:07 +01:00
Richard W.M. Jones
6fb4428358 v2v: Fix bogus comment. 2015-10-09 13:21:07 +01:00
Richard W.M. Jones
6334261497 inspect: Don't free uninitialized string.
libguestfs: trace: v2v: read_lines "/etc/os-release"
[...]
libguestfs: trace: v2v: read_lines = ["NAME=Fedora", "VERSION="20 (Heisenbug)"", "ID=fedora", "VERSION_ID=20", "PRETTY_NAME="Fedora 20 (Heisenbug)"", "ANSI_COLOR="0;34"", "CPE_NAME="cpe:/o:fedoraproject:fedora:20"", "HOME_URL="https://fedoraproject.org/"", "BUG_REPORT_URL="https://bugzilla.redhat.com/"", "REDHAT_BUGZILLA_PRODUCT="Fedora"", "REDHAT_BUGZILLA_PRODUCT_VERSION=20", "REDHAT_SUPPORT_PRODUCT="Fedora"", "REDHAT_SUPPORT_PRODUCT_VERSION=20"]

At this point libguestfs segfaulted.

It seems as if 'major' is not used here, so don't try to free it.

This fixes commit 32d19e3289.
2015-10-09 12:35:06 +01:00
Richard W.M. Jones
4f9899dd01 Version 1.31.15. 2015-10-08 22:05:19 +01:00
Richard W.M. Jones
48ae2d1dd1 handle: Free g->identifier on close.
This fixes commit f6e13aeb65.
2015-10-08 21:49:37 +01:00
Richard W.M. Jones
108c8173fa v2v: Add xpath_int64 functions, and use them to read memory values.
On 32 bit platforms, reading the memory values can cause some numbers
to be read as negative numbers.  Fix this by treating memory values as
64 bit integers throughout the parsing and calculation.
2015-10-08 20:14:04 +01:00
Richard W.M. Jones
37360159bf Version 1.31.14. 2015-10-08 19:51:43 +01:00
Richard W.M. Jones
e5fd9b54dd test/qemu: Fix free/close of log file.
The log file was not being closed at the right time, resulting in the
process running out of open files.  Also the log filename buffer was
not freed.

This fixes commit 7bbf5cab28.
2015-10-08 17:04:05 +01:00
Richard W.M. Jones
bd0b52d08e v2v: Use handle identifier in a few places.
Set the handle identifier of the main handle to "v2v".

Whenever we open a second handle for any substantial operation, set
the handle identifier for that handle too.

This should make traces clearer.
2015-10-08 16:52:43 +01:00
Roman Kagan
a94019f52f v2v: add test for v2v with virtio-win drivers on iso
For that, add autofoo machinery to generate the iso out of the fake
virtio-win drivers introduced in the previous patches, and pass the
resulting image in $VIRTIO_WIN to v2v in a new test otherwise similar to
test-v2v-windows-conversion.sh.

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
2015-10-08 16:37:19 +01:00
Roman Kagan
3c26dbf309 v2v:tests: use fake virtio-win drivers
In order to test the copying of virtio-win drivers into the guest during
v2v, create a set of fake virtio-win drivers and make use of them in the
corresponding v2v tests.

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
2015-10-08 16:37:18 +01:00
Richard W.M. Jones
7bbf5cab28 tests/qemu: Add qemu-boot --log option.
This option can be used to direct output from each individual
boot test to a different file.  Usual usage is:

  qemu-boot --log /tmp/output.% -v -x -n 1000
2015-10-08 16:35:25 +01:00
Richard W.M. Jones
f291411f76 Add the thread identifier to various multi-threaded programs and tests. 2015-10-08 16:35:24 +01:00
Richard W.M. Jones
f6e13aeb65 New APIs: set-identifier, get-identifier
Add a per-handle identifier.  The main effect of this is to change
trace output from:

  libguestfs: trace: foo

to:

  libguestfs: trace: ID: foo

which makes it simpler to follow traces from multi-threaded programs.
2015-10-08 16:35:24 +01:00
Roman Kagan
5f352f6eea v2v:test:win: actually check the eventual layout
v2v/test-v2v-windows-conversion.sh used to query if the expected
directories and files were present in the VM upon conversion; however it
would ignore the results of that query.

That lead to the test passing even though the checks failed.

To fix it, parse the output of guestfish and verify that all is-file and
is-dir commands report the expected "true".

The approach taken is slightly more elaborate than what is being used in
other components, but it allows to generate comprehensible reports in
case of test failure, and facilitates future expansion of the set of
checks including negative ones.

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
2015-10-08 16:34:48 +01:00
Roman Kagan
2fabb89fee v2v: add fake rhev-apt.exe
Without rhev-apt.exe the code path where firstboot scripts are created
isn't taken, so it isn't tested and v2v/test-v2v-windows-conversion.sh
is supposed to fail (it actually doesn't but for another reason,
addressed in a followup patch).

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
2015-10-08 16:34:48 +01:00
Roman Kagan
c1af1ba32f v2v:tests: use fake rhsrvany.exe
The tests that depend on rhsrvany.exe being available, actually don't
need it to be the real one: all they want is the file being present.

So, instead of skipping the tests if the real rhsrvany.exe is not found,
store a fake one in the repository, and point $VIRT_TOOLS_DATA_DIR at
its location.

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
2015-10-08 16:34:48 +01:00
Pino Toscano
0f414edd11 build: use libintl where needed
Followup of commit a5426cce5f.
2015-10-08 16:31:54 +02:00
Pino Toscano
4d3466af68 fuse: test-fuse: close files even on errors
Make sure to close the open files even when test_fuse() returns earlier
because of failures, otherwise the mountpoint is still in use by open
files when later guestunmount is called on it.
2015-10-08 13:34:03 +02:00
Richard W.M. Jones
411e8e30e7 v2v: Skip test-v2v-o-libvirt.sh on !x86_64. 2015-10-07 17:26:22 +01:00
Richard W.M. Jones
95fe361215 Version 1.31.13. 2015-10-07 14:24:37 +01:00
Richard W.M. Jones
b1f11ef75b ocaml/examples: Fix use of event_callback in debug_logging.ml.
This fixes commit 8bbc5e73cb.
2015-10-07 14:16:00 +01:00
Richard W.M. Jones
a332e23dde ocaml/examples: Remove all programs in 'make clean'.
Previously the debug_logging program was not being deleted.
2015-10-07 14:15:05 +01:00
Richard W.M. Jones
9c97cc720b Version 1.31.12. 2015-10-07 14:02:56 +01:00
Richard W.M. Jones
63d1a8050a configure: Check that OCaml version >= 3.11. 2015-10-07 13:25:32 +01:00
Richard W.M. Jones
585a7e1f3e ocaml: Add regression test for failure of implicit close. 2015-10-06 22:28:54 +01:00
Richard W.M. Jones
8bbc5e73cb ocaml: Allow Guestfs.t handle to be garbage collected.
** NB: This is an API break for OCaml programs using Guestfs.event_callback. **

Because of the way I implemented Guestfs.event_callback which had the
Guestfs.t handle as the first parameter, we had to store the (OCaml)
Guestfs.t handle in the C handle's private data area.  To do that, we
had to create a global root pointing to the handle.

This of course meant that the handle could not be garbage collected
(thanks Roman Kagan for spotting this).

This changes the API of Guestfs.event_callback so that a handle is no
longer passed.  The OCaml handle can now be garbage collected again.

For programs that need the Guestfs.t handle in the callback function
(which turns out to be *none* of the OCaml programs we have written),
you can do:

  g#set_event_callback (callback_fn g) [Guestfs.EVENT_FOO];

In this case, since the closure passed to Guestfs.set_event_callback
is still registered as a global root, that will capture a reference to
the handle, so the handle won't be able to be garbage collected until
you delete the callback.
2015-10-06 22:28:27 +01:00
Richard W.M. Jones
3858db9d58 ocaml: Use generational global roots.
These are considerably more efficient than ordinary global roots, but
with the caveat that the program is not allowed to modify them without
calling a special function.  We don't modify them, so this change is
safe.

This requires OCaml >= 3.11, but we have that on RHEL 6
(since we dropped support for RHEL 5).

See also:
http://caml.inria.fr/pub/ml-archives/caml-list/2008/03/c3bf86990088236ceeb9a0f0f4c35390.en.html
2015-10-06 15:53:31 +01:00
Richard W.M. Jones
0944acf90c mllib: Replace various ad hoc string_* functions with String.*
This is just a straight refactoring.  Various ad hoc string_*
functions that appeared in Common_utils have been renamed and placed
in the String.* namespace.  The old vs "new" functions are:

string_prefix  -> String.is_prefix
string_suffix  -> String.is_suffix
string_find    -> String.find
replace_str    -> String.replace
string_nsplit  -> String.nsplit
string_split   -> String.split
string_lines_split -> String.lines_split
string_random8 -> String.random8
2015-10-06 13:40:34 +01:00
Richard W.M. Jones
47892b580b mllib: Hide unsafe lower/uppercase functions.
The ones in the OCaml stdlib assume ISO-8859-1 bytes and strings, and
so can end up corrupting UTF-8 strings.
2015-10-06 12:50:36 +01:00
Richard W.M. Jones
932e5ad089 mllib: Add (Char|String).(lower|upper)case_ascii functions.
These functions come from upstream OCaml (4.03) where they were
written by Gabriel Scherer under a compatible license.

See also:
http://caml.inria.fr/mantis/view.php?id=6694
http://caml.inria.fr/mantis/view.php?id=6695
2015-10-06 12:49:47 +01:00
Richard W.M. Jones
672920f3e9 mllib: Override Char and String modules from stdlib.
In Common_utils, override the Char and String modules from stdlib.
This hides the original (stdlib) modules, and means that whenever you
use Char.foo or String.foo you are in fact calling the
Common_utils.Char.foo or Common_utils.String.foo function.

As it stands, this change does nothing, but it will allow us to drop
unsafe functions (like String.lowercase) and add extra functions.
2015-10-06 12:34:30 +01:00
Richard W.M. Jones
7d7a1aeeac mllib: Don't alias G = Guestfs in Common_utils module. 2015-10-06 12:23:21 +01:00
Richard W.M. Jones
bdedb47cf0 tests: Don't leave a libguestfs tmpdir lying around after running test-launch-race.pl.
Calling _exit(2) in the child process has the side effect that
tmp/libguestfsXXXXXX is not cleaned up.  Clean it up by ensuring the
handle is properly closed before _exit.
2015-10-06 11:47:08 +01:00
Richard W.M. Jones
3b56001583 tests: Fix test-launch-race.
This test has been broken for a while.  It is meant to test that when
the appliance cachedir is empty, two simultaneous runs of libguestfs
(both rebuilding the full appliance) will not cause conflicts, because
(eg) the locking in either supermin or libguestfs is not working.

However the test only set $TMPDIR, but the ./run script sets
$LIBGUESTFS_CACHEDIR which overrides $TMPDIR, so it was simply reusing
the existing appliance, and hence not testing anything.

Fix this by clearing $LIBGUESTFS_CACHEDIR.

Note the test now takes a lot longer to run since it does a full
appliance rebuild.
2015-10-06 11:44:48 +01:00
Richard W.M. Jones
cab3d5d2f6 builder: Remove duplicate planner transition.
Seems to be a copy and paste bug in
commit 62cc7d3361.
2015-10-06 11:22:21 +01:00
Richard W.M. Jones
540ce6a4e5 clean: Remove null.* and sockets from builddir tmp/ subdirectory. 2015-10-05 22:00:13 +01:00
Richard W.M. Jones
fe4630e033 Update translations from Zanata.
However I reverted the Catalan file since it did not appear to be
newer than the version provided in
commit 6404114515.
2015-10-05 20:39:31 +01:00
Richard W.M. Jones
dd1dbc5191 Version 1.31.11. 2015-10-05 17:13:18 +01:00
Pino Toscano
7c1bb1b40c p2v: fix mode for gtk_label_set_line_wrap_mode
Accoding to its documentation [1], it takes as second parameter a
PangoWrapMode and not a GtkWrapMode.  While the change should reflect
the actual value intended, it should slightly change the label wrap
mode: GTK_WRAP_WORD is 2, which corresponds (as int value) to
PANGO_WRAP_WORD_CHAR.

[1] https://developer.gnome.org/gtk2/stable/GtkLabel.html#gtk-label-set-line-wrap-mode
2015-10-05 15:43:35 +02:00
Pino Toscano
29e6368f4c daemon: use str_udevadm in udev_settle
There is GUESTFSD_EXT_CMD defining a string for udevadm (so it is marked
as "used tool" in the appliance), but it is not actually used when
starting udevadm.

There should be no behaviour change.
2015-10-05 15:43:35 +02:00
Pino Toscano
d98c9c0e0b Fix shebang in perl scripts
Instead of hardcoding the location of perl (assuming it is installed in
/usr), use /usr/bin/env to run it, and thus picking it from $PATH.
This makes it possible to run these scripts also on installations with
perl in a different prefix than /usr.

Also, given that we want enable warnings on scripts, turn the -w
previously in shebang to explicit "use warnings;" in scripts which
didn't have it before.
2015-10-05 15:43:35 +02:00
Pino Toscano
1e0cbe6681 lib: include <sys/socket.h> for accept4
Apparently implicitly pulled by something else on Linux, it is not when
building on e.g. FreeBSD.

This reverts the change to this file of
commit 3b17152ec3.
2015-10-05 15:43:35 +02:00
Pino Toscano
b530bc764e Revert "lib: Don't need to include <rpc/types.h>."
The include is not needed with GNU libc, where rpc/xdr.h includes it
[1].  But this does not happen on other libc's, for example the
FreeBSD [2] and Mac OS X [3] ones.

Hence put it back, with an extra comment about this.

[1] http://linux.die.net/man/3/xdr
[2] http://www.freebsd.org/cgi/man.cgi?query=xdr&sektion=3&apropos=0&manpath=freebsd
[3] https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man3/xdr.3.html

This reverts commit ada85d1566.
2015-10-05 15:43:35 +02:00
Richard W.M. Jones
8554dbbc03 Remove multiple hacks that only apply to RHEL 5.
We don't support RHEL 5 upstream (see the 'oldlinux' branch for a
version that works with RHEL 5).  Therefore remove a bunch of hacks
that were only needed on RHEL 5.
2015-10-05 14:32:28 +01:00
Richard W.M. Jones
677c721e85 Fix whitespace.
Because of previous automated commits, such as changing 'guestfs___'
-> 'guestfs_int_', several function calls no longer lined up with
their parameters, and some lines were too long.

The bulk of this commit was done using emacs batch mode and the
technique described here:

  http://www.cslab.pepperdine.edu/warford/BatchIndentationEmacs.html

The changes suggested by emacs were then reviewed by hand.
2015-10-05 14:28:33 +01:00
Richard W.M. Jones
d07b32e14f Change 'fprintf (stdout,...)' -> printf.
Result of earlier copy and paste.
2015-10-05 14:28:33 +01:00
Roman Kagan
82763c0444 v2v:utils: ignore files w/o extension
When searching for virtio drivers, it makes no sense to fail if we
encounter a file without extension.

Ignore such files instead, just like we do for the files whose extension
doesn't match that of a driver-related file.

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
2015-10-05 14:28:33 +01:00
Pino Toscano
1f47ba92f2 actions: fix documented limit for btrfs labels
Our documentation of set-label says that labels for btrfs are limited
to 256 characters, while btrfs-filesystem(1) says:

  Note
  the maximum allowable length shall be less than 256 chars

which is indeed true, as trying to set a label with 256 characters
fails. Hence, fix our documentation to say that the limit is actually
255 characters.

Related to RHBZ#1164708.
2015-10-05 11:41:03 +02:00
Richard W.M. Jones
67bd4f37a1 Version 1.31.10. 2015-10-04 20:03:46 +01:00
Richard W.M. Jones
5d2ebb7076 launch: direct: Use a single -machine [type, ]accel=... option.
Previously we used (on arm): -M virt -machine accel=...

After this change, we use: -machine virt,accel=...
On x86 there is no change.

The -M option is an abbreviation for -machine, and we can combine the
two options together.  (Qemu combines the two options internally, but
it's more predictable if we do it ourselves).

Upstream qemu has supported the -machine option for over 5 years, and
in fact we implicitly relied on it (despite what the comment in the
code said).
2015-10-04 19:20:35 +01:00
Richard W.M. Jones
45cc5489b2 launch: Change comment.
Making -machine configurable would be a really bad idea.
2015-10-04 19:20:35 +01:00
Cédric Bosdonnat
bc8e1ff9ae customize: remove zypper's gpg keys auto-import
This option was considered unsecure, found a fix on the generated
opensuse images instead.
2015-10-02 17:21:47 +01:00
Pino Toscano
9c836e8669 ruby: improve rdoc markup
- fix the syntax of hyperlinks
- replace the deprecation text with a simplier named list item, so it's
  more visible
- use a named list item for the pointer to the C documentation of each
  API
- add a named list item for the version of each API
2015-10-02 15:30:38 +02:00
Robert Antoni Buj Gelonch
6404114515 add Catalan in po/Makefile.am 2015-10-02 12:25:20 +01:00
Richard W.M. Jones
7bc6fb2451 build: Remove ./configure --enable-valgrind-daemon.
If you've ever tried to use this option, you'll know that it didn't
work well.  It broke random things (probably RHBZ#1020216, definitely
RHBZ#1023630), and caused random failures generally, while often not
actually failing when valgrind itself found problems.
2015-10-01 15:32:49 +01:00
Richard W.M. Jones
4414de775a ocaml: Conditionally remove bindtests.* when doing 'make install'.
Commit f6a790b67d changed the Makefile
so it only builds the tests when you run 'make check'.

If you didn't run 'make check' then (in particular) bindtests won't be
built, and so when you install it cannot be removed.

The simple fix for this is to make the removal of bindtests.*
conditional.

This fixes commit f6a790b67d.
2015-10-01 14:17:52 +01:00
Richard W.M. Jones
2c519cf055 Add missing generated files to generator_built and EXTRA_DIST.
Use the generator_built variable to list any files which are built by
the generator.  This ensures they get automatically rebuilt.

Three files were missing from EXTRA_DIST, so they were not included in
the tarball, meaning you would have needed OCaml to build from the
tarball.  You would have seen this when building:

  cd .. && /builddir/build/BUILD/libguestfs-1.31.9/generator/generator
  written gobject/docs/guestfs-title.sgml
  written customize/customize-synopsis.pod
  written customize/customize-options.pod
  generated 476921 lines of code
2015-10-01 14:13:30 +01:00
Cédric Bosdonnat
3b4f83e0b2 customize: sles password defaults. 2015-10-01 13:01:59 +01:00
Richard W.M. Jones
24d2230831 Version 1.31.9. 2015-09-30 17:30:47 +01:00
Cédric Bosdonnat
d0aa7a032c Add opensuse.gpg to the dist tarball
Adding missing opensuse.gpg to EXTRA_DIST.
2015-09-30 16:04:12 +01:00
Richard W.M. Jones
3f3d9353a3 ocaml: Improve ocamldoc.
Miscellaneous improvements to the ocamldoc:

 - Generate more sub-headings.

 - Document the object-oriented API.

 - Use a common function to generate the doc for module and OO APIs.
2015-09-30 14:19:12 +01:00
Richard W.M. Jones
b482593a07 ocaml: Use ocamlfind to run ocamldoc.
Using 'ocamlfind ocamldoc' is much faster than running 'ocamldoc'
directly, because ocamlfind will run the native code program
'ocamldoc.opt' if it is available.

This change approximately halves the time taken to compile the ocaml
bindings.
2015-09-30 13:33:39 +01:00
Richard W.M. Jones
84598ef6f5 daemon: Compile stubs.c first.
This shaves about 20% off the compile time for the daemon subdirectory.

See also:
https://rwmj.wordpress.com/2015/09/30/make-and-queuing-theory/#content
2015-09-30 13:33:39 +01:00
Richard W.M. Jones
538c5d5eb7 java: Only build the tests when running 'make check'.
Make the tests 'check_DATA' so they only get built when running the
tests.
2015-09-30 13:33:39 +01:00
Richard W.M. Jones
f6a790b67d ocaml: Only build the tests when running 'make check'.
Make the tests 'check_DATA' so they only get built when running the
tests.  This saves a couple of seconds on the build time.
2015-09-30 13:33:39 +01:00
Richard W.M. Jones
3b17152ec3 lib: Remove unused header files.
I used ESR's deheader program to look for unused includes.  I then
examined each instance by hand, and also test-compiled (on Linux).
2015-09-30 13:32:42 +01:00
Richard W.M. Jones
ada85d1566 lib: Don't need to include <rpc/types.h>.
It is already included by <rpc/xdr.h>.
2015-09-30 13:32:42 +01:00
Richard W.M. Jones
c938202bc8 lib: Move <libintl.h> -> files that use it.
Don't include <libintl.h> (for gettext etc) in <guestfs-internal.h>.
Include include it only in files that use internationalized strings.
2015-09-30 13:32:42 +01:00
Pino Toscano
2ff115a736 copy-in: error out early if the localpath does not exist 2015-09-30 10:55:38 +02:00
Cédric Bosdonnat
4bb4c0f4f7 builder: add opensuse images sources 2015-09-30 10:55:37 +02:00
Richard W.M. Jones
8571c1298a haskell: Remove whitespace in Makefile.am. 2015-09-29 22:45:19 +01:00
Richard W.M. Jones
491b3d4f44 Version 1.31.8. 2015-09-29 19:02:33 +01:00
Cédric Bosdonnat
66efad4172 customize: get zypper to eat licenses and gpg keys
Without these flags --install will most likely fail as the GPG key
may no be imported in the guest image.
2015-09-29 17:48:19 +01:00
Richard W.M. Jones
bbc4a649b4 copy-in/copy-out: Capture errors from tar subprocess (RHBZ#1267032).
Modify the copy-in/copy-out APIs to use the new guestfs_int_cmd_pipe
internal API.

This new API allows us to capture the stderr from the tar subprocess
if it fails, fixing RHBZ#1267032.  The user will now see errors like
this:

$ guestfish -N fs -m /dev/sda1 copy-in '/tmp/d/*' / : ll /
libguestfs: error: tar subprocess failed: tar: *: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors
2015-09-29 12:51:14 +01:00
Richard W.M. Jones
e98bb86929 cmd: New internal API for read/writing to a subprocess via a pipe.
Roughly equivalent to popen(...,"r"|"w") the new internal API allows
you to run a subprocess and either read its stdout, or write to its
stdin.
2015-09-29 12:51:13 +01:00
Richard W.M. Jones
2fc1e14625 cmd: Move all the common processing code for running the child into a subfunction.
Anything that doesn't involve pipes [parent-child communication] is
moved into the run_child function, so we can reuse the same code when
writing the new pipe APIs (see following commit).  Anything involving
setting up pipes stays in the existing run_command function.

This is just refactoring.
2015-09-29 12:45:22 +01:00
Richard W.M. Jones
60aa4238c4 lib: Move read_whole_file function into separate library.
Allow this useful function to be called from elsewhere.

This commit is almost, but not completely refactoring.  I made a minor
change to the function so that it \0-terminates the returned data,
which is convenient for some callers.
2015-09-29 12:44:25 +01:00
Richard W.M. Jones
73928e9e35 lib: Whitespace cleanups. 2015-09-29 11:16:38 +01:00
Richard W.M. Jones
1b6f0daa9a Revert "cmd: add a way to run (and wait) asynchronously commands"
This reverts commit c5d3d198dc.
2015-09-29 11:06:10 +01:00
Richard W.M. Jones
3c27f3d91e Revert "cmd: add the possibility to get a fd to the process stdin"
This reverts commit db055262d4.
2015-09-29 11:05:07 +01:00
Richard W.M. Jones
5786191718 v2v: Further information on using ovftool to create OVA files.
c9291a91b0 (commitcomment-13440884)

Thanks: GitHub user https://github.com/angystardust
2015-09-25 20:24:21 +01:00
Richard W.M. Jones
f37d363f18 v2v: Update /etc/sysconfig/kernel DEFAULTKERNEL (RHBZ#1176801). 2015-09-25 13:55:46 +01:00
Richard W.M. Jones
c9291a91b0 v2v: Mention ovftool in the man page as a way to create OVA files. 2015-09-25 10:36:36 +01:00
Richard W.M. Jones
2d1d485265 installcheck: Use 'make check -k' option.
Run all the tests, even if some of them fail, so you can easily see
the complete list of failures.  This still exits with an error if any
test fails.
2015-09-22 14:16:54 +01:00
Richard W.M. Jones
cc1c010aa0 Version 1.31.7. 2015-09-20 15:26:15 +01:00
Richard W.M. Jones
3fa674df5f Remove make-check-on-installed.pl from EXTRA_DIST.
Removed in commit f2540d68e4.
2015-09-18 17:31:21 +01:00
Richard W.M. Jones
dd61872582 configure: Require OCaml and findlib if we need to run the generator.
When building from git, you need OCaml to compile the generator to
build the generated files.  Previously configure didn't detect that
situation, resulting in failed builds.  This commit causes the
configure script to error out if the generated files are not present
and OCaml is not installed.

Note that you can still build without OCaml, if you get the generated
files from somewhere else.  The source tarballs distributed on the
website contain the generated files.
2015-09-18 15:55:57 +01:00
Richard W.M. Jones
bc0ea59587 v2v: documentation: Add link to import-to-ovirt.pl script. 2015-09-18 14:12:17 +01:00
Richard W.M. Jones
dda1a7c37c v2v: documentation: Add 'OTHER TOOLS' section.
This currently contains just a link to rhevm-image-uploader.
2015-09-18 14:12:17 +01:00
Richard W.M. Jones
38be2da9be python: Set program name to the true name instead of 'python'.
As in commit e102bcf3cf (for Perl), any
Python program has the handle program name field set to 'python'.  Set
it to the true name (derived from sys.argv[0]).
2015-09-18 14:12:17 +01:00
Richard W.M. Jones
bb7d088eda python: Allow bindings to be compiled with different version of libguestfs (RHBZ#1262983).
When compiling the libguestfs bindings as a pip module, it's helpful
if you can compile the bindings with a different version of libguestfs
(eg. installed 1.28, pip module 1.30).

That broke the previous assumption that we were always compiling
against precisely the same version of libguestfs (which made sense
because the python bindings are part of the libguestfs source tree).

Python distutils has no way to check a C library to find out if
functions are defined.  Therefore we have to rely on GUESTFS_HAVE_*
macros from <guestfs.h>.
2015-09-18 14:12:17 +01:00
Richard W.M. Jones
ac5b3a050d header: Define GUESTFS_HAVE_STRUCT_* for each struct defined in the header. 2015-09-18 14:12:17 +01:00
Richard W.M. Jones
a17627cdd2 header: Define GUESTFS_HAVE_* for every function.
Previously we only defined GUESTFS_HAVE_* macros for functions that
were not deprecated, test or debug functions.  The reasoning for that
is given in this commit message [note that 'LIBGUESTFS_HAVE_' is the
old/deprecated macro]:

  commit 2d8fd7dacd
  Author: Richard Jones <rjones@redhat.com>
  Date:   Thu Sep 2 22:45:54 2010 +0100

    Define LIBGUESTFS_HAVE_<shortname> for C API functions.

    The actions each have a corresponding define, eg:

      #define LIBGUESTFS_HAVE_VGUUID 1
      extern char *guestfs_vguuid (guestfs_h *g, const char *vgname);

    However functions which are for testing, debugging or deprecated do
    not have the corresponding define.  Also a few functions are so
    basic (eg. guestfs_create) that there is no point defining a symbol
    for them.

This wasn't in fact carried through very consistently, since when we
replaced s/LIBGUESTFS_HAVE_/GUESTFS_HAVE_/, we kept the old
LIBGUESTFS_HAVE_* macros, but defined them for every function.  Oops.

This commit defines GUESTFS_HAVE_* for every function in <guestfs.h>,
making it easier to write the Python language bindings (see following
commits).
2015-09-18 14:12:17 +01:00
Richard W.M. Jones
f2540d68e4 Add 'make installcheck' rule to test installed packages.
Allow the tests to be run on the installed libguestfs.so library and
on installed programs (but not installed language bindings, yet).

To run the tests, you have to have a copy of the libguestfs source
tree with exactly the same version as the installed libguestfs.  You
have to build the libguestfs source tree.  Then you do:

  make installcheck

I investigated making automake 'make installcheck' work, but it's
basically broken (no surprise there).

This is derived from the old 'make-check-on-installed.pl'
script (which is also removed in this patch).
2015-09-18 14:12:17 +01:00
Pino Toscano
59a9101e44 daemon: initrd: print return value from failing process
If either zcat or cpio fails when spawned in initrd-list, pclose will
return the actual return value of it, but reply_with_perror still uses
errno regardless; thus, the reported error is:

  libguestfs: error: initrd_list: pclose: Success

which is not much helpful.

Instead, when pclose returns > 0, extract the actual return value of the
subprocess, and print that. Thus now we get for example:

  libguestfs: error: initrd_list: pclose: command failed with return code 1
2015-09-15 10:19:58 +02:00
Richard W.M. Jones
e102bcf3cf perl: Set program name to the true name instead of 'perl'.
Currently any Perl program has the handle program name field set
to 'perl'.  Set it to the true name (derived from $0).
2015-09-13 13:45:32 +01:00
Shahar Lev
1b856a20ba v2v: fix provides list whitespace trim
Tabs should not be doubly-escaped in regexp.

Signed-off-by: Shahar Lev <shahar@stratoscale.com>
2015-09-13 11:47:52 +01:00
Richard W.M. Jones
7fb21afff6 Version 1.31.6. 2015-09-11 15:28:39 +01:00
Richard W.M. Jones
edcd02a965 launch: libvirt: Better error when bridge / virbr0 doesn't exist (RHBZ#1262127).
The current diagnostic is terrible.  This one tells the user how to
diagnose and fix the problem.
2015-09-10 23:06:20 +01:00
Richard W.M. Jones
0ed3855098 v2v: Add --dcpath parameter to allow dcPath to be overridden (RHBZ#1256823).
It's currently impossible to correctly predict the dcPath parameter
from the data that libvirt gives us.  So allow the user to override
--dcpath themselves.

Eventually we will get better support in libvirt for this, and this
option will no longer be needed:

  https://www.redhat.com/archives/libvir-list/2015-September/thread.html#00201

This enhances commit 51bc573d0c
and commit 20f1eb400b.
2015-09-10 12:38:56 +01:00
Pino Toscano
1b8dd2150b builder: fix prototype virt_builder_yajl_tree_parse
Declare the prototype depending whether libyajl is available, and if it
isn't add also the noreturn attribute.

Fixes commit 87a42174f9.
2015-09-10 11:12:53 +02:00
Pino Toscano
32d19e3289 inspect: try to use /etc/os-release on Linux guests
If a Linux guest has /etc/os-release (mandatory for systemd, so all the
recent Linux distributions have it), try to parse it for the distro, its
version, and its product name.  If we cannot get all of them, the
detection as done so far continues.

Other than changes in the product_name string (which is free-form
anyway, and already documented to not be parseable), there should be no
regressions in the detected distro and version.
2015-09-09 16:17:59 +02:00
Richard W.M. Jones
e3aee9c14d v2v: -o rhev, -o vdsm: Set DefaultDisplayType back to 1 (RHBZ#1260590).
In commit c4bc8116d9, the DefaultDisplayType
was changed from 1 -> 2.  However this is in fact wrong.  See
https://bugzilla.redhat.com/show_bug.cgi?id=1260590#c17 for details.

This reverts the code back to what it was in
commit 829e3fe7a6.

Thanks: Omer Frenkel
2015-09-09 13:47:19 +01:00
Richard W.M. Jones
d68be534ea v2v: Detect AVG Technologies as AV software (RHBZ#1261436).
Thanks: Junqin Zhou
2015-09-09 13:33:12 +01:00
Richard W.M. Jones
6734fce8c8 v2v: Move anti-virus (AV) detection code to a separate module.
This is just code refactoring of earlier
commit 8e28d6b188.
2015-09-09 13:33:12 +01:00
Pino Toscano
27becc7e2f builder: handle output filenames with ':'
Use qemu_input_filename for the output file in the qemu-img convert
invocation.

See also commit 1709263613 for
virt-sparsify.
2015-09-09 13:19:57 +02:00
Pino Toscano
87a42174f9 builder: add noreturn for yajl functions without libyajl
caml_invalid_argument will not return, and GCC warns (or errors out with
-Werror) when the function is not marked as such.
2015-09-09 10:50:01 +02:00
Pino Toscano
1b4c1d74d3 customize: password: use SHA-512 on openSUSE >= 11.0
openSUSE 11.0 has glibc 2.8, which supports the SHA-512 method.
Fallback to an explicit MD5 for older versions.
2015-09-08 19:07:23 +02:00
Pino Toscano
f788b3c48d inspect: recognize the Frugalware distribution
Just basic identification, name and version.
2015-09-08 19:05:49 +02:00
Richard W.M. Jones
6c3bc24f90 Version 1.31.5. 2015-09-08 14:20:28 +01:00
Pino Toscano
6d08da07dc build: improve maintainer-check-extra-dist target
Filter out from the git ls-files output the files we don't care they
appeared (gnulib and intltools stuff), and use comm to only show the
remaining added files (i.e. files not being distributed).

The output of comm is redirected to file and then printed, so we can
check it is empty (failing the target if not).
2015-09-08 12:08:43 +02:00
Cédric Bosdonnat
fb9c17c8d4 Allow curl to follow redirects.
download.opensuse.org uses redirects to point to the relevant mirror.
Adding -L --max-redirs 5 to curl options will get us the requested
images.
2015-09-08 12:08:43 +02:00
Pino Toscano
268de62db6 builder: distribute simplestreams test files
Fixes commit b024aef6fb.
2015-09-08 11:51:49 +02:00
Pino Toscano
c8436df4a2 builder: replace colons in simplestreams test files
Colons won't be handled by make at all, so replace them with underscore
to be able to distribute them.
2015-09-08 11:51:49 +02:00
Richard W.M. Jones
c4bc8116d9 v2v: -o rhev, -o vdsm: Use correct DefaultDisplayType for qxl (RHBZ#1260590).
This fixes commit 829e3fe7a6.
2015-09-08 09:11:36 +01:00
Richard W.M. Jones
5ed4388ecd customize: Create .ssh as 0700 and .ssh/authorized_keys as 0600 (RHBZ#1260778).
Both ssh-copy-id and ssh create .ssh as 0700.  ssh-copy-id creates
.ssh/authorized_keys as 0600.

Thanks: Ryan Sawhill for finding the bug.
2015-09-08 09:09:40 +01:00
Pino Toscano
b024aef6fb builder: support Simple Streams v1.0 as index metadata
Add a new "simplestreams" repository type, and a simple parser for
fetching and reading the JSON indexes of the Simple Streams v1.0
format.

Read only datatype=image-downloads contents, and only the latest
versions of each content available as disk image (disk.img or
disk1.img).

Add a simple test, using the "released" images from the CirrOS project.
2015-09-08 09:51:49 +02:00
Pino Toscano
13eac43e28 build: expose HAVE_YAJL to automake
This way it can be used in automake conditionals.
2015-09-08 09:51:49 +02:00
Pino Toscano
23d1719105 builder: add simple libyajl binding
Only yajl_val and yajl_tree_parse are exposed for now.
2015-09-08 09:51:49 +02:00
Pino Toscano
7dfbb1f11c builder: add non-int revisions
Add support for non-integer revisions of entries, comparing them as
integer when possible.
2015-09-08 09:51:48 +02:00
Richard W.M. Jones
8e28d6b188 v2v: windows: Warn if Group Policy or AV software may result in 7B boot failure (RHBZ#1260689).
Check if the Windows guest has Group Policy Objects installed, or one
of several popular pieces of anti-virus software.  If we are
installing a virtio block driver, then experience has shown this may
cause a 7B boot failure.

Print a warning when this combination happens.

The warnings look like this:

[  19.9] Converting Windows Server 2008 R2 Enterprise to run on KVM
virt-v2v: warning: 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.
virt-v2v: warning: 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.
virt-v2v: This guest has virtio drivers installed.
2015-09-07 17:47:21 +01:00
Richard W.M. Jones
8f889f0c3e v2v: windows: Refactor Xen uninstaller detection code.
No change, just refactoring.
2015-09-07 17:17:49 +01:00
Richard W.M. Jones
4335088d74 dib: Move 'isdigit' utility function to common code.
No change, just simple refactoring.
2015-09-07 16:53:17 +01:00
Richard W.M. Jones
4ded4430bf v2v: -o rhev, -o vdsm: Add sound card to OVF output.
For the two sound card types that RHEV can emulate, add
them to the output.
2015-09-07 15:00:50 +01:00
Richard W.M. Jones
829e3fe7a6 v2v: -o rhev, -o vdsm: Review XML based on oVirt description of format.
After reviewing http://www.ovirt.org/images/8/86/Ovirt_ovf_format.odt
this commit makes some small revisions to the OVF that we generate.

Possible fix for https://bugzilla.redhat.com/show_bug.cgi?id=1260590
2015-09-07 15:00:44 +01:00
Richard W.M. Jones
e271992746 v2v: Error if certain options appear twice on the command line.
Change the handling of -ic, -if, -oc, -of, -on, -os, --password-file,
--vdsm-vm-uuid, --vdsm-ovf-output, --vmtype options, so that if any
appear multiple times on the command line we error out:

$ virt-v2v -i disk /tmp/centos-6.img -o null -of qcow2 -of raw
virt-v2v: error: -of option used more than once on the command line

Thanks: Juquin Zhou for finding the bug.
2015-09-07 12:18:21 +01:00
Richard W.M. Jones
0afe4773d0 Version 1.31.4. 2015-09-03 21:49:56 +01:00
Richard W.M. Jones
7e63d3680f v2v: test-harness: Allow test boot at fixed dates in the past.
Turns out that some of the Windows guests in the test suite try to
reactivate if the date is more than some time delta (maybe 1 year?)
after the previous activation.  Just disabling the network wasn't
enough to prevent this.

qemu allows us to boot guests with the clock set to a particular date
in the past, and libvirt exposes this (albeit very clumsily):

https://docs.fedoraproject.org/en-US/Fedora/18/html/Virtualization_Administration_Guide/sect-Virtualization-Tips_and_tricks-Libvirt_Managed_Timers.html

Allow guests to be booted with the date set to a particular past date,
by setting the test_plan.guest_clock field.

This required adding some more libxml2 bindings.
2015-09-03 20:11:07 +01:00
Richard W.M. Jones
6246bebf82 p2v: Clear previous version and driver information when testing connection (RHBZ#1227609).
When calling test_connection to test the connection to a conversion
server, we also query for the remote server's version and driver
information (using 'virt-v2v --version' and
'virt-v2v --machine-readable').

However we didn't clear the existing information from previous runs.

One consequence of this was that if you used the back button in the
GUI, the list of output drivers would be repopulated two or more
times.  https://bugzilla.redhat.com/show_bug.cgi?id=1227609

Another is that connecting to a different server could confuse
test_connection into thinking the connection was successful (because
of data from the previous run) when in fact it was not.

Thanks: Tingting Zheng for finding the original bug.
2015-09-03 16:12:22 +01:00
Richard W.M. Jones
302ea2aa5b p2v: Use gtk_list_store_clear instead of loop.
The model implements GtkListStore, so an easier way to clear the list
is simply to call the clear method.
2015-09-03 16:06:59 +01:00
Richard W.M. Jones
314713c3b0 p2v: Use GtkComboBoxText instead of deprecated gtk_combo_box_new_text.
Requires Gtk >= 2.24, which is the same version that RHEL 6 has.
2015-09-03 15:56:19 +01:00
Pino Toscano
cf3d93c826 get-kernel: respect -q
Now that virt-get-kernel has -q/--quiet, support it by printing the
download messages only if not specified.
2015-09-02 00:25:55 +02:00
Pino Toscano
45f6cfe1a1 get-kernel: refactor list and download code
Split in an own function the code dong the mounting, the inspection of
the kernel files, and the downloading, including a per-OS function for
the actual kernel files.  This gives few advantages:
- the download phease is not repeated for all the files to fetch
- it is easier to eventually support multi-root disk images
- it is possible to support OSes different than Linux; virt-get-kernel
  now will just report the unsupported OS, instead of a generic
  "no kernel found" message

This is mostly code refactoring, with (on Linux) no actual behaviour
change.
2015-09-02 00:25:55 +02:00
Pino Toscano
997c59139e get-kernel: split command line handling in own function
Simple refactoring, no actual behaviour changes.
2015-09-02 00:25:55 +02:00
Pino Toscano
b360e99ff6 builder, dib, get-kernel: document new -q/--quiet options
Provided as common options for all the OCaml-based tools.
2015-09-02 00:25:55 +02:00
Pino Toscano
2ec0332e5e mllib: move -q/--quiet as common option
Most of the OCaml-based tools had it already, except from virt-dib and
virt-get-kernel.
2015-09-02 00:25:55 +02:00
Pino Toscano
875f46fddc mllib: make few command line options stuff private
Make print_version_and_exit, long_options, display_short_options, and
display_long_options private, as set_standard_options now takes care of
handling the job for the common command line options.
2015-09-02 00:25:55 +02:00
Richard W.M. Jones
51bc573d0c v2v: Fix handling of extra slashes in dcPath calculation (RHBZ#1258342).
This updates commit 20f1eb400b.

Thanks: Tingting Zheng
2015-09-01 14:56:10 +01:00
Pino Toscano
4cc3cc3fbd mllib: set --debug-gc as common option
Move --debug-gc as common option for all the OCaml-based tools, even a
couple of them which didn't have it previously.

As implementation note, make set_debug_gc private to
set_standard_options, as it needed to be moved otherwise, and it is no
more required as public function.
2015-08-31 18:34:37 +02:00
Pino Toscano
2af6e48ba3 mllib: add and use set_standard_options
Introduce a new common helper to add the common options for libguestfs
tools (short/long options, version, verbose, trace), and sort them.
All the OCaml-based tools had these options already, so there are no
functional changes in the interface they provide.

The only difference is that now the options are always sorted, while
some tools didn't had them like that previously: because of this, a
couple of ditto markers (as descriptions) don't match what's above them
anymore, and thus their full description is put instead.
2015-08-31 18:25:48 +02:00
Pino Toscano
7bdb3e0df9 customize: fix running commands on the same architecture
Wrap the command around an heredoc only if setarch needs to be used;
otherwise the heredoc will not be run at all.

Fix commit d875346ad4.
2015-08-31 17:55:14 +02:00
Richard W.M. Jones
2596b78bcb Version 1.31.3. 2015-08-28 19:34:15 +01:00
Richard W.M. Jones
95233a8eee p2v: Add test-virt-p2v-pxe.sshd_config.in to EXTRA_DIST.
Fixes commit afe3c77014.
2015-08-28 19:32:15 +01:00
Richard W.M. Jones
d875346ad4 customize: Use setarch when running commands on i686 guest (RHBZ#1256405).
When running (eg) dnf on a 32 bit i686 guest when the host is 64 bit
x86_64, dnf believes it is running on a 64 bit machine and so tries to
install x86_64 packages.  We can 'trick' dnf into believing it's a 32
bit machine using the setarch program.

$ virt-builder fedora-22 --arch i686 --install 'gperf'
...
[  27.4] Installing packages: gperf
...
Running transaction test
Error: Transaction check error:
  package libgcc-5.1.1-4.fc22.x86_64 is intended for a different architecture
...

The use of a heredoc to solve quoting issues comes from:
http://stackoverflow.com/a/3435460

Thanks: Jan Sedlák for finding the solution.
2015-08-28 19:09:17 +01:00
Richard W.M. Jones
18b019e3dd v2v: -i libvirtxml: Map empty network or bridge name to default (RHBZ#1257895).
As with the -i ova driver, if an unnamed network is found, map it to
"eth0", "eth1" etc.
2015-08-28 19:09:17 +01:00
Richard W.M. Jones
261d05749f v2v: Convert xpath_to_* to use xpath convenience functions.
In -i libvirtxml, -i ova and -o libvirt drivers, replace the ad hoc
xpath_to_* functions with use of the new xpath convenience functions
introduced in the previous commit.

This is not entirely refactoring because I fixed a few bugs found by
type safety.
2015-08-28 19:09:17 +01:00
Richard W.M. Jones
00e1260d34 v2v: Add convenience functions for parsing xpath expressions. 2015-08-28 19:09:17 +01:00
Richard W.M. Jones
20f1eb400b v2v: vcenter: Calculate dcPath correctly (RHBZ#1256823).
Previously given a path such as:

  vpx://vcenter/Folder/Datacenter/esxi

we calculated dcPath=Folder.  However this is obviously wrong.  We
should chop the path at the final (esxi) element to give
dcPath=Folder/Datacenter.
2015-08-28 17:53:41 +01:00
Richard W.M. Jones
1585bb5bee v2v: vcenter: Change function get_datacenter -> get_dcPath.
In vCenter, the datacenter is identified by a path, and the parameter
used for this is called 'dcPath'.  Rename the function to avoid any
confusion about what we're getting here.

This is just renaming function/variable names and has no other effect.
2015-08-28 17:53:41 +01:00
Roman Kagan
a628fb65fa handle --debug-gc universally via at_exit hook
Several tools handle --debug-gc command-line option, by explicitly
forcing GC on every exit path.  This is tedious and prone to forgetting
some of the exit paths.

Instead, add a generic handler for --debug-gc, which installs an at_exit
hook to do the GC consistency check, and which can be called right in
the command-line parser.  Also adjust all users of --debug-gc to use
that handler.

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
2015-08-28 17:53:41 +01:00
Richard W.M. Jones
afe3c77014 p2v: Add a test for the PXE boot path (RHBZ#1256222).
Build the P2V disk image and boot it.  We don't actually use PXE
specifically, but we do test the whole PXE / kernel command line path
much more thoroughly.

This is a 'check-slow' test because it takes ages to run.
2015-08-27 15:42:55 +01:00
Richard W.M. Jones
ca4725e1c7 p2v: Add SSH Identity URL.
Allow SSH identities (ie. secret keys) to be used for authentication
instead of passwords.
2015-08-27 15:42:55 +01:00
Richard W.M. Jones
3c30fb4a79 Revert "p2v: Add tip about the root password of the virt-v2v conversion server appliance."
This reverts commit 35efaf8208.
2015-08-27 15:42:55 +01:00
Richard W.M. Jones
4c34d240a1 p2v: Wait for network to come online before testing connection (RHBZ#1256222).
When using the virt-p2v ISO in command line mode, we did not wait for
the network to come online before starting virt-p2v.  Therefore
virt-p2v could exit with an error when testing the ssh connection (or
on the other hand, it might work randomly).  If the user logs in and
runs 'launch-virt-p2v' by hand, then it would usually work because the
network had been brought online in the meantime.

Fix this by waiting for NetworkManager to bring the connection online
before calling test_connection().  Note that the obvious way to fix
this (changing the systemd service to wait for network-online.target)
does *not* work - I added a comment to the service about this.

Thanks: Tingting Zheng
2015-08-27 15:42:55 +01:00
Pino Toscano
c1e1e23285 osinfo: add altlinux and mageia distributions 2015-08-25 17:39:26 +02:00
Pino Toscano
70579d08cd inspect: recognize the ALT Linux distribution
Check its presence ahead of /etc/redhat-release, as the distro provides
it and thus previously it was recognized as "redhat-based".
2015-08-25 16:17:59 +02:00
Pino Toscano
74f0b45ddf v2v: ignore missing kernels from grub (RHBZ#1230412)
Raise a warning for each kernel specified in grub which does not
actually exist, keep going on with the conversion using the remaining
(existing) kernels.
2015-08-24 18:25:10 +02:00
Pino Toscano
baa4ec6e45 ocaml: Add handling for errno ENOENT. 2015-08-24 18:11:18 +02:00
Pino Toscano
649f439cb7 ocaml: dynamically generate the content of Guestfs.Errno
Put in a list the errnos to expose, filling the content of the
Guestfs.Errno submodule from that.
Also, generate a separate guestfs-c-errnos.c with the implementations of
the functions returning the errno codes.

Only code motion and refactoring, no actual changes on the content of
the ocaml Guestfs module.
2015-08-24 17:57:10 +02:00
Pino Toscano
0dcb862943 configure: look for "java" as directory for Java in lib64 too
On 64-bit openSUSE versions, /usr/lib64/jvm/java provides the symlink to
the default Java version.
2015-08-20 17:25:34 +02:00
Pino Toscano
e6dd9b5d6b appliance: explicitly add libyajl on Mageia
It seems yajl was bringing it, but seems not on Mageia 5.  Leave yajl
for older versions.
2015-08-19 14:46:39 +02:00
Richard W.M. Jones
97bd64f588 FAQ: the -> and in previous commit.
This fixes commit 571fca8e71.
2015-08-13 22:54:30 +01:00
Richard W.M. Jones
571fca8e71 FAQ: Further improve debugging section. 2015-08-13 22:51:43 +01:00
Richard W.M. Jones
8828005691 Version 1.31.2. 2015-08-13 16:46:08 +01:00
Richard W.M. Jones
08b57ae1f4 builder/website: Fix EXTRA_DIST.
This fixes commit 190a9f4534 and
commit 864ca489ac.
2015-08-13 16:45:30 +01:00
Richard W.M. Jones
c9ad61b37b p2v: Modify some partial match regexps to work with pcre 7.8.
pcre < 8 has limitations on the types of partial matching
possible.  As noted in the pcrepartial(3) man page, these can
be worked around by adding non-capturing parentheses around
various subexpressions, as I have done here.
2015-08-13 15:48:36 +01:00
Richard W.M. Jones
92e155dbdd p2v: For pcre < 8 (RHEL 6), abort if partial matching cannot be used on a regexp. 2015-08-13 15:48:36 +01:00
Richard W.M. Jones
1d082d127e p2v: Print an error if gtk_init_check fails.
Apparently gtk_init_check doesn't (always?) print an error message
when it returns false, so virt-p2v just exits without any message.

This was observed on RHEL 6 when $DISPLAY was not set.
2015-08-13 14:13:49 +01:00
Richard W.M. Jones
2bfb9ff9ea p2v: Call g_thread_init with old glib2 as used by RHEL 6. 2015-08-13 13:51:11 +01:00
Richard W.M. Jones
00bceec421 v2v: Help RHEL 6 OCaml to determine type of class.
File input_libvirt_other.ml, line 1, characters 0-1:
Error: The implementation input_libvirt_other.ml
       does not match the interface input_libvirt_other.cmi:
       Class declarations do not match:
         class virtual input_libvirt :
           'a ->
           string option ->
           string ->
           object
             method adjust_overlay_parameters : Types.overlay -> unit
             method as_options : string
             method virtual source : unit -> Types.source
           end
       does not match
         class virtual input_libvirt :
           string option ->
           string option ->
           string ->
           object
             method adjust_overlay_parameters : Types.overlay -> unit
             method as_options : string
             method virtual source : unit -> Types.source
           end
       A parameter has type 'a but is expected to have type string option
2015-08-13 13:23:59 +01:00
Richard W.M. Jones
b0cd6917ca v2v: Hide StringMap functions we're not actually using.
In RHEL 6 OCaml, some of these functions were not part of the Map
class, giving an error.  Hide the ones we aren't using.
2015-08-13 13:23:59 +01:00
Richard W.M. Jones
437cb7b6ff handle: Move #pragma out of functions.
RHEL 6 gcc did not support #pragma within functions.
2015-08-13 13:23:59 +01:00
Richard W.M. Jones
06e92bffd4 p2v: Add replacement for xmlBufferDetach function not available in RHEL 6. 2015-08-13 13:23:59 +01:00
Richard W.M. Jones
42b6bb12dc v2v: -oa preallocated for qcow2 output now fully allocates the file (RHBZ#1251909).
When the output format is qcow2 and -oa preallocated is used,
previously it would only allocate the metadata.  That was a regression
over previous behaviour of virt-v2v 0.9.  Change it so it allocates
the full file size in this case.
2015-08-13 13:23:59 +01:00
Richard W.M. Jones
66daad38f3 disk-create: Allow preallocation off/metadata/full.
For raw, this allows "off" as a synonym for "sparse" (to make it
consistent with qcow2).

For qcow2, this allows "sparse" as a synonym for "off".

It also adds qcow2 "full" preallocation, which is actually mapped to
the qemu option "falloc" (see arguments about this on the qemu-devel
mailing list, which we lost).

This also updates the test.
2015-08-13 13:23:58 +01:00
Pino Toscano
d78f685c0e builder: normalize architectures
Normalize the target architecture, and also each architecture when
checking for a compatible image.

This sort of reverts the effects of
commit 8864c47b94, but at least it is
possible to build e.g. Debian-based amd64 images on any x86_64 system
without being considered as foreign architecture.
2015-08-12 18:22:34 +02:00
Pino Toscano
0bbb903f42 mllib: add normalize_arch helper
Small helper to normalize an architecture string, so it is easier to
compare them and check for compatibilities.

Make use of it in guest_arch_compatible, simplifying it.
2015-08-12 18:22:34 +02:00
Pino Toscano
90b459a5db dib: expand doc on external dependencies for appliance 2015-08-12 18:21:08 +02:00
John Eckersberg
c2bb87e8f2 dib: handle unsetting functions in environment
If a function name, with its trailing parentheses, is in the
environment , trying to unset it will error out with a message of "not
a valid identifier".  Handle this as a special case, and unset it with
the -f option which can handle the parentheses in the supplied
identifier.
2015-08-12 17:20:38 +02:00
Pino Toscano
70d020f074 inspect: support the APK package manager and its format
Associate the Alpine Linux distribution with it.
2015-08-12 16:23:45 +02:00
Pino Toscano
120f06a8a1 inspect: recognize the Alpine Linux distribution
Just basic identification, name and version.
2015-08-12 16:23:45 +02:00
Richard W.M. Jones
190a9f4534 builder: Add script for building RHEL for aarch64. 2015-08-12 14:00:24 +01:00
Richard W.M. Jones
f3a7cf994b customize: firstboot: Place firstboot.service file in systemd unit directory (RHBZ#1250955).
It turns out that -- some of the time -- systemd ignores unit files
which are not placed in one of the official unit directories.  This
caused the service to be timed out and killed when the systemd daemon
was reloaded, as could happen for long-running package installs at
first boot.

Thanks: Marius Vollmer for diagnosing the problem and finding the
solution.
2015-08-12 10:42:57 +01:00
Richard W.M. Jones
75006fc27c p2v: Add mesa-dri-drivers.
Requires on Fedora 22 to work around:
https://bugzilla.redhat.com/show_bug.cgi?id=1242195
2015-08-11 16:27:49 +01:00
Richard W.M. Jones
bfd151b8bf p2v: Add tar to the kickstart.
Work around https://bugzilla.redhat.com/show_bug.cgi?id=1182362
2015-08-11 15:49:28 +01:00
Richard W.M. Jones
6f74d8044b p2v: Add a note about building a 32- or 64-bit virt-p2v ISO. 2015-08-11 15:38:07 +01:00
Richard W.M. Jones
864ca489ac builder: Add script for building Fedora i686 (32 bit) images. 2015-08-11 13:56:55 +01:00
Richard W.M. Jones
8cb82aec12 builder: fedora: Use os variant fedora22. 2015-08-11 13:34:27 +01:00
Pino Toscano
4e5d9962ce builder: improve "converting" message on unknown format
If the format of the disk image of the template is not specified in the
index, virt-builder would print
  Converting auto to qcow2
when asking to generate a qcow2 image.  Instead, in this case print only
the destination format, like
  Converting to qcow2
2015-08-10 13:22:27 +02:00
Richard W.M. Jones
068443843d v2v: vCenter: Suggest using %20 to escape spaces in Datacenter paths (RHBZ#1250715). 2015-08-06 17:29:56 +01:00
Richard W.M. Jones
fc70ea696b docs: Document CVE-2015-5745 qemu vulnerability. 2015-08-06 16:41:09 +01:00
Richard W.M. Jones
f8a81d6bae update-bugs.sh: Remove comment. 2015-08-06 16:24:56 +01:00
Pino Toscano
1c43c0800f get-kernel: remove extra progname from error messages
error() prints it already
2015-08-06 15:15:40 +02:00
Richard W.M. Jones
16e6378a5b customize: Make dnf upgrade to the latest versions of packages.
I discovered that 'dnf upgrade' doesn't actually upgrade to the latest
versions of packages unless you also supply the '--best' flag.

This also changes update -> upgrade, since apparently 'dnf update'
is deprecated.
2015-08-05 13:01:12 +01:00
Richard W.M. Jones
91c06391c1 automake: Admit defeat and use 'subdir-objects'.
Because this 'feature' is broken (since 2013):

  https://debbugs.gnu.org/cgi/bugreport.cgi?bug=13928

we have to replace all instances of $(top_srcdir) in *_SOURCES lines
with a relative path.  According to what I read, this shouldn't break
split builds, but I didn't test it.

The only things automake moans about now are:

* Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/\${ <-- HERE ([^ \t=:+{}]+)}/ at /usr/bin/automake line 3936.

  - This is another bug in automake

* autoreconf: configure.ac: AM_GNU_GETTEXT is used, but not AM_GNU_GETTEXT_VERSION

  - This is a feature, not a bug.
2015-08-05 13:01:12 +01:00
Richard W.M. Jones
f3ed65525c p2v: Display full package version (including extra string) in p2v.ks file. 2015-08-05 13:01:12 +01:00
Richard W.M. Jones
da87760407 p2v: Allow 'virt-p2v-make-kickstart rhel-7.1' to set up RHEL repos. 2015-08-05 13:01:12 +01:00
Richard W.M. Jones
007004a536 p2v: Disable ssh service in the ISO (RHBZ#1248678).
We don't want people to be able to ssh into the p2v ISO while it is
running, with a simple, known root password.
2015-08-05 13:01:12 +01:00
Richard W.M. Jones
d9c6370831 sysprep: Allow test-virt-sysprep.sh to be skipped.
It fails in Fedora Rawhide because LVM is broken (RHBZ#1237136).
2015-08-02 17:33:07 +01:00
Richard W.M. Jones
12898a8862 dib: Fix typo in documentation.
Thanks: Yuri Chornoivan
2015-07-31 08:30:00 +01:00
Richard W.M. Jones
3e71e8ee93 Version 1.31.1. 2015-07-30 14:50:11 +01:00
Richard W.M. Jones
380002b133 README: Add the dnf builddep command (for Fedora >= 22). 2015-07-30 14:45:21 +01:00
Cédric Bosdonnat
2d2a65504d appliance init: find NIC name for dhcpcd
dhcpcd requires an interface name as parameter to work. We are now
getting it from /proc/sys/net/ipv4/conf/ folder children. dhclient
on Debian also has the problem, thus use the guessed interface name
for it too.
2015-07-29 17:31:33 +01:00
Pino Toscano
37a0378556 sysprep: machine_id: handle /var/lib/dbus/machine-id
Another machine-id file, used by D-Bus.
2015-07-29 13:47:08 +02:00
Pino Toscano
bc598ff52a sysprep: machine_id: simplify implementation
Instead of rm + touch, just truncate the file if existing.
In case there was no file previously, now nothing is created, as most
probably the system was fine even without it.

Also, turn the single path into a list, so more machine-id files can be
handled at once.
2015-07-29 13:36:23 +02:00
Richard W.M. Jones
dbbf4b8afe customize: Combine separate -a and -d option synopses (RHBZ#1246882) 2015-07-28 14:13:03 +01:00
Pino Toscano
ae9954e0b4 builder: add Sigchecker.verify_and_remove_signature
New helper to remove the signature from a file, returning a temporary
file without the signature.
2015-07-28 13:30:39 +02:00
Pino Toscano
51d40267d7 builder: expose Sigchecker.verifying_signatures
Useful to know whether a Sigchecker instance is verifying signatures,
hence it is possible to decide whether download signed content or not.
2015-07-28 13:30:39 +02:00
Pino Toscano
3b44b7d878 builder: split Index_parser.index in an own module
Move the index and entry definitions in an own Index module, together
with the (previously internal to Index_parser) print_entry debugging
function.
2015-07-28 13:30:39 +02:00
Pino Toscano
6a86a3d8ff builder: allow signatures from subkeys
When importing a key, read the list of the valid subkeys of it, and use
it to check whether a signature was done by one of them.
This allows index provides to sign them using a subkey instead of the
main key.
2015-07-28 13:30:39 +02:00
Pino Toscano
63175fb3c3 builder: internally use a list of checksums for indexes
Extend Index_parser.entry to hold a list of checksums to validate, and
validate all of them.

This does change nothing currently, as only sha512 is read, while still
allowing us to fetch more checksums if needed.
2015-07-28 13:30:39 +02:00
Pino Toscano
43499579bf builder: add SHA256 support in Checksums 2015-07-28 13:30:39 +02:00
Pino Toscano
7056af81bd builder: create and use a new Checksums module
Introduce a new Checksums module to handle the check of checksums,
moving part of the Sigchecker code to it.

Adapt the rest of virt-builder to this new module.
2015-07-28 13:30:39 +02:00
Pino Toscano
a1a1e8e508 builder: add format=FMT in repository .conf files
First step in allow different formats for indexes of images, aside the
current one.

The only accepted value is "native".
2015-07-28 13:30:39 +02:00
Pino Toscano
6c9ea0471e customize: password: improve unknown default crypto message
When warning that there is no known default password encryption for the
current guest, print also its minor version (help debugging unsupported
guests).

Also, fix wrapping (and indentation) of the message.
2015-07-24 16:40:11 +02:00
Pino Toscano
563b388b8e customize: random_seed: add CirrOS location
CirrOS has its random-seed file in /etc.
2015-07-24 15:25:28 +02:00
Richard W.M. Jones
7eed43da6c appliance: Exclude /usr/lib/modules as well as /lib/modules.
It normally makes no difference to the final size of the appliance,
because 'supermin --build' will copy back the host kernel modules.
2015-07-23 16:41:06 +01:00
Richard W.M. Jones
0c7b957c13 appliance: exclude /lib/firmware
Brings the size of the appliance down to 95 MB [xz-compressed], which
is the same as for libguestfs 1.28.
2015-07-23 16:40:52 +01:00
Richard W.M. Jones
46600019b1 appliance: exclude /usr/share/fonts and /usr/share/icons.
I also sorted the list.

Between libguestfs 1.28 and 1.30, the appliance grew from 95MB to 213MB.

Using guestmount and filelight (see link below) I could see that the
main contributor was these two directories, which should not be
necessary.

With this change, the size goes down to 119MB.

See also:
https://rwmj.wordpress.com/2015/07/23/why-has-the-libguestfs-appliance-grown-by-118-mb/
2015-07-23 14:47:33 +01:00
Pino Toscano
c60cd11e73 actions: tar_in: add xattrs, selinux, and acls optargs
Add additional arguments for tar, so extended attributes and/or SELinux
contexts and/or POSIX ACLs can be restored from input tars.
2015-07-21 18:12:52 +02:00
Pino Toscano
afb5db7837 actions: tar_out: add xattrs, selinux, and acl optargs
Add additional arguments for tar, so extended attributes and/or SELinux
contexts and/or POSIX ACLs can be saved in output tars.
2015-07-21 18:12:52 +02:00
Richard W.M. Jones
499678a8a6 build: Add virt-dib.1.html and virt-get-kernel.1.html to HTMLFILES. 2015-07-21 17:00:24 +01:00
Pino Toscano
a6433aff70 tests/nbd: pass --format to qemu-nbd if possible
Run `qemu-nbd --help` to know whether it supports --format, and if so
pass it explicitly.  This avoids warnings with newer qemu versions,
where they really recommends to explicit the format of disk images being
specified on command line.
2015-07-21 16:56:00 +02:00
Pino Toscano
42ff22a909 tests/syslinux: add /usr/lib/SYSLINUX as directory for mbr.bin
Yet another new location (found on recent Debian/sid) for mbr.bin.
2015-07-21 16:54:29 +02:00
Richard W.M. Jones
1a9e06b228 docs: Finish off release notes for 1.30. 2015-07-21 13:34:56 +01:00
Richard W.M. Jones
8ac2c4da9f Version 1.31.0. 2015-07-21 13:30:40 +01:00
Richard W.M. Jones
251c608e48 Version 1.30.0. 2015-07-21 13:13:38 +01:00
Richard W.M. Jones
95fde969ea Pull translations from Zanata. 2015-07-21 12:33:48 +01:00
Richard W.M. Jones
5a28634bdc Update gnulib to latest. 2015-07-21 11:55:01 +01:00
Richard W.M. Jones
83a0b4b37c p2v: tests: Don't fail when test machine has only a single hard disk.
virt-p2v looks in /sys/block to find disks, and ignores the hard disk
containing the root device.  This is correct when virt-p2v runs off
the ISO, but when running the tests on a machine that has a single
hard disk, all_disks would be NULL, resulting in a test failure.

Fix this by allowing all_disks to be NULL, but adding an extra check
later so that we don't perform the conversion with no hard disks (the
gui.c path already has this check, so it is only needed in the
kernel.c path).
2015-07-21 10:54:52 +01:00
Pino Toscano
7c470c1179 tests: fix string comparison
Use 'eq' for comparing strings instead of '=='.
2015-07-21 11:13:45 +02:00
Pino Toscano
19020ea3f8 appliance: adding qemu-img and which dependencies for more distros
In particular, add them for Archlinux, openSUSE, Frugalware, and Mageia.
2015-07-21 09:38:11 +02:00
Pino Toscano
44f71d0782 customize: add basic subscription-manager operations
Add simple operations for RHEL guests using subscription-manager, so it
is possible to e.g. install software on them.
2015-07-17 17:03:04 +02:00
Pino Toscano
b357553cd6 mllib: add and use read_first_line_from_file
Move the read_password_from_file helper in Password to mllib with a more
generic name, and use it in place of the former.

Also, use it in v2v instead of reading the whole file contaning a
password: given that the documentation says that the whole content is
used, there will not be newlines in the password file, so the behaviour
will be preserved. The oly difference is that newline is no more an
acceptable character for passwords, but that is a really unlikely
(if not impossible at all) situation.
2015-07-17 17:03:04 +02:00
Chen Hanxiao
d29337605a daemon: add a space after func/macro to fit code-style
more daemon codes covered

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-07-17 13:27:13 +01:00
Pino Toscano
9d3447ad7a dib: handle --name with path
Make sure to write in the directory of the specified image name, using
just the basename where needed (e.g. for $IMAGE_NAME).
2015-07-14 11:11:29 +02:00
Chen Hanxiao
c3edd076b9 daemon: add a space after func name to fit code-style
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-07-13 12:31:52 +01:00
Richard W.M. Jones
08bfad986a v2v: windows: Set gcaps_video correctly (RHBZ#1233093).
Depending on whether we found a QXL driver and installed it in the
guest, set gcaps_video to either Cirrus or QXL.
2015-07-13 10:12:29 +01:00
Richard W.M. Jones
b7fcfb59ef v2v: OVF: Add a comment about always using QXL. 2015-07-13 10:12:29 +01:00
Pino Toscano
ad4067a508 Improvements to the 1.30 release notes 2015-07-10 14:41:08 +02:00
Richard W.M. Jones
e6404be6ee Version 1.29.50. 2015-07-09 18:31:47 +01:00
Richard W.M. Jones
42cee8f8fc docs: When making a stable release, run ./configure --without-libvirt. 2015-07-09 17:55:23 +01:00
Richard W.M. Jones
6561c96fb7 v2v: domainxml: Fix missing functions in the !HAVE_LIBVIRT case.
This also uses a C macro to simplify the error functions in this case.

This fixes commit badfc2e9b2.
2015-07-09 17:54:17 +01:00
Richard W.M. Jones
ae5844cc54 Draft release notes for 1.30 release. 2015-07-09 16:57:21 +01:00
Richard W.M. Jones
350dfe1fa2 v2v: Remove RHEL 7 conversion server.
We are no longer planning to ship virt-v2v as an appliance.  In RHEL 7.2
it will be included in the base RHEL Server product.

This reverts commit 4e4ece5364.
2015-07-09 15:36:31 +01:00
Richard W.M. Jones
95bb1916eb appliance: Exclude more log files (RHBZ#1239154).
This removes further possible log files from the appliance, but
without removing any subdirectories.
2015-07-09 15:36:31 +01:00
Richard W.M. Jones
2080f4b0dd appliance: Remove typo $@ at beginning of line.
This fixes commit 82b486a908.
2015-07-09 15:36:31 +01:00
Richard W.M. Jones
c238a9caa1 appliance: Rebuild appliance if excludefiles changes. 2015-07-09 15:36:31 +01:00
Pino Toscano
85fe0abdd0 New tool: virt-dib
virt-dib is a new tool to run the elements of diskimage-builder using
libguestfs.
2015-07-09 14:55:43 +02:00
Chen Hanxiao
46be6934fc labels: return ENOTSUP if could not set label for specific fs
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-07-08 13:02:42 +02:00
Chen Hanxiao
d9b53a2752 labels: use existing do_xfs_admin for xfslabel
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-07-08 12:26:59 +02:00
Chen Hanxiao
5c6be8846f labels: move ntfslabel to ntfs.c
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-07-08 12:26:52 +02:00
Chen Hanxiao
d5a60f2148 labels: move e2label to ext2.c and call it directly
ext2 should not call function in labels

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-07-08 12:26:47 +02:00
Chen Hanxiao
16232ffd58 labels: move btrfslabel to btrfs.c
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-07-08 09:56:56 +02:00
Chen Hanxiao
de93c690a1 doc: add missing ms-dos fs section in set_label
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-07-07 09:55:00 +02:00
Chen Hanxiao
105fa8bf31 uuids: return ENOTSUP if could not set UUID for specific fs
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-07-07 09:20:38 +02:00
Richard W.M. Jones
b04f39bf10 v2v: Add a check before copying that UEFI is supported (RHBZ#1184690).
If UEFI is required by the guest, but not supported by the host, then
you wouldn't see an error message until after copying.

Add an additional method to the output object so we can check this
before copying, to avoid a long wait.

Thanks: Junqin Zhou
https://bugzilla.redhat.com/show_bug.cgi?id=1184690#c22
2015-07-06 12:37:23 +01:00
Richard W.M. Jones
74e87a970b v2v: -o libvirt: Add readonly=yes to UEFI <loader> attribute (RHBZ#1184690).
Thanks: Junqin Zhou for diagnosing the bug and finding the correct
solution.  https://bugzilla.redhat.com/show_bug.cgi?id=1184690#c22

This fixes commit 40558450dd.
2015-07-06 12:20:48 +01:00
Richard W.M. Jones
659d56db3c v2v: Catch real exception thrown by failing aug_get (RHBZ#1239053).
When converting the old Perl virt-v2v code, I made a silly mistake
with the exception that aug_get throws when it doesn't find any node.
It throws a 'Guestfs.Error' exception, not 'Not_found'.

As a result of this, the exception was escaping and the proper error
message was not displayed.  With a malformed grub configuration you
would see this error:

  $ virt-v2v -i disk centos-6.img -o null
  [...]
  virt-v2v: error: libguestfs error: aug_get: no matching node

After applying this patch:

  $ virt-v2v -i disk centos-6.img -o null
  [...]
  virt-v2v: error: no kernels were found in the grub configuration.

  This probably indicates that virt-v2v was unable to parse the grub
  configuration of this guest.

which is the correct error message.
2015-07-06 10:47:45 +01:00
Chen Hanxiao
a477e282db New API: set_uuid_random
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-07-03 11:31:41 +02:00
Richard W.M. Jones
db9bd61585 Version 1.29.49. 2015-07-02 18:06:15 +01:00
Richard W.M. Jones
ccdbbc7fe4 Fix various -Wformat problems.
Updating gnulib has caused -Wformat-signedness to be enabled.  This
has revealed many problems in C format strings.  The fixes here fall
into the following main categories:

 - Using %d with an unsigned parameter.

 - %x and %o expect an unsigned argument.

 - uid_t and gid_t are unsigned on Linux.  The safe way to print these
   is to cast them to uintmax_t and then print them using the %ju
   modifier (see http://stackoverflow.com/a/1401581).

 - Using %d to print an enum.  Since enums may be either char or int,
   I fixed this by casting the enum to int.

 - strtol_error & lzma_ret are both unsigned types.
2015-07-02 16:08:44 +01:00
Richard W.M. Jones
b263035c1a Update gnulib to latest. 2015-07-02 15:35:48 +01:00
Richard W.M. Jones
fba82456a9 Pull latest translations from Zanata. 2015-07-02 14:49:37 +01:00
Richard W.M. Jones
f5698c3793 v2v: TODO: Add note about -i ova / -o rhev and removable device slots. 2015-07-02 14:17:24 +01:00
Richard W.M. Jones
afd80a27ef v2v: Remove some items from TODO file which we've implemented. 2015-07-02 14:17:24 +01:00
Richard W.M. Jones
b7166e1a9e v2v: Add a regression test for RHBZ#1238053. 2015-07-02 14:17:23 +01:00
Richard W.M. Jones
309e14189f v2v: Pass target_buses to output object (RHBZ#1238053).
Pass the target_buses assignment to the output#create_metadata method.

Now output modes have a choice: they can either ignore the new
parameter and continue to use the flat list of targets.  This is
suitable for output modes that cannot model multiple buses (eg.
-o glance) or can model it but don't bother (currently -o rhev).

Or they can ignore the flat targets parameter and use the new
target_buses parameter, translating that into the appropriate list of
devices.  This is implemented in this commit for these modes:

 -o libvirt
 -o local
 -o qemu
2015-07-02 14:17:23 +01:00
Richard W.M. Jones
ce83f2751b v2v: Introduce the concept of target buses.
The target VM will have several buses to which disks can be attached.
Commonly it will have an IDE bus, and possibly a virtio-blk "bus" (not
really a bus) and/or a SCSI bus.

Virt-v2v does not model this at the moment.  Disks are just added to
the output XML in the order that we write them, and so they can move
around with respect to the target VM.

This commit introduces the idea that we should model the target disk
buses, and we should try to assign fixed and removable disks to slots
on each of those buses.  In this commit, the modelling is not used by
any output mode, but that will be fixed in the next commit.
2015-07-02 14:17:23 +01:00
Richard W.M. Jones
847c303a15 v2v: -i libvirt and -i ova: Record the slot number of removable drives.
When we see libvirt source XML for a removable drive like this:

   <disk type='file' device='cdrom'>
     <driver name='qemu' type='raw'/>
     <target dev='hdc' bus='ide'/>
   </disk>

as well as recording the bus (s_removable_controller) as we do at the
moment, also record the slot number (eg. hdc == 2 in the example
above).

Do the same for OVA input files.
2015-07-02 14:11:29 +01:00
Richard W.M. Jones
4ef80f28c8 v2v: Add a binding for guestfs_int_drive_index and a unit test. 2015-07-02 14:11:29 +01:00
Richard W.M. Jones
36e22d1e8e v2v: Add unit test of Utils.drive_name function. 2015-07-02 14:11:29 +01:00
Richard W.M. Jones
c8a9e4b928 v2v: Refactor ~printer parameter in unit tests.
Simple refactoring, no functional change.
2015-07-02 14:11:29 +01:00
Richard W.M. Jones
a54fef132a utils: Add guestfs_int_drive_index and unit test.
Add guestfs_int_drive_index which does basically the opposite of
guestfs_int_drive_name.  This commit also includes a unit test.
2015-07-02 14:11:29 +01:00
Richard W.M. Jones
625eae504d utils: Add a test of the guestfs_int_drive_name function.
This function didn't have a unit test before.
2015-07-02 14:11:29 +01:00
Pino Toscano
d9fc0656b2 tests: do not init a partition for btrfs-image tests
They create an own partition layout, so don't do that over the
testing-created layout.

At least for me, this fixes parted issues when creating the new
partition layout and the old one is still reported as in use.

Followup/fix for commit 52d1b0c593.
2015-07-02 11:25:06 +02:00
Chen Hanxiao
4e8ef1ae37 uuid: use newly introduced swap_set_uuid
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-07-02 11:08:52 +02:00
Chen Hanxiao
80cf46e110 uuid: add support to change uuid of btrfs partition
btrfs-progs v4.1 add support to change uuid of btrfs fs.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-07-02 11:08:42 +02:00
Pino Toscano
261be1f952 sysprep: rework and fix cron-spool operation (RHBZ#1229305)
When cleaning the directories with cron/at jobs, remove only files
there, as subdirectories might be used by other systems; for example
in Debian under /var/spool/cron/ there is the atjobs subdirectory with
the actual at queue.

Make sure to not remove .SEQ files anymore, as they represent the at job
counter which is needed by the at daemon. Instead, reset these files to
0.

Furthermore, add also the path to the .SEQ location in Debian-based
systems.
2015-07-01 17:17:58 +02:00
Pino Toscano
a614f3451d mllib: add and use last_part_of
Collect this small snippet to get the part of a string after the last
occurrency of a character; replace with it the current snippets doing
the same.

Should be just code motion.
2015-07-01 17:17:58 +02:00
Pino Toscano
775e68c461 mllib: add an optional filter for rm_rf_only_files
This way it is possible to use rm_rf_only_files, but not removing
specific files.
2015-07-01 16:36:25 +02:00
Richard W.M. Jones
9f0036a026 v2v: Match any non-"Client" variant, instead of just "Server" (RHBZ#1234351, RHBZ#1237869).
When checking if a Windows variant is a server variant, assume it is a
server variant unless the i_product_variant field is "Client".

Windows 2008 and Windows 2008R2 does not have an InstallationType key
in the registry at all, so for these the product variant is returned
as "unknown".

Windows "Core" would have, according to the reference below,
"Server Core".

https://msdn.microsoft.com/en-us/library/ee391629%28v=vs.85%29.aspx

This fixes commit 47b5f245be.
2015-07-01 11:14:23 +01:00
Richard W.M. Jones
a324ae2ad7 v2v: Fix detection of Win2008R2 drivers (RHBZ#1234351).
This fixes commit 47b5f245be.
2015-07-01 11:01:43 +01:00
Pino Toscano
e1e4d8648d tests: add/expand UUID and label tests for swap and xfs 2015-06-30 16:42:52 +02:00
Chen Hanxiao
d0c067df87 daemon: add get_random_uuid
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-06-30 15:54:57 +02:00
Chen Hanxiao
5166388914 uuid: use newly introduced xfs_set_uuid of xfs
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-06-30 14:48:12 +02:00
Chen Hanxiao
ad21fb8acf uuid: use existing function of ext2
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-06-30 14:48:06 +02:00
Chen Hanxiao
98e1e9bcc2 tests: fix two minor warnings
"my" variable $output masks earlier declaration in same scope at /home/libguestfs/tests/daemon/test-btrfs.pl line 66.
"my" variable @r masks earlier declaration in same scope at /home/libguestfs/tests/daemon/test-btrfs.pl line 72.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-06-30 11:08:32 +01:00
Richard W.M. Jones
2b67342bda Version 1.29.48. 2015-06-29 23:20:54 +01:00
Richard W.M. Jones
93cf45cadf tests: Add a test of btrfs-qgroup-show using the captive daemon. 2015-06-29 23:08:47 +01:00
Richard W.M. Jones
336b8f6b16 tests: Add a test of btrfs-subvolume-list using the captive daemon. 2015-06-29 23:08:47 +01:00
Richard W.M. Jones
f2438b75a2 tests: daemon: Cleanly shut down the daemon on exit.
This refines the previous commit by shutting down the daemon cleanly
at the end of the test (assuming the test was successful).  It
repurposes the 'internal_exit' API for this, which was previously used
by the now defunct --enable-valgrind-daemon functionality.
2015-06-29 23:08:46 +01:00
Richard W.M. Jones
9f85477cba tests: Add tests using a captive daemon process.
This allows us to test the daemon running as a host process, allowing
us to meaningfully test it using valgrind.

This commit only adds a single test that check that the daemon starts
up, can be pinged, and exits.
2015-06-29 23:08:46 +01:00
Richard W.M. Jones
8cb1a35d75 daemon: Move all the kernel command line parsing to the init script.
Instead of parsing /proc/cmdline from the daemon, move all of that
parsing into the init script, and pass the argument via the daemon
command line.

For example, previously the daemon and init script both looked for
guestfs_network=1 in /proc/cmdline.  Now the init script still looks
for it, and if found it runs `guestfsd --network'.
2015-06-29 23:08:43 +01:00
Richard W.M. Jones
64ff631127 daemon: Add -l / --listen flag.
This option, used for testing, causes the daemon to create the Unix
domain socket (from guestfs_channel), listen on it, and accept a
single connection.
2015-06-29 23:06:21 +01:00
Richard W.M. Jones
9e0e2247ff daemon: Add undocumented --test / -t option to enable test mode.
This is a catch-all mode for turning off daemon features which
interfere with our testing of the daemon.
2015-06-29 23:06:21 +01:00
Richard W.M. Jones
4b721a1e0b configure: Remove test for valgrind --vgdb option.
We'll now just require that valgrind is new enough.

As best as I can tell from the valgrind subversion(!) repository, this
option was added to valgrind in around 2011.
2015-06-29 23:06:21 +01:00
Richard W.M. Jones
3888582da8 v2v: Free XML objects in the correct order.
If you free an xmlDocPtr before any xmlXPathObjectPtrs that reference
the doc, you'll get valgrind errors like this:

  ==7390== Invalid read of size 4
  ==7390==    at 0x4EB8BC6: xmlXPathFreeNodeSet (xpath.c:4185)
  ==7390==    by 0x4EB8CC5: xmlXPathFreeObject (xpath.c:5492)
  ==7390==    by 0x400A56: main (in /tmp/test)
  ==7390==  Address 0x60c0928 is 8 bytes inside a block of size 120 free'd
  ==7390==    at 0x4C29D2A: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==7390==    by 0x4E8784F: xmlFreeNodeList (tree.c:3683)
  ==7390==    by 0x4E87605: xmlFreeDoc (tree.c:1242)
  ==7390==    by 0x400A4A: main (in /tmp/test)

The following simple test program demonstrates the problem:

  #include <stdio.h>
  #include <stdlib.h>
  #include <assert.h>
  #include <libxml/xpath.h>

  int
  main (int argc, char *argv[])
  {
    xmlDocPtr doc;
    xmlXPathContextPtr xpathctx;
    xmlXPathObjectPtr xpathobj;

    doc = xmlReadMemory ("<test/>", 7, NULL, NULL, XML_PARSE_NONET);
    assert (doc);
    xpathctx = xmlXPathNewContext (doc);
    assert (xpathctx);
    xpathobj = xmlXPathEvalExpression (BAD_CAST "/test", xpathctx);
    assert (xpathobj);
    xmlFreeDoc (doc);
    xmlXPathFreeObject (xpathobj);
    xmlXPathFreeContext (xpathctx);
    exit (EXIT_SUCCESS);
  }

In virt-v2v we were not freeing up objects in the correct order,
because we didn't express the dependency between objects at the C
level into the OCaml, where the OCaml garbage collector could see
those dependencies.  For example code like:

  let doc = ... in
  let xpathctx = xpath_new_context doc in
  let xpathobj = xpath_eval_expression xpathctx "/foo" in

might end up freeing the 'doc' (xmlDocPtr) if, say, there were no
further references to it in the code, even though the 'xpathobj'
(xmlXPathObjectPtr) remains live.

To avoid this, we change the OCaml-level representation of objects
like xpathobj so they contain a reference back to the higher-level
objects (xpathctx & doc).  Therefore holding an xpathobj means that
the doc cannot be freed.

However that alone is not quite sufficient.  There is a further
problem when the program calls Gc.full_major, Gc.compact etc., or even
just when xpathctx & doc happen to be freed at the same time.  The GC
won't necessarily free them in the right order as it knows both need
to be freed but doesn't know that one must be freed before the other.

To solve this we have to move the finalisers into OCaml code, since
the OCaml Gc.finalise function comes with an explicit ordering
guarantee (that finalisers are always called in reverse order that
they were created), which the C-level finaliser does not.
2015-06-29 19:59:59 +01:00
Cao jin
36a197e2cc New API: btrfs_replace
Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
2015-06-29 16:39:13 +02:00
Richard W.M. Jones
52ca4d5dd4 v2v: OVF: If actual_size field is estimated, add a comment to the output.
The 'note:' comment is added, as below:

  <Section xsi:type='ovf:DiskSection_Type'>
    <Info>List of Virtual Disks</Info>
    <!-- note: actual_size field is estimated -->
    <Disk ovf:actual_size='7' [...]/>
  </Section>
2015-06-29 10:43:42 +01:00
Richard W.M. Jones
801832e676 v2v: Increase the timeout of VMware curl connections (RHBZ#1146007).
On certain webservers these appear to go beyond even 600 seconds (10
minutes).
2015-06-29 10:43:42 +01:00
Richard W.M. Jones
800e501e1e v2v: test-harness: Build dependencies correctly. 2015-06-25 21:22:37 +01:00
Chen Hanxiao
1d58cd4e1d do_btrfs_subvolume_list: fix a bad return value
don't return a value which is to be freed.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-06-23 21:31:32 +01:00
Chen Hanxiao
268c425791 do_btrfs_qgroup_show: fix a bad return value
We should not use temporary lines buffer as return value,
for lines buffer will be freed.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-06-23 21:31:32 +01:00
Richard W.M. Jones
445d20c117 lib: Add optional 'append' parameter to copy-(device|file)-to-file APIs.
This allows you to append one file to another:

  copy-file-to-file /input.txt /output.txt append:true

will append the contents of /input.txt to /output.txt.
2015-06-23 21:31:31 +01:00
Richard W.M. Jones
47b5f245be v2v: Support loading virtio-win drivers from virtio-win.iso (RHBZ#1234351).
This makes several changes to the handling of virtio-win drivers:

The VIRTIO_WIN_DIR environment variable has been renamed
VIRTIO_WIN (but you can still use the old name).

You can point the VIRTIO_WIN either at a RHEL virtio-win directory
(ie. /usr/share/virtio-win), OR at a loopback-mounted virtio-win ISO,
OR at the virtio-win.iso file itself.  In the latter case, libguestfs
is used to open the ISO file and read drivers from it.

The code is more flexible about the pathnames of drivers, because the
paths in the ISO are completely different from the paths in RHEL
/usr/share/virtio-win.
2015-06-23 21:31:31 +01:00
Richard W.M. Jones
57ae2a5cc3 daemon: Rewrite prog_exists so it uses the actual PATH, not hard-coded list. 2015-06-23 21:31:31 +01:00
Cao jin
68ed6dd88a Modify the function: analyze_line, make it more flexible
Modify the function from a fixed delimiter to a variable. So,
it can be used in more APIs later. Also modified the existing
callers

Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
2015-06-23 13:28:31 +02:00
Chen Hanxiao
35710595c1 btrfs: remove redundant whitespace
s/  =/ =

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-06-23 11:51:40 +02:00
Richard W.M. Jones
a1f3404516 v2v: test-harness: Add Config module to library.
Missing dependency.
2015-06-22 18:49:10 +01:00
Richard W.M. Jones
158204529f appliance: Make uefi_firmware variable static.
It is not used outside the compilation unit.

This fixes commit 544a731482.
2015-06-22 18:09:22 +01:00
Richard W.M. Jones
029fc60ee5 launch: Refactor guestfs_int_get_cpu_model code.
Shorter and does the same thing.
2015-06-20 15:06:46 +01:00
Richard W.M. Jones
544a731482 aarch64: appliance: Use kraxel's edk2.git repo if available.
Gerd is making EDK2 builds available here:

https://www.kraxel.org/repos/

These are convenient for Fedora/aarch64 users, so use this firmware if
available.

This commit also refactors the UEFI searching code.
2015-06-20 15:05:39 +01:00
Chen Hanxiao
74f5bb17a1 btrfs: fix leak in btrfs_balance_status
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-06-19 11:26:59 +01:00
Pino Toscano
abf0df6884 v2v: remove unused sources and libraries 2015-06-18 18:22:27 +01:00
Pino Toscano
9f683fbf0f btrfs: fix leak in btrfs_scrub_status
Properly free the output buffer.
2015-06-18 14:04:43 +02:00
Richard W.M. Jones
d8ab90cdd6 Version 1.29.47. 2015-06-18 12:59:53 +01:00
Richard W.M. Jones
c4f8d1d1a3 v2v: Improve handling when one of the input disks is blank (RHBZ#1232192).
In commit 4c73d1d4f1, I changed the
behaviour of virt-v2v so it ignores all errors from the
g#part_get_parttype method.  However that would ignore I/O errors and
similar.

Only ignore the "unrecognised disk label" error from parted, by
testing if the return code is EINVAL.

This fixes commit 4c73d1d4f1.
2015-06-18 10:26:53 +01:00
Richard W.M. Jones
94ea635fb1 ocaml: Add handling for errno EINVAL. 2015-06-18 10:26:53 +01:00
Richard W.M. Jones
b467afb621 daemon: parted: Always use -s option even with -m.
See: https://bugzilla.redhat.com/show_bug.cgi?id=1232241#c3

However adding the -s parameter changes the error code returned by
parted when it processes a blank disk (or other unrecognized partition
table).  Without -s it prints an error but returns a non-error exit
code (0).  With -s it prints an error and returns an error exit code.

Because it's useful to be able to catch this case in user code, turn
"unrecognised disk label" into EINVAL.

Change virt-alignment-scan to catch this error and ignore it.
2015-06-18 10:26:46 +01:00
Chen Hanxiao
3ae5f72743 error log: keep more calloc and its error messages match
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-06-18 10:19:41 +01:00
Pino Toscano
6118e2239c daemon: add split_lines_sb
Mold split_lines_sb from split_lines, so it returns the strings buffer
with the result of the split. This way, we can have the number of lines
in the array, with no need to count them again later.

split_lines is rewritten to take the ownership of the result of
split_lines_sb.
2015-06-17 17:43:13 +02:00
Pino Toscano
23ac997d06 daemon: add take_stringsbuf 2015-06-17 17:43:13 +02:00
Pino Toscano
fd6a66fde4 daemon: add CLEANUP_FREE_STRINGSBUF 2015-06-17 17:43:13 +02:00
Pino Toscano
26a0ccdb4e daemon: introduce free_stringsbuf
Simple shortcut to easily cleanup a stringsbuf.
2015-06-17 17:43:13 +02:00
Chen Hanxiao
596b8f85a9 btrfs: use CLEANUP_FREE_STRING_LIST for list free
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-06-17 11:05:36 +02:00
Chen Hanxiao
9c24314f6f btrfs: keep calloc and its error message match
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-06-17 11:05:32 +02:00
Pino Toscano
3f4ba2e98d btrfs: use calloc instead of malloc+memset
Small optimization, and eases the code.
2015-06-16 17:31:43 +02:00
Pino Toscano
9574e793e2 btrfs: remove unused 'out' variables
If we are not interested in output of a command being run, then there's
no need to still capture it in a (automatically freed, but still)
variable.

If any of those outputs is needed, a variable for it can be easily added
back.
2015-06-16 17:07:47 +02:00
Pino Toscano
993140219c Improve fixed appliance documentation
Move the "FIXED APPLIANCE" section from
libguestfs-make-fixed-appliance(1) to the "INTERNALS" section of
guestfs(3), so it's more visible and less hidden in the documentation
of a rarely-used tool.  Also slightly improve it.

Expand the FAQ question about libguestfs without supermin, mentioning
the build options needed and pointing to the aforementioned new section.
2015-06-16 14:57:19 +02:00
Chen Hanxiao
d11857aa87 guestfs.pod: fix a typo
s/caling/calling

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-06-16 14:57:19 +02:00
Richard W.M. Jones
4c73d1d4f1 v2v: Don't fail if one of the input disks is blank (RHBZ#1232192).
This also adds a regression test since it is probably easy to break
this in future.

Thanks: Junqin Zhou
2015-06-16 12:24:34 +01:00
Pino Toscano
99dc53bba7 resize: make available expand method warnings more prominent
When hitting a filesystem which we cannot or don't know how to expand,
instead of print a warning in verbose mode only, print it always when
showing the summary of the changes.

In the virt-resize documentation, add a paragraph about this warning.

Thanks to: Luigi Toscano.
2015-06-15 18:15:40 +02:00
Pino Toscano
54c7d3f61e get-kernel: add --prefix
New --prefix option to specify a prefix for the extracted file names.
2015-06-15 18:07:52 +02:00
Pino Toscano
cdb1e6eeca get-kernel: add --unversioned-names
New --unversioned-names option to save extracted files just with their
base name (i.e. "vmlinux", "initrd.img").
2015-06-15 18:07:52 +02:00
Pino Toscano
1183809f4d (Almost) new tool: virt-get-kernel
Extract the guest kernel/ramdisk extraction from virt-builder into a
separate utility, so it can be used and improved without cluttering
virt-builder.

Currently it does what virt-builder --get-kernel did, adding also the
options for remote disks and libvirt access, much like other libguestfs
tools.

virt-builder --get-kernel now just spawns virt-get-kernel.
2015-06-15 18:07:03 +02:00
Richard W.M. Jones
533901409e pod: Use F<> for filenames instead of C<>.
Done using a sequence of regular expressions like this:

  perl -pi.bak -e 's{C</}{F</}g' `git ls-files \*.pod` generator/actions.ml
  perl -pi.bak -e 's{C<C:\\}{F<C:\\}g' `git ls-files \*.pod` generator/actions.ml
  [etc]

and then tediously checking every change by hand.
2015-06-15 15:42:46 +01:00
Richard W.M. Jones
47e9a3d739 FAQ: Add sections about libguestfs NTFS & XFS support.
Both popular questions.
2015-06-14 16:35:52 +01:00
Richard W.M. Jones
dafb4bf283 v2v: Document 7B boot problems with Windows Group Policy. 2015-06-13 22:21:28 +01:00
Richard W.M. Jones
54fe6d369d p2v: Add proper test for command line parsing.
This also adds a couple of deliberately undocumented (and unsupported)
command line parameters to make testing simpler:

p2v.skip_test_connection  - don't try to test the connection
p2v.dump_config_and_exit  - after parsing command line, print it and exit

This updates commit 716244c337.
2015-06-10 14:06:03 +01:00
Richard W.M. Jones
a716adac35 p2v: Make sure command is printed before running it.
This updates commit b45f6a0435.
2015-06-10 14:04:49 +01:00
Richard W.M. Jones
4c8bbc45be p2v: Refactor code that dumps the configuration for debugging.
This is just code motion.
2015-06-10 14:03:43 +01:00
Richard W.M. Jones
bb5b23c151 p2v: Fix parsing of p2v.memory parameter (RHBZ#1229262).
The sscanf call always failed because we checked for the wrong return
code.

We don't need to allocate two characters for the mem_code field since
sscanf doesn't append a nul byte.

This commit also allows you to use lowercase 'm' or 'g' as a memory
unit.

Also clarify the documentation: the memory unit must be given.
2015-06-10 13:39:26 +01:00
Richard W.M. Jones
b45f6a0435 p2v: Add p2v.pre, p2v.post, p2v.fail commands (RHBZ#1229385).
The default p2v.post command, when run from the ISO, is to poweroff
the machine after successful conversion.
2015-06-09 18:17:04 +01:00
Richard W.M. Jones
716244c337 p2v: Correct parsing of /proc/cmdline, including quoting.
Fix the parsing of /proc/cmdline, including allowing double quoting of
parameters.

This allows you to pass parameters to p2v on the command line which
include spaces.
2015-06-09 18:17:04 +01:00
Richard W.M. Jones
154251b3f0 p2v: Modify /etc/issue with clearer instructions. 2015-06-09 15:27:55 +01:00
Richard W.M. Jones
cca4343203 p2v: Update documentation.
- How to configure virt-p2v for PXE boot.

- How to test PXE boot using qemu.
2015-06-09 15:27:55 +01:00
Richard W.M. Jones
fc554d422a p2v: Chomp kernel command line (fix) (RHBZ#1229340).
Calculate the length of the string, not the length of the buffer.

This fixes commit 6114c10df0.
2015-06-09 15:27:55 +01:00
Pino Toscano
aa50d02f36 builder: add a doc snippet about firstboot scripts
Document basic information about them for Linux and Windows guests.
2015-06-09 15:30:16 +02:00
Pino Toscano
d8f1962bd2 podwrapper: simplify external references pointing to self
When convering a POD documentation, possibily combining various
sub-documents together, simplify the L<> links that explicitly point to
the very same documentation being generated.

For example, when generating the virt-builder documentation, links like
  L<virt-builder(1)/SECTION>
will be turned into
  L</SECTION>
thus not making Pod::Simple parse them as external reference.

While it is a slightly crude hack, it seems there's no easy way to
process the link parsing with Pod::Simple subclasses.
2015-06-09 10:54:13 +02:00
Richard W.M. Jones
6114c10df0 p2v: Chomp kernel command line (RHBZ#1229340).
When using the kernel command line to configure virt-p2v, if any p2v.*
parameter appeared right at the end of the kernel command line, then a
bogus \n would be appended.  Remove this.

This is essentially the same fix as:
4819655b3c
2015-06-08 14:49:22 +01:00
Richard W.M. Jones
9b9be6d1c6 Version 1.29.46. 2015-06-06 18:34:15 +01:00
Richard W.M. Jones
61ac4233b5 Update translations from Zanata. 2015-06-06 18:32:38 +01:00
Nikos Skalkotos
4f020682ee Use safe_realloc() in favor of realloc overall. 2015-06-06 14:30:29 +01:00
Chen Hanxiao
7429b6b261 sysprep_operation: fix a typo
s/rathern/rather

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-06-06 14:21:34 +01:00
Richard W.M. Jones
47a15da2e7 lib: command: Fix leak in the per-child-process rlimit structures.
This fixes commit 9db0f807a9.

Bug found by valgrind.
2015-06-06 14:08:34 +01:00
Richard W.M. Jones
8b1b3a10b3 fuse: Use SKIP_TEST_FUSE_SH consistently.
This fixes commit 96a02f0864.
2015-06-06 14:08:24 +01:00
Richard W.M. Jones
4ce94cede6 proto: Don't set g->last_errnum directly.
I'm trying to think if there was any reason why we would have set
g->last_errnum directly instead of using the proper function
(guestfs_int_error_errno), but I cannot think of one.

Since error (g, ...) is just a macro that calls
guestfs_int_error_errno (g, 0, ...), this code is equivalent.
2015-06-06 14:07:14 +01:00
Richard W.M. Jones
34439a04f1 appliance: Make sure /tmp and /var/tmp are real directories.
Currently if /tmp (on the host) is a symlink, then the symlink is
copied into the appliance, probably pointing to a non-existent
directory, and everything goes downhill from there.

Avoid this by making sure that /tmp and /var/tmp are real directories.
2015-06-06 14:04:40 +01:00
Nikos Skalkotos
ee87fdaf8f inspector: tests: Enable the Arch Linux test 2015-06-03 18:59:44 +01:00
Pino Toscano
fa80f88c9c mllib: use Unix.gettimeofday instead of Unix.time
Unix.gettimeofday returns a finer resolution than seconds, which is what
we need since deciseconds of timestamps are printed.
2015-06-03 16:13:43 +02:00
Richard W.M. Jones
14a8461a5c Version 1.29.45. 2015-06-02 17:43:02 +01:00
Pino Toscano
1ff463e869 inspection: fix CentOS 7 detection
In newer CentOS 7 versions /etc/redhat-release says that the distro is
derived from RHEL, so we need to look at /etc/centos-release for
actually identifying it as CentOS.

The old code is needed as sub-case of /etc/redhat-release, as on
CentOS < 7 that file is a symlink to /etc/centos-release.
2015-06-02 17:43:02 +01:00
Pino Toscano
a50af9e148 inspection: lift size limit for RHEL icons
In RHEL-based distros, the provided icons have (obviously) different
sizes than the RHEL ones, used in icon_rhel as reference.

Since 100K should be a reasonable threshold for avoid keeping a
per-distro list of limits, just use it as only size limit.
2015-06-02 17:43:02 +01:00
Nikos Skalkotos
25ca08f490 Add tests for CoreOS
Signed-off-by: Nikos Skalkotos <skalkoto@grnet.gr>
2015-06-02 17:40:01 +01:00
Nikos Skalkotos
8cc36215f9 inspection: Add support for CoreOS
* Implement coreos distro
* Detect CoreOS images

Signed-off-by: Nikos Skalkotos <skalkoto@grnet.gr>
2015-06-02 17:40:01 +01:00
Nikos Skalkotos
721cd0d66e inspection: Add func for merging fs inspections
Add a new guestfs_int_merge_fs_inspections() function that merges the OS
inspection information of two inspect_fs instances into one. This
function is useful if the inspection information for an OS are gathered
by inspecting multiple filesystems.

Signed-off-by: Nikos Skalkotos <skalkoto@grnet.gr>
2015-06-02 17:40:01 +01:00
Richard W.M. Jones
467cd4b760 p2v: Introduce a common file to store virt-p2v ISO dependencies.
Instead of having virt-p2v-make-disk and virt-p2v-make-kickstart
separately contain a list of the virt-p2v ISO dependencies, combine
the dependencies into a single file ('p2v/dependencies.m4') and use
that to generate the respective dependencies in each script.
2015-06-02 16:27:13 +01:00
Richard W.M. Jones
3e9a0fac14 p2v: Set status to "Conversion cancelled by user" when user cancels (RHBZ#1226794).
Thanks: Tingting Zheng.
2015-06-02 13:51:47 +01:00
Richard W.M. Jones
2dc88ba8cb FAQ: Document using libguestfs to access live guest disk images.
Gets asked on the mailing list several times a year.
2015-06-01 11:58:22 +01:00
Richard W.M. Jones
0bf4be64ee v2v: -o libvirt: Remove unnecessary comment. 2015-05-31 22:30:18 +01:00
Richard W.M. Jones
2e2f016ce9 v2v: Add a <!-- generated by .. --> comment in output XML files. 2015-05-31 22:22:20 +01:00
Richard W.M. Jones
284d220091 v2v: OVF: Add comment that 'IsInitilized' is not a typo. 2015-05-31 21:49:49 +01:00
Richard W.M. Jones
98e40a0cc8 perl: XML::XPath and XML::XPath::XMLParser are not required. 2015-05-29 15:07:31 +01:00
Pino Toscano
c31c077aa5 java: doc: add the version (if available) of APIs 2015-05-28 16:47:21 +02:00
Pino Toscano
db1b0bc508 ocaml: doc: add the version (if available) of APIs
Make sure to not add more newline's than needed.
2015-05-28 16:47:21 +02:00
Pino Toscano
0a18465c23 gobject: doc: add the version (if available) of APIs 2015-05-28 16:47:21 +02:00
Pino Toscano
fc1f6deab1 generator: move api_version to a common version_added
This way the version string of each API can be used also in other
generator modules.

Mostly code motion, no actual behaviour changes.
2015-05-28 16:47:21 +02:00
Maros Zatko
33d2b4a734 inspector: recognize ppc64 and ppc64le archs (RHBZ#1211996) 2015-05-28 12:49:04 +01:00
Richard W.M. Jones
0645cd3655 builder: Add Fedora 22 (armv7l) image. 2015-05-27 21:26:01 +01:00
Richard W.M. Jones
c0e7bb5ef2 builder: armv7l: Fix build script for Fedora 22 release.
(The same change as was made in
commit c4a54e00a3).
2015-05-27 17:36:49 +01:00
Richard W.M. Jones
54f54697b9 Version 1.29.44. 2015-05-26 21:47:42 +01:00
Richard W.M. Jones
41ce78f02e builder: Add Fedora 22 aarch64 image. 2015-05-26 21:13:44 +01:00
Richard W.M. Jones
9db0f807a9 lib: Limit space and time used by 'qemu-img info' subprocess.
After fuzzing 'qemu-img info' I found that certain files can cause the
command to use lots of memory and time.  Modify the command
mini-library to allow us to place resource limits on subprocesses, and
use these to limit the amount of space and time used by 'qemu-img info'.
2015-05-26 21:13:44 +01:00
Richard W.M. Jones
9c773962c5 Remove src/api-support and generate this information from actions added field. 2015-05-26 21:13:44 +01:00
Richard W.M. Jones
b59c81d9e8 generator: Check 'added' field is set for each API. 2015-05-26 20:21:16 +01:00
Richard W.M. Jones
8816f06cdc generator: Move version first added to generator.
This change was generated automatically using the following Perl
script, with a few hand corrections afterwards.

use strict;
my %map;
open ADDED, "src/api-support/added" or die "added: $!";
while (<ADDED>) {
    chomp;
    if (/^guestfs_(.*)_(argv|va|opts) /) {
        # ignore _argv, _va, _opts entries.
    }
    elsif (/^guestfs_(compare|copy)_/) {
        # ignore guestfs_compare_*, guestfs_copy_* struct functions.
    }
    elsif (/^guestfs_(.*) [01]\.(\d+)\.(\d+)$/) {
        $map{$1} = [1, $2, $3];
    }
    elsif (/^guestfs_(.*) 0\.(\d+)$/) {
        $map{$1} = [0, 0, $2];
    }
    else {
        die "cannot parse line: `$_'\n"
    }
}
close ADDED;
open ACTIONS, "generator/actions.ml" or die "actions.ml: $!";
open ACTIONS_OUT, ">generator/actions.ml.out" or die "actions.ml.out: $!";
while (<ACTIONS>) {
    chomp;
    if (/name = "(.*)";$/ && exists $map{$1}) {
        my @v = @{$map{$1}};
        $_ .= sprintf (" added = (%d, %d, %d);", $v[0], $v[1], $v[2]) ;
        delete $map{$1};
    }
    print ACTIONS_OUT "$_\n";
}
close ACTIONS_OUT;
close ACTIONS;
2015-05-26 20:21:16 +01:00
Richard W.M. Jones
d0d492def2 generator: Add 'added' (version when added) field. 2015-05-26 20:21:16 +01:00
Richard W.M. Jones
41cf78f36b Update API support. 2015-05-26 20:21:16 +01:00
Richard W.M. Jones
a59fc8ee32 api-support: Ignore guestfs_impl_* symbols. 2015-05-26 20:21:15 +01:00
Richard W.M. Jones
c919f6f75c api: Don't truncate /dev/stdout or /dev/stderr when used as FileOut.
In APIs such as guestfs_download, when the FileOut parameter exactly
matches "/dev/stdout" or "/dev/stderr", don't reopen the possibly
redirected output file with O_TRUNC (truncate).  Instead dup the file
descriptor.

This magic behaviour doesn't happen for /dev/fd/* (or any other output
file) allowing callers the choice of using /dev/stderr or /dev/fd/2
depending on whether or not they want truncation.

This works around an annoying virt-builder bug.  If you do:

  $ virt-builder fedora-21 --install no_such_package -v -x >& /tmp/log

then when the `--install' command fails, virt-builder will download
the log file using `guestfs_download (g, log, "/dev/stderr")'.  Since
this truncates the redirected /dev/stderr, the final log file is
truncated and corrupted.

With this patch the log file is no longer corrupted.
2015-05-26 20:21:15 +01:00
Richard W.M. Jones
c4a54e00a3 builder: aarch64: Fix build script for Fedora 22 release. 2015-05-26 20:21:15 +01:00
Richard W.M. Jones
aa4dee7b7c builder: Add Fedora 22 image. 2015-05-26 20:21:15 +01:00
Richard W.M. Jones
aa7fa1cf00 v2v: RHEL 7 virt-v2v conversion server requires virtio-win. 2015-05-21 21:58:08 +01:00
Richard W.M. Jones
3a63ee2aaf v2v: Fix confusion over rhel-7 virt-v2v conversion server / appliance.
This fixes commit 4c7fb62f4a
and updates commit 4e4ece5364.
2015-05-20 07:40:22 -04:00
Richard W.M. Jones
10cb9b9545 p2v: Force systemd default target to be multi-user (text mode). 2015-05-19 17:41:16 +01:00
Richard W.M. Jones
f6dd8a3221 p2v: Explicitly depend on nm-connection-editor.
Previously it was only being pulled in implicitly.  However virt-p2v
runs this binary from the "Configure Network" button.

This fixes commit e464774a79.
2015-05-19 17:32:16 +01:00
Richard W.M. Jones
63cd28974e p2v: kickstart: Try harder to stop systemd from renaming network devices. 2015-05-19 14:44:32 +01:00
Chen Hanxiao
0fbe8fb3e0 resize: add sector size in debug_partition
This patch will add fields of sector size for:
  - partition sector data size
  - target partition sector data size

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-05-18 13:36:53 +01:00
Richard W.M. Jones
ce9f059dce Version 1.29.43. 2015-05-15 21:16:38 +01:00
Richard W.M. Jones
58c24a6bf8 builder: sigchecker: Fix error message.
Error messages are automatically wrapped, and don't require a newline
at the end.
2015-05-15 20:34:28 +01:00
Richard W.M. Jones
ef4f0fc8f9 sparsify: Use message function instead of printf. 2015-05-15 20:30:43 +01:00
Richard W.M. Jones
f2aa9261a8 ocaml tools: Translate a few messages which were not internationalized. 2015-05-15 19:10:28 +01:00
Richard W.M. Jones
59228c39b1 ocaml tools: Use global variable to store quiet (--quiet) flag.
Don't pass this flag to dozens of functions.

This change is analogous to the change made in
commit 79fc6074a7 for the -v & -x flags.
2015-05-15 19:08:36 +01:00
Richard W.M. Jones
71854a56c1 builder: Remove a few unnecessary 'virt-builder' strings from error messages. 2015-05-15 15:26:11 +01:00
Richard W.M. Jones
a43e8405ef customize: Allow --selinux-relabel flag to work on cross-architecture builds (RHBZ#1212807). 2015-05-15 15:18:20 +01:00
Richard W.M. Jones
8864c47b94 customize: Give a clear error message if host_cpu not compatible with guest arch.
In cases where we are asked to run commands in the guest (eg.  options
such as --run-command or --install), give a clear error in the cases
where the guest arch is not compatible with the host arch.

Similar code existed in virt-builder, but I have removed that.  Users
will still get an error message, it will just happen a bit later on.

There is a slight change in semantics here, in that architectures are
no longer normalized when matching, but that's probably fine since
`virt-builder -l' prints the exact arch string that people should use.
2015-05-15 15:18:20 +01:00
Richard W.M. Jones
ab7197476d ocaml tools: Only tell people to use -v -x if they're not already set (RHBZ#1167623).
When you get an error in tools, it will print a message like:

  If reporting bugs, run virt-v2v with debugging enabled and include the
  complete output:

    virt-v2v -v -x [...]

Only print this message if -v or -x were not already specified on the
command line.
2015-05-15 15:18:19 +01:00
Richard W.M. Jones
79fc6074a7 ocaml tools: Use global variables to store trace (-x) and verbose (-v) flags.
Don't pass these flags to dozens of functions.
2015-05-15 15:18:19 +01:00
Richard W.M. Jones
e35605ad8d ocaml tools: Define Common_utils.prog and don't pass it to every function.
This large commit is just code refactoring.  Instead of having
every OCaml tool define 'prog' the same way, always as:

  let prog = Filename.basename Sys.executable_name

move that into a single place, Common_utils.prog.  Then we can use
that global value everywhere else, instead of having to pass it as a
parameter into a dozen different functions.
2015-05-15 15:18:19 +01:00
Richard W.M. Jones
a255e283d0 resize: Remove unnecessary 'prog' from error message.
The common error function already prints the program name, so
we don't need to print it twice.

Before:

  $ virt-resize --expand ""
  virt-resize: error: virt-resize: empty --expand option

After:

  $ virt-resize --expand ""
  virt-resize: error: empty --expand option
2015-05-15 15:18:19 +01:00
Richard W.M. Jones
7800fbda19 builder: Fix expand partition for fedora-21 armv7l image.
Thanks: d.marlin
2015-05-15 10:09:25 +01:00
Richard W.M. Jones
0833c192b6 p2v: Display network card MAC address and vendor in conversion dialog (RHBZ#855059).
This displays the MAC address and vendor next to each network
interface, aiding users in determining which network cards they want
to transfer to the virtualized machine.
2015-05-14 13:57:41 +01:00
Richard W.M. Jones
5bf7f770b6 When calling getline first time, initialize length to zero.
The man page for getline says:

   ssize_t getline(char **lineptr, size_t *n, FILE *stream);
 [...]
   If  *lineptr  is set to NULL and *n is set 0 before the call, then get‐
   line() will allocate a buffer for storing the line.  This buffer should
   be freed by the user program even if getline() failed.

which seems to indicate that we must initialize both line and len to 0
before the first call to getline.

In several places we were not initializing len.  The program still
worked fine, but it seems better to initialize the length anyway.
2015-05-14 13:22:00 +01:00
Chen Hanxiao
7eb1ed8cb4 resize: show sector infor in debug_partition
Show partition sector data and target partition sector data
in debug_partition.
Also, if --verbose, call debug_partition again before
parted partitions.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>

RWMJ: Changed ~sectsize:sectsize => ~sectsize
2015-05-14 12:22:21 +01:00
Richard W.M. Jones
6574134feb Version 1.29.42. 2015-05-14 10:49:53 +01:00
Richard W.M. Jones
82cc8a8f8f build: Add ocaml-link.sh to EXTRA_DIST.
This fixes commit 13dd632301.
2015-05-14 10:49:24 +01:00
Pino Toscano
fd85a2a22b mllib: link tests with automake
Add a dummy C source, otherwise automake tries to look for e.g.
common_utils_tests.c.

Also, set check_PROGRAMS properly with them.
2015-05-13 16:45:41 +02:00
Pino Toscano
13dd632301 build: factor out the OCaml link.sh scripts
Create a single ocaml-link.sh script, which supports a -cclib parameter
so it can be used instead of the per-project link.sh scripts.
As result, the libraries for each OCaml application can be moved back to
each Makefile.am.
2015-05-13 15:30:39 +02:00
Pino Toscano
0e5ccabd83 configure: simplify check for oUnit v2
Instead of parsing the version, try to look for the OUnit2 module within
the oUnit package.

Followup of commit 46bc79109b.
2015-05-13 10:42:13 +02:00
Richard W.M. Jones
85347e32e0 v2v: Close libvirt connection after fetching libvirt capabilities.
Memory leak found by valgrind.

This fixes commit e7833a5eea.
2015-05-12 22:19:08 +01:00
Richard W.M. Jones
96a02f0864 fuse: Add more consistent SKIP_* environment variables.
The new behaviour is as follows:

Skip all of the fuse tests:

  SKIP_TEST_FUSE_SH=1

Individual tests can be skipped by setting:

  SKIP_TEST_FUSE_UMOUNT_RACE_SH=1
  SKIP_TEST_GUESTMOUNT_FD=1
  SKIP_TEST_GUESTUNMOUNT_FD=1
  SKIP_TEST_GUESTUNMOUNT_NOT_MOUNTED_SH=1
2015-05-12 11:48:44 +01:00
Pino Toscano
41df8a2c46 builder: enable batch mode when validating non-verbose (RHBZ#1180170)
When running gpg to validate a signature, use also --batch in
non-verbose mode to avoid the extra "Good signature" messages that are
printed by gpg2 even in quiet mode.
We are parsing the status output anyway to check the validation result,
so this should be harmless (and the full gpg output is printed in
verbose mode anyway).
2015-05-12 09:13:34 +02:00
Pino Toscano
6442bcb7eb builder: trust the imported keys
In every SigChecker, trust by default the keys imported.
This should make gpg happier when using the keys later, used only when
validating the signatures of index files.
2015-05-12 09:13:34 +02:00
Pino Toscano
a1a165e3c4 builder: move gpg status parsing within import_keyfile
Parse the gpg status output directly within import_keyfile, returning
just the key fingerprint.

Just code motion, no actual behaviour changes.
2015-05-12 09:13:34 +02:00
Richard W.M. Jones
46bc79109b configure: Ensure oUnit version >= 2 before using it.
This fixes commit e12c0dfe1f.
2015-05-11 20:44:22 +01:00
Richard W.M. Jones
e9ea21b27d Version 1.29.41. 2015-05-11 13:22:24 +01:00
Richard W.M. Jones
43e3a4e37f v2v: Add v2v_unit_tests.ml to EXTRA_DIST.
This fixes commit e12c0dfe1f.
2015-05-11 13:21:56 +01:00
Richard W.M. Jones
e12c0dfe1f v2v: OVF: Add unit tests for modified OVF.get_ostype function.
This adds unit tests for commit 6f9d5dce47.
2015-05-11 10:38:22 +01:00
Richard W.M. Jones
936ddfbb38 mllib: Require OUnit2 for tests.
OUnit2 has an OUnit (v1) compatibility module.  Unfortunately it
is rather gravely broken:
https://forge.ocamlcore.org/tracker/?func=detail&aid=1392&group_id=162&atid=730

Since there is no new release fixing this, it's easier to switch to
using OUnit2 for unit tests.
2015-05-11 10:26:53 +01:00
Richard W.M. Jones
6f9d5dce47 v2v: OVF: Fix list of operating system variants for RHEV >= 3.3 (RHBZ#1219857).
Since RHEV 3.3, OS variant names like "RHEL6x64" were deprecated and
replaced by names like "rhel_6x64".  "RHEL7x64" was never valid, and
we should have used "rhel_7x64".  "Windows2012R2x64" was also never
valid and should have been "windows_2012R2x64".

For backwards compatibility, RHEV still understands the old names, and
we still pass them for compatiblity with old RHEV.

However for the new OS variants supported by virt-v2v in RHEL 7.2, use
the new names.

This commit also adds support for SLES and ppc64.

This updates commit 3c51302d69
and also RHBZ#1213324.
2015-05-10 16:15:56 +01:00
Richard W.M. Jones
61a021713e p2v: Update documentation for Configure network button.
This updates commit e464774a79.
2015-05-09 17:59:26 +01:00
Richard W.M. Jones
35efaf8208 p2v: Add tip about the root password of the virt-v2v conversion server appliance. 2015-05-09 17:53:57 +01:00
Richard W.M. Jones
a3edef9295 v2v: Remove obsolete README.RHEV-M file. 2015-05-09 17:41:57 +01:00
Richard W.M. Jones
4c7fb62f4a v2v: Rename virt-v2v appliance to "conversion server".
This is for consistency with the rest of the documentation.

This commit also adds the files to EXTRA_DIST so they are shipped in
the tarball.

This updates commit 4e4ece5364.
2015-05-09 17:40:42 +01:00
Richard W.M. Jones
4e4ece5364 v2v: Add scripts for building RHEL 7 virt-v2v appliance. 2015-05-08 15:46:11 +01:00
Richard W.M. Jones
4f489b28fe Try to discourage people from using 'make install' because it causes
endless support troubles.
2015-05-07 22:19:13 +01:00
Richard W.M. Jones
dcd382d9d4 Version 1.29.40. 2015-05-06 17:10:07 +01:00
Richard W.M. Jones
e464774a79 p2v: Add Configure Network button (RHBZ#1167921).
The old version of virt-p2v had a whole custom-written dialog which
interacted with NetworkManager over dbus.  After trying that approach,
it's really complex to get right.

Instead this button simply opens NetworkManager's connection editor.

This also adds nm-applet to the disk and starts it.  However nm-applet
does not display any visible indication -- probably because we are
lacking a system tray.
2015-05-06 16:20:36 +01:00
Richard W.M. Jones
9b2ca08ab5 p2v: Switch from matchbox-window-manager to metacity.
Matchbox only supports a single window on screen.  This worked fine
until we added the NetworkManager connection dialog -- which tries to
open in a new top level window, and of course fails.

Metacity supports multiple top-level windows so doesn't suffer this
problem.

Apart from that it's hard to tell the difference between the two.
2015-05-06 15:14:04 +01:00
Richard W.M. Jones
d5305c9672 p2v: Use "About virt-p2v [VERSION]" on the about button.
This makes it clearer what the button does.

This updates commit a743f57cb8.
2015-05-05 21:02:27 +01:00
Richard W.M. Jones
badfc2e9b2 v2v: -o libvirt: Check if the domain exists on the target (RHBZ#889082). 2015-05-05 20:14:15 +01:00
Richard W.M. Jones
e7833a5eea v2v: Add a C function to fetch libvirt hypervisor capabilities.
Instead of having to run external 'virsh capabilities' command and
parsing the output.
2015-05-05 15:55:53 +01:00
Richard W.M. Jones
1189d5919e p2v: Warn if vcpus or memory would be larger than supported by RHEL (RHBZ#823758).
Display a warning if the number of vCPUs or memory selected in the GUI
would be larger than the limits currently supported on RHEL 6 and RHEL 7.

This is just a warning -- the user is free to ignore it and continue
anyway.

This warning does not apply if the selections were made through the
kernel command line, because there is no place to display the warning
for automated conversions.
2015-05-05 15:10:27 +01:00
Richard W.M. Jones
b1336f26e6 p2v: Factor out code for parsing vcpus & memory from conversion dialog.
No functional change, just code refactoring.
2015-05-05 15:09:33 +01:00
Richard W.M. Jones
ed19af781f tests/data: Add IA64 (Intel Itanium II) test binaries. 2015-05-03 14:58:59 +01:00
Richard W.M. Jones
f1b7e1b58b Version 1.29.39. 2015-05-02 09:21:47 +01:00
Richard W.M. Jones
4f414c7299 v2v: docs: General updates to the manual. 2015-05-01 22:19:58 +01:00
Richard W.M. Jones
9246d75eeb v2v: docs: Replace "VMware ESX" with more accurate VMware vCenter/ESXi.
"VMware ESX" is no longer a VMware product.  The hypervisor is
called VMware ESXi and the management software is VMware vCenter.
2015-05-01 22:19:30 +01:00
Richard W.M. Jones
1b74e90de8 tests/data: Add ppc64/ppc64le binaries to the test ISO.
This fixes commit 58bbb93a25.
2015-05-01 14:30:46 +01:00
Richard W.M. Jones
ac04939309 tests/data: Add mipsel (32 bit MIPS little endian) test binaries. 2015-05-01 14:29:23 +01:00
Richard W.M. Jones
40558450dd v2v: efi: Support output of UEFI guests, for some output drivers (RHBZ#1184690).
Add the Types.target_firmware type, which stores our final decision
for whether the guest requires BIOS or UEFI on the target.

Not all output modes support UEFI.  In order to fail as early as
possible if conversion isn't going to be possible, there is an
output#supported_firmware method which returns the list of supported
target_firmware.

Add the target_firmware parameter to output#create_metadata so it can
select the correct firmware in the final metadata.
2015-04-30 17:40:21 +01:00
Richard W.M. Jones
086f71c7d8 v2v: Dump inspect and guestcaps structs when running in verbose mode.
This helps with debugging.
2015-04-30 17:40:21 +01:00
Richard W.M. Jones
6a76d6d780 v2v: efi: Detect if the guest could boot with UEFI.
Use a heuristic to detect if the guest could boot with UEFI.

This is only used where we have missing metadata (in the
source.s_firmware == UnknownFirmware case).  Currently that only
applies for `-i disk' and `-i libvirt/libvirtxml'.

Eventually we'll be able to get this information from the libvirt
metadata (RHBZ#1217444), so it'll only be used for `-i disk'.
2015-04-30 17:38:49 +01:00
Richard W.M. Jones
ef77725081 v2v: efi: Model firmware in source metadata.
Also modify the input_* drivers so they pull out the firmware from the
metadata.  Currently this is only possible for `-i ova', since libvirt
does not expose it (RHBZ#1217444).
2015-04-30 17:38:49 +01:00
Richard W.M. Jones
9a45508f23 v2v: efi: linux: Add support for grub2-efi. 2015-04-30 17:38:48 +01:00
Richard W.M. Jones
051f1f1a3f v2v: efi: linux: Remove EFI hacks.
Old virt-v2v had a bunch of code for removing EFI configuration from a
Linux guest, and replacing it with grub.  I copied this code to new
virt-v2v but it was never tested.

Now that OVMF exists, we can simply boot EFI guests directly on KVM.

Thus these hacks can finally be removed.
2015-04-30 17:38:32 +01:00
Richard W.M. Jones
06e93bf3ea mips: Ignore missing prototypes in flex-generated code. 2015-04-30 11:20:45 +01:00
Pino Toscano
1f514f3466 inspector: fix formatting of xpath result (RHBZ#1212680)
Discard blank nodes when reading the XML from stdin, while enabling
formatting in output nodes.
2015-04-29 14:57:22 +02:00
Pino Toscano
22686d2cfd customize: add a "touch" operation (RHBZ#1212808) 2015-04-28 15:22:45 +02:00
Richard W.M. Jones
63e0045926 builder: Fix release notes for Debian 8.
Editing inittab is not required for this version since it
uses systemd.

This fixes commit be81fbb323.
2015-04-28 10:01:42 +01:00
Richard W.M. Jones
be81fbb323 builder: Add Jessie (Debian 8). 2015-04-28 09:39:27 +01:00
Richard W.M. Jones
21764ec7c2 Version 1.29.38. 2015-04-27 20:29:37 +01:00
Richard W.M. Jones
b70aec11c6 random_seed: Don't try to create random seed if no parent directory.
Partial fix for https://bugzilla.redhat.com/show_bug.cgi?id=1215803
2015-04-27 20:28:26 +01:00
Richard W.M. Jones
2841400721 firstboot: Don't create very long filenames for --firstboot-command (RHBZ#1212152). 2015-04-27 16:19:33 +01:00
Richard W.M. Jones
aa8d66e755 firstboot: Factor out regular expression constant.
Don't need to evaluate this every time we call the function.
2015-04-27 16:19:33 +01:00
Pino Toscano
8c26ef91f9 v2v: convert old-style libvirt listen configuration (RHBZ#1174073)
Use the listen configuration from the "listen" attribute of <graphics>,
in case <listen> is missing.

Followup of commit 9360675dc2.
2015-04-27 10:16:40 +02:00
Richard W.M. Jones
2dd01c5d2d v2v: Remove warning when compiling --without-libvirt. 2015-04-25 22:27:50 +01:00
Richard W.M. Jones
e3443a7549 v2v: -o libvirt: Minor refactoring of arch sanity check. 2015-04-25 22:11:07 +01:00
Richard W.M. Jones
4546d3f21d v2v: Replace polymorphic variant source_hypervisor with ordinary variant.
See commit 3a080c3fbf.
2015-04-25 21:46:26 +01:00
Richard W.M. Jones
946d49cbbc v2v: Remove further uses of polymorphic variants.
See commit 3a080c3fbf.
2015-04-25 21:40:49 +01:00
Richard W.M. Jones
ce630dfc33 valgrind: Add suppression for libvirt memory leak.
Related to RHBZ#1215042.
2015-04-24 09:04:38 +01:00
Richard W.M. Jones
e9910b4887 Version 1.29.37. 2015-04-23 19:57:56 +01:00
Richard W.M. Jones
578c7c0868 builder: Add rhel-ppc64.sh & rhel-ppc64le.sh to EXTRA_DIST.
This fixes commit c5f0d39c64.
2015-04-23 19:57:06 +01:00
Richard W.M. Jones
b02980d5af fuse: tests: Add some debugging to test-fuse-umount-race.sh.
This test fails on recent kernels, sometimes.

Apparently calling 'fusermount -u mp' can exit with an EBUSY error,
but still unmount the filesystem.  Or possibly guestmount crashes
coincidentally.  It's impossible to debug because debugging tools like
strace prevent fuse from working at all.
2015-04-23 19:03:36 +01:00
Richard W.M. Jones
6dee5a4152 fuse: guestunmount: Make the -v (verbose) option do something useful.
guestunmount had a -v / --verbose option, but it didn't change the
behaviour of the program in any way.

Make it print the invocations of the underlying fusermount program.
2015-04-23 19:02:41 +01:00
Richard W.M. Jones
0e4c351bb4 mllib: Link config.ml to the test program.
This fixes commit a1646fa65c.
2015-04-23 17:56:28 +01:00
Richard W.M. Jones
4f021006e9 v2v: When debugging, dump OVF to stderr.
Useful for debugging problems like RHBZ#1213701.
2015-04-23 10:53:04 +01:00
Richard W.M. Jones
c5f0d39c64 builder: Add scripts for generating RHEL 7 ppc64 & ppc64le images. 2015-04-22 22:16:52 +01:00
Richard W.M. Jones
2b0c6e8565 v2v: Pass sound card information from the source to the target (RHBZ#1176493).
Collect sound card information from the source, and where possible,
create a compatible sound card on the target.

Notes:

* VMware's libvirt driver, and also OVF files, do not appear to
  contain any sound card information, so it cannot be collected from
  VMware sources.

* Xen does emulate sound cards and makes that information available
  through libvirt XML.

* There are no paravirt drivers for sound that I'm aware of.
  Therefore we can just copy the same sound model to the target (so
  the sound device does not appear to change).  If the target, KVM,
  does not support the device, it is dropped.  But ...

* ... Unfortunately we cannot easily tell which sound cards are
  supported by KVM on the target.  This is especially a problem for
  RHEL, where many sound drivers have been removed.  There is a
  convenience function, `Utils.qemu_supports_sound_card', which can be
  modified by packagers to hard code the list of supported sound
  cards.

* If a sound card is dubious / not supported by the target / has any
  other problem, then we drop it, since it is more important that the
  guest boots on the target than that sound works.
2015-04-20 22:14:16 +01:00
Richard W.M. Jones
3834a1064f v2v: tests: Don't need to generate test-v2v-networks-and-bridges.xml.
virt-v2v understands relative paths in libvirt XML (even though they
are not legal and libvirt itself wouldn't generate it).  We don't need
to generate this file.
2015-04-20 21:07:47 +01:00
Pino Toscano
a1646fa65c build: create and use a full version string
Create a version string that includes the "extra" string as well, and
make use of it in print_version_and_exit (which can avoid creating a new
Guestfs handle).

Folloup of commit 478a552ab4.
2015-04-20 15:38:32 +02:00
Pino Toscano
4268865a78 build: require Config before Common_utils
Build the Config mllib module before Common_utils, as the latter will
soon make use of the former.
2015-04-20 15:38:31 +02:00
Richard W.M. Jones
0576fdd0b6 v2v: Only emit fstrim warning when debugging (RHBZ#1168144).
fstrim is an optimization.  If it fails, it's not fatal (although
virt-v2v will run a lot more slowly).

We also expect that it will fail for non-aligned NTFS partitions found
on old versions of Windows, and in that case there's nothing that can
be done about it.

Therefore only emit the warning when we are debugging.
2015-04-20 13:12:08 +01:00
Richard W.M. Jones
3c51302d69 v2v: OVF: Add more Windows operating system variants (RHBZ#1213324).
When generating OVF (eg. for -o rhev, -o vdsm) we have to put the
operating system type into a particular field of the output, in a
format that oVirt/RHEV will understand.  Add further Windows OS
variants to this list.  The variants are derived by examining
ovirt-engine sources.

Thanks: Tingting Zheng for testing Windows conversions to RHEV and
finding this bug.
2015-04-20 12:07:18 +01:00
Richard W.M. Jones
86a91d6c65 p2v: Make --version output consistent with other tools (RHBZ#1213247). 2015-04-20 08:55:03 +01:00
Richard W.M. Jones
3b3f06d224 virt-win-reg: Make output of --version flag consistent (RHBZ#1213247). 2015-04-20 08:51:13 +01:00
Richard W.M. Jones
478a552ab4 Common function to implement --version flag in all OCaml tools (RHBZ#1213247).
Add a common function print_version_and_exit ~prog () and use this
function to display the version in all OCaml tools, to ensure
consistent output.
2015-04-20 08:48:08 +01:00
Richard W.M. Jones
921a3b8be2 fish: Whitespace changes. 2015-04-20 08:47:45 +01:00
Richard W.M. Jones
1d78b312bf builder: Add CentOS 7.1 image. 2015-04-18 11:26:03 +01:00
Richard W.M. Jones
58bbb93a25 tests/data: Add ppc64 & ppc64le test binaries. 2015-04-17 20:46:13 +01:00
Richard W.M. Jones
b2fbd88d9f builder: As TCG is single threaded, use 1 vCPU for Fedora ppc64 guests. 2015-04-17 16:11:18 +01:00
Richard W.M. Jones
0debc0b3a7 builder: Set expand=/dev/sda3 for Fedora 21 ppc64 images. 2015-04-17 11:28:43 +01:00
Richard W.M. Jones
0e73a97ef4 builder: Fedora 21 ppc64 images are now raw not qcow2.
Fixes commit f2109068e5.
2015-04-17 11:17:01 +01:00
Richard W.M. Jones
f2109068e5 builder: Upload new ppc64/ppc64le images which try to resolve console and partitioning problems. 2015-04-17 09:56:10 +01:00
Richard W.M. Jones
8670c784db Version 1.29.36. 2015-04-16 14:04:54 +01:00
Richard W.M. Jones
49867a22ba filearch: Fix memory leak.
Found by 'make check-valgrind'.

This fixes commit 20acc1f124.
2015-04-16 14:04:53 +01:00
Richard W.M. Jones
0f4ad9cd84 builder: Use console=hvc0 for serial console in ppc64 guests, and change partitioning type to LVM. 2015-04-16 10:31:33 +01:00
Richard W.M. Jones
b4be660ed6 Version 1.29.35. 2015-04-15 22:30:52 +01:00
Richard W.M. Jones
cc44a5b511 builder: Add fedora-ppc64le.sh script to EXTRA_DIST. 2015-04-15 22:30:25 +01:00
Pino Toscano
8f55030965 v2v: test-v2v-i-ova-formats.sh: test ova as tar.gz and tar.xz
Extend test-v2v-i-ova-formats.sh to test for tarballs compressed as gzip
or xz; followup of commit 3c582cfb8d.
2015-04-15 15:28:14 +02:00
Pino Toscano
454220ab43 v2v: generalize test-v2v-i-ova-zip.sh
Rename test-v2v-i-ova-zip.sh (and associated data) to
test-v2v-i-ova-formats, and generalize it a bit so it can test different
compression types for the ova "envelope".
2015-04-15 15:28:14 +02:00
Richard W.M. Jones
eab054a574 builder: website: Set format=qcow2 for Fedora 21 ppc64 images.
Since I created these with virt-builder without specifying the format,
they have format=qcow2 (not raw).  Instead of tediously recreating or
reuploading these images, just change the metadata.
2015-04-15 13:32:45 +01:00
Richard W.M. Jones
f358d3d1ed builder: In new virt-install, you must specify the format when creating disk images.
New virt-install defaults to qcow2 format unless specified.
Previously it defaulted to raw.  Specify the format explicitly.
2015-04-15 13:32:05 +01:00
Pino Toscano
11450a2d36 v2v: tests: add port='-1' to test-v2v-i-ova.xml reference
Followup of commit 1db249a0cc, as it
outputs a new port attribute.
2015-04-15 14:28:05 +02:00
Pino Toscano
8049474636 v2v: use .ovf and .mf files anywhere within ova files
Do not rely on .ovf and .mf files being in the top-level of the ova
archive, but search them anywhere within the content of the ova.

This also changes the result of the search of the .ovf file: previously,
one (random) file was picked in case there were more than one, while now
this situation triggers an error.

Related to RHBZ#1186800.
2015-04-15 14:24:13 +02:00
Pino Toscano
3c582cfb8d v2v: support tar.gz and tar.xz ova files
When dealing with a ova detected as gzip of xz, uncompress few bytes of
it to check whether it is a compressed tarball, and if so untar it.

Related to RHBZ#1186800.
2015-04-15 14:24:13 +02:00
Richard W.M. Jones
05f5d069ba builder: Upload second revision of ppc64/ppc64le templates.
The serial console should be fixes in these versions.
2015-04-15 12:45:40 +01:00
Pino Toscano
08b1ba35cf v2v: start importing "volume" disk types (RHBZ#1146832)
Import disks stored as "file"-type volumes.

Side effect: a guest converted to libvirt using virt-v2v can be
converted again using virt-v2v.
2015-04-15 09:36:33 +02:00
Pino Toscano
f7529522ab v2v: pass libvirt connection URI to parse_libvirt_xml
This makes it possible to connect to the right libvirt.
2015-04-15 09:36:33 +02:00
Pino Toscano
5da2ed95c1 v2v: domainxml: add vol_dumpxml
Add a new vol_dumpxml to get the XML dump of a pool's volume.
2015-04-15 09:36:33 +02:00
Pino Toscano
9001f61a40 v2v: domainxml: factor out connect and pool loading
Factor out the connection and pool loading out of v2v_pool_dumpxml, so
it can be used in later implementations requiring a pool.

Should be just code motion.
2015-04-15 09:36:32 +02:00
Richard W.M. Jones
eee28390ff builder: Add Fedora 21 ppc64 & ppc64le images.
This also corrects the size= field on all Fedora images.  It should
be 6GB but was 4GB.
2015-04-14 18:20:09 +01:00
Richard W.M. Jones
c65bba313d builder: Add fedora-ppc64le script and build ppc64le template. 2015-04-14 18:20:09 +01:00
Richard W.M. Jones
c5b5442315 builder: Update fedora-ppc64 script and build ppc64 big endian template. 2015-04-14 18:20:09 +01:00
Pino Toscano
1db249a0cc v2v: convert libvirt display port configuration
Read the port configuration from the XML of libvirt domains, restoring
it when writing new libvirt XMLs instead of always setting the
"autoport" option.
2015-04-14 13:22:10 +02:00
Pino Toscano
7291b226d1 filearch: support gzip/xz-compressed files
Extract them to find out the architecture of the data they hold.
Useful to detect the architecture of e.g. compressed Linux modules.

Provide in the test.iso two samples (compressing existing test data) of
binaries compressed with gzip and xz.
2015-04-14 11:13:23 +02:00
Pino Toscano
9360675dc2 v2v: convert libvirt display listen configuration (RHBZ#1174073)
Read the listen configuration from the XML of libvirt domains, restoring
it when writing new libvirt XMLs.
2015-04-14 11:12:23 +02:00
Pino Toscano
20acc1f124 filearch: move libmagic code in an own function
Also use a cleanup attribue to ease the close of the magic_t handle.

This is mostly code motion, hopefully with no actual behaviour changes.
2015-04-13 13:40:21 +02:00
Richard W.M. Jones
e062093881 v2v: Add a man page section on importing from OVA files. 2015-04-13 12:01:22 +01:00
Richard W.M. Jones
abf23ece49 v2v: Document that vCenter >= 5.0 is required (RHBZ#1174200).
vCenter 5.0 was released in 2011.  We have not tested against any
earlier versions, but it was reported that it does not work with
vCenter 4.

Thanks: Sokratis
2015-04-13 11:47:22 +01:00
Richard W.M. Jones
80fcbe6eee v2v: Document that Windows up to 8.1 / 2012R2 now supported.
Commit 2817824bd3 added support for
converting more recent versions of Windows, but neglected to document
it.
2015-04-11 16:39:53 +01:00
Richard W.M. Jones
d23134c5b8 php: Clean up more intermediate files. 2015-04-10 13:55:07 +01:00
Richard W.M. Jones
2e6b14e046 Version 1.29.34. 2015-04-10 13:48:02 +01:00
Richard W.M. Jones
3f98018b43 v2v: test-harness: Describe how to get the test harness.
I don't think it's worth building the test harness as a separate
Fedora package.  It just means the harness gets out of date
quickly and is hard to install.  Instead the test cases can now
be configured to use the libguestfs source directory to get the
test harness.
2015-04-10 13:10:13 +01:00
Richard W.M. Jones
2817824bd3 v2v: Support conversion of Windows >= 8 (RHBZ#1190669).
Tested on:

- Windows 8.1 Pro 64 bit
- Windows Server 2012 R2 64 bit
2015-04-10 12:04:02 +01:00
Richard W.M. Jones
7260b0fc08 v2v: test-harness: Don't send key to wake up guest from blank unless the display is black.
Grub2 in RHEL 6 responds to any key including shift keys by entering
the grub menu (and thus waiting for the 'user' to press Enter).  This
means our previous strategy of always hitting the shift key before
taking a screenshot didn't work well.

Instead, take a screenshot, if it's all (or mostly) black, hit a shift
key and take another screenshot.
2015-04-10 12:04:02 +01:00
Richard W.M. Jones
12be9f831e v2v: test-harness: Match on subimages instead of screenshots.
Previously we fuzzy-matched on screenshots of the entire display.

There were several problems:

 - dates/times in images required fuzzy matching, but it's not clear
   how much fuzz to use (Windows 8.1/2012R2 timestamp is huge,
   requiring an enormous amount of fuzz)

- cannot cope with Windows 7 irregular placement of windows on
  the desktop

It's better to match on subimages.

This requires some changes to the test data, using gimp to clip the
images and remove any changing elements (dates/times/etc) but in the
long run it's more flexible than fuzzy matching on the whole display.

Note that because of peculiarities in 'compare' we still need to have
a little bit of fuzz in the matching.  Seemingly bit-for-bit identical
images still have a similarity > 0.
2015-04-10 12:03:08 +01:00
Richard W.M. Jones
ddeec8b504 v2v: test-harness: Improve boot loop.
Take screenshots each time around the loop (every 10 seconds).  These
are very useful for debugging.

Check for the final screenshot on every iteration.  If the final
screenshot is encountered then the guest is terminated immediately.

Reverse a few loop tests to try to make the code more readable.
2015-04-09 19:03:11 +01:00
Richard W.M. Jones
1fabb99f11 v2v: test-harness: Rearrange 'in' in function definition.
Just a whitespace change.
2015-04-09 17:40:31 +01:00
Richard W.M. Jones
6c27ce649b v2v: test-harness: Use xzcat instead of unxz --keep.
unxz --keep fails on the symlinks used by git-annex with this
rather unnecessary error:

  unxz --keep 'rhel_511_x86_64_pv.img.xz'
  unxz: rhel_511_x86_64_pv.img.xz: Is a symbolic link, skipping

Use xzcat instead.
2015-04-09 15:08:53 +01:00
Richard W.M. Jones
a23f82a5ac v2v: test-harness: New repository URLs, and details of using git-annex. 2015-04-09 15:08:53 +01:00
Richard W.M. Jones
4fd70eab4f v2v: Add support for REG_MULTI_SZ (multiple strings) to registry editor. 2015-04-07 16:58:40 +01:00
Richard W.M. Jones
e264317b04 v2v: test-harness: Update the man page. 2015-04-01 13:57:11 +01:00
Richard W.M. Jones
3034f9a658 v2v: test-harness: Send different shift keys to wake up guests from screen blank.
See:
https://rwmj.wordpress.com/2015/03/30/tip-wake-up-a-guest-from-screen-blank/
2015-04-01 13:24:42 +01:00
Richard W.M. Jones
3cb2b9da25 Version 1.29.33. 2015-04-01 10:06:46 +01:00
Roman Kagan
b8cb5c0d69 v2v: allow configurable location for virtio drivers
Make the location of the Windows virtio drivers overridable with the
environment variable VIRTIO_WIN_DIR, in the same vein as is done for
virt-tools.

Signed-off-by: Roman Kagan <rkagan@parallels.com>
2015-03-31 14:41:49 +01:00
Chen Hanxiao
26b9134450 actions.ml: fix a typo
s/inclding/including

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-03-31 13:03:02 +01:00
Chen Hanxiao
6e989fd709 resize: add p_mbr_p_type as member of type partition
Add p_mbr_p_type as member of type partition
to describe mbr partition type.

Currently we use:
List.filter (fun p -> parttype <> MBR || p.G.part_num <= 4_l)
to filter out logical partitions.

Commit 0c396a4bce
introduce API part_get_mbr_part_type,
we could use this to know the part_type.
Furthermore, we could also use p_mbr_p_type for resizing
logical partitions.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-03-30 18:59:52 +01:00
Richard W.M. Jones
309f7062e8 v2v: test-harness: Don't need to use Unix. prefix, since module is opened. 2015-03-30 13:27:17 +01:00
Richard W.M. Jones
6f53c6c026 v2v: test-harness: Send shift key to wake up screen from blank before taking screenshots. 2015-03-30 13:27:17 +01:00
Richard W.M. Jones
453db7e210 v2v: RHEL 4: You have to update lvm2, device-mapper to get virtio support.
Also include the updated selinux policy that goes with RHEL 4.8.

Also mention that policycoreutils should be updated - see previous
commit.
2015-03-30 13:27:17 +01:00
Richard W.M. Jones
d4ab702dad v2v: Add note about RHEL 4 conversions hanging during SELinux relabelling. 2015-03-30 13:27:17 +01:00
Richard W.M. Jones
f3c17ab0d8 builder: Fix arch= field in previous commit.
Fixes commit 8ddc564730.
2015-03-30 09:43:34 +01:00
Richard W.M. Jones
8ddc564730 builder: Update index for new armv7 Fedora guest. 2015-03-30 09:09:22 +01:00
Richard W.M. Jones
2cb691e46e builder: Add script for building Fedora armv7l (32 bit ARM) guests. 2015-03-30 09:05:07 +01:00
Richard W.M. Jones
5c65b9108d ruby: Only rebuild rdoc when absolutely necessary.
Rebuilding the ruby documentation takes 51 seconds on my laptop, and
that's a significant fraction of the entire build.  Make sure we only
rebuild the documentation when necessary.
2015-03-28 18:08:21 +00:00
Richard W.M. Jones
e86df90e52 guestfs-performance: Suggest using 'ts' instead of annotate.
'ts' allows incremental timings which is a lot more useful.
2015-03-28 17:53:35 +00:00
Richard W.M. Jones
f1007fc26d lib: Fix static linking by forcing launch-*.o objects to be always linked.
Because the launch-*.o objects only contain statically scoped
declarations, the linker doesn't need to link them in.  This causes a
problem when static linking as they will be left out of the final
binary, and so no backends will be available.

This is essentially the same problem as described here:

https://stackoverflow.com/questions/1202494/why-doesnt-attribute-constructor-work-in-a-static-library
2015-03-28 10:20:44 +00:00
Richard W.M. Jones
7906c34a0f build: Fix ./configure --without-libvirt option. 2015-03-27 22:45:08 +00:00
Richard W.M. Jones
c370ca75c8 lib: Remove bogus visibility declaration (GUESTFS_DLL_PUBLIC) from internal function. 2015-03-27 22:45:02 +00:00
Richard W.M. Jones
a1a42d0002 Version 1.29.32. 2015-03-27 11:02:18 +00:00
Richard W.M. Jones
403e32df23 fuse: Add a note about preserving inode numbers using -o use_ino.
Thanks: David Juran
2015-03-27 11:01:00 +00:00
Maros Zatko
e6dadd6aca customize: fix --upload to FAT partition (RHBZ#1196101)
Some filesystems, such as FAT doesn't support file
ownership, so show warning instead of error on EPERM.
2015-03-27 10:05:12 +00:00
Richard W.M. Jones
d308d0f703 builder: Fix rhel 5 repository location.
RHEL 5 was unusual in having separate sub-repositories (Server, VT,
Cluster etc) within the main RHEL-5-Server directory.  Thankfully no
other version of RHEL does this.  Previously we set up the repository
baseurl incorrectly so it didn't include .../Server in the path.

In commit 1a1cb1ec3c, I tried to fix the
RHEL 5 repo location to include .../Server.  However that broke the
virt-install --location parameter.

Use a separate baseurl path, which should fix both problems.

This fixes commit 1a1cb1ec3c and
commit 3bc9ba6c84.
2015-03-26 11:19:47 +00:00
Richard W.M. Jones
6f7c1663c1 Revert "builder: Fix RHEL 5 download location."
This reverts commit 1a1cb1ec3c.
2015-03-26 11:18:16 +00:00
Richard W.M. Jones
6c5451b34f v2v: test-harness: Rebuild v2v_test_harness.cmi if OCaml API changes.
The error you would have seen before was:

File "v2v_test_harness.ml", line 1:
Error: The files ../../ocaml/guestfs.cmi and v2v_test_harness.cmi
       make inconsistent assumptions over interface Guestfs
2015-03-26 09:44:23 +00:00
Richard W.M. Jones
6297534091 ocaml: Add Guestfs.Errno.errno_EPERM. 2015-03-26 09:16:44 +00:00
Chen Hanxiao
0c396a4bce New API: part_get_mbr_part_type for showing partition type
This patch will add support for getting partition type
of a partiton numbered device.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-03-24 13:44:16 +00:00
Chen Hanxiao
af9aa2eb05 parted: introduce enum for whether parted has option -m
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>

RWMJ: Use enum consistently, don't assign the result to int.
2015-03-24 13:35:29 +00:00
Chen Hanxiao
52d1b0c593 New API: btrfs-image
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-03-24 13:35:28 +00:00
Maros Zatko
ea6d4e5535 customize: add --move (RHBZ#1203817).
This adds --move SOURCE:DEST, equivalent of calling g#mv src dst.

RFE: RHBZ#1203817
2015-03-24 13:27:44 +00:00
Maros Zatko
943fec0399 customize: add --copy (RHBZ#1203817).
This adds --copy SOURCE:DEST, equivalent of calling g#cp_a src dst.

RFE: RHBZ#1203817
2015-03-24 13:27:40 +00:00
Richard W.M. Jones
c227cbcc14 Version 1.29.31. 2015-03-23 14:03:14 +00:00
Richard W.M. Jones
d48615577c builder: Add test-virt-index-validate-good-3 to EXTRA_DIST
Fixes commit fc6c16af0b.
2015-03-23 13:59:08 +00:00
Chen Hanxiao
039ba9cf19 btrfs-qgroup-show: add check for "--raw"
btrfs-prog commit:
58a39524619f38d193b8adc3d57888ec07b612aa
change the default output to binary prefix,
and introduced a new option '--raw'
to keep the traditional behaviour.

This patch will add a check function to determine
whether to add '--raw' option to 'btrfs show qgroup'.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-03-23 12:50:33 +00:00
Pino Toscano
fc6c16af0b builder: handle empty lines in indexes before first section (RHBZ#1201526)
Properly skip empty lines before the first section, otherwise they will
trigger a syntax error in parsing.

Add a simple test for it, so it doesn't regress.
2015-03-23 12:49:27 +00:00
Chen Hanxiao
09e239a726 tests: add test case of set-label and vfs-label for btrfs
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-03-23 12:49:00 +00:00
Chen Hanxiao
017f1c6729 guestfs.pod: don't encourage 'make syntax-check'
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-03-23 12:46:26 +00:00
Maros Zatko
7e8ed7cb21 customize: add --truncate-recursive option
Allows user to recursively truncate files in PATH. e.g.:
virt-builder --truncate-recursive /var/log

Relates to RHBZ#119673
2015-03-23 12:34:05 +00:00
Maros Zatko
ce144c4d7a virt-copy, virt-tar: show help for --help 2015-03-23 12:24:59 +00:00
Richard W.M. Jones
5a445c2e40 docs: You normally need to set SUPERMIN_KERNEL_VERSION as well. 2015-03-23 12:14:59 +00:00
Richard W.M. Jones
762c0bdab9 docs: Remove some rogue references to 'febootstrap'. 2015-03-23 12:12:23 +00:00
Richard W.M. Jones
5ac87b975f v2v: test-harness: Add support for OVA.
This makes VMware testing easier, since it means you don't need to
test against a live server.
2015-03-20 12:14:42 +00:00
Pino Toscano
04f1f1b741 generator: small optimization of pod2text cache memoization
Instead of save every time there's a new element in the cache, batch the
saving to disk every 100 changes, saving the unsaved remainder at the
exit.

While not a big optimization, this reduces a bit the disk usage during
generator run.
2015-03-12 18:08:25 +01:00
Richard W.M. Jones
078bd8ad06 v2v: test harness: Add list of FILES to the manual page. 2015-03-12 15:02:59 +00:00
Chen Hanxiao
c3fa537aeb guestfs.pod: fix a typo
s/applicance/appliance

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-03-12 08:30:38 +00:00
Richard W.M. Jones
32e5056f4a Revert "launch: libvirt: In debug messages use ls --lcontext instead of ls -Z."
The --lcontext option was removed from coreutils ls (in 2007, cough).

Fedora carried a patch re-adding these options [I believe
unintentionally], but that patch was dropped in Fedora 23, so the
--lcontext option is gone for good.

This reverts commit f9c5b4aa2a.
2015-03-11 17:28:19 +00:00
Richard W.M. Jones
ffa8584699 tests: mount-local: Print some more debugging along error paths.
Trying to track down a memory leak somewhere.
2015-03-11 15:08:40 +00:00
Richard W.M. Jones
0827b006e4 v2v: test-harness: Fix boot loop so it detects disk inactivity properly. 2015-03-11 15:05:13 +00:00
Richard W.M. Jones
a3beda8b77 v2v: test-harness: Measure similarity between images when comparing screenshots.
Since wallclock time differs between boots, we cannot just compare two
screenshots by checking if they are identical -- if the screenshot
contains any time information, then that will be different, and it
turns out that VMs print the current time at boot.

Therefore parse out and use the "similarity" metric printed by the
ImageMagick "compare" command when it compares the screenshots, and
allow a small epsilon for the case where a few oixels are different.
2015-03-11 15:02:58 +00:00
Richard W.M. Jones
f052270039 Version 1.29.30. 2015-03-10 21:47:15 +00:00
Richard W.M. Jones
ccb3894915 v2v: Add the test-harness used by external tests.
See the new man page virt-v2v-test-harness(1) added in this commit for
details of this library/harness, and also how to get the external
tests.
2015-03-10 19:39:23 +00:00
Chen Hanxiao
35916e700b gui: fix a syntax-check issue of bindtextdomain
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-03-10 19:39:23 +00:00
Richard W.M. Jones
8873c51475 po-docs: Update list of manual pages to be translated.
There should be an automatic way to keep this list updated, but while
there isn't, keep it updated by hand ...
2015-03-10 16:51:06 +00:00
Richard W.M. Jones
1fba1d1edc builder: Fix path to RHEL source RPMs in internal repo.
Thanks: Jan Scotka
2015-03-10 10:15:42 +00:00
Richard W.M. Jones
ce56c7d30e FAQ: Don't refer to RHEL 7 in future tense.
Thanks: orc_emacs on IRC.
2015-03-09 17:51:36 +00:00
Richard W.M. Jones
3053785db8 builder: Fix comparison between signed/unsigned in parallel xzcat.
block.header_size is uint32_t so cannot be compared directly with n (ssize_t).

pxzcat-c.c: In function 'worker_thread':
pxzcat-c.c:602:21: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
     if (n >= 0 && n != block.header_size-1) {
                     ^
2015-03-09 13:13:16 +00:00
Richard W.M. Jones
c807546619 v2v: xml: Add some more bindings to libxml2.
These are not used by libguestfs, but are used by the external
virt-v2v tests.
2015-03-06 17:05:50 +00:00
Richard W.M. Jones
ce5a51a34c v2v: xml: Remove dependency on libguestfs internals.
This is just so I can share the code with the virt-v2v external tests.
2015-03-06 17:03:01 +00:00
Richard W.M. Jones
4ee6e4ddc8 Version 1.29.29. 2015-03-05 13:42:20 +00:00
Richard W.M. Jones
025f1d2bc7 bugs: Ignore bugs in RELEASE_PENDING state.
It's effectively the same as CLOSED.
2015-03-05 13:41:21 +00:00
Richard W.M. Jones
4592caedd4 builder: Add fedora-ppc64.sh script to EXTRA_DIST.
This updates commit 7867abc5c2.
2015-03-05 13:39:21 +00:00
Pino Toscano
1d93cb9e4b actions: improve man page links
Switch from C<> to L<> for links to man pages, where wasn't done before.
2015-03-05 12:31:57 +00:00
Maros Zatko
7867abc5c2 builder: add build script for PPC64 Fedora 2015-03-05 12:30:10 +00:00
Maros Zatko
a084758e83 customize: add --truncate option (RHBZ#119673) 2015-03-05 12:29:21 +00:00
Richard W.M. Jones
e51420c61f arm: Ignore -Wpointer-to-int-cast in c-pointer API.
This API converts the C guestfs_h pointer to a 64 bit integer,
which should always be possible on reasonable architectures.
Therefore silence a GCC warning (which only occurs on 32 bit ARM).
2015-03-05 12:18:23 +00:00
Richard W.M. Jones
af762e4342 arm: Use -M virt on 32 bit ARM, don't pass -dtb parameter.
Note this means all the dtb code in libguestfs & supermin is
obsolete/unused, and may be deleted at some point in future.
2015-03-05 10:28:59 +00:00
Chen Hanxiao
7fb85dcde3 actions.ml: fix a typo
s/tto/to

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-03-03 08:45:01 +00:00
Richard W.M. Jones
e6445e982a ocaml: Don't run check-valgrind on run-bindtests (bash script).
Fix the 'make check-valgrind' rule in the ocaml subdirectory so it
doesn't run '$VG run-bindtests', effectively running valgrind on bash.

Bash in Fedora Rawhide has added a new memory leak, resulting in a
failure, but we don't want to test bash anyway.
2015-03-02 17:46:06 +00:00
Richard W.M. Jones
1cdb5a103a Version 1.29.28. 2015-03-02 13:54:13 +00:00
Richard W.M. Jones
064628632b build: Fix 'maintainer-check-extra-dist' to only list relevant files. 2015-03-02 13:53:12 +00:00
Chen Hanxiao
250db12c24 New API: btrfstune_enable_skinny_metadata_extent_refs
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-03-02 10:27:27 +00:00
Chen Hanxiao
aa70209558 New API: btrfstune_enable_extended_inode_refs
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-03-02 10:27:27 +00:00
Chen Hanxiao
fa14c3d6bc New API: btrfstune_seeding
Use btrfstune_seeding to enable or disable seeding.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-03-02 10:27:27 +00:00
Richard W.M. Jones
78e1a1472c builder: Fix 'os-version' in man page examples. 2015-03-02 09:11:47 +00:00
Michael Scherer
e4944043fb Use a debian distribution for the apt example 2015-03-02 09:10:29 +00:00
Richard W.M. Jones
4e9bda4598 appliance: Create /etc/mtab in init script to work around util-linux nuttiness. 2015-02-28 11:10:31 +00:00
Richard W.M. Jones
41d4d606e5 Version 1.29.27. 2015-02-27 14:38:07 +00:00
Richard W.M. Jones
ecbbfc9ddd po-docs: Ship some untranslated PO files.
Add untranslated PO files to EXTRA_DIST.
2015-02-27 14:37:07 +00:00
Roman Kagan
6c7823b9a9 convert_windows: split firstboot into steps
Instead of doing all firstboot actions in a single script, take the
advantage of the firstboot infrastructure and store and run unrelated
actions as individual steps.

This facilitates troubleshooting and fault recovery; besides it makes
adding more actions easier.

Signed-off-by: Roman Kagan <rkagan@parallels.com>
2015-02-27 13:25:45 +00:00
Roman Kagan
58eb977c0d firstboot: make script naming descriptive
The firstboot infrastructure used to give the firstboot scripts some
cryptic names which were impossible to relate to the actions they were
supposed to take.

This patch reworks the scheme such that the caller registering a
firstboot script has to provide a descriptive name for the action.  That
name, with non-alphanumeric characters replaced with dashes, prefixed by
the serial number, is then used as the name of the script, e.g.

  0004-install-gcc

or

  0002-msiexec--i-foo-msi.bat

OTOH the numbering becomes internal to the API, i.e. the scripts are
numbered and executed in the order they are registered.

This greatly facilitates debugging and troubleshooting in case when
there are multiple firstboot scripts.

Signed-off-by: Roman Kagan <rkagan@parallels.com>
2015-02-27 13:25:45 +00:00
Roman Kagan
7aa9d63674 firstboot: enhance firstboot driver script for Windows
This patch is an attempt to enhance the firstboot driver script for
Windows, and make it somewhat closer in functionality to what is done
for Linux guests.

Specifically, for every firstboot script it now will log its exit
status, and, if the script reported success, move it to -done directory.

Signed-off-by: Roman Kagan <rkagan@parallels.com>
2015-02-27 13:25:45 +00:00
Roman Kagan
3edd770b09 firstboot: consolidate line ending conversion
This patch moves line ending conversion for windows scripts into a
separate helper function.

This simplifies code a bit, and fixes the problem that actual firstboot
scripts used to remain with unix-style line endings.

Signed-off-by: Roman Kagan <rkagan@parallels.com>
2015-02-27 13:25:45 +00:00
Pino Toscano
be79bdfd3a builder: handle -v and -x flags like in other tools (RHBZ#1196100)
Make sure that -x enables tracing and -v enables verbose mode, just like
other tools do.

Kind of followup of commit b6b9b90dd7.
2015-02-26 10:01:14 +01:00
Pino Toscano
652af7a33a builder: use mkdir_p to create the cachedir (RHBZ#1195204) 2015-02-23 14:08:02 +01:00
Pino Toscano
d54132f94d mllib: add helper mkdir_p
Small function to create in OCaml-based code a directory and its
parents, much like `mkdir -p`.
2015-02-23 14:04:00 +01:00
Pino Toscano
ef992c2b07 build: fix distfiles for zanata
Followup of commit c328ac9e04.
2015-02-23 10:58:58 +01:00
Richard W.M. Jones
2acf98c784 Update translations from Zanata.
I added the new linguas for the po/ directory.  But not for the
po-docs/ directory, since the new po files hardly contain any
translations there.
2015-02-22 14:33:17 +00:00
Richard W.M. Jones
c328ac9e04 Move upstream translations from Tranifex to Zanata.
This is at the request of the Fedora localization team.
For further information see:

https://www.redhat.com/archives/libguestfs/2015-February/msg00168.html
2015-02-22 14:10:50 +00:00
Nikos Skalkotos
6200abf92e Fix a bug in e2fsck execution code
Use commandrvf() instead of commandvf() to execute e2fsck. A non-zero
exit status does not always indicate a failure.

Signed-off-by: Nikos Skalkotos <skalkoto@grnet.gr>
2015-02-18 14:43:15 +00:00
Pino Toscano
869b9fcf97 builder: when not checking sigs, ignore --fingerprint args (RHBZ#1193237)
When the user chooses to not verify the signatures on the indexes
(using --no-check-signature), there is no point in requiring as many
--fingerprint as --source (or even just one), as they will not be used
anyway.

In this case just ignore all the values of the specified --fingerprint
arguments.
2015-02-18 15:19:58 +01:00
Pino Toscano
17dabd57c7 builder: process --source sources before
Process the sources specified via the --source command line arguments
before sources read from repositories, so the former have a chance to
"override" the latter.

Related to RHBZ#1193238.
2015-02-18 15:19:44 +01:00
Richard W.M. Jones
fa36b70b20 Version 1.29.26. 2015-02-17 12:11:41 +00:00
Richard W.M. Jones
c7de22b0d3 aarch64: Add fedora-aarch64.sh builder script to EXTRA_DIST.
This fixes commit 5809a5a802.
2015-02-17 12:11:12 +00:00
Maros Zatko
568a33d7ef inspector: add /reactos as systemroot
Fixes RHBZ#709326
Related bug RHBZ#709327 seems to be already fixed in ReactOS 0.4.
2015-02-16 19:32:30 +00:00
Hu Tao
f265371868 New API: btfs_scrub_status
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-02-16 18:05:30 +00:00
Hu Tao
88dbae4cbf New API: btrfs_balance_status
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-02-16 18:05:30 +00:00
Richard W.M. Jones
6c6ce85f94 v2v: -o libvirt: Prevent possible XPath injection.
Ensure the arch string is sane before using it in the following XPath
expression.  Since the arch string can be derived from untrusted guest
data [see src/filearch.c], this prevents a possible XPath injection
vulnerability.
2015-02-14 18:46:05 +00:00
Richard W.M. Jones
c3566da409 python: Call PyErr_Clear() on non-error paths out of the Python bindings.
We also need to be more careful about PyString_FromString and similar
functions returning NULL on failure.  Currently we don't check this
every time.  This commit adds more checks, but is still not complete.
2015-02-14 18:46:05 +00:00
Richard W.M. Jones
0f029a5f58 Whitespace changes arising from the previous two commits. 2015-02-14 18:46:05 +00:00
Richard W.M. Jones
1efd8aa8f1 Change guestfs__* to guestfs_impl_*
libguestfs has used double and triple underscores in identifiers.
These aren't valid for global names in C++.

The second step is to replace all guestfs__* (2 underscores) with
guestfs_impl_*.

These functions are used where a libguestfs API call is implemented on
the library side.  The generator creates a wrapper function which
calls guestfs_impl_* to do the work.  (Libguestfs APIs which are
passed directly by the daemon work differently and don't require a
guestfs_impl_* function).

This is an entirely mechanical change done using:
  git ls-files | xargs perl -pi.bak -e 's/guestfs___/guestfs_impl_/g'

Reference: http://stackoverflow.com/a/228797
2015-02-14 18:46:04 +00:00
Richard W.M. Jones
bfbcc01403 Change guestfs___* to guestfs_int_*
libguestfs has used double and triple underscores in identifiers.
These aren't valid for global names in C++.

The first step is to replace all guestfs___* (3 underscores) with
guestfs_int_*.  We've used guestfs_int_* elsewhere already as a prefix
for internal identifiers.

This is an entirely mechanical change done using:
  git ls-files | xargs perl -pi.bak -e 's/guestfs___/guestfs_int_/g'

Reference: http://stackoverflow.com/a/228797
2015-02-14 18:46:04 +00:00
Richard W.M. Jones
46010912ef Update gnulib to latest. 2015-02-14 18:46:04 +00:00
Richard W.M. Jones
98aa470bc6 Update TODO.
Remove some things which have been implemented already.
2015-02-14 18:46:04 +00:00
Margaret Lewicka
5f67d23cf5 fuse: Alternatives for Linux-specific commands
* fusermount is Linux-only; on BSD and OS X umount should be used
* fuser has no -v flag on BSD/OSX, and -c is the
  POSIX-compatible equivalent of -m
* Does not solve the lack of pretty output of fuser -v, but does make it
  work on Mac OS X.
2015-02-14 09:39:49 +00:00
Richard W.M. Jones
88d16e6fb9 aarch64: builder: Fix metadata so virt-builder --size works.
The wrong partition was being expanded.

This fixes commit 5809a5a802.
2015-02-13 14:47:15 +00:00
Pino Toscano
f71168497d php: skip bindtests on 32bit platforms
bindtests checks also 64bit int values, which won't work when the
underlying platform has sizeof(long) < 8 (like on 32bit architectures).
2015-02-13 14:37:46 +01:00
Richard W.M. Jones
a34416091e daemon: btrfs: Remove full stop from end of error message.
This fixes commit 56732ed6a0.
2015-02-13 10:48:10 +00:00
Richard W.M. Jones
cae7909f5e ./run: Use 'prepend' function to build paths.
Add a bash function 'prepend' for intelligently prepending elements to
paths.  eg:

  prepend PYTHONPATH "/foo"

would set PYTHONPATH to "/foo" or "/foo:<previous-contents-of-PYTHONPATH>"

Tested by:

(1) Building and testing libguestfs twice: first without libguestfs
installed as a system library, and then with it installed.

(2) Examining the output of './run printenv' by hand and comparing
environment variables to the expected values.
2015-02-13 10:26:22 +00:00
Chen Hanxiao
928430f111 actions.ml: fix a typo
s/scannning/scanning

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-02-13 09:02:43 +00:00
Margaret Lewicka
b969be72cd lib: Check if crypt() comes from a separate library
Mac OS X includes crypt() in libc.
2015-02-13 08:55:44 +00:00
Margaret Lewicka
cc4baac815 run: Set DYLD_LIBRARY_PATH along with LD_LIBRARY_PATH
Mac OS X uses DYLD_LIBRARY_PATH rather than LD_LIBRARY_PATH.
2015-02-13 08:55:43 +00:00
Margaret Lewicka
5fc07e87bb macosx: Includes/defines for byteswap operations 2015-02-12 20:34:40 +00:00
Margaret Lewicka
e39ab27dea lib: Add third, zero parameter to xdrproc_t
As advised by Daniel P. Berrange, the third parameter can be passed on all
platforms rather than specifically Mac.

Quoting a libvirt commit rationale after Daniel:

 commit 9fa3a8ab6fd82ad2f5a14b490696085061418718
 Author: Doug Goldstein <cardoe@cardoe.com>
 Date:   Wed Oct 30 11:22:58 2013 -0500

   MacOS: Handle changes to xdrproc_t definition

   With Mac OS X 10.9, xdrproc_t is no longer defined as:

   typedef bool_t (*xdrproc_t)(XDR *, ...);

   but instead as:

   typedef bool_t (*xdrproc_t)(XDR *, void *, unsigned int);

   For reference, Linux systems typically define it as:

   typedef bool_t (*xdrproc_t)(XDR *, void *, ...);

   The rationale explained in the header is that using a vararg is
   incorrect and has a potential to change the ABI slightly do to compiler
   optimizations taken and the undefined behavior. They decided
   to specify the exact number of parameters and for compatibility with old
   code decided to make the signature require 3 arguments. The third
   argument is ignored for cases that its not used and its recommended to
   supply a 0.
2015-02-12 20:28:20 +00:00
Margaret Lewicka
bbc8c20a2d builder: Check HAVE_POSIX_FADVISE before using it 2015-02-12 20:27:41 +00:00
Richard W.M. Jones
5809a5a802 aarch64: builder: Add script for building Fedora aarch64 images. 2015-02-12 17:29:38 +00:00
Pino Toscano
a0892aa29e ocaml: hide internal methods from apidocs 2015-02-12 15:07:58 +01:00
Pino Toscano
3dff1582d4 actions: fix a couple of docs references 2015-02-12 14:42:57 +01:00
Pino Toscano
8c91a68b80 gobject: generate deprecation markers
Generate proper deprecation markers for API documentation and
introspection annotations.
2015-02-12 14:42:57 +01:00
Richard W.M. Jones
ab8a442952 Version 1.29.25. 2015-02-11 17:03:05 +00:00
Richard W.M. Jones
fb24d7405a tests/charsets: Fix bogus comparison of STRNEQ() == -1.
gcc 5 rightly flags this code as bogus.
2015-02-11 15:30:55 +00:00
Pino Toscano
e157226064 java: further <p> fixes
javadoc's HTML parser seems more limited, so just close <p> blocks
before opening <pre> or <ol>.

Followup of commit f4186a7a49.
2015-02-11 15:46:19 +01:00
Pino Toscano
3b8d56d491 php: add a simple bindtests test
Generate a simple bindtests test for the PHP binding, so it is possible
to easily test all the argument types.

Unlike the bindtests for other languages, optional arguments are not
tested, due to the limitations of optional arguments in PHP (or maybe
they way we implement them).
2015-02-11 15:02:57 +01:00
Pino Toscano
2b06c27fd7 php: fix memory leak in OStringList optargs
Make sure to free the char** created to convert the arguments.
2015-02-11 15:02:56 +01:00
Pino Toscano
8e4bf5cf9e php: fix invalid memory access with stringlist params
Make sure to copy the strings we add to the char** array, otherwise they
are stale pointers which we'll try to free later.

Also, properly destruct the temporary zval.
2015-02-11 15:02:56 +01:00
Pino Toscano
ee65fabd97 php: move common code in helper functions
Simple code motion.
2015-02-11 15:02:56 +01:00
Pino Toscano
4debb44a44 php: fix invalid memory access with OptString
OptString maps to a "s!" argument, which makes zend_parse_parameters not
touch the variables (char* and length) when NULL is passed as parameter.
Hence, set both to NULL/0, and check for non-NULL char* variable before
checking its length.
2015-02-11 15:02:56 +01:00
Pino Toscano
85b6b5e589 java: add @Deprecated annotation for deprecated methods 2015-02-11 15:02:56 +01:00
Pino Toscano
f4186a7a49 java: fix/improve slightly the javadoc
- use <p>..</p> for text paragraphs, instead of just using <p> to
  separate them
- slightly improve the metadata in eventToString and set_event_callback
- fix the textual @see in set_event_callback, so it is accepted also in
  JDK 8
- escape the doc text, so &, <, and > will not be considered as HTML
  tags but actual text
- use the @deprecated tag instead of adding the customary deprecation
  note to the doc text
2015-02-11 15:02:56 +01:00
Pino Toscano
8b268bd897 generator: add a simple HTML escaping function 2015-02-11 15:02:56 +01:00
Pino Toscano
4905d6eb95 Revert "java: Turn off doclint to prevent errors on JDK 8"
The errors will be fixed for good, together will other small javadoc
improvements.

This reverts commit 8940b03658.
2015-02-11 15:02:56 +01:00
Margaret Lewicka
28462caacc macosx/bsd: Use getprogname() where available 2015-02-11 13:50:33 +00:00
Margaret Lewicka
8940b03658 java: Turn off doclint to prevent errors on JDK 8
On JDK 8, doclint is enabled by default with strict validation of HTML
tags, which causes the build to fail. See
http://blog.joda.org/2014/02/turning-off-doclint-in-jdk-8-javadoc.html
2015-02-11 13:49:47 +00:00
Pino Toscano
668c4784a9 perl: tests: reenable set_path tests
guestfs_set_path now does a copy of the passed string, so bindings don't
need to take care of the lifetime of strings parameters for it.
2015-02-09 11:00:47 +01:00
Richard W.M. Jones
5cafedaa45 lib: Change 'program_name' macro to avoid conflict with gnulib.
The gnulib 'error' module uses 'program_name'.  On some platforms --
but not Linux / glibc -- it references it as:

  extern char *program_name;

This means when you compile libguestfs on non-glibc (eg. Mac OS X)
gnulib requires 'program_name' as an external string reference, which
we don't provide.

This change doesn't define this string reference for gnulib, but it
does change the name of the macro we use to avoid conflicts if we
eventually need to export 'program_name' as a string.

Thanks: Margaret Lewicka
2015-02-07 16:30:28 +00:00
Margaret Lewicka
7ddf6bcbfd macosx: Include <sys/un.h> and define SOCK_* for Mac OS X. 2015-02-06 10:01:28 +00:00
Margaret Lewicka
eaae0b614c macosx: ruby: Use correct dllib extension instead of assuming '.so'. 2015-02-06 09:53:45 +00:00
Richard W.M. Jones
f630677c14 resize: Preserve GPT GUID so we don't break EFI bootloaders (RHBZ#1189284).
When copying disks that use EFI, we created a new partition table,
randomizing the GPT GUID of the first partition.  Since EFI may store
the GUID in its NVRAM variables, this could make the guest unbootable.
2015-02-05 08:19:19 +00:00
Richard W.M. Jones
40c133b2c8 New APIs: part-set-gpt-guid and part-get-gpt-guid
In GPT, each partition has a GUID assigned randomly.  Allow this GUID
to be written and read.

Note this is different from the GUID type code which is used to
identify the type of the partition.
2015-02-05 08:19:19 +00:00
Richard W.M. Jones
b3e3750b13 daemon: Fix whitespace. 2015-02-05 08:01:48 +00:00
Richard W.M. Jones
ff1cf989fd builder: Fix large performance regression in pxzcat (RHBZ#1188866).
Commit 9135129b0f changed
two stack buffers to pointers:

-  uint8_t buf[BUFFER_SIZE];
-  unsigned char outbuf[BUFFER_SIZE];
+  CLEANUP_FREE uint8_t *buf = NULL;
+  CLEANUP_FREE uint8_t *outbuf = NULL;

but we were still using sizeof buf to calculate the size of the
buffer.  sizeof buf == 8 so the original code which used large buffers
for reading/writing the file changed to using 8 byte buffers.
2015-02-04 13:17:40 +00:00
Cédric Bosdonnat
5f663c2082 customize: Invoke zypper correctly. 2015-02-03 14:38:02 +00:00
Richard W.M. Jones
8fd4231051 btrfs: Proper error when output of 'btrfs qgroup show' command cannot be parsed.
sscanf doesn't set errno in these cases so it's wrong to call perror
here.

This fixes commit 2b7f7810ed.
2015-02-03 08:53:43 +00:00
Richard W.M. Jones
725d95422b Version 1.29.24. 2015-02-02 20:01:45 +00:00
Pino Toscano
573fe962b9 customize: add copy-in operation (RHBZ#1135585).
Add the copy-in operation to virt-customize/builder/sysprep, so it is
possible to easily copy directories at once in the guest.
2015-02-02 18:55:10 +00:00
Pino Toscano
5efce8c56d fish: use copy-in and copy-out
Simply the copy-in & copy-out commands of guestfish using the new
implementations of copy-in & copy-out in the library.
2015-02-02 18:44:52 +00:00
Pino Toscano
fb9bc908f8 New APIs: copy-in and copy-out
Currently implemented as guestfish commands, provide them instead as
single source -> destination functions for the library, so they can be
used also in other places.

These functions are not added to guestfish, since guestfish has its own
implementation (which will soon switch to call copy-in and copy-out for
multiple paths).
2015-02-02 18:44:52 +00:00
Pino Toscano
8aadde50b3 generator: add VPublicNoFish visibility type
Usable to have public functions, i.e. like VPublic, but do not showing
them in guestfish.
2015-02-02 18:44:52 +00:00
Pino Toscano
db055262d4 cmd: add the possibility to get a fd to the process stdin
Add the possibility to forward to the stdin of the process, and get the
fd for it; only in async mode for now.
2015-02-02 18:44:52 +00:00
Pino Toscano
449fab3ed1 cmd: add a child-setup callback
Easy way to do pre-exec setup in the child process.
2015-02-02 18:44:52 +00:00
Pino Toscano
c5d3d198dc cmd: add a way to run (and wait) asynchronously commands 2015-02-02 18:44:52 +00:00
Pino Toscano
4bb3c44a28 sparsify: ignore read-only devices
In copy mode, make sure to not zero-free-space devices mounted as
read-only, as we cannot write to them.

Related to RHBZ#1079625.
2015-02-02 15:02:31 +01:00
Pino Toscano
864c2ee371 sparsify: ignore read-only btrfs snapshots (RHBZ#1079625)
In copy mode, make sure to not zero-free-space read-only btrfs
snapshots, as we cannot write to them.
2015-02-02 14:50:52 +01:00
Richard W.M. Jones
8d83f57799 sparsify: Ignore read-only LVs (RHBZ#1185561). 2015-02-02 13:32:24 +00:00
Richard W.M. Jones
7d784fb9c9 mllib: Add function for comparing LVM2 UUIDs, ignoring '-' characters. 2015-02-02 13:32:24 +00:00
Richard W.M. Jones
ab950f8290 mllib: Add a better List.assoc function.
You can specify what comparison function is used; and instead of
having it raise 'Not_found', it returns a ~default value.
2015-02-02 13:32:24 +00:00
Pino Toscano
83eea0b197 tests: don't add test-dlopen twice
test-dlopen needs to be added only when libdl is available, and it is
like that already (within if HAVE_LIBDL); hence don't unconditionally
add it as well.
2015-01-29 12:00:32 +01:00
Pino Toscano
e57ed7cd34 build: use libintl where needed
Followup of commit a5426cce5f.
2015-01-29 12:00:01 +01:00
Pino Toscano
2313f28895 daemon: parted: use --part-type with recent sfdisk
Check whether --part-type is supported (in the rewritten sfdisk in
util-linux >= 2.26), and use it instead of --print-id & --change-id.

The actual result should be the same, just not using a (recently)
deprecated command line API.
2015-01-28 15:34:49 +01:00
Richard W.M. Jones
6a195d0f95 v2v: -i ova: Make error message "unsupported file format" clearer.
Thanks: Moran Goldboim
2015-01-28 13:30:55 +00:00
Pino Toscano
282a131677 customize: handle Arg.Set parameters in commands file
When reading commands from a file, handle also Arg.Set parameters, so
they can be enabled as well.
2015-01-28 09:59:27 +01:00
Richard W.M. Jones
d0cecca272 Version 1.29.23. 2015-01-26 17:15:51 +00:00
Richard W.M. Jones
d6cfd24feb .gitignore: Ignore mllib/oUnit-anon.cache file from oUnit.
This updates commit d19eb31060.
2015-01-26 17:15:51 +00:00
Pino Toscano
d0a2ba40c8 mllib: fix JSON_tests
Properly write int64 values, so they are handled correctly also on 32bit
architectures.
2015-01-26 16:36:26 +01:00
Shahar Havivi
889e555168 v2v: -o vdsm should assume data domain at -os path
Unlike -o rhev which have only one data domin, -o vdsm can and usually
does have multiple data domain.
The path to vdsm is pre mounted so no need to assume nfs path with -os
Example:
-o vdsm -os /rhev/data-center/<data-center-uuid>/<data-domain-uuid>

Bug-Url: https://bugzilla.redhat.com/1176591
Signed-off-by: Shahar Havivi <shaharh@redhat.com>
2015-01-26 10:31:14 +00:00
Richard W.M. Jones
c24f242521 aarch64: Increase default appliance memory size on aarch64.
Kernel 3.19 has problems uncompressing the RAM disk with <= 500 MB.
(This is likely to be a kernel bug)

64 KB pages are common on aarch64, so treat this case the same as ppc,
and use a larger default appliance memory size.

Thanks: Laszlo Ersek for help and reproducing the bug.
2015-01-24 15:40:05 +00:00
Richard W.M. Jones
987273ebd0 launch: libvirt: When debugging the appliance dir, use 'ls -R'.
Since libguestfs >= 1.26 / supermin 5, the appliance has lived in a
subdirectory of $TMPDIR/.guestfs-$UID.  As a result using 'ls -l'
didn't display any information about the files in the appliance.

Using '-R' causes this information to be displayed again.
2015-01-24 08:47:00 +00:00
Richard W.M. Jones
f9c5b4aa2a launch: libvirt: In debug messages use ls --lcontext instead of ls -Z.
ls -Z stops ls from displaying the size field.  --lcontext uses longer
lines but has the advantage of still displaying the size field as well
as the SELinux context.
2015-01-24 08:45:48 +00:00
Richard W.M. Jones
b6cd5c3a2b p2v: Add NetworkManager in the hope of getting working network.
I know "working network" and "NetworkManager" are oxymorons, but
sometimes we have to live in hope.
2015-01-23 15:34:51 +00:00
Richard W.M. Jones
9638b13ba0 p2v: Set root password of virt-p2v ISO to 'p2v'.
It is documented as 'p2v', but in fact this was not implemented
so there is no way to log in as root on the console.

On RHEL we also have to add the 'passwd' package, else you get:

  Error creating Live CD : Unable to set unencrypted password due to lack of /usr/bin/passwd
2015-01-23 15:34:51 +00:00
Pino Toscano
515c3e3e73 mllib: do not show --short-options among the long options
--long-options is ignored because it is only meant as aid for shell
completers, so --short-options should be too for the same reason.
2015-01-23 14:15:09 +01:00
Pino Toscano
6bc9976886 mllib: add simple tests for the JSON module 2015-01-23 11:23:35 +01:00
Pino Toscano
6f14cae1ba mllib: tests: add tests for string_lines_split 2015-01-23 11:08:27 +01:00
Pino Toscano
d19eb31060 mllib: convert common_utils_tests to oUnit
Covert common_utils_tests to use oUnit as testing framework, replacing
the hand-made assert in favour of structured unit tests and better
error reporting.

common_utils_tests is now built only when the oUnit module has been
found.
2015-01-23 10:57:23 +01:00
Pino Toscano
1f5e525533 configure: look for the oUnit OCaml module
It will be used for the OCaml unit tests.
2015-01-23 10:57:23 +01:00
Pino Toscano
eda4126868 customize: add --commands-from-file
Pass to --commands-from-file the name of a file containing customization
commands in each line, as if they were specified as command line
arguments.

This eases the reuse of commands among different
builder/customize/sysprep invocations.
2015-01-22 17:07:02 +01:00
Pino Toscano
09f76fd2a9 mllib: add string_lines_split
Introduce an helper function to split a text into lines, keeping into
accout continuation lines (i.e. with \ at the end).
2015-01-22 17:06:56 +01:00
Richard W.M. Jones
145db4f629 test: fuse: Add debugging of commands run in the test. 2015-01-22 10:44:32 +00:00
Richard W.M. Jones
34b118a25a Version 1.29.22. 2015-01-21 20:45:17 +00:00
Hu Tao
d4c8433e6e New API: add btrfs_rescue_super_recover
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
2015-01-21 14:28:10 +00:00
Hu Tao
15c75eaace New API: add btrfs_rescue_chunk_recover
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
2015-01-21 14:28:10 +00:00
Hu Tao
e32b59c926 New API: add btrfs_filesystem_defragment
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
2015-01-21 14:28:10 +00:00
Hu Tao
fd7df408d1 New API: btrfs_balance_resume
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
2015-01-21 14:28:10 +00:00
Hu Tao
a72204bde7 New API: btrfs_balance_cancel
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
2015-01-21 14:28:10 +00:00
Hu Tao
9f11ddd29e New API: btrfs_balance_pause
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
2015-01-21 14:28:10 +00:00
Hu Tao
47f0336e09 btrfs: replace "btrfs filesystem balance" with "btrfs balance"
"btrfs filesystem balance" is deprecated in favor of "btrfs balance".

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
2015-01-21 14:28:10 +00:00
Hu Tao
9e6122265e New API: btrfs_scrub_resume
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
2015-01-21 14:28:10 +00:00
Hu Tao
55bfd127d4 New API: btrfs_scrub_cancel
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
2015-01-21 14:28:10 +00:00
Hu Tao
a4d6cc525a New API: btrfs_scrub
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
2015-01-21 14:28:10 +00:00
Richard W.M. Jones
7e4b7a346a aarch64: launch: libvirt: As a workaround, pass -cpu parameter to qemu.
When libguestfs is running using TCG on aarch64, we need to pass the
-cpu cortex-a57 parameter to qemu.  Libvirt doesn't let us do this,
complaining "Unable to find CPU definition".

As a temporary workaround only, use <qemu:commandline> to pass this
argument directly to qemu.  When libvirt is fixed we can remove this
hack.

This is a workaround for libvirt bug RHBZ#1184411.

See:
https://www.redhat.com/archives/libvirt-users/2014-August/msg00043.html
https://bugzilla.redhat.com/show_bug.cgi?id=1184411
2015-01-21 14:28:10 +00:00
Richard W.M. Jones
7dc837c7be aarch64: appliance: Use AAVMF (UEFI) if available for running the appliance.
AAVMF is an open source UEFI implementation for aarch64 based on OVMF.
As aarch64 is heading for requiring UEFI even inside guests, if the
AAVMF firmware is installed on the host, use it as a hint that we
should boot the guest using AAVMF instead of the default "empty
machine".

Note this requires very recent AAVMF, libvirt, qemu.  However that's
OK since it's only applicable to aarch64.  On non-aarch64, this patch
does nothing.

Thanks: Laszlo Ersek for a lot of help getting this right.
2015-01-21 14:28:09 +00:00
Pino Toscano
cb0c2c3357 launch: libvirt: do not leak the backend string on error
Make sure to free the backend string after using it.
2015-01-20 16:23:12 +01:00
Pino Toscano
bff99cec4d fish: remove extra "prompt" checks
The code is already within a "if (prompt) {...}" block, so checking for
"prompt" again is redundant.
2015-01-20 16:09:53 +01:00
Pino Toscano
7618e41d33 daemon: readdir: fix invalid memory access on error
If "strdup (d->d_name)" fails with "i" > 0, then both "p" and
"ret->guestfs_int_dirent_list_val" are non-null pointers, but the latter
is no more valid (since "p" is the new realloc'ed buffer). Hence, trying
to free both will access to invalid memory.

Make sure to free only one of them, "p" if not null or
"ret->guestfs_int_dirent_list_val" otherwise.
2015-01-20 16:09:53 +01:00
Pino Toscano
0eedddad2f fuse: test-fuse: free "acl_text"
Make sure to free the buffer returned by acl_to_any_text.
2015-01-20 16:09:53 +01:00
Richard W.M. Jones
91c34ff8ff p2v: Fix wait_qemu_nbd to use getaddrinfo.
wait_qemu_nbd would fail in Rawhide where /etc/hosts contains:

  127.0.0.1   localhost [...]
  ::1         localhost [...]

This peculiar mapping caused qemu-nbd to always select an IPv6
address.  However since we used the obsolete inet_pton function and
forced AF_INET, we were always trying to connect to the IPv4
localhost.

As this was never going to work anyway, fix the code to use
getaddrinfo to resolve "localhost", and use a loop to connect to all
possible addresses.

Also: Add a short sleep in the reconnection loop so that we don't
hammer the qemu-nbd server while it is starting up.
2015-01-20 09:49:31 +00:00
Richard W.M. Jones
0b54e111e4 p2v: Move debug message earlier.
This ensures we can see the port numbers even when the
connection fails.
2015-01-20 09:49:31 +00:00
Richard W.M. Jones
3ca0ce45af p2v: Correct garbled comments in test script. 2015-01-20 09:49:31 +00:00
Richard W.M. Jones
f45b6928c5 aarch64: python: Skip test that requires IDE.
This test launches a dummy guest using IDE.  Aarch64 doesn't support
IDE, and because it also doesn't support PCI (virtio-mmio instead)
it's hard to formulate libvirt XML that will work on both x86 and
virtio-mmio.

Since this bug is not architecture specific (RHBZ#912499), skip it on
non-x86.  The test will print:

  skipping test: arch is not x86 and does not support IDE
2015-01-20 09:49:31 +00:00
Richard W.M. Jones
9bf6f7f056 Version 1.29.21. 2015-01-19 19:19:12 +00:00
Pino Toscano
cfc142399f gobject: fix printf conversion specifier
Use PRIu64 to correctly handle uint64_t.
2015-01-19 19:05:23 +00:00
Richard W.M. Jones
52528729f6 gcc5: test-tool: Initialize local variable.
gcc 5 cannot prove that the variable is always initialized
and therefore prints a warning.
2015-01-19 16:06:16 +00:00
Pino Toscano
fceab82647 build: check for single libsystemd before libsystemd-journal
Since systemd 209, all the functionalities of the former libsystemd-*
(including libsystemd-journal) have been merged into a single
libsystemd, with the former libraries left as compatibility ones.

Thus, first look for libsystemd, and if not found try again with the
libsystemd-journal as used before.
2015-01-19 16:47:54 +01:00
Pino Toscano
1709263613 sparsify: handle output filenames with ':'
With commit a594b7f90a the checks for
input and output files with ':' were removed; while the input file is
handled correctly by the disk_create API, an output filename with ':'
could still be handled as specifying a transport, failing the last
"qemu-img convert" call.

Use the new qemu_input_filename helper to handle the output filename
correctly.
2015-01-19 16:47:54 +01:00
Pino Toscano
c796280a8e mllib: add simple qemu filename sanitizing function
It mimics a bit in OCaml the logic used in
commit a95214b198 (for the main library)
and commit 588af1953e (in disk-create),
so in OCaml tools direct calls to qemu/qemu-img with filenames provided
by the user can properly handle filenames with e.g. ':'.
2015-01-19 16:47:53 +01:00
Pino Toscano
8b9ca28e11 mknod: filter modes in mkfifo, mknod_b, mknod_c (RHBZ#1182463).
Since mkfifo, mknod_b, and mknod_c add the correct file type to the
modes of the resulting file, make sure the specified mode contains only
permissions bits.
2015-01-19 16:47:53 +01:00
Pino Toscano
8ad667f198 daemon: use ntfslabel(1) to get ntfs labels
blkid(1) (or actually, libblkid) seems to handle filesystem labels up
to 127 characters. Considering that btrfs labels can be up to 128
characters, this means long labels are not read correctly (i.e. get
truncated) by blkid.  Furthermore, ntfs labels are actually unicode,
and libblkid seems to not decode them correctly.

Hence, if ntfsprogs is available invoke `ntfslabel` to get the label
of ntfs filesystems.

Related to RHBZ#1164708.
2015-01-19 16:47:53 +01:00
Pino Toscano
6db3c100e7 daemon: use btrfs(1) to get btrfs labels
blkid(1) (or actually, libblkid) seems to handle filesystem labels up
to 127 characters. Considering that btrfs labels can be up to 255
characters, this means long labels are not read correctly (i.e. get
truncated) by blkid.

Get the filesystem type, and if btrfs is available invoke
`btrfs filesystem` to get the label of btrfs filesystems.

Related to RHBZ#1164708.
2015-01-19 16:47:53 +01:00
Pino Toscano
d7abf5c8f2 format, make-fs: specify the label on mkfs
If specified, pass the label for the new filesystem directly to the
mkfs (or mkfs_btrfs) call.

This saves one set_label call, mostly.
2015-01-19 16:47:53 +01:00
Pino Toscano
7723614a91 mkfs: add 'label' optional argument
Add the 'label' optional argument to the mkfs action, so it is possible
to set a filesystem label direct when creating it. There may be
filesystems not supporting changing the label of existing filesystems
but only setting it at creation time, so this new optarg will help.

Implement it for the most common filesystems (ext*, fat, ntfs, btrfs,
xfs), giving an error for all the others, just like set_label does.
2015-01-19 16:47:53 +01:00
Richard W.M. Jones
19c09bcdee tests/lvm: Remove use of deprecated sfdiskM API.
See: https://bugzilla.redhat.com/show_bug.cgi?id=1183236
for the sorry tale.
2015-01-19 15:01:37 +00:00
Richard W.M. Jones
eb85ac6a0d valgrind: Remove suppression for fixed memory leak in libselinux.
This memory leak has been fixed since libselinux 2.1.13.

Thanks: Daniel Walsh
2015-01-19 13:03:24 +00:00
Richard W.M. Jones
4f3c288a1b lua: Define luaL_checkint which was deprecated in lua 5.3. 2015-01-18 07:38:58 +00:00
Richard W.M. Jones
5ab3a75e1d tests/lvm: Allow test-lvm-mapping.pl to be skipped. 2015-01-17 14:24:35 +00:00
Richard W.M. Jones
9d9ef2960c Version 1.29.20. 2015-01-17 11:45:31 +00:00
Richard W.M. Jones
c5800dc97d Update copyright dates for 2015. 2015-01-17 09:08:15 +00:00
Richard W.M. Jones
378ed3be5e ocaml: Convert debug_logging example from C to OCaml.
Continue gradual conversion of C examples to other languages.
2015-01-17 07:14:33 +00:00
Kashyap Chamarthy
4bd0d17047 virt-buider: doc: Use osinfo-query to get OS variants
Upstream dropped[1] support for '--os-variant list' in favor of using
`osinfo-query` tool provided by the libosinfo project.

To get a list of all accepted operating systems, invoke:

  osinfo-query os

[1] https://git.fedorahosted.org/cgit/virt-manager.git/commit/?id=bcb60f0
2015-01-14 13:16:21 +01:00
Pino Toscano
ea761df687 builder: export the "osinfo" attribute to json
Thanks to: Federico Simoncelli.
2015-01-09 11:14:35 +01:00
Pino Toscano
4f51519c9f ocaml: findlib is required when building from git
Update README according to the current requirement.

Thanks to: Gabriele Cerami.
2015-01-07 15:07:07 +01:00
Hilko Bengen
e6f77d2345 Fix out-of-tree build: Don't create empty .y file in builddir 2014-12-31 13:57:25 +00:00
Shahar Havivi
14d11916fa v2v: adding --vdsm-ovf-output option
This option is needed by vdsm for writing the ovf to a specific directory.
The default is current directory.

Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1176598
Signed-off-by: Shahar Havivi <shaharh@redhat.com>
2014-12-25 09:59:56 +00:00
Richard W.M. Jones
3a080c3fbf v2v: Reduce use of polymorphic variants.
Ordinary variants prevent coding errors.
2014-12-24 18:10:37 +00:00
Richard W.M. Jones
70c28f3d5e v2v: -i libvirtxml: Only handle NBD source with host 'localhost', for virt-p2v.
We only care/support virt-p2v for network disks.  Give a warning about
anything else.

This avoids a potential quoting issue.
2014-12-24 17:58:36 +00:00
Richard W.M. Jones
45bd4f604d v2v: Update TODO. 2014-12-24 17:09:57 +00:00
Richard W.M. Jones
c5e11785af v2v: DOM: Fix quoting of XML comments.
We need to quote at least & and > in XML comments.
2014-12-24 16:51:15 +00:00
Richard W.M. Jones
86a08d860a v2v: Hide implementation of 'element'.
Following the previous commit, the implementation of 'element'
does not need to be public.
2014-12-24 13:34:26 +00:00
Richard W.M. Jones
47b54a7ba5 v2v: Move append_* functions to DOM module.
Just code motion.
2014-12-24 13:32:18 +00:00
Richard W.M. Jones
791db53b10 Version 1.29.19. 2014-12-23 15:30:06 +00:00
Richard W.M. Jones
29df51d9bc v2v: Add a note about escaping username like DOMAIN\user.
Thanks: Ben Hooper.
2014-12-23 15:30:06 +00:00
Richard W.M. Jones
91b5863a7d aarch64: builder: Silence gcc warnings from flex-generated code. 2014-12-23 12:10:10 +00:00
Richard W.M. Jones
fdf6221f33 fish: c-pointer: Print the pointer in hexadecimal.
$ guestfish
><fs> c-pointer
0x1fb4f80

This updates commit d8c43d556b.
2014-12-22 11:00:32 +00:00
Richard W.M. Jones
92575d0eab errors: Even clearer error message.
Obviously no one reads the FAQ, so make the error message
even clearer.

The new error messages are variation on this:

libguestfs: error: /bin/false exited with error status 1.
To see full error messages you may need to enable debugging.
Do:
  export LIBGUESTFS_DEBUG=1 LIBGUESTFS_TRACE=1
and run the command again.  For further information, read:
  http://libguestfs.org/guestfs-faq.1.html#debugging-libguestfs
You can also run 'libguestfs-test-tool' and post the *complete* output
into a bug report or message to the libguestfs mailing list.
2014-12-19 19:40:04 +00:00
Richard W.M. Jones
f6e74ecd73 ping-daemon: Fix error in the description of this API (RHBZ#1175676).
Thanks: Lingfei Kong
2014-12-18 10:59:15 +00:00
Richard W.M. Jones
47d909808a v2v: -o libvirt: Replace List.mapi with mapi.
Don't depend on OCaml >= 4.00.

https://bugs.gentoo.org/show_bug.cgi?id=532698

Thanks: Fabian Ohler
2014-12-18 08:30:18 +00:00
Richard W.M. Jones
045dcfbd18 v2v: Treat "oraclelinux" as if it was plain RHEL (RHBZ#1174280). 2014-12-17 15:50:44 +00:00
Richard W.M. Jones
f1ecd6af80 fish: Add regression test for RHBZ#1175196. 2014-12-17 14:38:44 +00:00
Richard W.M. Jones
5f6677ebd0 environment: Use guestfs___is_true when parsing various boolean environment variables (RHBZ#1175196).
You can now use LIBGUESTFS_DEBUG=true (etc.)

You can disable debugging/tracing by setting LIBGUESTFS_DEBUG=0 (etc.)
2014-12-17 14:38:44 +00:00
Richard W.M. Jones
bdcd2fabe9 fish: Move 'is_true' function to library utilities.
The 'is_true' function can be useful elsewhere, not just for parsing
guestfish command parameters.

This is just code motion.
2014-12-17 14:38:44 +00:00
Richard W.M. Jones
d375b7818a v2v: -o qemu: Replace List.iteri with iteri.
So we don't have to depend on OCaml >= 4.00 which is when this
function was added to the stdlib.

https://bugs.gentoo.org/show_bug.cgi?id=532698
2014-12-17 14:38:44 +00:00
Richard W.M. Jones
abf51ec70b is-blockdev: Clarify documentation (RHBZ#1175035). 2014-12-17 10:28:33 +00:00
Pino Toscano
1f7db85b30 builder: recommend use of --selinux-relabel
Add a small documentation paragraph in the "SELINUX" section
recommending the usage of --selinux-relabel for guests using SELinux.
2014-12-16 15:52:32 +01:00
Richard W.M. Jones
6264c255d4 Version 1.29.18. 2014-12-16 13:25:35 +00:00
Richard W.M. Jones
8e0fc5fb46 python: Fix regression test so it works when KVM is not available.
The test assumed (for no particular reason) that it could always run a
KVM guest.  When run on a machine without KVM, or in a VM without
nested KVM, you get this error:

libvirt: Domain Config error : internal error: no supported architecture for os type 'hvm'
Traceback (most recent call last):
  File "./t/820-rhbz912499.py", line 77, in <module>
    dom = conn.createXML (xml, libvirt.VIR_DOMAIN_START_AUTODESTROY)
  File "/usr/lib64/python2.7/site-packages/libvirt.py", line 3523, in createXML
    if ret is None:raise libvirtError('virDomainCreateXML() failed', conn=self)
libvirt.libvirtError: internal error: no supported architecture for os type 'hvm'
FAIL: ./t/820-rhbz912499.py

Use a qemu guest instead, which should have a better chance of working
on all hosts.
2014-12-16 13:16:07 +00:00
Richard W.M. Jones
974216f612 p2v: Document that virt-p2v-make-kickstart copies the virt-p2v binary into the kickstart. 2014-12-16 11:06:43 +00:00
Richard W.M. Jones
54f85f8482 p2v: virt-p2v-make-kickstart(1): Fix various typos in the man page. 2014-12-16 11:06:15 +00:00
Richard W.M. Jones
cf979dd796 p2v: virt-p2v-make-kickstart: Add URL example to the man page.
It turns out this is required for Fedora 21 (or perhaps livecd-creator
is broken yet again, who knows).
2014-12-16 09:45:29 +00:00
Richard W.M. Jones
2912fa7a43 Version 1.29.17. 2014-12-15 22:45:35 +00:00
Richard W.M. Jones
2162d09b2c Use -fno-strict-overflow throughout the build.
Builds of bison-generated files currently fail with:

index-parse.y: In function 'yyparse':
index-parse.c:1256:6: error: assuming pointer wraparound does not occur when comparing P +- C1 with P +- C2 [-Werror=strict-overflow]
     if (yyss + yystacksize - 1 <= yyssp)
        ^

This error only occurred on one machine, and it was unclear why.  It
turned out to be because the other build machines I use had:

  CFLAGS="-Wall" ./configure ...

whereas on the failing machine I was just using ./configure w/o CFLAGS.

This caused the compile flags of index-parse.c to be changed from:

  gcc -Wstrict-overflow ... index-parse.c

to:

  gcc -Wstrict-overflow -Wall ... index-parse.c

but since -Wstrict-overflow is short for -Wstrict-overflow=2, and
-Wall is short for -Wstrict-overflow=1, and since the error only
occurs at level >= 2, using CFLAGS="-Wall" was effectively turned off
the warning.

Anyway, I believe the optimizations that GCC does when
-fstrict-overflow is enabled to be dubious, frequently dangerous, and
useless.  They are only done because we want C99 to work on
architectures that don't exist in reality (and which even if they did
exist, libguestfs would probably not support).

The Linux kernel uses -fno-strict-overflow, and we should too, for the
same reasons.
2014-12-15 22:26:51 +00:00
Richard W.M. Jones
8a33d534e5 Version 1.29.16. 2014-12-15 18:46:31 +00:00
Gabriele Cerami
5a4fd83176 diff/diff.c: diff output to show correct file handles and presence symbol 2014-12-15 18:46:31 +00:00
John Eckersberg
09080a2887 p2v: avoid connecting to ourself while probing qemu-nbd (RHBZ#1167774) 2014-12-15 18:46:31 +00:00
Richard W.M. Jones
f843abe400 tests: Fix memory leaks in test-add-libvirt-dom.
Found by valgrind.

This fixes commit df9782ec3a
and commit 96158d42f5.
2014-12-15 17:28:30 +00:00
Hu Tao
e74bd45111 New API: btrfs_qgroup_remove
btrfs_qgroup_remove removes a qgroup from its parent qgroup.

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
2014-12-15 16:22:46 +00:00
Hu Tao
bd4a114272 New API: btrfs_qgroup_assign
btrfs_qgroup_assign adds a qgroup to a parent qgroup.

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
2014-12-15 16:22:46 +00:00
Hu Tao
2b7f7810ed New API: btrfs_qgroup_show
btrfs_qgroup_show shows all qgroups on a btrfs filesystem.

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
2014-12-15 16:22:46 +00:00
Hu Tao
3617938b48 New API: btrfs_qgroup_destroy
btrfs_qgroup_destroy destroys a qgroup.

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
2014-12-15 16:22:46 +00:00
Hu Tao
1144c692dc New API: btrfs_qgroup_create
btrfs_qgroup_create creates a new qgroup.

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
2014-12-15 16:22:46 +00:00
Hu Tao
a325f887b3 New API: btrfs_qgroup_limit
btrfs_qgroup_limit limits the size of a qgroup.

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
2014-12-15 16:22:46 +00:00
Hu Tao
4e145bb44d New API: btrfs_quota_rescan
btrfs_quota_rescan trashs all qgroup numbers and scans the metadata
again with the current config.

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
2014-12-15 16:22:45 +00:00
Hu Tao
29812b8fd6 New API: btrfs_quota_enable
btrfs_quota_enable enables or disables quota for btrfs filesystems.

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
2014-12-15 16:22:45 +00:00
Hu Tao
7a25a6d141 New API: btrfs_subvolume_show
btrfs_subvolume_show shows the detailed information of a subvolume or
snapshot.

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
2014-12-15 16:22:45 +00:00
Hu Tao
56732ed6a0 New API: btrfs_subvolume_get_default
btrfs_subvolume_get_default is for getting the default subvolume of
a btrfs filesystem.

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
2014-12-15 16:22:45 +00:00
Hu Tao
152d17ddbf daemon: btrfs: add helper functions mount and umount
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
2014-12-15 16:22:45 +00:00
Richard W.M. Jones
d3e93e1011 inspection: Recognise 'dnf' as the package manager in Fedora 22.
Also fix virt-sysprep and virt-customize so they can work with dnf.

I also sorted some of the lists alphabetically.
2014-12-15 14:41:29 +00:00
Richard W.M. Jones
7a218cbdf6 v2v: Password attr in domain XML should be 'passwd=' (RHBZ#1174123). 2014-12-15 13:43:34 +00:00
Richard W.M. Jones
dfded7c941 v2v: Get passwords in domain XML (RHBZ#1174123).
Thanks: Tingting Zheng
2014-12-15 08:55:12 +00:00
Richard W.M. Jones
9c4af17add v2v: Whitespace change. 2014-12-15 08:54:59 +00:00
Richard W.M. Jones
da34797987 p2v: Add more authors. 2014-12-13 19:34:29 +00:00
Richard W.M. Jones
5a964144b2 p2v: Rename authors.c, copying.c -> about-* to avoid confusion.
Just file renaming, no other change.
2014-12-13 19:30:47 +00:00
Richard W.M. Jones
f9e0aee149 sysprep: Use automake to build the library.
Normally this requires the program to have at least one C source file.
virt-sysprep doesn't have this, but it uses C sources from other
directories, and therefore we can make it work.
2014-12-13 18:10:58 +00:00
Richard W.M. Jones
604bb7fd7b mllib: Use automake to build the library. 2014-12-13 14:56:30 +00:00
Richard W.M. Jones
ccb1f2a4a0 recipes: Tidy up section about hex-dumping and hex-editing sectors. 2014-12-13 14:49:50 +00:00
Richard W.M. Jones
603d0fbd95 p2v: Test two disk guest.
Make the test harder (evil grin).
2014-12-12 17:41:47 +00:00
Richard W.M. Jones
402bba3505 Version 1.29.15. 2014-12-12 17:13:51 +00:00
Richard W.M. Jones
f4b846445e builder: Try again to fix the infinitely recursive index-parse.h rule.
I ran 'make clean && make' hundreds of times in the builder
subdirectory and it didn't fail.
2014-12-12 16:00:58 +00:00
Richard W.M. Jones
b547b62789 v2v: C files are located in srcdir, not builddir. 2014-12-12 15:50:08 +00:00
Richard W.M. Jones
9d3a02792f sparsify: C files are located in srcdir, not builddir. 2014-12-12 15:50:08 +00:00
Richard W.M. Jones
d8c43d556b New API: guestfs_c_pointer
This returns the C pointer to the guestfs_h handle (ie. guestfs_h *).

The purpose of this API is to interwork with other non-C libraries.
See RHBZ#1075164 for the rationale when applied to another library.
2014-12-12 15:50:08 +00:00
Richard W.M. Jones
1e7a6d9f10 perl: Implement Pointer ("virDomainPtr", _).
This allows the Perl binding of guestfs_add_libvirt_dom to work.

This relies on the internal Perl representation of virDomainPtr, but
Dan assures me this isn't going to change.
2014-12-12 15:50:07 +00:00
Richard W.M. Jones
df9782ec3a tests: Enable and fix test-add-libvirt-dom test.
Commit 96158d42f5 enabled the previously
private guestfs_add_libvirt_dom API.  It also tried to enable the
existing test for this API, but failed to do that correctly.  Also the
test was broken.  Fix all of this.

This fixes commit 96158d42f5.
2014-12-12 15:50:07 +00:00
Richard W.M. Jones
741403d718 v2v: Replace .. with $(top_builddir)
No functional change.
2014-12-12 15:50:07 +00:00
Richard W.M. Jones
85b664dacd builder: index-parse: Remove unused destructor.
YACC     index-parse.c
index-parse.y:97.34-41: warning: type <fields> is used, but is not associated to any symbol [-Wother]
 %destructor { field_free ($$); } <fields>
                                  ^^^^^^^^
index-parse.y:95.36-45: warning: type <sections> is used, but is not associated to any symbol [-Wother]
 %destructor { section_free ($$); } <sections>
                                    ^^^^^^^^^^
2014-12-12 15:50:07 +00:00
Richard W.M. Jones
9135129b0f builder: Use automake to build the binary.
As this has the side effect of enabling warnings in the C code, I had
to fix a lot of C problems in this commit too.
2014-12-12 15:50:07 +00:00
Richard W.M. Jones
e87df1d581 customize: Use automake to build the binary. 2014-12-12 15:12:17 +00:00
Richard W.M. Jones
bd74c6f09a resize: Use automake to build the binary. 2014-12-12 13:24:24 +00:00
Richard W.M. Jones
5a1204594c Version 1.29.14. 2014-12-11 16:29:29 +00:00
Richard W.M. Jones
90e9ad7ff9 python: Add a regression test for disk labelling. 2014-12-11 15:16:42 +00:00
Richard W.M. Jones
39f7eaea80 launch: libvirt: Fix labelling of overlay files.
We had code (added for RHBZ#912499) which labels overlay files
correctly so that libvirt can read them.  Unfortunately this code was
broken by subsequent commits: the new backend setting for the
imagelabel is only copied to the 'data' struct during launch, but the
create_cow_overlay callback is called before launch (when adding
drives).

The fix is easy: ensure create_cow_overlay_libvirt checks for the
backend setting and initializes the 'data' struct.

This change also means we need to free (data->selinux_imagelabel)
before setting it in launch (and we do the same for
data->selinux_label, although that's not strictly necessary).

For background on this, see:
https://bugzilla.redhat.com/show_bug.cgi?id=912499#c10
2014-12-11 15:16:42 +00:00
Richard W.M. Jones
f4b4dcc03a debug: add-domain: Dump XML of original domain.
Useful for debugging labelling issues.
2014-12-11 15:16:42 +00:00
Richard W.M. Jones
2c9f6da034 python: Implement Pointer ("virDomainPtr", _) (RHBZ#1075164).
This allows the Python binding of guestfs_add_libvirt_dom to work.

There is a regression test to ensure this keeps working.

Note this requires a patched libvirt-python, supporting the
c_pointer() method.
2014-12-11 15:16:42 +00:00
Richard W.M. Jones
db1c8a6436 python: Improve harness for running Python tests.
It now understands exit code 77 == skip, amongst other improvements.
2014-12-11 14:15:00 +00:00
Richard W.M. Jones
96158d42f5 New(ish) API: guestfs_add_libvirt_dom.
This API already existed (as guestfs___add_libvirt_dom), and was used
by a few tools.

This commit changes it to a public API.

Note that for reasons outlined in the previous commit message, it is
impossible to call this from guestfish or from non-C language
bindings.
2014-12-11 14:15:00 +00:00
Richard W.M. Jones
fd9ac7f47d generator: Implement Pointer arguments.
This implements Pointer arguments properly, at least for certain
limited definitions of "implements" and "properly".

'Pointer' as an argument type is meant to indicate a pointer passed to
an API.  The canonical example is the following proposed API:

  int guestfs_add_libvirt_dom (guestfs_h *g, virDomainPtr dom, ...);

where 'dom' is described in the generator as:

  Pointer ("virDomainPtr", "dom")

Pointer existed already in the generator, but the implementation was
broken.  It is not used by any existing API.

There are two basic difficulties of implementing Pointer:

(1) In language bindings there is no portable way to turn (eg.) a Perl
Sys::Virt 'dom' object into a C virDomainPtr.

(2) We can't rely on <libvirt/libvirt.h> being included (since it's an
optional dependency).

In this commit, we solve (2) by using a 'void *'.

We don't solve (1), really.  Instead we have a macro
POINTER_NOT_IMPLEMENTED which is used by currently all the non-C
language bindings.  It complains loudly and passes a NULL to the
underlying function.  The underlying function detects the NULL and
safely returns an error.  It is to be hoped that people will
contribute patches to make each language binding work, although in
some bindings it will always remain impossible to implement.
2014-12-11 14:15:00 +00:00
John Eckersberg
841aa0faf3 p2v: show error dialog if virt-v2v fails (RHBZ#1167601)
Ensure the control connection exits with the same status code as
virt-v2v, and return an error from start_conversion if virt-v2v
failed.
2014-12-11 14:15:00 +00:00
Richard W.M. Jones
3d7ea11272 lib: Don't mention whitelist in guestfs_modprobe documentation.
There is no such whitelist any longer.  All modules are copied into
the appliance.
2014-12-10 13:28:35 +00:00
Richard W.M. Jones
e1fd9615cc v2v: linux: Fix modifications to default kernel for legacy grub.
This didn't work at all because the regular expression did not match
the returned Augeas path.

In future if the regular expression doesn't match, this will give an
internal error instead of continuing with a bogus value.

Thanks: Junqin Zhou for providing the test case and debug information.
2014-12-10 13:09:59 +00:00
Richard W.M. Jones
7a34855265 builder: Add Fedora 21 image, remove RHEL 7 RC image. 2014-12-09 19:16:57 +00:00
Kashyap Chamarthy
6468b9d601 arm: Use -cpu host on KVM. 2014-12-09 16:58:11 +00:00
Richard W.M. Jones
bdf772db32 inspection: Not an installer if there are multiple partitions (RHBZ#1171666).
Regular EFI disks have /EFI on the first (VFAT) partition, but they
are not installers.

Fix this by only considering something to be an installer if it has a
single partition (or whole disks like ISOs).

Implementing this is quite complex since when checking a filesystem,
we don't have information about whether we are even looking at a
partition, nor about whether it's the first partition out of how many.
The majority of the commit is changing the code to collect that
information.
2014-12-09 14:07:39 +00:00
Hu Tao
9d6f0b6a86 resize: fix 'No space left on device' problem when copying to an extended partition (RHBZ#1169015)
Because of the size of an extended partition reported by Linux is always 1024
bytes, so it will always fail to copy to an extended partition.

This patch fixes this problem by copying to the offset of an extended
partition in the destination disk.

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
2014-12-08 11:00:54 +00:00
John Eckersberg
33098d2302 p2v: wait for qemu-nbd before starting conversion (RHBZ#1167774)
Wait up to 10 seconds for qemu-nbd to start up and respond to clients.
Otherwise the conversion server may attempt to connect before qemu-nbd
is ready to serve it.
2014-12-08 10:55:37 +00:00
Richard W.M. Jones
ee57b5f45a Version 1.29.13. 2014-12-05 16:16:23 +00:00
Pino Toscano
d4ffaad983 sysprep: user-account: mark "changed file" if users were removed
Removing an user causes /etc/passwd, /etc/shadow, and /etc/group to
change, so mark the side effects as such if any user has been removed.
2014-12-05 16:10:56 +01:00
Pino Toscano
acb6e8f344 sysprep: add a "changed file" side effect 2014-12-05 16:10:56 +01:00
Pino Toscano
1ea9b684b2 customize, sysprep: add a short SELinux note
Add a short paragraph about SELinux, mostly to point to the
documentation about it provided in the documentation of virt-builder.
2014-12-05 16:10:56 +01:00
Richard W.M. Jones
be73b1750f v2v: Add documentation about what to do about BSOD 0x0000007B (RHBZ#1161333).
After a very long and trying episode with a Windows guest that refused
to boot after conversion, we managed to successfully boot it by
disabling Windows Group Policy.  It appears that Group Policy
prevented the virtio driver from being used.

Document this in the manual.
2014-12-05 15:04:03 +00:00
Richard W.M. Jones
a542389767 v2v: Remove documentation about Windows Recovery Console not supported.
We have now successfully converted guests using WRC, so this statement
is no longer necessary.
2014-12-05 14:29:26 +00:00
Richard W.M. Jones
1bd779c983 v2v: Fix missing loop device which breaks conversion of RHEL 3 guests (RHBZ#1171130). 2014-12-05 13:52:25 +00:00
Richard W.M. Jones
205a8c7ca1 v2v: Don't use epoch prefix on RPM command line for RHEL <= 4 (RHBZ#1170685).
See the explanation here:
https://bugzilla.redhat.com/show_bug.cgi?id=1170685#c7
2014-12-05 13:09:10 +00:00
Hu Tao
eddc8862e0 fish: fix build warning when readline-devel is missing
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
2014-12-05 12:41:34 +00:00
Richard W.M. Jones
212660f70f builder: Add support for RHEL 3, RHEL 4. 2014-12-05 12:38:58 +00:00
Nikos Skalkotos
20098d4534 Add freebsd and netbsd distros
Prior to this commit the distro for a FreeBSD or a NetBSD system, in
conjuction to what happened for OpenBSD, was shown as 'unknown'.
*BSDs are complete OSes, not a kernel like Linux, but theoritically you
could have FreeBSD as ostype and PC-BSD as distro.

Signed-off-by: Nikos Skalkotos <skalkoto@grnet.gr>
2014-12-04 22:08:09 +00:00
Nikos Skalkotos
b58022eca7 Fix fstab block device resolution for FreeBSD
Take into granted that partition 'c' has a special purpose. It has
always the same size as the enclosing slice and is not mapped under
Linux.

This is a best effort try. The mapping will be incorrect if there is a
gap in the disklabel partitions sequence, e.g. 'b' (swap) partition is
missing but 'd' partition is defined.

Signed-off-by: Nikos Skalkotos <skalkoto@grnet.gr>
2014-12-04 22:08:09 +00:00
Nikos Skalkotos
af6ea8fa8f Support fstab block device resolution for NetBSD
Make a best effort try to map NetBSD disklabel partitions to Linux
partitions. The mapping will be incorrect if there is a gap in the
disklabel partitions sequence, e.g. 'b' (swap) partition is missing but
'e' partition is defined.

Signed-off-by: Nikos Skalkotos <skalkoto@grnet.gr>
2014-12-04 22:08:09 +00:00
Nikos Skalkotos
7adbf72f1b inspect_os: Add support for detecting OpenBSD
Signed-off-by: Nikos Skalkotos <skalkoto@grnet.gr>
2014-12-04 22:08:09 +00:00
Richard W.M. Jones
0c2e676f6c v2v: When picking a default kernel, favour non-debug kernels over debug kernels (RHBZ#1170073). 2014-12-04 22:00:56 +00:00
Richard W.M. Jones
c712f880db mllib: Add Common_utils.string_suffix function and extend test coverage. 2014-12-04 22:00:56 +00:00
Richard W.M. Jones
39d64121ec v2v: Disable autoreboot when converting Windows guests.
This allows users to see stop errors, so we can get an accurate report
when things go wrong.
2014-12-04 17:39:11 +00:00
Pino Toscano
1033847f00 gobject: link against uninstalled libraries
Make sure to link the gobject library and the gir using the in-tree
built libguestfs, so a system library won't be used accidentally.
2014-12-04 17:09:32 +01:00
Nikos Skalkotos
7c7755eb60 Remove extra space in inspect-fs-unix.c
Signed-off-by: Nikos Skalkotos <skalkoto@grnet.gr>
2014-12-02 23:06:50 +00:00
Richard W.M. Jones
de0b7c4e66 build: Map host CPU 'powerpc64le' to qemu-system-ppc64.
Make the corresponding change in libguestfs-test-tool as well.

Thanks: Dan Horák
2014-12-02 09:51:41 +00:00
Hu Tao
a21ab21b1a fish: show synopsis if command syntax is wrong
This patch lets guestfish show command synopsis if the syntax of command issued
by user is wrong, rather than telling user that the number of parameters is wrong.

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
2014-12-02 08:37:46 +00:00
Richard W.M. Jones
391d90d9e7 p2v: Refer to virt-v2v resource requirements in virt-p2v man page. 2014-11-29 18:20:52 +00:00
Richard W.M. Jones
1b52139339 p2v: Mention sshd_config setting in the manual page.
The precise sshd configuration has confused some users of virt-p2v.
Only one setting (AllowTcpForwarding=yes) is required, so document it.
2014-11-29 18:20:00 +00:00
Richard W.M. Jones
4d9a14fc75 configure: Require yajl >= 2.0.4 (RHBZ#1169045).
Earlier versions fail to parse integers from 'qemu-img info' output
correctly, resulting in bugs like
https://bugzilla.redhat.com/show_bug.cgi?id=1169045

Thanks: muued @ IRC
2014-11-29 12:03:08 +00:00
Richard W.M. Jones
2990db8d1a tests/c-api: Test that the library can really be loaded with dlopen.
Answer is yes, but it was good to know.
2014-11-28 22:26:57 +00:00
Richard W.M. Jones
3a5613eb22 Version 1.29.12. 2014-11-28 19:51:47 +00:00
Richard W.M. Jones
4a63cddae4 Add HACKING file to EXTRA_DIST.
Updates commit 3d3694610f.
2014-11-28 19:50:56 +00:00
Richard W.M. Jones
d0a676c91c lib: Add COMPILE_REGEXP macro to hide regexp constructors/destructors. 2014-11-28 15:04:19 +00:00
Nikos Skalkotos
282132c58b inspect: Fix a bug in the *BSD root detection
The assumption that Linux will map the MBR partition to /dev/sda1
and the BSD 'a' partition to /dev/sda5 is not always correct.

Signed-off-by: Nikos Skalkotos <skalkoto@grnet.gr>
2014-11-28 14:56:07 +00:00
Hu Tao
b53ba64a26 uuid: make alias get-uuid for vfs_uuid
Because get-uuid looks more like a counterpart to set-uuid, and is
more likely come to mind if one knows set-uuid.

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
2014-11-28 14:19:27 +00:00
Hu Tao
45266e3d49 uuid: cannot change btrfs filesystem's UUID
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
2014-11-28 14:19:27 +00:00
Hu Tao
95644f33cd uuid: add support to change uuid of swap partition
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
2014-11-28 14:19:27 +00:00
Richard W.M. Jones
196813ea74 v2v: Fix command line --help output for --no-trim option. 2014-11-27 17:41:13 +00:00
Pino Toscano
6faa7b4c84 bash: add a completion module for virt-v2v 2014-11-27 16:26:14 +01:00
Pino Toscano
e3834188a9 bash: complete some params for resize, sparsify, and builder
Hardcode the list of fixed arguments for some of the parameters of these
tools.
2014-11-27 16:26:13 +01:00
Pino Toscano
1784cd2633 bash: complete also short options
Propose both short and long options when trying to complete a single
dash ("-").
2014-11-27 16:26:13 +01:00
Pino Toscano
4b792354f0 bash: execute --long-options only when needed
Delay the execution of $tool --long-options only when really using its
output.
2014-11-27 16:26:13 +01:00
Pino Toscano
b00adf3b78 tools: implement --short-options
Just like --long-options, it makes it possible to know which short
options are supported by each tool; this can help improving the bash
completion, for example.
2014-11-27 16:26:13 +01:00
Richard W.M. Jones
3d3694610f p2v: Add HACKING file. 2014-11-27 14:39:31 +00:00
Richard W.M. Jones
7ee6977f7e Version 1.29.11. 2014-11-27 12:04:30 +00:00
Pino Toscano
5e81c838e8 Update gobject/Makefile.inc and POTFILES
Followup of commit a120449c979993f4b5bd458ece00fadb339546d3.
2014-11-26 17:22:02 +01:00
Hu Tao
1622e3d218 btrfs: add optional parameter `qgroupid' to btrfs_subvolume_create
Parameter `qgroupid' is for adding the created subvolume to a qgroup.

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
2014-11-26 17:22:02 +01:00
Hu Tao
9e7b9ef97f btrfs: add optional parameter `qgroupid' to btrfs_subvolume_snapshot
Parameter `qgroupid' is for adding the created snapshot to a qgroup.

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
2014-11-26 17:22:01 +01:00
Pino Toscano
5f608f0735 Update gobject/Makefile.inc and POTFILES
Followup of commit 0b3c1762965f339915fd080884a61dbb36545204.
2014-11-26 17:22:01 +01:00
Hu Tao
b349076aee btrfs: add optional parameter `ro' to btrfs_subvolume_snapshot
Parameter `ro' is for creating readonly btrfs snapshot.

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
2014-11-26 17:22:01 +01:00
Richard W.M. Jones
8cd2620448 Add debug APIs: bmap-file, bmap-device, bmap.
Add *interim* support for a block mapping API, used by the 'virt-bmap'
tool.  These are debug APIs so they will eventually be replaced by
real APIs along the lines described here:

https://www.redhat.com/archives/libguestfs/2014-November/msg00197.html
2014-11-26 16:15:47 +00:00
Hu Tao
dc1f15aa3e typo fix: commmand -> command
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
2014-11-26 13:22:36 +01:00
Hu Tao
b6f6454678 typo fix: preceeding -> preceding
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
2014-11-26 13:22:32 +01:00
Richard W.M. Jones
55f6dc7f3d Version 1.29.10. 2014-11-25 19:38:44 +00:00
Nikos Skalkotos
f3dbf340b8 Add tests for Arch Linux
Signed-off-by: Nikos Skalkotos <skalkoto@gmail.com>
2014-11-25 15:25:45 +00:00
Pino Toscano
7ce73d8980 mllib: check the right out channel for tty
Make sure to check whether the given output channel is a tty before
sending ANSI terminal codes to it, instead of always check what stdout
is.
2014-11-25 15:40:49 +01:00
Pino Toscano
b2b65bcefb mllib: remove the TTY module
The only function provided is isatty_stdout, which is no more used now
in favour of Unix.isatty.
2014-11-25 15:40:49 +01:00
Pino Toscano
8a56fc8e08 mllib: use Unix.isatty
Make use of Unix.isatty instead of our TTY.isatty_stdout, as the
supported OCaml provides the former already.
2014-11-25 15:40:49 +01:00
Hu Tao
bd61f25625 generator: force longdesc to begin with uppercase
As contrast to shortdesc which is forced to begin with lowercase, this
patch forces longdesc to begin with uppercase.

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
2014-11-25 14:35:40 +00:00
Richard W.M. Jones
7030635e51 v2v: -i ova: Small correction to warning message.
Thanks: Pino Toscano
2014-11-25 14:34:27 +00:00
Richard W.M. Jones
350b6eec4d New API: guestfs_blockdev_setra: Adjust readahead for filesystems and devices.
This adds a binding for 'blockdev --setra', allowing you to adjust the
readahead parameter for filesystems and devices.
2014-11-25 14:34:27 +00:00
Richard W.M. Jones
dbdfa79d91 daemon: blockdev: Allow extraarg to be 0.
No change, since extraarg is not actually used.
2014-11-25 14:31:42 +00:00
Richard W.M. Jones
79fb3debc4 v2v: -i ova: Remove incorrect warning for disks that have no parent controller (RHBZ#1167302).
Don't assume every disk <Item> has a <Parent> field.  For floppy disks
this is not the case.

Thanks: Junqin Zhou
2014-11-24 19:02:34 +00:00
Richard W.M. Jones
dc845c9a66 ntfsresize: Capture errors sent to stdout (RHBZ#1166618).
ntfsresize sends error messages to stdout.  Capture those error
messages.
2014-11-24 19:02:34 +00:00
Richard W.M. Jones
e90ab1530e lib: guestfs_disk_create: Allow vmdk as a valid backingformat.
Commit 588af1953e started with a very
conservative list of permitted backing formats (just "raw" or
"qcow2").  We can allow almost any format permitted by qemu, but this
commit just adds "vmdk" to this whitelist.
2014-11-23 22:15:42 +00:00
Hu Tao
5a84407f57 btrfs: correct words about subvolume and snapshot
btrfs_subvolume_create creates only subvolumes. btrfs_subvolume_delete
deletes subvolumes or snapshots.

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
2014-11-21 18:11:44 +01:00
Pino Toscano
99263616ca src: inspect: move read_package within the -Wno-cast-align block
Starting from commit e260460a8f be32toh is
used, which means possible "unaligned cast" warnings (already covered in
get_rpm_header_tag).
2014-11-21 16:10:33 +01:00
Pino Toscano
2305fe3fc6 build: mllib: put $(LIBTINFO_LIBS) within '...'
This helps when $(LIBTINFO_LIBS) contains spaces (i.e. more than one
"word").
2014-11-21 16:08:50 +01:00
Richard W.M. Jones
c64467a4c1 p2v: Include version and md5sum in kickstart.
Include the version of virt-p2v and its MD5 checksum in the source
kickstart.  This is useful for working out which version of virt-p2v
the kickstart corresponds to.
2014-11-20 22:22:49 +00:00
Richard W.M. Jones
ac1b4bcd7d Version 1.29.9. 2014-11-20 21:49:03 +00:00
Richard W.M. Jones
25b979a0c4 p2v: Make the "Cancel Conversion" button work (RHBZ#1165569).
This relies on the remote to keep sending us data.  If it hangs, then
the cancel button won't work.  This could also be fixed by introducing
a timeout to the read syscall.
2014-11-20 16:11:19 +00:00
Richard W.M. Jones
98dd01728f p2v: Disable "Cancel Conversion" button after the conversion (RHBZ#1165569).
Actually this bug does nothing and remains cancelled all the
way through.  The next commit makes it function.
2014-11-20 16:11:19 +00:00
Richard W.M. Jones
141832e2b2 p2v: Add 'Reboot' button to the GUI (RHBZ#1165564). 2014-11-20 16:11:19 +00:00
Richard W.M. Jones
5d695d37a5 p2v: gui: Get the correct button for cancel_button.
I was fetching cancel_button from the wrong dialog (conv_dlg, not
run_dlg), and therefore getting the wrong button.

This explains why the back button on the conversion dialog was always
insensitive.  It's because cancel_button was assigned to this button,
and then I was setting cancel_button to insensitive.
2014-11-20 16:11:19 +00:00
Richard W.M. Jones
11347db576 p2v: Remove --fullscreen option.
It did nothing and was left over from an earlier attempt to add
fullscreen mode.  That is not needed any longer since we now run
virt-p2v under the matchbox window manager.
2014-11-20 16:11:19 +00:00
Richard W.M. Jones
3dabc7a7ba appliance: When running systemd-tmpfiles, pass --boot option (RHBZ#1165785).
This causes all tmpfiles to be created.
2014-11-20 13:05:26 +00:00
Richard W.M. Jones
8e78a83067 appliance: Create tmpfiles before running udev.
This is the same order as systemd would run them.
2014-11-20 13:04:45 +00:00
Richard W.M. Jones
63d67ac8ac v2v: linux: Delete the LVM cache which may reference old devices (RHBZ#1164853).
Thanks: Bryn M. Reeves
2014-11-20 11:22:32 +00:00
Richard W.M. Jones
7b8c6e762e v2v: linux: Remap device names in /boot/grub2/device.map (RHBZ#1165975).
Thanks: Junquin Zhou
2014-11-20 10:08:51 +00:00
Richard W.M. Jones
171e6383a2 v2v: linux: In verbose mode, add dracut --verbose parameter.
So we can see exactly what dracut is doing in the debug output.
2014-11-19 13:20:13 +00:00
Nikos Skalkotos
6aaff1fffa inspection: deb: Seperate epoch field from version
Return it in the app2_epoch field of the guestfs_application2 struct

Signed-off-by: Nikos Skalkotos <skalkoto@gmail.com>
2014-11-18 20:41:05 +00:00
Richard W.M. Jones
28f2cb7e3a Version 1.29.8. 2014-11-18 16:55:21 +00:00
Richard W.M. Jones
467bbf72f7 v2v: linux: Refactor device replacement code.
No functional change.  This should be equivalent to previously.
2014-11-18 14:38:14 +00:00
Richard W.M. Jones
b1053150a2 v2v: linux: Always match partition number in regexp.
Change the rex_device_p regular expression to always include a
partition number.

There should be no functional change here.
2014-11-18 14:38:14 +00:00
Richard W.M. Jones
e25f68c47e v2v: linux: Print block device map in verbose mode.
Very useful for debugging device mapping problems.
2014-11-18 14:38:14 +00:00
Richard W.M. Jones
4c7026fb7a v2v: Don't change Augeas device entries unless the value has changed.
When remapping block devices, don't change an entry unless its value
has changed.  This avoids unnecessary Augeas writes.
2014-11-18 14:38:14 +00:00
Richard W.M. Jones
9ebc125723 v2v: Don't use <target dev> attribute, use <target bus> instead.
The <target dev> attribute in libvirt isn't very informative.  What we
really want to know is whether the source disk used IDE or SCSI, as
that allows us to remap block devices accurately during conversion.
For example, if the source was IDE and RHEL 5, and after conversion
virtio will be supported, then we know that we need to remap
"/dev/hda" to "/dev/vda".

Drop the s_target_dev and s_removable_target_dev fields and replace
them with s_controller and s_removable_controller.

For -i libvirt, use the <target bus> attribute to get this information.

For -i ova, use the OVF disk controller's ResourceType.
(http://blogs.vmware.com/vapp/2009/11/virtual-hardware-in-ovf-part-1.html)
2014-11-18 13:34:57 +00:00
Richard W.M. Jones
78f6d3aff5 v2v: -i ova: XML is case-sensitive, so replace 'InstanceId' with 'InstanceID'. 2014-11-18 12:35:38 +00:00
Nikos Skalkotos
01bdfe7d81 list-applications: Add support for pacman
Extend the guestfs_inspect_list_applications2 API call to work on Arch
Linux guest images.

Signed-off-by: Nikos Skalkotos <skalkoto@gmail.com>
2014-11-17 19:54:45 +00:00
Richard W.M. Jones
e260460a8f inspection: rpm: Return Epoch field of RPMs in application data.
Bug found by: Nikos Skalkotos
2014-11-17 13:17:07 +00:00
Richard W.M. Jones
4239191328 inspection: Allow /etc/favicon.png to be a symbolic link (RHBZ#1164619).
If /etc/favicon.png is a symbolic link, follow it.

Unfortunately RHEL 7 and Fedora have crappy 16x16 /etc/favicon.png
symlinks in the base distro.  It would be nice to ignore this symlink,
but it's almost impossible to determine if the symlink is part of the
base distro or was added by the user.  (This is a bug in those
distros.)  virt-inspector and virt-mananger both ignore favicons.
2014-11-17 10:33:35 +00:00
Richard W.M. Jones
c8a608ecf8 inspection: Get icons from RHEL and CentOS 7 (RHBZ#1164619). 2014-11-17 10:25:33 +00:00
Richard W.M. Jones
6dd371f913 Fix description of 'set_append' and 'get_append' APIs (RHBZ#1164732).
These should refer to the libguestfs appliance kernel command
line, not the guest kernel command line.

Thanks: Lingfei Kong
2014-11-17 10:07:28 +00:00
Richard W.M. Jones
88f2bc1a7b Fix minor typo in release notes (RHBZ#1164697). 2014-11-17 09:31:55 +00:00
Richard W.M. Jones
40cd76eb79 v2v: Simplify calculation of Mbps in verbose output. 2014-11-17 08:58:19 +00:00
Richard W.M. Jones
e02b261e48 v2v: Comment change. 2014-11-17 08:58:19 +00:00
Richard W.M. Jones
a5bb1a4ccb v2v: Make source s.hypervisor field type-safe. 2014-11-15 18:26:54 +00:00
Richard W.M. Jones
5920f7a568 v2v: Rename source field 's_dom_type' to 's_hypervisor'.
Also the source hypervisor cannot be "kvm".  Choose another example
for the comment.

For disks, set the source hypervisor string to "unknown".
2014-11-15 17:45:22 +00:00
Richard W.M. Jones
f421c7cae8 ocaml: Remove *.annot files when doing 'make clean'.
Commit fd70cdc3c5 passes the -annot flag
to the compiler, generating *.annot files (containing type information
used by emacs and IDEs).  Remove these files when doing 'make clean'.
2014-11-15 17:39:01 +00:00
Richard W.M. Jones
52dfb831db Version 1.29.7. 2014-11-15 17:09:59 +00:00
Pino Toscano
643162a61a appliance: explicitly add libyajl2 on openSUSE
While it has always been needed, it has been implicitly pulled in by
some other package. Hence, make it sure to always have it.
2014-11-14 18:04:12 +01:00
Richard W.M. Jones
891959cf7f df: Allow policykit and SASL authentication when reading list of domains.
Use virConnectOpenAuth instead of virConnectOpenReadOnly.

See also:
https://www.redhat.com/archives/libguestfs/2014-November/thread.html#00035
2014-11-13 15:33:21 +00:00
Pino Toscano
57547dcdcf daemon: check xfs label lengths (RHBZ#1162966).
Similar to commit 52f9cd4882, but for xfs
filesystems.
2014-11-13 14:32:01 +01:00
Pino Toscano
e698daabbc configure: simplify the qemu cpu mapping
Use AS_CASE to properly map from the host cpu to the qemu cpu suffix;
this avoids doing multiple string replacements using sed, and it is
possible to use case-like syntax.
2014-11-13 14:32:00 +01:00
Richard W.M. Jones
34d6851574 Rename LIBNCURSES* to LIBTINFO*.
We actually depend on libtinfo or libtermcap, not curses, so
rename the variable.

This updates commit 96add4d5b3.
2014-11-13 13:22:21 +00:00
Mike Frysinger
96add4d5b3 use pkg-config to look up ncurses
Hardcoding -ltinfo breaks on distros that do not build the sep library
(which is the default ncurses behavior).  Use pkg-config to look up the
right libraries regardless of how the distro built things.
2014-11-13 13:19:55 +00:00
Richard W.M. Jones
7407c0ae14 v2v: -o glance: Fix metadata for disk type and NIC (RHBZ#1161575).
The labels 'hw_disk_bus' and 'hw_vif_model' were swapped.  This
happened to work for virtio guests.  For non-virtio guests you ended
up with absurdities like requiring an rtl8139 driver for the disk.

Thanks: Junquin Zhou
2014-11-07 11:25:06 +00:00
Richard W.M. Jones
75b37b7589 Version 1.29.6. 2014-11-06 22:07:26 +00:00
Richard W.M. Jones
4a187b7faf v2v: Warn if a kernel-* package is found containing no files. 2014-11-06 18:55:04 +00:00
Richard W.M. Jones
377bc302f1 v2v: Fix kernel detection when multiple kernels are installed (RHBZ#1161250).
Previously we used to try to find the 'vmlinuz' file by running 'rpm
-ql kernel' and looking for any file called 'vmlinuz-*'.

If there were multiple 'kernel' packages installed, the rpm command
would list files from all of them, resulting in a random 'vmlinuz-*'
being chosen, not necessarily the one corresponding to the kernel
package we were looking at.

Use 'rpm -ql kernel-<VERSION>-<RELEASE>' instead so that we only look
for files in the right kernel package.

Thanks: James Mighion
2014-11-06 18:55:04 +00:00
Richard W.M. Jones
bd589a1d53 test-tool: Map powerpc64 -> ppc64 when searching for qemu.
Consequence of the previous commit.

This also adjusts the whitespace to make the generated script
a bit nicer.
2014-11-06 15:15:39 +00:00
David Sommerseth
a550ecb5f1 configure: Map powerpc64 -> ppc64. 2014-11-06 15:14:04 +00:00
Richard W.M. Jones
5de06a3571 v2v: Document minimum free filesystem space requirements. 2014-11-06 09:52:32 +00:00
Richard W.M. Jones
918dd3705d v2v: Ignore small filesystems when checking for sufficient free space. 2014-11-06 09:47:21 +00:00
Richard W.M. Jones
ea04bcbc84 Use -ltinfo instead of -lncurses.
In tools except guestfish, we don't use ncurses, or even curses, just
2 termcap functions and a global variable.  These are provided by
libtinfo, so just link to that.

In guestfish we use readline which needs ncurses.  Leave that alone.
2014-11-05 21:34:58 +00:00
Richard W.M. Jones
8c2f27518a Version 1.29.5. 2014-11-05 15:41:32 +00:00
Richard W.M. Jones
f27e242649 daemon: strings: Use -a option to avoid using BFD to parse files.
Avoids hitting CVE-2014-8484 and CVE-2014-8485 and similar problems
with BFD parsing on untrusted files.
2014-11-05 14:50:54 +00:00
Pino Toscano
a5426cce5f build: check for libintl, and use it
Look for libint/gettext and link to it; this properly detects whether
libint is part of libc.
2014-11-05 13:45:17 +01:00
Richard W.M. Jones
c58d335952 v2v: -i libvirt vcenter: Change 'esx:' to 'vcenter:' in errors/warnings.
'esx' is inaccurate.
2014-11-04 21:21:20 +00:00
Pino Toscano
1fab78c7b2 tests/qemu: isolate MD5 calculation in an own shared function
md5sum(1) does not exist everywhere, so wrap it in an own function so
the right implementation can be chosen on each OS.  Also, wrapping it
avoid using awk everytime.
2014-11-04 18:02:20 +01:00
Pino Toscano
3d02e53c48 ruby: fix detection of ruby library
Query RbConfig::CONFIG for "libdir", and use that when trying to link to
the ruby library.  This fixes the libruby detection when it is installed
in a non-standard library directory.
2014-11-04 18:02:20 +01:00
Pino Toscano
9deafea846 test-charset-fidelity: use and link against gnulib
It uses error() which is specific to GNU libc, but supplied by gnulib if
not available.
2014-11-04 18:02:04 +01:00
Pino Toscano
a293ac1e91 build: isolate the libdb tools search in an own autoconf macro
Create an autoconf macro to deal with the possible combinations of names
and versions of the libdb tools. This also eases the addition of a libdb
version, or a new pattern for the names of tools.

There is no functional change.
2014-11-04 17:59:55 +01:00
Pino Toscano
aba82825a3 builder: fix inclusion of <config.h> in lex-generated source
Use a %top block for including <config.h>, so it is included prior to
any other include, even for system ones. This makes sure its definitions
are properly used in gnulib replacement headers.
2014-11-04 17:59:55 +01:00
Pino Toscano
d1634799e3 src: launch: cast the sockaddr args to sockaddr*
This matches what generally done for passing socket addresses to e.g.
socket and bind, and already done in other parts of libguestfs.
2014-11-04 15:33:23 +01:00
Pino Toscano
8c8e089ad1 build: check for UNIX_PATH_MAX, and properly define it if not
Do a configure check to see whether UNIX_PATH_MAX is defined; if it is
not defined, provide it with the size of sun_path in the struct
sockaddr_un, thus with the proper size for any libc.
2014-11-04 15:33:22 +01:00
Pino Toscano
65a54c6c92 bash: fix build/clean when srcdir==builddir
Use CLEANFILES to remove the generated symlinks, and just ignore the
errors when copying the scripts in srcdir!=builddir situations.

Followup of commit 40ac54829d.
2014-11-04 10:50:59 +01:00
Hilko Bengen
40ac54829d Fix, simplify out-of-tree build/install for bash completions 2014-11-04 09:40:13 +00:00
Pino Toscano
25cad1e62f customize: firstboot: fix Linux log output
Pass -a to each tee invocation, otherwise just the last one (so only for
the last script executed) will appear in the log file.
2014-11-04 09:16:17 +01:00
Pino Toscano
f8ed15462f customize: firstboot: make sure to run Linux scripts only once
If a script does not finish, hangs, etc, it would be executed again at
the next boot, since the injected firstboot.sh helper removes it only
after it finished.

Before executing a script, move it to another internal subdirectory
(scripts-done) and execute it from there, so it is not run again by
firstboot.sh.  The downside is that now scripts are executed only once
at all, so if a script fails it will not be attempted at the next boot.

Also, remove all the files found in scripts-done, as they have been run
(or at least attempted) in a previous boot.

This fixes RHBZ#1159651.
2014-11-03 21:15:59 +01:00
Pino Toscano
3d6c2af450 customize: Add --ssh-inject option for injecting SSH keys.
This adds a customize option:

  virt-customize --ssh-inject USER
  virt-customize --ssh-inject USER:string:KEY_STRING
  virt-customize --ssh-inject USER:file:FILENAME

(ditto for virt-builder and virt-sysprep)

In each case this injects into the guest user USER
a) the current (host) user's ssh pubkey
b) the key specified as KEY_STRING
c) the key in FILENAME
adding it to ~USER/.ssh/authorized_keys in the guest.

For example:

  virt-builder fedora-20 --ssh-inject root

will add the local user's ssh pubkey into the root account of the
newly created guest.  Or:

  virt-customize -a disk.img \
     --ssh-inject 'mary:string:ssh-rsa AAAA.... mary@localhost'

adds the given ssh pubkey to mary's account in the guest.

This doesn't set the SELinux labels correctly on newly created files
and directories, so you have to use --selinux-relabel (probably we
should fix this as part of the general effort to fix SELinux
relabelling).  However it should preserve the labels if the
~/.ssh/authorized_keys file already exists.

Most of this work is based on a patch sent to the mailing list by
Richard W.M. Jones <rjones@redhat.com>:
https://www.redhat.com/archives/libguestfs/2014-November/msg00000.html
2014-11-03 20:47:38 +01:00
Richard W.M. Jones
39f524d79b v2v: Ensure --bridge and --network args are documented correctly in --help output. 2014-11-03 19:38:37 +00:00
Richard W.M. Jones
0121f4fd56 generator: customize: Insert whitespace between entries.
Just a whitespace change.
2014-11-01 21:08:53 +00:00
Richard W.M. Jones
0701b24e5c daemon: No longer needs its own copy of gnulib.
Since the daemon has long since used the same build system as the rest
of libguestfs, it no longer needs its own gnulib.

This arcane bit of code was left over from
commit e05ddc70f1 (added 2009-08-03 !)
2014-10-31 18:30:36 +00:00
3065 changed files with 1800621 additions and 651538 deletions

451
.gitignore vendored
View File

@@ -14,22 +14,27 @@
*.jar
*.la
*.lo
*.log
*.o
*.orig
*.patch
*.pyc
*.rej
*.swp
*.trs
bindtests.tmp
cscope.out
.deps
.dirstamp
dll*.so
.gdb_history
.libs
Makefile
Makefile.in
/.sc-*
/ABOUT-NLS
/*.patch
/aclocal.m4
/align/stamp-virt-alignment-scan.pod
/align/virt-alignment-scan
@@ -41,34 +46,70 @@ Makefile.in
/appliance/stamp-libguestfs-make-fixed-appliance.pod
/appliance/stamp-supermin
/appliance/supermin.d
/AUTHORS
/autom4te.cache
/bash/guestunmount
/bash/virt-builder
/bash/virt-cat
/bash/virt-copy-in
/bash/virt-copy-out
/bash/virt-customize
/bash/virt-df
/bash/virt-dib
/bash/virt-diff
/bash/virt-edit
/bash/virt-filesystems
/bash/virt-format
/bash/virt-get-kernel
/bash/virt-inspector
/bash/virt-log
/bash/virt-ls
/bash/virt-p2v-make-disk
/bash/virt-p2v-make-kickstart
/bash/virt-p2v-make-kiwi
/bash/virt-resize
/bash/virt-sysprep
/bash/virt-sparsify
/build-aux
/bash/virt-tail
/bash/virt-tar-in
/bash/virt-tar-out
/bash/virt-win-reg
/build-aux/.gitignore
/build-aux/ar-lib
/build-aux/compile
/build-aux/config.guess
/build-aux/config.sub
/build-aux/depcomp
/build-aux/install-sh
/build-aux/ltmain.sh
/build-aux/missing
/build-aux/snippet/
/build-aux/test-driver
/build-aux/ylwrap
/builder/.depend
/builder/*.img
/builder/index-parse.c
/builder/index-parse.h
/builder/index_parser_tests
/builder/index-scan.c
/builder/libguestfs.conf
/builder/opensuse.conf
/builder/osinfo_config.ml
/builder/oUnit-*
/builder/*.out
/builder/*.qcow2
/builder/stamp-virt-builder.pod
/builder/stamp-virt-index-validate.pod
/builder/test-config/virt-builder/repos.d/test-index.conf
/builder/test-console-*.sh
/builder/test-simplestreams/virt-builder/repos.d/cirros.conf
/builder/test-website/virt-builder/repos.d/libguestfs.conf
/builder/virt-builder
/builder/virt-builder.1
/builder/virt-index-validate
/builder/virt-index-validate.1
/builder/*.xz
/builder/yajl_tests
/cat/stamp-virt-*.pod
/cat/virt-cat
/cat/virt-cat.1
@@ -78,7 +119,44 @@ Makefile.in
/cat/virt-log.1
/cat/virt-ls
/cat/virt-ls.1
/cat/virt-tail
/cat/virt-tail.1
/ChangeLog
/common/errnostring/errnostring.c
/common/errnostring/errnostring-gperf.c
/common/errnostring/errnostring-gperf.gperf
/common/errnostring/errnostring.h
/common/miniexpect/miniexpect.3
/common/mlaugeas/.depend
/common/mlgettext/.depend
/common/mlgettext/common_gettext.ml
/common/mlpcre/.depend
/common/mlpcre/pcre_tests
/common/mlprogress/.depend
/common/mlstdutils/.depend
/common/mlstdutils/bytes.ml
/common/mlstdutils/guestfs_config.ml
/common/mlstdutils/oUnit-*
/common/mlstdutils/std_utils_tests
/common/mltools/.depend
/common/mltools/getopt_tests
/common/mltools/JSON_tests
/common/mltools/tools_utils_tests
/common/mltools/oUnit-*
/common/mlutils/.depend
/common/mlutils/c_utils_unit_tests
/common/mlutils/oUnit-*
/common/mlvisit/.depend
/common/mlvisit/visit_tests
/common/mlxml/.depend
/common/protocol/guestfs_protocol.c
/common/protocol/guestfs_protocol.h
/common/protocol/guestfs_protocol.x
/common/qemuopts/qemuopts-tests
/common/structs/structs-cleanups.c
/common/structs/structs-cleanups.h
/common/structs/structs-print.c
/common/structs/structs-print.h
/compile
/config.cache
/config.guess
@@ -95,65 +173,94 @@ Makefile.in
/customize/customize-options.pod
/customize/customize-synopsis.pod
/customize/stamp-virt-customize.pod
/customize/test-firstboot-*.sh
/customize/test-password-*.sh
/customize/test-settings-*.sh
/customize/virt-customize
/customize/virt-customize.1
/daemon/.depend
/daemon/actions.h
/daemon/errnostring.c
/daemon/errnostring-gperf.c
/daemon/errnostring-gperf.gperf
/daemon/errnostring.h
/daemon/callbacks.ml
/daemon/caml-stubs.c
/daemon/daemon_utils_tests
/daemon/dispatch.c
/daemon/guestfsd
/daemon/guestfsd.8
/daemon/guestfsd.exe
/daemon/guestfs_protocol.c
/daemon/guestfs_protocol.h
/daemon/install-sh
/daemon/missing
/daemon/lvm-tokenization.c
/daemon/names.c
/daemon/optgroups.c
/daemon/optgroups.h
/daemon/optgroups.ml
/daemon/optgroups.mli
/daemon/stamp-guestfsd.pod
/daemon/stubs.c
/daemon/structs-cleanups.c
/daemon/structs-cleanups.h
/daemon/structs.ml
/daemon/structs.mli
/daemon/stubs-?.c
/daemon/stubs.h
/daemon/types.ml
/depcomp
/df/stamp-virt-df.pod
/df/virt-df
/df/virt-df.1
/dib/.depend
/dib/output_format_*.mli
/dib/stamp-virt-dib.pod
/dib/virt-dib
/dib/virt-dib.1
/diff/stamp-virt-diff.pod
/diff/virt-diff
/diff/virt-diff.1
/docs/guestfs-building.1
/docs/guestfs-faq.1
/docs/guestfs-hacking.1
/docs/guestfs-internals.1
/docs/guestfs-performance.1
/docs/guestfs-recipes.1
/docs/guestfs-release-notes.1
/docs/guestfs-security.1
/docs/guestfs-testing.1
/docs/internal-documentation.pod
/docs/stamp-guestfs-building.pod
/docs/stamp-guestfs-faq.pod
/docs/stamp-guestfs-hacking.pod
/docs/stamp-guestfs-internals.pod
/docs/stamp-guestfs-performance.pod
/docs/stamp-guestfs-recipes.pod
/docs/stamp-guestfs-release-notes.pod
/docs/stamp-guestfs-security.pod
/docs/stamp-guestfs-testing.pod
/edit/stamp-virt-*.pod
/edit/virt-edit
/edit/virt-edit.1
/erlang/actions-?.c
/erlang/actions.h
/erlang/bindtests.erl
/erlang/dispatch.c
/erlang/erl-guestfs
/erlang/erl-guestfs.c
/erlang/examples/guestfs-erlang.3
/erlang/examples/stamp-guestfs-erlang.pod
/erlang/guestfs.beam
/erlang/guestfs.erl
/erlang/libguestfs-1.*
/erlang/structs.c
/examples/copy-over
/examples/create-disk
/examples/debug-logging
/examples/display-icon
/examples/guestfs-examples.3
/examples/guestfs-faq.1
/examples/guestfs-performance.1
/examples/guestfs-recipes.1
/examples/guestfs-testing.1
/examples/inspect-vm
/examples/libvirt-auth
/examples/mount-local
/examples/stamp-guestfs-examples.pod
/examples/stamp-guestfs-faq.pod
/examples/stamp-guestfs-performance.pod
/examples/stamp-guestfs-recipes.pod
/examples/stamp-guestfs-testing.pod
/examples/virt-dhcp-address
/fish/cmds.c
/fish/cmds-gperf.c
/fish/cmds-gperf.gperf
/fish/completion.c
/fish/entries-?.c
/fish/event-names.c
/fish/fish-cmds.h
/fish/guestfish
@@ -166,12 +273,15 @@ Makefile.in
/fish/prepopts.h
/fish/rc_protocol.c
/fish/rc_protocol.h
/fish/run-?.c
/fish/run.h
/fish/stamp-guestfish.pod
/fish/stamp-libguestfs-tools.conf.pod
/fish/stamp-virt-copy-in.pod
/fish/stamp-virt-copy-out.pod
/fish/stamp-virt-tar-in.pod
/fish/stamp-virt-tar-out.pod
/fish/test-prep.sh
/fish/virt-copy-in.1
/fish/virt-copy-out.1
/fish/virt-tar-in.1
@@ -193,6 +303,10 @@ Makefile.in
/generator/generator
/generator/.pod2text.data*
/generator/stamp-generator
/get-kernel/.depend
/get-kernel/stamp-virt-get-kernel.pod
/get-kernel/virt-get-kernel
/get-kernel/virt-get-kernel.1
/.gitattributes
/.git-module-status
/gnulib
@@ -200,84 +314,55 @@ Makefile.in
/gobject/bindtests.js
/gobject/Guestfs-1.0.gir
/gobject/Guestfs-1.0.typelib
/gobject/guestfs-gobject.3
/gobject/stamp-guestfs-gobject.pod
/golang/bindtests.go
/golang/examples/guestfs-golang.3
/golang/examples/stamp-guestfs-golang.pod
/golang/pkg
/guestfs-release-notes.1
/guestfsd-in-wine.log
/haskell/Bindtests
/haskell/Bindtests.hs
/haskell/Guestfs010Load
/haskell/Guestfs030Config
/haskell/Guestfs050LVCreate
/haskell/Guestfs.hs
/html/guestfish.1.html
/html/guestfs.3.html
/html/guestfs-erlang.3.html
/html/guestfs-examples.3.html
/html/guestfs-faq.1.html
/html/guestfs-golang.3.html
/html/guestfs-java.3.html
/html/guestfs-lua.3.html
/html/guestfs-ocaml.3.html
/html/guestfs-performance.1.html
/html/guestfs-perl.3.html
/html/guestfs-python.3.html
/html/guestfs-recipes.1.html
/html/guestfs-release-notes.1.html
/html/guestfs-ruby.3.html
/html/guestfs-testing.1.html
/html/guestfsd.8.html
/html/guestmount.1.html
/html/guestunmount.1.html
/html/libguestfs-make-fixed-appliance.1.html
/html/libguestfs-test-tool.1.html
/html/libguestfs-tools.conf.5.html
/html/virt-alignment-scan.1.html
/html/virt-builder.1.html
/html/virt-cat.1.html
/html/virt-copy-in.1.html
/html/virt-copy-out.1.html
/html/virt-customize.1.html
/html/virt-df.1.html
/html/virt-diff.1.html
/html/virt-edit.1.html
/html/virt-filesystems.1.html
/html/virt-format.1.html
/html/virt-index-validate.1.html
/html/virt-inspector.1.html
/html/virt-list-filesystems.1.html
/html/virt-list-partitions.1.html
/html/virt-log.1.html
/html/virt-ls.1.html
/html/virt-make-fs.1.html
/html/virt-p2v.1.html
/html/virt-p2v-make-disk.1.html
/html/virt-p2v-make-kickstart.1.html
/html/virt-rescue.1.html
/html/virt-resize.1.html
/html/virt-sparsify.1.html
/html/virt-sysprep.1.html
/html/virt-tar.1.html
/html/virt-tar-in.1.html
/html/virt-tar-out.1.html
/html/virt-v2v.1.html
/html/virt-win-reg.1.html
/inspector/actual-*.xml
/inspector/stamp-virt-inspector.pod
/inspector/test-virt-inspector.sh
/inspector/test-xmllint.sh
/inspector/virt-inspector
/inspector/virt-inspector.1
/installcheck.sh
/install-sh
/java/actions-?.c
/java/api
/java/Bindtests.java
/java/com_redhat_et_libguestfs_GuestFS.c
/java/com_redhat_et_libguestfs_GuestFS.h
/java/com/redhat/et/libguestfs/GuestFS.java
/java/doc-stamp
/java/examples/guestfs-java.3
/java/examples/stamp-guestfs-java.pod
/lib/actions-?.c
/lib/actions-variants.c
/lib/bindtests.c
/lib/event-string.c
/lib/guestfs.3
/lib/guestfs-actions.pod
/lib/guestfs-availability.pod
/lib/guestfs.h
/lib/guestfs-internal-actions.h
/lib/guestfs-structs.pod
/lib/libguestfs.3
/lib/libguestfs.pc
/lib/libguestfs.syms
/lib/.libs/libguestfs.so
/lib/libvirt-is-version
/lib/stamp-guestfs.pod
/lib/structs-compare.c
/lib/structs-copy.c
/lib/structs-free.c
/lib/unit-tests
/lib/uefi.c
/libguestfs.spec
/libguestfs-*.tar.gz
/libtool
@@ -301,22 +386,19 @@ Makefile.in
/make-fs/virt-make-fs
/make-fs/virt-make-fs.1
/missing
/mllib/.depend
/mllib/common_gettext.ml
/mllib/common_utils_tests
/mllib/config.ml
/mllib/dummy
/mllib/libdir.ml
/ocaml-dep.sh
/ocaml/bindtests.bc
/ocaml/bindtests.opt
/ocaml/bindtests.ml
/ocaml/.depend
/ocaml/dllmlguestfs.so
/ocaml/examples/create_disk
/ocaml/examples/debug_logging
/ocaml/examples/guestfs-ocaml.3
/ocaml/examples/inspect_vm
/ocaml/examples/stamp-guestfs-ocaml.pod
/ocaml/guestfs-c-actions.c
/ocaml/guestfs-c-errnos.c
/ocaml/guestfs.ml
/ocaml/guestfs.mli
/ocamlinit-stamp
@@ -324,27 +406,50 @@ Makefile.in
/ocaml/stamp-mlguestfs
/ocaml/t/*.bc
/ocaml/t/*.opt
/p2v/launch-virt-p2v
/p2v/about-authors.c
/p2v/dependencies.archlinux
/p2v/dependencies.debian
/p2v/dependencies.redhat
/p2v/dependencies.suse
/p2v/stamp-test-virt-p2v-pxe-data-files
/p2v/stamp-test-virt-p2v-pxe-hostkey
/p2v/stamp-test-virt-p2v-pxe-kernel
/p2v/stamp-test-virt-p2v-pxe-userkey
/p2v/stamp-virt-p2v.pod
/p2v/stamp-virt-p2v-make-disk.pod
/p2v/stamp-virt-p2v-make-kickstart.pod
/p2v/stamp-virt-p2v-make-kiwi.pod
/p2v/test-virt-p2v-pxe.authorized_keys
/p2v/test-virt-p2v-pxe.id_rsa
/p2v/test-virt-p2v-pxe.id_rsa.pub
/p2v/test-virt-p2v-pxe.img
/p2v/test-virt-p2v-pxe.initramfs
/p2v/test-virt-p2v-pxe.sshd_config
/p2v/test-virt-p2v-pxe.ssh_host_rsa_key
/p2v/test-virt-p2v-pxe.ssh_host_rsa_key.pub
/p2v/test-virt-p2v-pxe.vmlinuz
/p2v/virt-p2v
/p2v/virt-p2v.1
/p2v/virt-p2v.i686
/p2v/virt-p2v.img
/p2v/virt-p2v-make-disk
/p2v/virt-p2v-make-disk.1
/p2v/virt-p2v-make-kickstart
/p2v/virt-p2v-make-kickstart.1
/p2v/virt-p2v-make-kiwi
/p2v/virt-p2v-make-kiwi.1
/p2v/virt-p2v.xz
/perl/_build
/perl/bindtests.pl
/perl/blib
/perl/Build
/perl/Build.PL
/perl/examples/guestfs-perl.3
/perl/examples/stamp-guestfs-perl.pod
/perl/Guestfs.bs
/perl/Guestfs.c
/perl/Guestfs.xs
/perl/lib/Sys/Guestfs.bs
/perl/lib/Sys/Guestfs.c
/perl/lib/Sys/Guestfs.xs
/perl/lib/Sys/Guestfs.pm
/perl/Makefile-pl
/perl/Makefile.PL
/perl/Makefile-pl.old
/perl/MYMETA.json
/perl/MYMETA.yml
/perl/pm_to_blib
@@ -363,12 +468,6 @@ Makefile.in
/php/extension/configure.in
/php/extension/env
/php/extension/guestfs_php.c
/php/extension/guestfs_php_*.diff
/php/extension/guestfs_php_*.exp
/php/extension/guestfs_php_*.log
/php/extension/guestfs_php_*.out
/php/extension/guestfs_php_*.php
/php/extension/guestfs_php_*.sh
/php/extension/install-sh
/php/extension/libtool
/php/extension/ltmain.sh
@@ -381,6 +480,13 @@ Makefile.in
/php/extension/php-for-tests.sh
/php/extension/php_guestfs_php.h
/php/extension/run-tests.php
/php/extension/tests/guestfs_*.diff
/php/extension/tests/guestfs_*.exp
/php/extension/tests/guestfs_*.log
/php/extension/tests/guestfs_*.out
/php/extension/tests/guestfs_*.php
/php/extension/tests/guestfs_*.sh
/php/extension/tests/guestfs_090_bindtests.phpt
/php/extension/tmp-php.ini
/pick-guests.pl
/po-docs/*/*.1
@@ -392,25 +498,31 @@ Makefile.in
/podwrapper.1
/podwrapper.pl
/po/*.gmo
/python/actions-?.c
/python/actions.h
/python/bindtests.py
/python/build
/python/c-ctype.h
/python/cleanups.c
/python/cleanups.h
/python/config.h
/python/dist
/python/examples/guestfs-python.3
/python/examples/stamp-guestfs-python.pod
/python/guestfs.py
/python/guestfs-py.c
/python/guestfs.pyc
/python/guestfs.pyo
/python/guestfs-internal-all.h
/python/guestfs-internal-frontend-cleanups.h
/python/guestfs-internal-frontend.h
/python/guestfs-utils.h
/python/ignore-value.h
/python/MANIFEST
/python/module.c
/python/structs.c
/python/__pycache__
/python/setup.py
/python/stamp-extra-files
/python/t/tests_helper.py
/python/utils.c
/qemu-wrapper.sh
/rescue/stamp-virt-rescue.pod
/rescue/virt-rescue
/rescue/virt-rescue.1
@@ -422,48 +534,21 @@ Makefile.in
/ruby/doc/site/api
/ruby/examples/guestfs-ruby.3
/ruby/examples/stamp-guestfs-ruby.pod
/ruby/ext/guestfs/actions-?.c
/ruby/ext/guestfs/actions.h
/ruby/ext/guestfs/extconf.h
/ruby/ext/guestfs/extconf.rb
/ruby/ext/guestfs/_guestfs.bundle
/ruby/ext/guestfs/_guestfs.c
/ruby/ext/guestfs/_guestfs.so
/ruby/ext/guestfs/module.c
/ruby/ext/guestfs/mkmf.log
/ruby/Rakefile
/ruby/stamp-rdoc
/run
/sparsify/.depend
/sparsify/link.sh
/sparsify/stamp-virt-sparsify.pod
/sparsify/virt-sparsify
/sparsify/virt-sparsify.1
/src/actions-?.c
/src/actions-variants.c
/src/bindtests.c
/src/errnostring.c
/src/errnostring-gperf.c
/src/errnostring-gperf.gperf
/src/errnostring.h
/src/event-string.c
/src/guestfs.3
/src/guestfs-actions.pod
/src/guestfs-availability.pod
/src/guestfs.h
/src/guestfs-internal-actions.h
/src/guestfs-internal-frontend-cleanups.h
/src/guestfs_protocol.c
/src/guestfs_protocol.h
/src/guestfs_protocol.x
/src/guestfs-structs.pod
/src/libguestfs.pc
/src/libguestfs.syms
/src/.libs/libguestfs.so
/src/libvirt-is-version
/src/stamp-guestfs.pod
/src/structs-cleanup.c
/src/structs-compare.c
/src/structs-copy.c
/src/structs-free.c
/src/test-utils
/stamp-guestfs-release-notes.pod
/stamp-h1
/sysprep/.depend
/sysprep/stamp-script1.sh
@@ -472,10 +557,9 @@ Makefile.in
/sysprep/stamp-virt-sysprep.pod
/sysprep/sysprep-extra-options.pod
/sysprep/sysprep-operations.pod
/sysprep/sysprep_operation_*.mli
/sysprep/virt-sysprep
/sysprep/virt-sysprep.1
/test.err
/test.out
/tests/c-api/test-add-drive-opts
/tests/c-api/test-add-libvirt-dom
/tests/c-api/test-backend-settings
@@ -483,6 +567,7 @@ Makefile.in
/tests/c-api/test-config
/tests/c-api/test-create-handle
/tests/c-api/test-debug-to-file
/tests/c-api/test-dlopen
/tests/c-api/test-environment
/tests/c-api/test-event-string
/tests/c-api/test*.img
@@ -494,68 +579,92 @@ Makefile.in
/tests/c-api/test-pwd
/tests/c-api/tests
/tests/c-api/tests.c
/tests/c-api/test-threads
/tests/c-api/test*.tmp
/tests/c-api/test-user-cancel
/tests/charsets/test-charset-fidelity
/tests/data/100kallnewlines
/tests/data/100kallspaces
/tests/data/100kallzeroes
/tests/data/100krandom
/tests/data/10klines
/tests/data/abssymlink
/tests/data/blank-disk-*
/tests/data/blank-disk-*
/tests/data/hello.b64
/tests/data/initrd
/tests/data/initrd-x86_64.img
/tests/data/initrd-x86_64.img.gz
/tests/data/test-grep.txt.gz
/tests/data/test.iso
/tests/daemon/captive-daemon.pm
/tests/disks/test-add-disks
/tests/disks/test-qemu-drive-libvirt.xml
/tests/events/test-libvirt-auth-callbacks
/tests/guests/blank-*.img
/tests/guests/debian.img
/tests/guests/fedora.img
/tests/guests/fedora-btrfs.img
/tests/guests/fedora-md1.img
/tests/guests/fedora-md2.img
/tests/guests/guests.xml
/tests/guests/guests-all-good.xml
/tests/guests/guest-aux/fedora-name.db
/tests/guests/guest-aux/fedora-packages.db
/tests/guests/guest-aux/windows-software
/tests/guests/guest-aux/windows-system
/tests/guests/stamp-fedora-md.img
/tests/guests/ubuntu.img
/tests/guests/windows.img
/tests/mount-local/test-parallel-mount-local
/tests/mountable/test-internal-parse-mountable
/tests/parallel/test-parallel
/tests/protocol/test-error-messages
/tests/qemu/qemu-boot
/tests/qemu/qemu-speed-test
/tests/regressions/rhbz501893
/tests/regressions/rhbz790721
/tests/regressions/rhbz914931
/tests/regressions/rhbz1044014.out
/tests/regressions/rhbz1055452
/tests/regressions/test-big-heap
/tests/rsync/rsyncd.pid
/tests/syslinux/extlinux-guest.img
/tests/syslinux/syslinux-guest.img
/test-data/test.iso
/test-data/blank-disks/blank-disk-*
/test-data/fake-virtio-win/fake-virtio-win.iso
/test-data/files/100kallnewlines
/test-data/files/100kallspaces
/test-data/files/100kallzeroes
/test-data/files/100krandom
/test-data/files/10klines
/test-data/files/abssymlink
/test-data/files/bin-x86_64-dynamic.gz
/test-data/files/hello.b64
/test-data/files/initrd
/test-data/files/initrd-x86_64.img
/test-data/files/initrd-x86_64.img.gz
/test-data/files/lib-i586.so.xz
/test-data/files/test-grep.txt.gz
/test-data/phony-guests/archlinux.img
/test-data/phony-guests/blank-*.img
/test-data/phony-guests/coreos.img
/test-data/phony-guests/debian.img
/test-data/phony-guests/fedora.img
/test-data/phony-guests/fedora-btrfs.img
/test-data/phony-guests/fedora-md1.img
/test-data/phony-guests/fedora-md2.img
/test-data/phony-guests/fedora-name.db
/test-data/phony-guests/fedora-packages.db
/test-data/phony-guests/guests.xml
/test-data/phony-guests/guests-all-good.xml
/test-data/phony-guests/stamp-fedora-md.img
/test-data/phony-guests/ubuntu.img
/test-data/phony-guests/windows.img
/test-data/phony-guests/windows-software
/test-data/phony-guests/windows-system
/test-tool/libguestfs-test-tool
/test-tool/libguestfs-test-tool.1
/test-tool/libguestfs-test-tool-helper
/test-tool/stamp-libguestfs-test-tool.pod
/tools/stamp-virt-*.pod
/tools/virt-*.1
/utils/boot-analysis/boot-analysis
/utils/boot-analysis/boot-analysis.1
/utils/boot-benchmark/boot-benchmark
/utils/boot-benchmark/boot-benchmark.1
/utils/qemu-boot/qemu-boot
/utils/qemu-speed-test/qemu-speed-test
/v2v/.depend
/v2v/centos-6.img
/v2v/centos-7.0.img
/v2v/fedora-20.img
/v2v/link.sh
/v2v/rhel-5.10.img
/v2v/rhel-6.5.img
/v2v/rhel-7.0.img
/v2v/oUnit-*
/v2v/real-*.d/
/v2v/real-*.img
/v2v/real-*.xml
/v2v/stamp-virt-v2v.pod
/v2v/test-v2v-networks-and-bridges.xml
/v2v/stamp-virt-v2v-copy-to-local.pod
/v2v/test-harness/.depend
/v2v/test-harness/META
/v2v/test-harness/stamp-virt-v2v-test-harness.pod
/v2v/test-harness/virt-v2v-test-harness.1
/v2v/test-v2v-conversion-of-*.sh
/v2v/uefi.ml
/v2v/uefi.mli
/v2v/v2v_unit_tests
/v2v/virt-v2v
/v2v/virt-v2v.1
/v2v/virt-v2v-copy-to-local
/v2v/virt-v2v-copy-to-local.1
/v2v/windows.vmdk
/website/*.html
/website/README.txt
/website/TODO.txt

Submodule .gnulib updated: 322e0b052c...419a2b5ed2

View File

@@ -1,12 +0,0 @@
[main]
host = https://www.transifex.com
[libguestfs.libguestfspot]
file_filter = po/<lang>.po
source_file = po/libguestfs.pot
source_lang = en
[libguestfs.libguestfsdocspot]
file_filter = po-docs/<lang>.po
source_file = po-docs/libguestfs-docs.pot
source_lang = en

View File

@@ -1,7 +0,0 @@
^tests/data/
^COPYING(.LIB)?$
^\.gitmodules$
(^|\/)ChangeLog[^/]*$
(^|\/)(?:GNU)?[Mm]akefile[^/]*$
\.(am|mk)$
^po/Rules-quot$

View File

@@ -1 +0,0 @@
^examples/to-xml\.c$

View File

@@ -1,2 +0,0 @@
^examples/hello.c
^examples/to-xml.c

View File

@@ -1,2 +0,0 @@
^.*\.java$
^.*\.pl$

View File

@@ -1 +0,0 @@
^examples/to-xml\.c$

View File

@@ -1 +0,0 @@
^examples/to-xml\.c$

View File

@@ -1,2 +0,0 @@
tests/data/bin-win64.exe
*.pod

56
AUTHORS
View File

@@ -1,56 +0,0 @@
Adam Huffman
Angus Salkeld
Ani Peter
Bastien ROUCARIÈS
Charles Duffy
Cole Robinson
Colin Walters
Dan Lipsitt
Daniel Berrange
Daniel Cabrera
Daniel Exner
Dave Vasilevsky
Douglas Schilling Landgraf
Eric Blake
Erik Nolte
Evaggelos Balaskas
Geert Warrink
Guido Günther
Hilko Bengen
Hu Tao
infernix
Jaswinder Singh
Jim Meyering
Jiri Popelka
John Eckersberg
Joseph Wang
Karel Klíč
Lee Yarwood
Marcin Gibula
Maros Zatko
Martin Kletzander
Masami HIRATA
Matthew Booth
Maxim Koltsov
Menanteau Guy
Michael Scherer
Mike Kelly
Nicholas Strugnell
Nikita A Menkovich
Nikita Menkovich
Nikos Skalkotos
Olaf Hering
Or Goshen
Paul Mackerras
Pino Toscano
Piotr Drąg
Qin Guan
Rajesh Ranjan
Richard W.M. Jones
Sandeep Shedmake
Shahar Havivi
Shankar Prasad
Thomas S Hatch
Török Edwin
Wanlong Gao
Wulf C. Krueger

809
BUGS

File diff suppressed because it is too large Load Diff

18
HACKING
View File

@@ -1,2 +1,16 @@
The contents of this page have moved to the section "EXTENDING LIBGUESTFS"
in the guestfs(3) man page.
To learn how to compile libguestfs from sources:
guestfs-building(1) or http://libguestfs.org/guestfs-building.1.html
To learn how to extend libguestfs:
guestfs-hacking(1) http://libguestfs.org/guestfs-hacking.1.html
To learn about the architecture and internals of libguestfs:
guestfs-internals(1) http://libguestfs.org/guestfs-internals.1.html
To learn how to write programs using the libguestfs API:
guestfs(3) http://libguestfs.org/guestfs.3.html
guestfs-examples(3) http://libguestfs.org/guestfs-examples.3.html

View File

@@ -1,5 +1,5 @@
# libguestfs
# Copyright (C) 2009-2014 Red Hat Inc.
# Copyright (C) 2009-2017 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
@@ -19,17 +19,37 @@ include $(top_srcdir)/common-rules.mk
ACLOCAL_AMFLAGS = -I m4
# The generator - must be before anything else.
SUBDIRS = common/mlstdutils generator
# Must be the first tests that run.
if ENABLE_APPLIANCE
SUBDIRS += tests/qemu
endif
# Files and other test data used by the tests. Must be before any
# tests run, except tests/qemu.
SUBDIRS += test-data
# Gnulib - must be built and tested before the library.
SUBDIRS = gnulib/lib
SUBDIRS += gnulib/lib
if ENABLE_GNULIB_TESTS
SUBDIRS += gnulib/tests
endif
# Basic source for the library.
SUBDIRS += tests/data generator src examples po
SUBDIRS += common/errnostring common/protocol common/qemuopts
SUBDIRS += common/utils
SUBDIRS += common/structs
SUBDIRS += lib docs examples po
# The daemon and the appliance.
SUBDIRS += common/mlutils
SUBDIRS += common/mlaugeas
SUBDIRS += common/mlpcre
if ENABLE_DAEMON
SUBDIRS += daemon
SUBDIRS += tests/daemon
endif
if ENABLE_APPLIANCE
SUBDIRS += appliance
@@ -37,8 +57,6 @@ endif
# Tests - order is important.
if ENABLE_APPLIANCE
SUBDIRS += tests/qemu
SUBDIRS += tests/guests
SUBDIRS += tests/c-api
SUBDIRS += tests/tmpdirs
SUBDIRS += tests/protocol
@@ -53,7 +71,8 @@ SUBDIRS += tests/lvm
SUBDIRS += tests/luks
SUBDIRS += tests/md
SUBDIRS += tests/selinux
SUBDIRS += tests/ntfsclone
SUBDIRS += tests/relabel
SUBDIRS += tests/ntfs
SUBDIRS += tests/btrfs
SUBDIRS += tests/xfs
SUBDIRS += tests/charsets
@@ -68,11 +87,21 @@ SUBDIRS += tests/nbd
SUBDIRS += tests/http
SUBDIRS += tests/syslinux
SUBDIRS += tests/journal
SUBDIRS += tests/fuzz
SUBDIRS += tests/relative-paths
SUBDIRS += tests/gdisk
SUBDIRS += tests/regressions
SUBDIRS += tests/tsk
SUBDIRS += tests/yara
endif
# Common code used by the tools.
SUBDIRS += common/edit
SUBDIRS += common/options
SUBDIRS += common/parallel
SUBDIRS += common/progress
SUBDIRS += common/visit
SUBDIRS += common/windows
# libguestfs-test-tool
SUBDIRS += test-tool
@@ -82,7 +111,7 @@ SUBDIRS += fish
# virt-tools in C.
SUBDIRS += align cat diff df edit format inspector make-fs rescue
if HAVE_P2V
SUBDIRS += p2v
SUBDIRS += common/miniexpect p2v
endif
# bash-completion
@@ -126,17 +155,27 @@ endif
# Unconditional because nothing is built yet.
SUBDIRS += csharp
# OCaml tools. Note 'mllib' and 'customize' contain shared code used
# by other OCaml tools, so these must come first.
# OCaml tools. Note 'common/ml*' and 'customize' contain shared code
# used by other OCaml tools, so these must come first.
if HAVE_OCAML
SUBDIRS += \
mllib \
customize \
builder builder/website \
resize \
sparsify \
sysprep \
v2v
SUBDIRS += common/mlgettext
SUBDIRS += common/mlprogress
SUBDIRS += common/mlvisit
SUBDIRS += common/mlxml
SUBDIRS += common/mltools
SUBDIRS += customize
SUBDIRS += builder builder/templates
SUBDIRS += get-kernel
SUBDIRS += resize
SUBDIRS += sparsify
SUBDIRS += sysprep
SUBDIRS += v2v
if HAVE_OCAML_PKG_LIBVIRT
SUBDIRS += v2v/test-harness
endif
if HAVE_FUSE
SUBDIRS += dib
endif
endif
# Perl tools.
@@ -149,22 +188,31 @@ if HAVE_FUSE
SUBDIRS += fuse
endif
# Miscellaneous utilities.
if HAVE_BOOT_ANALYSIS
SUBDIRS += utils/boot-analysis
endif
SUBDIRS += \
utils/boot-benchmark \
utils/qemu-boot \
utils/qemu-speed-test
# po-docs must come after tools, inspector.
if HAVE_PO4A
SUBDIRS += po-docs
endif
EXTRA_DIST = \
BUGS HACKING TODO \
AUTHORS BUGS HACKING RELEASES TODO \
.gitignore \
.lvimrc \
.mailmap \
.tx/config \
bootstrap \
bugs-in-changelog.sh \
autogen.sh \
bindtests \
cfg.mk \
check-mli.sh \
contrib/autobuild/autobuild.sh \
contrib/intro/libguestfs-intro.html \
contrib/intro/overview.png \
@@ -177,7 +225,11 @@ EXTRA_DIST = \
contrib/intro/vmm-icons-t.png \
contrib/intro/vmm-icons.png \
contrib/intro/win7.xml \
contrib/make-check-on-installed.pl \
contrib/p2v/aux-scripts/do-build.sh \
contrib/p2v/build-p2v-iso.sh \
contrib/p2v/patches/0001-RHEL-5-ONLY-DISABLE-AUTOMATIC-REMOTE-PORT-ALLOCATION.patch \
contrib/p2v/patches/0002-RHEL-5-ONLY-QEMU-NBD-1.4-HAS-NO-f-OPTION.patch \
contrib/p2v/test-p2v-iso.sh \
contrib/README \
contrib/visualize-alignment/.gitignore \
contrib/visualize-alignment/guestfish-add-mount.qtr \
@@ -190,214 +242,169 @@ EXTRA_DIST = \
contrib/visualize-alignment/README \
contrib/visualize-alignment/tracetops.ml \
contrib/windows-icons.pl \
guestfs-release-notes.pod \
guestfs-release-notes.txt \
html/draft.png \
html/draft.svg \
html/pod.css \
html/virt-builder.svg \
libtool-kill-dependency_libs.sh \
logo/fish.svg logo/fish.png \
logo/fish-5yrs.svg logo/fish-5yrs.png \
logo/virt-builder.svg \
m4/.gitignore \
tests/run-xml-to-junit.sh \
tests/run-xml-to-junit.xsl \
ocaml-link.sh \
podcheck.pl \
tests/automake2junit.ml \
tests/test-functions.sh \
tmp/.gitignore \
tx-pull.sh \
update-bugs.sh \
utils/README \
valgrind-suppressions \
.x-sc_avoid_ctype_macros \
.x-sc_prohibit_have_config_h \
.x-sc_prohibit_magic_number_exit \
.x-sc_prohibit_strcmp \
.x-sc_prohibit_strcmp_and_strncmp \
.x-sc_TAB_in_indentation \
.x-sc_trailing_blank
website/bugs.png \
website/communicate.png \
website/documentation.png \
website/download.png \
website/download/builder/README \
website/download/builder/index \
website/download/builder/index.asc \
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 \
zanata.xml \
zanata-pull.sh
# The website.
HTMLFILES = \
html/guestfs.3.html \
html/guestfs-examples.3.html \
html/guestfs-faq.1.html \
html/guestfs-performance.1.html \
html/guestfs-recipes.1.html \
html/guestfs-release-notes.1.html \
html/guestfs-testing.1.html \
html/guestfsd.8.html \
html/guestfish.1.html \
html/libguestfs-make-fixed-appliance.1.html \
html/libguestfs-test-tool.1.html \
html/virt-alignment-scan.1.html \
html/virt-builder.1.html \
html/virt-cat.1.html \
html/virt-copy-in.1.html \
html/virt-copy-out.1.html \
html/virt-customize.1.html \
html/virt-df.1.html \
html/virt-diff.1.html \
html/virt-edit.1.html \
html/virt-filesystems.1.html \
html/virt-format.1.html \
html/virt-inspector.1.html \
html/virt-list-filesystems.1.html \
html/virt-list-partitions.1.html \
html/virt-log.1.html \
html/virt-ls.1.html \
html/virt-make-fs.1.html \
html/virt-rescue.1.html \
html/virt-resize.1.html \
html/virt-sparsify.1.html \
html/virt-sysprep.1.html \
html/virt-tar.1.html \
html/virt-tar-in.1.html \
html/virt-tar-out.1.html \
html/virt-v2v.1.html \
html/virt-win-reg.1.html
if HAVE_ERLANG
HTMLFILES += html/guestfs-erlang.3.html
endif
if HAVE_GOLANG
HTMLFILES += html/guestfs-golang.3.html
endif
if HAVE_JAVA
HTMLFILES += html/guestfs-java.3.html
endif
if HAVE_LUA
HTMLFILES += html/guestfs-lua.3.html
endif
if HAVE_OCAML
HTMLFILES += html/guestfs-ocaml.3.html
endif
if HAVE_PERL
HTMLFILES += html/guestfs-perl.3.html
endif
if HAVE_PYTHON
HTMLFILES += html/guestfs-python.3.html
endif
if HAVE_RUBY
HTMLFILES += html/guestfs-ruby.3.html
endif
if HAVE_FUSE
HTMLFILES += \
html/guestmount.1.html \
html/guestunmount.1.html
endif
if HAVE_P2V
HTMLFILES += \
html/virt-p2v.1.html \
html/virt-p2v-make-disk.1.html \
html/virt-p2v-make-kickstart.1.html
endif
HTMLSUPPORTFILES = \
html/draft.png \
html/pod.css \
html/virt-builder.svg
TEXTFILES = BUGS README TODO
WEBSITESDIR = $(HOME)/d/websites
BUILDERFILES = \
builder/website/README \
builder/website/index \
builder/website/index.asc
website/download/builder/README \
website/download/builder/index \
website/download/builder/index.asc
WEBSITEDIR = $(HOME)/d/websites/libguestfs
noinst_DATA = \
website/index.html \
website/README.txt \
website/TODO.txt
# For reasons not fully understood, we need to rebuild all the
# man pages and HTMLFILES from scratch here.
website: $(HTMLFILES) $(HTMLSUPPORTFILES) $(TEXTFILES) $(BUILDERFILES)
find -name 'stamp-*.pod' -delete
$(MAKE)
cp $(HTMLFILES) $(HTMLSUPPORTFILES) $(WEBSITEDIR)
for f in $(TEXTFILES); do cp $$f $(WEBSITEDIR)/$$f.txt; done
cp $(BUILDERFILES) $(WEBSITEDIR)/download/builder/
cd $(WEBSITEDIR) && \
date=`date +%F`; \
sed -e "s/SUBST_VERSION/$(VERSION)/" \
-e "s/SUBST_DATE/$$date/" \
< index.html.in > index.html
website/README.txt: README
cp $< $@
website/TODO.txt: TODO
cp $< $@
maintainer-upload-website:
cp website/*.{css,html,png,svg,txt} $(WEBSITESDIR)/libguestfs/
cp $(BUILDERFILES) $(WEBSITESDIR)/libguestfs-builder/
# When doing 'make dist' update a few files automatically.
dist-hook:
git log --decorate=false > ChangeLog
cp ChangeLog $(distdir)/ChangeLog
$(top_srcdir)/update-bugs.sh > BUGS-t
mv BUGS-t BUGS
cp BUGS $(distdir)/BUGS
git shortlog -s | $(AWK) -F'\t' '{print $$2}' | sort -f > AUTHORS-t
mv AUTHORS-t AUTHORS
cp AUTHORS $(distdir)/AUTHORS
# Update the list of translatable files. These are separated into:
#
# po/POTFILES - files with ordinary extensions, but not OCaml files
# BUGS - list of bugs (created from Bugzilla)
# ChangeLog - changelog (created from git)
# docs/C_SOURCE_FILES
# - source files scanned for internal documentation
# po/POTFILES - files with ordinary extensions, but not OCaml files
# po/POTFILES-pl - Perl files that don't end in *.pl, which need a
# special xgettext option [not generated here]
# po/POTFILES-ml - OCaml files, which need a special tool to translate
#
# See po/Makefile.am.
#
dist-hook: BUGS ChangeLog docs/C_SOURCE_FILES po/POTFILES po/POTFILES-ml
cp BUGS $(distdir)/BUGS
cp ChangeLog $(distdir)/ChangeLog
BUGS: configure.ac
rm -f $@ $@-t
unset LC_ALL; \
$(top_srcdir)/update-bugs.sh > $@-t
mv $@-t $@
ChangeLog: configure.ac
rm -f $@ $@-t
git log --decorate=false > $@-t
mv $@-t $@
# This has to be in the top-level Makefile.am so that we have access
# to DIST_SUBDIRS.
all-local:
docs/C_SOURCE_FILES: configure.ac
rm -f $@ $@-t
find $(DIST_SUBDIRS) -name '*.[ch]' | \
grep -v -E '^(builder/index-parse\.|builder/index-scan\.|examples/|gnulib/|gobject/|java/com_redhat_et_libguestfs|perl/|php/extension/config\.h|ruby/ext/guestfs/extconf\.h|tests/|test-data/)' | \
grep -v -E '/(guestfs|rc)_protocol\.' | \
grep -v -E '.*/errnostring\.' | \
grep -v -E '.*-gperf\.' | \
LC_ALL=C sort -u > $@-t
mv $@-t $@
# For more information about translations, see po/Makefile.am.
po/POTFILES: configure.ac
rm -f $@ $@-t
cd $(srcdir); \
find $(DIST_SUBDIRS) -name '*.c' -o -name '*.pl' -o -name '*.pm' | \
grep -v -E '^(examples|gnulib|perl/(blib|examples)|po-docs|tests)/' | \
grep -v -E '^(examples|gnulib|perl/(blib|examples)|po-docs|tests|test-data)/' | \
grep -v -E '/((guestfs|rc)_protocol\.c)$$' | \
grep -v -E '^python/utils.c$$' | \
LC_ALL=C sort > po/POTFILES
grep -v -E '^python/utils\.c$$' | \
grep -v -E '^perl/lib/Sys/Guestfs\.c$$' | \
LC_ALL=C sort -u > $@-t
mv $@-t $@
po/POTFILES-ml: configure.ac
rm -f $@ $@-t
cd $(srcdir); \
find builder customize mllib resize sparsify sysprep v2v -name '*.ml' | \
LC_ALL=C sort > po/POTFILES-ml
find builder common/ml* customize dib get-kernel resize sparsify sysprep v2v -name '*.ml' | \
grep -v '^builder/templates/' | \
LC_ALL=C sort > $@-t
mv $@-t $@
# Manual pages in top level directory.
# Try to stop people using 'make install' without 'DESTDIR'.
install:
@if test "x$(DESTDIR)" != "x" || test "x$(REALLY_INSTALL)" = "xyes"; \
then \
$(MAKE) install-recursive; \
else \
echo "***"; \
echo "*** Using 'make install' is usually a very bad idea."; \
echo "*** Use the './run' script instead - see the guestfs-building(1) man page."; \
echo "***"; \
echo "*** You can override this by setting REALLY_INSTALL=yes, but don't do that."; \
echo "***"; \
exit 1; \
fi
man_MANS = \
guestfs-release-notes.1
noinst_DATA = \
$(top_builddir)/html/guestfs-release-notes.1.html
guestfs-release-notes.1 guestfs-release-notes.txt $(top_builddir)/html/guestfs-release-notes.1.html: stamp-guestfs-release-notes.pod
stamp-guestfs-release-notes.pod: guestfs-release-notes.pod
$(PODWRAPPER) \
--section 1 \
--man guestfs-release-notes.1 \
--text guestfs-release-notes.txt \
--html $(top_builddir)/html/guestfs-release-notes.1.html \
--license GPLv2+ \
$<
touch $@
# Test installed packages.
installcheck-local: installcheck.sh
$(builddir)/installcheck.sh
# NB. podwrapper is an internal tool, so the man page mustn't be installed.
noinst_MANS = podwrapper.1
# 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 = \
*~ \
html/*.html \
CLEANFILES += \
pod2htm?.tmp \
podwrapper.1 \
qemu-wrapper.sh \
stamp-guestfs-release-notes.pod \
tmp/disk* \
tmp/run-* \
tmp/valgrind-*.log
tmp/valgrind-*.log \
website/*~ \
website/*.html
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
# If you don't want to run all of the tests ('make check') then this
# will just run libguestfs-test-tool for a quick check. Note this
@@ -514,8 +521,26 @@ check-slow: build-test-guests
done; \
exit $$(( $$errors ? 1 : 0 ))
check-root: build-test-guests
@if test "$$(id -u)" -ne 0; then \
echo "***"; \
echo "*** error: You must run 'check-root' as root."; \
echo "***"; \
exit 1; \
fi
@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 tests/guests check
$(MAKE) -C test-data/phony-guests check
# Some tests which run at the top level.
TESTS = check-mli.sh
# Print subdirs.
#
@@ -541,18 +566,48 @@ maintainer-commit:
# Tag HEAD with current version (only for maintainer).
maintainer-tag:
git tag -a $(VERSION) -m "Version $(VERSION) ($(BRANCH_TYPE))" -f
git tag -a "v$(VERSION)" -m "Version $(VERSION) ($(BRANCH_TYPE))" -f
# Maintainer only: check EXTRA_DIST rule is complete.
# Maintainer only: compare authors (found in git commit messages) to
# generator/authors.ml.
maintainer-check-authors:
rm -f $@ $@-t
git shortlog -s | \
$(AWK) -F'\t' '{print $$2}' | \
sort -f | \
while read author; do \
if ! grep -sqiF "\"$$author\"," generator/authors.ml; then \
echo "FAIL: $$author" is missing from generator/authors.ml; \
exit 1; \
fi; \
done
@echo PASS: AUTHORS test
# 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 | sort > tmp/gitfiles
diff -ur tmp/tarfiles tmp/gitfiles | grep '^\+' | \
grep -v src/api-support/[0-9]
rm tmp/tarfiles tmp/gitfiles
git ls-files | \
grep -v '^intltool-.*\.in' | \
grep -v '^\.gitmodules' | \
grep -v '^\.gnulib' | \
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 ]
@echo Checking for generated files missing from the tarball ...
@for f in `cat generator/files-generated.txt`; do \
if ! grep -sq "^$$f\$$" tmp/tarfiles; then \
echo generated file missing from tarball: $$f; \
exit 1; \
fi; \
done
rm tmp/tarfiles tmp/gitfiles tmp/comm-out
@echo PASS: EXTRA_DIST tests
# Provide help on common Makefile targets.
@@ -572,11 +627,13 @@ help:
@echo "make check-with-upstream-qemu Test using upstream qemu."
@echo "make check-with-upstream-libvirt Test using upstream libvirt."
@echo "make check-slow Slow/long-running tests."
@echo "sudo make check-root Tests which must be run as root."
@echo
@echo "make check-all Runs all 'check*' rules."
@echo "make check-all Runs all 'check*' rules except check-root."
@echo "make check-release Runs 'check*' rules required for release."
@echo
@echo "make syntax-check -j1 -k Check syntax and style problems in the code."
@echo "make installcheck Test installed libguestfs packages."
@echo
@echo "make print-subdirs Print subdirectories."
@echo
@echo "make install Install everything."
@@ -586,5 +643,5 @@ help:
@echo "To run programs without installing:"
@echo " ./run ./fish/guestfish [or any other program]"
@echo
@echo "For more information, see EXTENDING LIBGUESTFS in guestfs(3); and README."
@echo "For more information, see guestfs-hacking(1); and README."
@echo

399
README
View File

@@ -8,400 +8,15 @@ list:
http://www.redhat.com/mailman/listinfo/libguestfs
To find out how to build libguestfs from source, read:
Requirements
----------------------------------------------------------------------
docs/guestfs-building.pod
http://libguestfs.org/guestfs-building.1.html
man docs/guestfs-building.1
Running ./configure will check you have all the requirements installed
on your machine.
Fedora/RHEL users:
A useful tip is to run:
yum-builddep libguestfs
which will install all build dependencies automatically. If that is
successful, you don't need to bother with the rest of this section.
Debian/Ubuntu users:
Use:
apt-get build-dep libguestfs
to install all build dependencies. If that doesn't work, take a
look at the Debian source package:
http://packages.debian.org/source/libguestfs
at the list of 'build-depends' and 'build-depends-indep', and
install everything listed there.
If either of those techniques is successful, you don't need to
bother with the rest of this section.
The full requirements are described below.
R = Required
O = Optional
+==============+=============+===+=========================================+
| Package name | Min.version | | Notes |
+==============+=============+===+=========================================+
| Install as many packages listed in appliance/packagelist.in as possible. |
| This installs the disk management tools required by the appliance. The |
| list below is *additional* packages needed on the host. |
+--------------+-------------+---+-----------------------------------------+
| qemu | 1.2.0 | R | 1.1 may work, but has broken virtio-scsi|
+--------------+-------------+---+-----------------------------------------+
| qemu-img | | R | >= 2.2.0 is required for virt-v2v but |
| | | | optional elsewhere |
+--------------+-------------+---+-----------------------------------------+
| kernel | 2.6.34 | R | Make sure the following are enabled |
| | | | compiled in or as a module: |
| | | | - virtio-pci |
| | | | - virtio-serial |
| | | | - virtio-block |
| | | | - virtio-net |
+--------------+-------------+---+-----------------------------------------+
| supermin | 5.1.0 | R | This is required on all distros. |
| | | | 'supermin' is the new name for |
| | | | 'febootstrap'. |
| | | | For alternatives, see: |
| | | | libguestfs.org/download/binaries/appliance/
+--------------+-------------+---+-----------------------------------------+
| glibc | | R | We use various glibc-isms. |
| | | | Also glibc provides XDR, rpcgen. |
+--------------+-------------+---+-----------------------------------------+
| GCC or LLVM | | R | We use __attribute__((cleanup)). |
+--------------+-------------+---+-----------------------------------------+
| Perl | | R | Various build and test programs need |
| | | | Perl. Not needed at runtime except if |
| | | | you need to run a handful of virt-* |
| | | | tools that are still written in Perl. |
+--------------+-------------+---+-----------------------------------------+
| Pod::Man | | R | Part of Perl core. |
+--------------+-------------+---+-----------------------------------------+
| Pod::Simple | | R | Part of Perl core. |
+--------------+-------------+---+-----------------------------------------+
| OCaml | |R/O| Required if compiling from git. |
| | | | Optional if compiling from tarball. |
| | | | To build generated files and OCaml bindings.
+--------------+-------------+---+-----------------------------------------+
| autotools | |R/O| Required if compiling from git. |
| | | | Optional if compiling from tarball. |
| | | | Autotools-based build system. |
+--------------+-------------+---+-----------------------------------------+
| cpio | | R | |
+--------------+-------------+---+-----------------------------------------+
| gperf | | R | |
+--------------+-------------+---+-----------------------------------------+
| flex | | R | flex & bison are required for virt- |
+--------------+-------------+---| builder. We could make these |
| bison | | R | optional but automakes makes it hard. |
+--------------+-------------+---+-----------------------------------------+
| PCRE | | R | Perl-compatible Regular Expression lib. |
+--------------+-------------+---+-----------------------------------------+
| genisoimage | | R | mkisofs may work. |
+--------------+-------------+---+-----------------------------------------+
| libxml2 | | R | Popular XML library. |
+--------------+-------------+---+-----------------------------------------+
| augeas | 1.0.0 | R | |
+--------------+-------------+---+-----------------------------------------+
| xz | | R | Used to compress disk images. |
| | | | Used by virt-builder for compression. |
+--------------+-------------+---+-----------------------------------------+
| po4a | |R/O| Required if compiling from git. |
| | | | Optional if compiling from tarball. |
| | | | For localizing man pages. |
+--------------+-------------+---+-----------------------------------------+
| hivex | 1.2.7 |R/O| Require if compiling from git. |
| | | | Windows Registry hive parser. |
+--------------+-------------+---+-----------------------------------------+
| libmagic | | O | The library used by the 'file' command. |
+--------------+-------------+---+-----------------------------------------+
| libvirt | | O | >= 0.10.2 is needed if you want to use |
| | | | libvirt to manage transient VMs. |
+--------------+-------------+---+-----------------------------------------+
| xmllint | | O | Part of libxml2. Used for tests only. |
+--------------+-------------+---+-----------------------------------------+
| libconfig | | O | Used to parse libguestfs's own config |
| | | | files eg. /etc/libguestfs-tools.conf. |
+--------------+-------------+---+-----------------------------------------+
| libselinux | | O | Used by the libvirt backend to securely |
| | | | confine the appliance (sVirt). |
+--------------+-------------+---+-----------------------------------------+
| db utils | | O | db_dump, db_load etc. Usually found in |
| | | | a package called db-utils, db4-utils, |
| | | | db4.X-utils, Berkeley DB utils, etc. |
+--------------+-------------+---+-----------------------------------------+
| systemtap | | O | For userspace probes. |
+--------------+-------------+---+-----------------------------------------+
| readline | | O | For nicer command line in guestfish. |
+--------------+-------------+---+-----------------------------------------+
| acl | | O | Library (libacl) and programs for |
| | | | handling POSIX ACLs. |
+--------------+-------------+---+-----------------------------------------+
| libcap | | O | Library (libcap) and programs for |
| | | | handling Linux capabilities. |
+--------------+-------------+---+-----------------------------------------+
| libldm | | O | Library (libldm) and 'ldmtool' for |
| | | | handling Windows Dynamic Disks. |
+--------------+-------------+---+-----------------------------------------+
| sd-journal | | O | systemd journal library |
+--------------+-------------+---+-----------------------------------------+
| yajl | 2 | O | JSON parser for parsing output of |
| | | | ldmtool and qemu-img info commands. |
+--------------+-------------+---+-----------------------------------------+
| gdisk | | O | GPT disk support. |
+--------------+-------------+---+-----------------------------------------+
| netpbm | | O | Render icons from guests. |
+--------------+-------------+---+-----------------------------------------+
| icoutils | | O | Render icons from Windows guests. |
+--------------+-------------+---+-----------------------------------------+
| Expect | | O | Perl module used to test virt-rescue. |
+--------------+-------------+---+-----------------------------------------+
| FUSE | | O | fusermount, libfuse, and kernel module |
| | | | are all needed if you want guestmount |
| | | | and/or 'mount-local' support. |
+--------------+-------------+---+-----------------------------------------+
| static glibc | | O | Used for testing only. |
+--------------+-------------+---+-----------------------------------------+
| qemu-nbd | | O | Used for testing only. |
+--------------+-------------+---+-----------------------------------------+
| uml_mkcow | | O | For the UML backend. |
+--------------+-------------+---+-----------------------------------------+
| curl | | O | Used by virt-builder for downloads |
+--------------+-------------+---+-----------------------------------------+
| gpg | | O | Used by virt-builder for digital |
| | | | signatures |
+--------------+-------------+---+-----------------------------------------+
| liblzma | | O | Can be used by virt-builder for fast |
| | | | uncompression of templates. |
+--------------+-------------+---+-----------------------------------------+
| gtk2 | | O | Used by virt-p2v user interface. |
+--------------+-------------+---+-----------------------------------------+
| zip, unzip | | O | Used by virt-v2v for OVA files. |
+--------------+-------------+---+-----------------------------------------+
| python-evtx | | O | Used by virt-log to parse Windows |
| | | | Event Log files. |
+--------------+-------------+---+-----------------------------------------+
| findlib | | O | For the OCaml bindings. |
+--------------+-------------+---+-----------------------------------------+
| ocaml-gettext| | O | For localizing OCaml virt-* tools. |
+--------------+-------------+---+-----------------------------------------+
| Python | 2.2 | O | For the Python bindings. |
+--------------+-------------+---+-----------------------------------------+
| Ruby | | O | >= 1.9 is better than 1.8. |
+--------------+-------------+---+-----------------------------------------+
| rake | | O | For the Ruby bindings. |
+--------------+-------------+---+-----------------------------------------+
| rubygem-minitest | O | For the Ruby bindings. |
+--------------+-------------+---+-----------------------------------------+
| Java | 1.6 | O | Java + JNI + jpackage-utils are needed |
| | | | for the Java bindings. |
+--------------+-------------+---+-----------------------------------------+
| GHC | | O | For the Haskell bindings. |
+--------------+-------------+---+-----------------------------------------+
| PHP | | O | For the PHP bindings. |
+--------------+-------------+---+-----------------------------------------+
| phpize | | O | For the PHP bindings. |
+--------------+-------------+---+-----------------------------------------+
| glib2 | | O | For the GObject bindings. |
+--------------+-------------+---+-----------------------------------------+
| gobject-introspection | O | For the GObject bindings. |
+--------------+-------------+---+-----------------------------------------+
| gjs | | O | For testing the GObject bindings. |
+--------------+-------------+---+-----------------------------------------+
| LUA | | O | For the LUA bindings. |
+--------------+-------------+---+-----------------------------------------+
| Erlang | | O | For the Erlang bindings. |
+--------------+-------------+---+-----------------------------------------+
| erl_interface| | O | For the Erlang bindings. |
+--------------+-------------+---+-----------------------------------------+
| golang | 1.1.1 | O | For the Go bindings. |
+--------------+-------------+---+-----------------------------------------+
| valgrind | | O | For testing for memory problems. |
+--------------+-------------+---+-----------------------------------------+
| Sys::Virt | | O | Perl bindings for libvirt. |
+--------------+-------------+---+-----------------------------------------+
| Win::Hivex | | O | Perl bindings for hivex. |
+--------------+-------------+---+-----------------------------------------+
| Pod::Usage | | O | Perl module used by tests. |
+--------------+-------------+---+-----------------------------------------+
| Test::More | | O | Perl module used by tests. |
+--------------+-------------+---+-----------------------------------------+
| XML::XPath | | O | Perl module used by some virt-* tools. |
+--------------+-------------+---+-----------------------------------------+
| XML::XPath::XMLParser | O | Perl module used by some virt-* tools. |
+--------------+-------------+---+-----------------------------------------+
| perl-libintl | | O | Perl module for localization. |
+--------------+-------------+---+-----------------------------------------+
| bash-completion | O | For tab-completion of commands in bash. |
+==============+=============+===+=========================================+
R = Required
O = Optional
Building
----------------------------------------------------------------------
Build the daemon, library and root filesystem:
building from tarball building from git
--------------------- -----------------
./configure ./autogen.sh
make make
Run the tests:
make check
Also:
make check-valgrind
runs a subset of the test suite under valgrind (requires valgrind to
be installed obviously).
make check-all
runs check-valgrind + even more tests, but these require that you have
some libvirt guests installed, that these guests' disks are accessible
by the current user, and these tests may fail for other reasons which
are not necessarily because of real problems.
make help
lists all 'make' targets.
You may install the library by running the following command as root.
However *most users should probably not do this*. Instead, './run'
the programs from the build directory as described below.
make install
Distro packagers should use this instead:
make INSTALLDIRS=vendor [DESTDIR=...] install
You can run guestfish, guestmount and the virt tools without needing
to install, using the "./run" script in the top directory. This
script sets up some environment variables. For example:
./run guestfish [usual guestfish args ...]
./run virt-inspector [usual virt-inspector args ...]
If you are already in the fish/ subdirectory, then the following
command will also work:
../run guestfish [...]
The ./run script adds every libguestfs binary to the $PATH, so the
above example runs guestfish from the build directory (not the
globally installed guestfish if there is one).
You can also run the C programs under valgrind like this:
./run valgrind [valgrind opts...] virt-cat [virt-cat opts...]
or under gdb:
./run gdb --args virt-cat [virt-cat opts...]
This also works with sudo (eg. if you need root access for libvirt or
to access a block device):
sudo ./run virt-cat -d LinuxGuest /etc/passwd
qemu
----------------------------------------------------------------------
By far the most common problem is with broken or incompatible
qemu releases.
Different versions of qemu have problems booting the appliance for
different reasons. This varies between versions of qemu, and Linux
distributions which add their own patches.
If you find a problem, you could try using your own qemu built from
source (qemu is very easy to build from source), with a 'qemu
wrapper'. Qemu wrappers are described in the guestfs(3) manpage.
Note on using KVM
----------------------------------------------------------------------
By default the configure script will look for qemu-kvm (KVM support).
You will need a reasonably recent processor for this to work. KVM is
much faster than using plain Qemu.
You may also need to enable KVM support for non-root users, by following
these instructions:
http://www.linux-kvm.org/page/FAQ#How_can_I_use_kvm_with_a_non-privileged_user.3F
On some systems, this will work too:
chmod 0666 /dev/kvm
On some systems, the chmod will not survive a reboot, and you will
need to make edits to the udev configuration.
Mirroring tip
----------------------------------------------------------------------
On my machines I can usually rebuild the appliance in around 3
minutes. If it takes much longer for you, use a local distro mirror
or squid.
To use squid to cache yum downloads, read this first:
https://lists.dulug.duke.edu/pipermail/yum/2006-August/009041.html
(In brief, because yum chooses random mirrors each time, squid doesn't
work very well with default yum configuration. To get around this,
choose a Fedora mirror which is close to you, set this with
'./configure --with-mirror=[...]', and then proxy the whole lot
through squid by setting http_proxy environment variable).
You will also need to substantially increase the squid configuration
limits:
http://fedoraproject.org/wiki/Using_Mock_to_test_package_builds#Using_Squid_to_Speed_Up_Mock_package_downloads
Porting to other Linux distros / non-Linux
----------------------------------------------------------------------
libguestfs itself should be fairly portable to other Linux
distributions. Non-Linux ports are trickier, but we will accept
patches if they aren't too invasive.
The main porting issues are with the dependencies needed to build the
appliance. You will need to port febootstrap first
(http://people.redhat.com/~rjones/febootstrap/).
Note on using clang (from LLVM) instead of GCC
----------------------------------------------------------------------
export CC=clang
./configure --disable-probes
make
SystemTap/DTrace-style userspace probe points don't work under the
clang compiler, which is why you may need to disable them.
Don't enable GCC warnings (ie. *don't* use
'./configure --enable-gcc-warnings').
Copyright and license information
----------------------------------------------------------------------
Copyright (C) 2009-2014 Red Hat Inc.
Copyright (C) 2009-2017 Red Hat Inc.
The library is distributed under the LGPLv2+. The programs are
distributed under the GPLv2+. Please see the files COPYING and
COPYING.LIB for full license information.
The examples are under a very liberal license.
COPYING.LIB for full license information. The examples are under a
very liberal license.

903
RELEASES Normal file
View File

@@ -0,0 +1,903 @@
# This file contains the release date of each version of libguestfs
# in the form <version> <date>. If you update the version field (in
# configure.ac) you must also add the current date to this file.
1.37.34 2017-11-16
1.37.33 2017-11-16
1.37.32 2017-11-15
1.37.31 2017-10-17
1.37.30 2017-10-16
1.37.29 2017-10-06
1.37.28 2017-09-28
1.37.27 2017-09-22
1.37.26 2017-09-16
1.37.25 2017-09-15
1.37.24 2017-09-14
1.37.23 2017-09-14
1.37.22 2017-09-04
1.37.21 2017-08-09
1.37.20 2017-08-03
1.37.19 2017-07-27
1.37.18 2017-07-18
1.37.17 2017-07-10
1.37.16 2017-06-22
1.37.14 2017-05-18
1.37.13 2017-05-08
1.37.12 2017-04-25
1.37.11 2017-04-13
1.37.10 2017-04-11
1.37.9 2017-04-06
1.37.8 2017-03-30
1.37.7 2017-03-24
1.37.6 2017-03-20
1.37.2 2017-03-13
1.37.1 2017-03-07
1.37.0 2017-02-28
1.36.5 2017-06-22
1.36.4 2017-05-19
1.36.3 2017-03-24
1.36.2 2017-03-07
1.36.1 2017-02-28
1.35.28 2017-02-24
1.35.27 2017-02-22
1.35.26 2017-02-21
1.35.25 2017-02-15
1.35.24 2017-02-11
1.35.23 2017-02-10
1.35.22 2017-02-10
1.35.21 2017-02-07
1.35.20 2017-01-27
1.35.19 2016-12-23
1.35.18 2016-12-14
1.35.17 2016-12-11
1.35.14 2016-10-25
1.35.9 2016-10-20
1.35.8 2016-10-11
1.35.6 2016-09-23
1.35.5 2016-09-12
1.35.4 2016-09-02
1.35.3 2016-09-01
1.34.6 2017-03-08
1.34.4 2017-01-29
1.34.3 2016-10-27
1.34.2 2016-09-01
1.34.0 2016-08-08
1.33.49 2016-08-04
1.33.46 2016-07-27
1.33.45 2016-07-22
1.33.44 2016-07-19
1.33.43 2016-07-14
1.33.42 2016-07-09
1.33.41 2016-07-06
1.33.40 2016-07-01
1.33.39 2016-06-23
1.33.38 2016-06-18
1.33.37 2016-06-17
1.33.36 2016-06-13
1.33.35 2016-06-06
1.33.34 2016-06-03
1.33.32 2016-05-27
1.33.31 2016-05-26
1.33.30 2016-05-23
1.33.29 2016-05-17
1.33.28 2016-05-09
1.33.27 2016-05-04
1.33.26 2016-05-03
1.33.24 2016-04-30
1.33.23 2016-04-24
1.33.20 2016-04-14
1.33.19 2016-04-12
1.33.18 2016-04-05
1.33.16 2016-03-24
1.33.15 2016-03-16
1.33.14 2016-03-07
1.33.13 2016-02-26
1.33.12 2016-02-12
1.33.11 2016-02-09
1.33.10 2016-02-08
1.33.9 2016-02-05
1.33.8 2016-02-03
1.33.7 2016-01-29
1.33.6 2016-01-27
1.33.5 2016-01-26
1.33.4 2016-01-22
1.33.1 2016-01-11
1.32.10 2016-09-01
1.32.7 2016-08-08
1.32.6 2016-07-12
1.32.5 2016-06-01
1.32.4 2016-04-05
1.32.3 2016-02-26
1.32.2 2016-01-29
1.32.1 2016-01-15
1.32.0 2016-01-06
1.31.30 2015-12-16
1.31.29 2015-12-05
1.31.28 2015-11-25
1.31.27 2015-11-19
1.31.26 2015-11-13
1.31.25 2015-11-06
1.31.24 2015-11-04
1.31.23 2015-10-31
1.31.22 2015-10-30
1.31.20 2015-10-25
1.31.19 2015-10-20
1.31.18 2015-10-20
1.31.17 2015-10-15
1.31.16 2015-10-09
1.31.15 2015-10-08
1.31.13 2015-10-07
1.31.11 2015-10-05
1.31.10 2015-10-04
1.31.9 2015-09-30
1.31.8 2015-09-29
1.31.7 2015-09-20
1.31.6 2015-09-11
1.31.5 2015-09-08
1.31.4 2015-09-03
1.31.3 2015-08-28
1.31.2 2015-08-13
1.31.1 2015-07-30
1.31.0 2015-07-21
1.30.6 2015-12-15
1.30.4 2015-10-25
1.30.3 2015-10-06
1.30.2 2015-09-08
1.30.1 2015-08-14
1.30.0 2015-07-21
1.29.50 2015-07-09
1.29.49 2015-07-02
1.29.48 2015-06-29
1.29.47 2015-06-18
1.29.46 2015-06-06
1.29.44 2015-05-26
1.29.43 2015-05-15
1.29.42 2015-05-14
1.29.41 2015-05-11
1.29.40 2015-05-06
1.29.39 2015-05-02
1.29.38 2015-04-27
1.29.37 2015-04-23
1.29.36 2015-04-16
1.29.34 2015-04-10
1.29.33 2015-04-01
1.29.32 2015-03-27
1.29.31 2015-03-23
1.29.30 2015-03-10
1.29.29 2015-03-05
1.29.26 2015-02-17
1.29.25 2015-02-11
1.29.24 2015-02-02
1.29.23 2015-01-26
1.29.22 2015-01-21
1.29.20 2015-01-17
1.29.19 2014-12-23
1.29.18 2014-12-16
1.29.17 2014-12-15
1.29.14 2014-12-11
1.29.13 2014-12-05
1.29.12 2014-11-28
1.29.11 2014-11-27
1.29.10 2014-11-25
1.29.9 2014-11-20
1.29.8 2014-11-18
1.29.7 2014-11-15
1.29.6 2014-11-06
1.29.5 2014-11-05
1.29.4 2014-10-31
1.29.3 2014-10-30
1.29.2 2014-10-25
1.29.1 2014-10-22
1.28.12 2015-07-16
1.28.10 2015-05-06
1.28.9 2015-04-26
1.28.7 2015-03-28
1.28.6 2015-02-03
1.28.5 2014-12-18
1.28.4 2014-11-30
1.28.3 2014-11-15
1.28.2 2014-10-27
1.28.1 2014-10-18
1.27.64 2014-10-17
1.27.63 2014-10-15
1.27.62 2014-10-10
1.27.61 2014-10-09
1.27.60 2014-10-08
1.27.58 2014-10-02
1.27.57 2014-10-01
1.27.56 2014-09-29
1.27.55 2014-09-26
1.27.54 2014-09-24
1.27.53 2014-09-23
1.27.50 2014-09-19
1.27.49 2014-09-18
1.27.48 2014-09-17
1.27.47 2014-09-16
1.27.46 2014-09-15
1.27.45 2014-09-14
1.27.44 2014-09-12
1.27.43 2014-09-11
1.27.42 2014-09-10
1.27.41 2014-09-09
1.27.39 2014-09-06
1.27.38 2014-09-05
1.27.37 2014-09-04
1.27.36 2014-09-02
1.27.35 2014-09-01
1.27.34 2014-08-29
1.27.33 2014-08-29
1.27.31 2014-08-24
1.27.30 2014-08-21
1.27.28 2014-08-19
1.27.27 2014-08-15
1.27.26 2014-08-13
1.27.25 2014-08-05
1.27.24 2014-07-26
1.27.23 2014-07-23
1.27.22 2014-07-21
1.27.21 2014-07-08
1.27.20 2014-07-02
1.27.19 2014-06-24
1.27.18 2014-06-16
1.27.16 2014-06-13
1.27.15 2014-06-11
1.27.14 2014-05-30
1.27.13 2014-05-24
1.27.12 2014-05-23
1.27.11 2014-05-16
1.27.10 2014-05-15
1.27.9 2014-05-07
1.27.8 2014-05-02
1.27.7 2014-04-23
1.27.6 2014-04-22
1.27.5 2014-04-15
1.27.4 2014-04-15
1.27.3 2014-04-06
1.27.2 2014-03-31
1.27.0 2014-03-27
1.26.10 2015-02-21
1.26.9 2014-09-04
1.26.8 2014-08-25
1.26.7 2014-07-31
1.26.6 2014-07-26
1.26.5 2014-07-04
1.26.3 2014-05-24
1.26.2 2014-05-07
1.26.1 2014-04-22
1.26.0 2014-03-27
1.25.49 2014-03-26
1.25.47 2014-03-25
1.25.46 2014-03-20
1.25.45 2014-03-16
1.25.44 2014-03-13
1.25.43 2014-03-08
1.25.42 2014-03-06
1.25.41 2014-03-03
1.25.40 2014-03-03
1.25.39 2014-03-01
1.25.37 2014-02-21
1.25.36 2014-02-17
1.25.34 2014-02-12
1.25.33 2014-02-05
1.25.32 2014-02-04
1.25.31 2014-01-28
1.25.29 2014-01-25
1.25.27 2014-01-23
1.25.26 2014-01-22
1.25.25 2014-01-21
1.25.24 2014-01-18
1.25.23 2014-01-17
1.25.21 2014-01-13
1.25.20 2014-01-12
1.25.19 2014-01-02
1.25.18 2013-12-18
1.25.15 2013-12-14
1.25.14 2013-12-12
1.25.13 2013-12-08
1.25.12 2013-12-02
1.25.11 2013-11-23
1.25.7 2013-11-08
1.25.6 2013-11-05
1.25.3 2013-11-01
1.25.2 2013-10-29
1.25.1 2013-10-26
1.25.0 2013-10-19
1.24.9 2015-02-21
1.24.8 2014-03-08
1.24.6 2014-02-12
1.24.5 2014-01-20
1.24.4 2014-01-02
1.24.3 2013-12-18
1.24.2 2013-12-06
1.24.1 2013-11-01
1.24.0 2013-10-19
1.23.33 2013-10-15
1.23.32 2013-10-14
1.23.31 2013-10-12
1.23.30 2013-10-11
1.23.28 2013-10-08
1.23.27 2013-10-05
1.23.25 2013-10-04
1.23.23 2013-09-27
1.23.22 2013-09-10
1.23.21 2013-09-06
1.23.20 2013-09-01
1.23.19 2013-08-29
1.23.18 2013-08-19
1.23.17 2013-08-14
1.23.16 2013-08-13
1.23.15 2013-08-11
1.23.14 2013-08-06
1.23.13 2013-08-03
1.23.12 2013-07-30
1.23.11 2013-07-28
1.23.10 2013-07-23
1.23.9 2013-07-18
1.23.8 2013-07-09
1.23.7 2013-07-03
1.23.6 2013-06-26
1.23.5 2013-06-18
1.23.4 2013-06-14
1.23.3 2013-06-10
1.23.2 2013-06-03
1.23.1 2013-05-28
1.22.9 2014-02-12
1.22.7 2013-10-17
1.22.6 2013-08-24
1.22.5 2013-07-26
1.22.4 2013-07-09
1.22.3 2013-06-14
1.22.2 2013-06-03
1.22.1 2013-05-28
1.22.0 2013-05-23
1.21.40 2013-05-21
1.21.39 2013-05-15
1.21.38 2013-05-11
1.21.37 2013-05-09
1.21.36 2013-05-02
1.21.35 2013-04-30
1.21.34 2013-04-29
1.21.33 2013-04-25
1.21.32 2013-04-23
1.21.31 2013-04-17
1.21.30 2013-04-16
1.21.29 2013-04-13
1.21.28 2013-04-09
1.21.27 2013-04-04
1.21.26 2013-04-02
1.21.25 2013-03-30
1.21.24 2013-03-29
1.21.23 2013-03-28
1.21.22 2013-03-18
1.21.21 2013-03-15
1.21.20 2013-03-13
1.21.19 2013-03-11
1.21.18 2013-03-07
1.21.17 2013-03-05
1.21.16 2013-03-01
1.21.15 2013-02-26
1.21.14 2013-02-25
1.21.13 2013-02-20
1.21.12 2013-02-19
1.21.11 2013-02-14
1.21.10 2013-02-11
1.21.9 2013-02-09
1.21.8 2013-02-05
1.21.7 2013-02-04
1.21.6 2013-01-28
1.21.5 2013-01-21
1.21.4 2013-01-18
1.21.3 2013-01-17
1.21.2 2012-12-22
1.21.1 2012-12-17
1.20.12 2013-10-17
1.20.11 2013-08-27
1.20.10 2013-07-26
1.20.9 2013-06-14
1.20.8 2013-06-03
1.20.7 2013-05-28
1.20.6 2013-04-11
1.20.5 2013-03-31
1.20.4 2013-03-12
1.20.3 2013-03-05
1.20.2 2013-02-14
1.20.1 2012-12-20
1.20.0 2012-12-13
1.19.66 2012-12-01
1.19.65 2012-11-29
1.19.64 2012-11-24
1.19.63 2012-11-23
1.19.62 2012-11-20
1.19.61 2012-11-19
1.19.60 2012-11-17
1.19.59 2012-11-13
1.19.58 2012-11-10
1.19.57 2012-11-07
1.19.56 2012-11-02
1.19.55 2012-10-30
1.19.54 2012-10-29
1.19.53 2012-10-19
1.19.52 2012-10-14
1.19.51 2012-10-11
1.19.50 2012-10-10
1.19.49 2012-10-09
1.19.48 2012-10-07
1.19.46 2012-10-01
1.19.45 2012-09-26
1.19.44 2012-09-24
1.19.43 2012-09-21
1.19.42 2012-09-17
1.19.41 2012-09-16
1.19.40 2012-09-04
1.19.39 2012-09-04
1.19.38 2012-09-03
1.19.37 2012-08-31
1.19.36 2012-08-30
1.19.35 2012-08-29
1.19.34 2012-08-28
1.19.33 2012-08-21
1.19.32 2012-08-18
1.19.31 2012-08-15
1.19.30 2012-08-14
1.19.29 2012-08-11
1.19.28 2012-08-02
1.19.27 2012-07-30
1.19.26 2012-07-26
1.19.25 2012-07-24
1.19.24 2012-07-23
1.19.23 2012-07-22
1.19.22 2012-07-19
1.19.21 2012-07-18
1.19.20 2012-07-17
1.19.19 2012-07-16
1.19.18 2012-07-09
1.19.17 2012-07-06
1.19.16 2012-07-04
1.19.15 2012-06-29
1.19.14 2012-06-28
1.19.13 2012-06-26
1.19.12 2012-06-26
1.19.11 2012-06-25
1.19.10 2012-06-22
1.19.9 2012-06-18
1.19.8 2012-06-14
1.19.7 2012-06-13
1.19.6 2012-06-12
1.19.5 2012-06-09
1.19.4 2012-06-07
1.19.3 2012-06-01
1.19.2 2012-05-28
1.19.1 2012-05-25
1.19.0 2012-05-21
1.18.12 2013-04-11
1.18.11 2012-11-22
1.18.10 2012-10-30
1.18.9 2012-10-01
1.18.8 2012-09-19
1.18.7 2012-08-30
1.18.6 2012-08-05
1.18.5 2012-07-10
1.18.4 2012-07-07
1.18.3 2012-06-28
1.18.2 2012-06-21
1.18.1 2012-06-01
1.18.0 2012-05-21
1.17.43 2012-05-17
1.17.42 2012-05-13
1.17.41 2012-05-11
1.17.40 2012-05-08
1.17.39 2012-05-03
1.17.38 2012-05-01
1.17.37 2012-05-01
1.17.36 2012-04-26
1.17.35 2012-04-25
1.17.34 2012-04-24
1.17.33 2012-04-22
1.17.32 2012-04-17
1.17.31 2012-04-15
1.17.30 2012-04-13
1.17.29 2012-04-12
1.17.28 2012-04-11
1.17.27 2012-04-10
1.17.26 2012-04-03
1.17.25 2012-04-02
1.17.24 2012-04-01
1.17.23 2012-04-01
1.17.22 2012-03-29
1.17.21 2012-03-21
1.17.20 2012-03-17
1.17.19 2012-03-16
1.17.18 2012-03-15
1.17.17 2012-03-14
1.17.16 2012-03-13
1.17.15 2012-03-12
1.17.14 2012-03-09
1.17.13 2012-03-08
1.17.12 2012-03-07
1.17.11 2012-03-05
1.17.10 2012-03-03
1.17.9 2012-02-29
1.17.8 2012-02-15
1.17.7 2012-02-13
1.17.6 2012-02-10
1.17.5 2012-02-08
1.17.4 2012-02-01
1.17.3 2012-01-27
1.17.2 2012-01-26
1.17.1 2012-01-24
1.16.35 2013-04-11
1.16.34 2012-11-22
1.16.33 2012-10-30
1.16.32 2012-10-01
1.16.31 2012-09-19
1.16.30 2012-08-30
1.16.29 2012-08-05
1.16.28 2012-07-10
1.16.27 2012-07-07
1.16.26 2012-06-28
1.16.25 2012-06-21
1.16.24 2012-06-01
1.16.23 2012-05-18
1.16.22 2012-05-14
1.16.21 2012-05-01
1.16.20 2012-04-24
1.16.19 2012-04-17
1.16.18 2012-04-13
1.16.17 2012-04-11
1.16.16 2012-04-10
1.16.15 2012-04-03
1.16.14 2012-04-02
1.16.13 2012-03-30
1.16.12 2012-03-23
1.16.11 2012-03-16
1.16.10 2012-03-13
1.16.9 2012-03-08
1.16.8 2012-03-05
1.16.7 2012-03-03
1.16.6 2012-03-01
1.16.5 2012-02-13
1.16.4 2012-02-10
1.16.3 2012-02-08
1.16.2 2012-01-30
1.16.1 2012-01-24
1.16.0 2012-01-23
1.15.19 2012-01-22
1.15.18 2012-01-19
1.15.17 2012-01-18
1.15.16 2012-01-10
1.15.15 2012-01-06
1.15.14 2011-12-23
1.15.13 2011-12-22
1.15.12 2011-12-22
1.15.11 2011-12-09
1.15.10 2011-12-06
1.15.9 2011-12-03
1.15.8 2011-11-29
1.15.7 2011-11-29
1.15.6 2011-11-24
1.15.5 2011-11-21
1.15.4 2011-11-17
1.15.3 2011-11-09
1.15.2 2011-11-03
1.15.1 2011-11-01
1.15.0 2011-10-27
1.14.10 2012-01-23
1.14.9 2012-01-10
1.14.8 2011-12-22
1.14.7 2011-12-09
1.14.6 2011-12-06
1.14.5 2011-12-02
1.14.4 2011-11-24
1.14.3 2011-11-22
1.14.2 2011-11-09
1.14.1 2011-10-31
1.14.0 2011-10-27
1.13.26 2011-10-26
1.13.25 2011-10-26
1.13.24 2011-10-24
1.13.23 2011-10-20
1.13.22 2011-10-19
1.13.21 2011-10-14
1.13.20 2011-10-11
1.13.19 2011-10-08
1.13.18 2011-10-05
1.13.17 2011-10-04
1.13.16 2011-10-01
1.13.15 2011-09-28
1.13.14 2011-09-24
1.13.13 2011-09-21
1.13.12 2011-09-14
1.13.11 2011-09-01
1.13.10 2011-08-28
1.13.9 2011-08-26
1.13.8 2011-08-26
1.13.7 2011-08-23
1.13.6 2011-08-18
1.13.5 2011-08-17
1.13.4 2011-08-11
1.13.3 2011-08-07
1.13.2 2011-08-02
1.13.1 2011-07-26
1.12.11 2011-12-22
1.12.10 2011-11-10
1.12.9 2011-10-31
1.12.8 2011-10-19
1.12.7 2011-09-16
1.12.6 2011-09-01
1.12.5 2011-08-28
1.12.4 2011-08-17
1.12.3 2011-08-07
1.12.2 2011-07-27
1.12.1 2011-07-26
1.12.0 2011-07-20
1.11.20 2011-07-19
1.11.19 2011-07-18
1.11.18 2011-07-15
1.11.17 2011-07-14
1.11.16 2011-07-13
1.11.15 2011-07-12
1.11.14 2011-07-06
1.11.13 2011-06-30
1.11.12 2011-06-28
1.11.11 2011-06-21
1.11.10 2011-06-10
1.11.9 2011-06-04
1.11.8 2011-05-18
1.11.7 2011-05-17
1.11.6 2011-05-12
1.11.5 2011-05-09
1.11.4 2011-05-08
1.11.3 2011-04-22
1.11.2 2011-04-18
1.11.1 2011-04-16
1.11.0 2011-04-12
1.10.12 2011-12-22
1.10.11 2011-11-09
1.10.10 2011-10-31
1.10.9 2011-09-16
1.10.8 2011-08-17
1.10.7 2011-08-07
1.10.6 2011-07-27
1.10.5 2011-07-13
1.10.4 2011-06-13
1.10.3 2011-05-18
1.10.2 2011-04-24
1.10.1 2011-04-18
1.10.0 2011-04-12
1.9.18 2011-04-09
1.9.17 2011-04-05
1.9.16 2011-04-01
1.9.15 2011-04-01
1.9.14 2011-03-28
1.9.13 2011-03-24
1.9.12 2011-03-18
1.9.11 2011-03-15
1.9.10 2011-03-08
1.9.9 2011-03-04
1.9.8 2011-02-06
1.9.7 2011-01-30
1.9.6 2011-01-22
1.9.5 2011-01-18
1.9.4 2011-01-15
1.9.3 2011-01-11
1.9.2 2011-01-03
1.9.1 2010-12-31
1.9.0 2010-12-19
1.8.16 2011-12-22
1.8.15 2011-11-09
1.8.14 2011-10-31
1.8.13 2011-09-16
1.8.12 2011-08-17
1.8.11 2011-08-07
1.8.10 2011-07-27
1.8.9 2011-07-16
1.8.8 2011-06-13
1.8.7 2011-05-18
1.8.6 2011-04-18
1.8.5 2011-04-11
1.8.4 2011-03-29
1.8.3 2011-03-21
1.8.2 2011-03-08
1.8.1 2011-01-10
1.8.0 2010-12-19
1.7.24 2010-12-16
1.7.23 2010-12-12
1.7.22 2010-12-11
1.7.21 2010-12-10
1.7.20 2010-12-07
1.7.19 2010-12-05
1.7.18 2010-12-01
1.7.17 2010-11-30
1.7.16 2010-11-26
1.7.15 2010-11-26
1.7.14 2010-11-25
1.7.13 2010-11-24
1.7.12 2010-11-23
1.7.11 2010-11-19
1.7.10 2010-11-17
1.7.9 2010-11-16
1.7.8 2010-11-15
1.7.7 2010-11-15
1.7.6 2010-11-13
1.7.5 2010-11-12
1.7.4 2010-11-11
1.7.3 2010-11-08
1.7.2 2010-11-05
1.7.1 2010-11-03
1.7.0 2010-11-02
1.6.2 2010-11-18
1.6.1 2010-11-05
1.6.0 2010-11-02
1.5.26 2010-10-29
1.5.25 2010-10-28
1.5.24 2010-10-27
1.5.23 2010-10-22
1.5.22 2010-10-19
1.5.21 2010-10-01
1.5.20 2010-09-26
1.5.19 2010-09-22
1.5.18 2010-09-22
1.5.17 2010-09-21
1.5.16 2010-09-15
1.5.15 2010-09-15
1.5.14 2010-09-14
1.5.13 2010-09-13
1.5.12 2010-09-11
1.5.11 2010-09-10
1.5.10 2010-09-09
1.5.9 2010-09-08
1.5.8 2010-09-04
1.5.7 2010-09-01
1.5.6 2010-08-27
1.5.5 2010-08-26
1.5.4 2010-08-24
1.5.3 2010-08-17
1.5.2 2010-07-22
1.5.1 2010-07-21
1.5.0 2010-07-08
1.4.6 2010-10-23
1.4.5 2010-09-08
1.4.4 2010-08-27
1.4.3 2010-08-26
1.4.2 2010-08-17
1.4.1 2010-07-12
1.4.0 2010-07-08
1.3.21 2010-06-16
1.3.20 2010-06-08
1.3.19 2010-06-04
1.3.18 2010-06-02
1.3.17 2010-05-27
1.3.16 2010-05-25
1.3.15 2010-05-25
1.3.14 2010-05-24
1.3.13 2010-05-15
1.3.12 2010-05-14
1.3.11 2010-05-08
1.3.10 2010-05-07
1.3.9 2010-04-30
1.3.8 2010-04-27
1.3.7 2010-04-23
1.3.6 2010-04-22
1.3.5 2010-04-19
1.3.4 2010-04-17
1.3.3 2010-04-12
1.3.2 2010-04-10
1.3.1 2010-04-08
1.3.0 2010-03-30
1.2.14 2010-10-23
1.2.13 2010-09-08
1.2.12 2010-08-26
1.2.11 2010-08-17
1.2.10 2010-07-12
1.2.9 2010-06-02
1.2.8 2010-05-24
1.2.7 2010-05-17
1.2.6 2010-05-14
1.2.5 2010-04-30
1.2.4 2010-04-23
1.2.3 2010-04-20
1.2.2 2010-04-12
1.2.1 2010-04-08
1.2.0 2010-03-30
1.0.89 2010-03-30
1.0.88 2010-03-26
1.0.87 2010-03-23
1.0.86 2010-03-12
1.0.85 2010-03-01
1.0.84 2010-02-12
1.0.83 2010-02-05
1.0.82 2010-01-28
1.0.81 2010-01-13
1.0.80 2009-12-16
1.0.79 2009-11-18
1.0.78 2009-11-10
1.0.77 2009-11-03
1.0.76 2009-10-29
1.0.75 2009-10-29
1.0.74 2009-10-20
1.0.73 2009-10-14
1.0.72 2009-09-23
1.0.71 2009-09-22
1.0.70 2009-09-15
1.0.69 2009-09-14
1.0.68 2009-08-19
1.0.67 2009-08-13
1.0.66 2009-08-06
1.0.65 2009-07-29
1.0.64 2009-07-23
1.0.63 2009-07-23
1.0.62 2009-07-17
1.0.61 2009-07-15
1.0.60 2009-07-14
1.0.59 2009-07-14
1.0.58 2009-07-10
1.0.57 2009-07-10
1.0.56 2009-07-07
1.0.55 2009-07-02
1.0.54 2009-06-29
1.0.53 2009-06-24
1.0.52 2009-06-24
1.0.51 2009-06-22
1.0.50 2009-06-22
1.0.49 2009-06-19
1.0.48 2009-06-16
1.0.47 2009-06-15
1.0.46 2009-06-15
1.0.45 2009-06-12
1.0.44 2009-06-10
1.0.43 2009-06-09
1.0.42 2009-06-06
1.0.41 2009-06-04
1.0.40 2009-06-04
1.0.39 2009-06-04
1.0.38 2009-06-02
1.0.37 2009-05-29
1.0.36 2009-05-28
1.0.35 2009-05-28
1.0.34 2009-05-27
1.0.33 2009-05-27
1.0.32 2009-05-26
1.0.31 2009-05-21
1.0.30 2009-05-21
1.0.29 2009-05-21
1.0.28 2009-05-21
1.0.27 2009-05-19
1.0.26 2009-05-18
1.0.25 2009-05-12
1.0.24 2009-05-12
1.0.23 2009-05-11
1.0.22 2009-05-09
1.0.21 2009-05-08
1.0.20 2009-05-07
1.0.19 2009-05-07
1.0.18 2009-05-01
1.0.17 2009-04-30
1.0.16 2009-04-30
1.0.15 2009-04-28
1.0.14 2009-04-26
1.0.13 2009-04-26
1.0.12 2009-04-24
1.0.11 2009-04-23
1.0.10 2009-04-22
1.0.9 2009-04-22
1.0.8 2009-04-22
1.0.7 2009-04-22
1.0.6 2009-04-22
1.0.5 2009-04-21
1.0.4 2009-04-20
1.0.3 2009-04-20
1.0.2 2009-04-20
1.0.1 2009-04-18
1.0.0 2009-04-16
0.9.9 2009-04-15
0.9.3 2009-04-15
0.9.2 2009-04-15
0.9.1 2009-04-14
0.9 2009-04-13
0.8.1 2009-04-12
0.8 2009-04-09
0.7 2009-04-09
0.6 2009-04-08
0.5 2009-04-07
0.4 2009-04-04
0.3 2009-04-04

46
TODO
View File

@@ -59,12 +59,6 @@ Ideas for extra commands
SELinux:
chcat
restorecon
[Wanlong Gao submitted patches for restorecon, but
there are problems with using the restorecon binary
from the host on the guest. Most of the time it
would do more harm than good.]
setfiles
Oddball:
pivot_root
@@ -501,12 +495,6 @@ this approach works, it doesn't solve the MBR problem, so likely we'd
have to write a library for that (or perhaps go back to sfdisk but
using a very abstracted interface over sfdisk).
virt-sparsify should use discard
--------------------------------
This requires some changes to qemu to make discard work properly
throughout the entire stack.
Reimplement some APIs to avoid protocol limits
----------------------------------------------
@@ -538,34 +526,18 @@ Ruby 1.8, and/or maintain volatile VALUEs on the stack.
virt-builder
------------
- set keyboard
- set default timezone and language
- set permissions on uploaded files & created directories
- how can we give users a shell for debugging purposes?
- allow non-xz-compressed templates (faster)
- let notes etc be localized, ie. notes[en]=...
- add a CLI option to print the in-built path/fingerprint(s)
- allow public keys to come from local file paths
- doing virt-builder then running (eg. via qemu, libvirt?) is common; is
it possible to make this more automatic?
- more common code between virt-sysprep & virt-builder:
* virt-sysprep should have --run, --run-command,
--firstboot-command options with common code from virt-builder
- document:
* how to integrate with ansible, puppet, chef
* how to import to OpenStack / Glance
* how to integrate with ansible, chef [puppet documented already]
* how to import to EC2
- /etc/resolv.conf handling works but is best described as a hack:
@@ -585,12 +557,6 @@ Write an extension for mc that would let people browse into
filesystems. See
http://repo.or.cz/w/midnight-commander.git/tree/HEAD:/misc/ext.d
Python
------
It seems as if we should call PyErr_Clear() somewhere in every
Python binding.
Improvements in virt-log
------------------------
@@ -604,3 +570,13 @@ Subsecond handling in virt-diff, virt-ls
Handle nanoseconds properly. You should be able to specify them on
the command line and display them.
Use QMP to query qemu features
------------------------------
The following command will dump out the QMP schema. With a lot of
work, this can be used to more accurately parse out various qemu
features that currently we get by looking at the -help text.
echo -e '{ "execute": "qmp_capabilities" }\n\n{ "execute": "query-qmp-schema" }\n\n{ "execute": "quit" }' | \
qemu-system-x86_64 -display none -M none -S -qmp-pretty stdio

View File

@@ -19,69 +19,55 @@ include $(top_srcdir)/subdir-rules.mk
EXTRA_DIST = \
test-virt-alignment-scan.sh \
test-virt-alignment-scan-docs.sh \
test-virt-alignment-scan-guests.sh \
virt-alignment-scan.pod
CLEANFILES = stamp-virt-alignment-scan.pod
bin_PROGRAMS = virt-alignment-scan
SHARED_SOURCE_FILES = \
../df/domains.c \
../df/domains.h \
../df/estimate-max-threads.c \
../df/estimate-max-threads.h \
../df/parallel.c \
../df/parallel.h \
../fish/config.c \
../fish/domain.c \
../fish/inspect.c \
../fish/keys.c \
../fish/options.h \
../fish/options.c \
../fish/uri.h \
../fish/uri.c
virt_alignment_scan_SOURCES = \
$(SHARED_SOURCE_FILES) \
scan.c
virt_alignment_scan_CPPFLAGS = \
-DGUESTFS_WARN_DEPRECATED=1 \
-DGUESTFS_PRIVATE=1 \
-I$(top_srcdir)/src -I$(top_builddir)/src \
-I$(top_srcdir)/df \
-I$(top_srcdir)/fish \
-I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \
-I$(top_srcdir)/common/structs -I$(top_builddir)/common/structs \
-I$(top_srcdir)/lib -I$(top_builddir)/lib \
-I$(top_srcdir)/common/options -I$(top_builddir)/common/options \
-I$(top_srcdir)/common/parallel -I$(top_builddir)/common/parallel \
-I$(srcdir)/../gnulib/lib -I../gnulib/lib \
-DLOCALEBASEDIR=\""$(datadir)/locale"\"
virt_alignment_scan_CFLAGS = \
-pthread \
$(WARN_CFLAGS) $(WERROR_CFLAGS) \
$(LIBCONFIG_CFLAGS) \
$(LIBXML2_CFLAGS) \
$(LIBVIRT_CFLAGS)
virt_alignment_scan_LDADD = \
$(LIBCONFIG_LIBS) \
$(top_builddir)/src/libutils.la \
$(top_builddir)/src/libguestfs.la \
$(top_builddir)/common/options/liboptions.la \
$(top_builddir)/common/parallel/libparallel.la \
$(top_builddir)/common/structs/libstructs.la \
$(top_builddir)/common/utils/libutils.la \
$(top_builddir)/lib/libguestfs.la \
$(LIBXML2_LIBS) \
$(LIBVIRT_LIBS) \
$(LTLIBINTL) \
../gnulib/lib/libgnu.la \
-lm
# Manual pages and HTML files for the website.
man_MANS = virt-alignment-scan.1
noinst_DATA = $(top_builddir)/html/virt-alignment-scan.1.html
noinst_DATA = $(top_builddir)/website/virt-alignment-scan.1.html
virt-alignment-scan.1 $(top_builddir)/html/virt-alignment-scan.1.html: stamp-virt-alignment-scan.pod
virt-alignment-scan.1 $(top_builddir)/website/virt-alignment-scan.1.html: stamp-virt-alignment-scan.pod
stamp-virt-alignment-scan.pod: virt-alignment-scan.pod
$(PODWRAPPER) \
--man virt-alignment-scan.1 \
--html $(top_builddir)/html/virt-alignment-scan.1.html \
--html $(top_builddir)/website/virt-alignment-scan.1.html \
--license GPLv2+ \
--warning safe \
$<
touch $@
@@ -89,13 +75,18 @@ stamp-virt-alignment-scan.pod: virt-alignment-scan.pod
TESTS_ENVIRONMENT = $(top_builddir)/run --test
TESTS =
TESTS = \
test-virt-alignment-scan-docs.sh
if ENABLE_APPLIANCE
TESTS += \
test-virt-alignment-scan.sh \
test-virt-alignment-scan.sh
if HAVE_LIBVIRT
TESTS += \
test-virt-alignment-scan-guests.sh
endif
endif
check-valgrind:
$(MAKE) VG="$(top_builddir)/run @VG@" check
$(MAKE) VG="@VG@" check

View File

@@ -26,6 +26,7 @@
#include <unistd.h>
#include <getopt.h>
#include <errno.h>
#include <error.h>
#include <locale.h>
#include <assert.h>
#include <libintl.h>
@@ -37,8 +38,12 @@
#include <libvirt/virterror.h>
#endif
#include "getprogname.h"
#include "guestfs.h"
#include "structs-cleanups.h"
#include "options.h"
#include "display-options.h"
#include "parallel.h"
#include "domains.h"
@@ -62,6 +67,8 @@ int keys_from_stdin = 0;
int echo_keys = 0;
const char *libvirt_uri = NULL;
int inspector = 0;
int in_guestfish = 0;
int in_virt_rescue = 0;
static int quiet = 0; /* --quiet */
static int uuid = 0; /* --uuid */
@@ -70,29 +77,29 @@ static void __attribute__((noreturn))
usage (int status)
{
if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
fprintf (stderr, _("Try %s --help for more information.\n"),
getprogname ());
else {
fprintf (stdout,
_("%s: check alignment of virtual machine partitions\n"
"Copyright (C) 2011 Red Hat Inc.\n"
"Usage:\n"
" %s [--options] -d domname\n"
" %s [--options] -a disk.img [-a disk.img ...]\n"
"Options:\n"
" -a|--add image Add image\n"
" -c|--connect uri Specify libvirt URI for -d option\n"
" -d|--domain guest Add disks from libvirt guest\n"
" --format[=raw|..] Force disk format for -a option\n"
" --help Display brief help\n"
" -P nr_threads Use at most nr_threads\n"
" -q|--quiet No output, just exit code\n"
" -v|--verbose Verbose messages\n"
" -V|--version Display version and exit\n"
" -x Trace libguestfs API calls\n"
"For more information, see the manpage %s(1).\n"),
program_name, program_name, program_name,
program_name);
printf (_("%s: check alignment of virtual machine partitions\n"
"Copyright (C) 2011 Red Hat Inc.\n"
"Usage:\n"
" %s [--options] -d domname\n"
" %s [--options] -a disk.img [-a disk.img ...]\n"
"Options:\n"
" -a|--add image Add image\n"
" -c|--connect uri Specify libvirt URI for -d option\n"
" -d|--domain guest Add disks from libvirt guest\n"
" --format[=raw|..] Force disk format for -a option\n"
" --help Display brief help\n"
" -P nr_threads Use at most nr_threads\n"
" -q|--quiet No output, just exit code\n"
" --uuid Print UUIDs instead of names\n"
" -v|--verbose Verbose messages\n"
" -V|--version Display version and exit\n"
" -x Trace libguestfs API calls\n"
"For more information, see the manpage %s(1).\n"),
getprogname (), getprogname (),
getprogname (), getprogname ());
}
exit (status);
}
@@ -106,7 +113,7 @@ main (int argc, char *argv[])
enum { HELP_OPTION = CHAR_MAX + 1 };
static const char *options = "a:c:d:P:qvVx";
static const char options[] = "a:c:d:P:qvVx";
static const struct option long_options[] = {
{ "add", 1, 0, 'a' },
{ "connect", 1, 0, 'c' },
@@ -115,7 +122,8 @@ main (int argc, char *argv[])
{ "help", 0, 0, HELP_OPTION },
{ "long-options", 0, 0, 0 },
{ "quiet", 0, 0, 'q' },
{ "uuid", 0, 0, 0, },
{ "short-options", 0, 0, 0 },
{ "uuid", 0, 0, 0 },
{ "verbose", 0, 0, 'v' },
{ "version", 0, 0, 'V' },
{ 0, 0, 0, 0 }
@@ -130,10 +138,8 @@ main (int argc, char *argv[])
int r;
g = guestfs_create ();
if (g == NULL) {
fprintf (stderr, _("guestfs_create: failed to create handle\n"));
exit (EXIT_FAILURE);
}
if (g == NULL)
error (EXIT_FAILURE, errno, "guestfs_create");
for (;;) {
c = getopt_long (argc, argv, options, long_options, &option_index);
@@ -143,15 +149,16 @@ main (int argc, char *argv[])
case 0: /* options which are long only */
if (STREQ (long_options[option_index].name, "long-options"))
display_long_options (long_options);
else if (STREQ (long_options[option_index].name, "short-options"))
display_short_options (options);
else if (STREQ (long_options[option_index].name, "format")) {
OPTION_format;
} else if (STREQ (long_options[option_index].name, "uuid")) {
uuid = 1;
} else {
fprintf (stderr, _("%s: unknown long option: %s (%d)\n"),
program_name, long_options[option_index].name, option_index);
exit (EXIT_FAILURE);
}
} else
error (EXIT_FAILURE, 0,
_("unknown long option: %s (%d)"),
long_options[option_index].name, option_index);
break;
case 'a':
@@ -167,10 +174,8 @@ main (int argc, char *argv[])
break;
case 'P':
if (sscanf (optarg, "%zu", &max_threads) != 1) {
fprintf (stderr, _("%s: -P option is not numeric\n"), program_name);
exit (EXIT_FAILURE);
}
if (sscanf (optarg, "%zu", &max_threads) != 1)
error (EXIT_FAILURE, 0, _("-P option is not numeric"));
break;
case 'q':
@@ -225,19 +230,14 @@ main (int argc, char *argv[])
if (r == -1)
exit (EXIT_FAILURE);
#else
fprintf (stderr, _("%s: compiled without support for libvirt.\n"),
program_name);
exit (EXIT_FAILURE);
error (EXIT_FAILURE, 0, _("compiled without support for libvirt"));
#endif
} else { /* Single guest. */
if (uuid) {
fprintf (stderr, _("%s: --uuid option cannot be used with -a or -d\n"),
program_name);
exit (EXIT_FAILURE);
}
if (uuid)
error (EXIT_FAILURE, 0, _("--uuid option cannot be used with -a or -d"));
/* Add domains/drives from the command line (for a single guest). */
add_drives (drvs, 'a');
add_drives (drvs);
if (guestfs_launch (g) == -1)
exit (EXIT_FAILURE);
@@ -279,11 +279,17 @@ scan (guestfs_h *g, const char *prefix, FILE *fp)
for (i = 0; devices[i] != NULL; ++i) {
CLEANUP_FREE char *name = NULL;
CLEANUP_FREE_PARTITION_LIST struct guestfs_partition_list *parts = NULL;
CLEANUP_FREE_PARTITION_LIST struct guestfs_partition_list *parts =
guestfs_part_list (g, devices[i]);
if (parts == NULL)
return -1;
guestfs_push_error_handler (g, NULL, NULL);
parts = guestfs_part_list (g, devices[i]);
guestfs_pop_error_handler (g);
if (parts == NULL) {
if (guestfs_last_errno (g) == EINVAL) /* unrecognised disk label */
continue;
else
return -1;
}
/* Canonicalize the name of the device for printing. */
name = guestfs_canonical_device_name (g, devices[i]);
@@ -350,15 +356,15 @@ scan (guestfs_h *g, const char *prefix, FILE *fp)
static int
scan_work (guestfs_h *g, size_t i, FILE *fp)
{
struct guestfs___add_libvirt_dom_argv optargs;
struct guestfs_add_libvirt_dom_argv optargs;
optargs.bitmask =
GUESTFS___ADD_LIBVIRT_DOM_READONLY_BITMASK |
GUESTFS___ADD_LIBVIRT_DOM_READONLYDISK_BITMASK;
GUESTFS_ADD_LIBVIRT_DOM_READONLY_BITMASK |
GUESTFS_ADD_LIBVIRT_DOM_READONLYDISK_BITMASK;
optargs.readonly = 1;
optargs.readonlydisk = "read";
if (guestfs___add_libvirt_dom (g, domains[i].dom, &optargs) == -1)
if (guestfs_add_libvirt_dom_argv (g, domains[i].dom, &optargs) == -1)
return -1;
if (guestfs_launch (g) == -1)

View File

@@ -0,0 +1,24 @@
#!/bin/bash -
# libguestfs
# Copyright (C) 2016 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.
set -e
$TEST_FUNCTIONS
skip_if_skipped
$top_srcdir/podcheck.pl virt-alignment-scan.pod virt-alignment-scan

View File

@@ -16,15 +16,10 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
$TEST_FUNCTIONS
skip_if_skipped
if [ -n "$SKIP_TEST_VIRT_ALIGNMENT_SCAN_GUESTS_SH" ]; then
echo "$0: skipping test because SKIP_TEST_VIRT_ALIGNMENT_SCAN_GUESTS_SH is set."
exit 77
fi
guestsdir="$(cd ../tests/guests && pwd)"
libvirt_uri="test://$guestsdir/guests-all-good.xml"
libvirt_uri="test://$abs_top_builddir/test-data/phony-guests/guests-all-good.xml"
$VG virt-alignment-scan -c "$libvirt_uri"
r=$?

View File

@@ -16,9 +16,10 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
$TEST_FUNCTIONS
skip_if_skipped
$VG virt-alignment-scan -a ../tests/guests/fedora.img
$VG virt-alignment-scan --format=raw -a ../test-data/phony-guests/fedora.img
r=$?
# 0, 2 and 3 are reasonable non-error exit codes. Others are errors.

View File

@@ -67,7 +67,7 @@ program. The columns are:
=item col 1
The device and partition name (eg. C</dev/sda1> meaning the
The device and partition name (eg. F</dev/sda1> meaning the
first partition on the first block device).
When listing all libvirt domains (no I<-a> or I<-d> option given) this
@@ -151,12 +151,12 @@ For example:
virt-alignment-scan --format=raw -a disk.img
forces raw format (no auto-detection) for C<disk.img>.
forces raw format (no auto-detection) for F<disk.img>.
virt-alignment-scan --format=raw -a disk.img --format -a another.img
forces raw format (no auto-detection) for C<disk.img> and reverts to
auto-detection for C<another.img>.
forces raw format (no auto-detection) for F<disk.img> and reverts to
auto-detection for F<another.img>.
If you have untrusted raw-format guest disk images, you should use
this option to specify the disk format. This avoids a possible
@@ -178,7 +178,7 @@ single thread.
=item B<--quiet>
Don't produce any output. Just set the exit code
Dont produce any output. Just set the exit code
(see L</EXIT STATUS> below).
=item B<--uuid>

View File

@@ -1,5 +1,5 @@
# libguestfs
# Copyright (C) 2009-2014 Red Hat Inc.
# Copyright (C) 2009-2017 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
@@ -15,13 +15,23 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# This subdirectory builds the appliance. It is first prepared as a
# supermin appliance (appliance/supermin.d/*), and then the supermin
# appliance is built into a full fat appliance in $TMPDIR/.guestfs-*
# (which is under tmp/ if you are using the ./run script).
#
# Because preparing the supermin appliance is expensive, even
# `make clean' does not delete it. If you want to force the supermin
# appliance to be reprepared, do:
#
# make -C appliance clean-supermin-appliance
# make -C appliance
include $(top_srcdir)/subdir-rules.mk
EXTRA_DIST = \
99-guestfs-serial.rules \
excludefiles.in \
guestfsd.suppressions \
guestfs_lvm_conf.aug \
guestfs_shadow.aug \
hostfiles.in \
init \
@@ -44,7 +54,7 @@ superminfs_DATA = \
supermin.d/udev-rules.tar.gz
supermin.d/base.tar.gz supermin.d/packages: stamp-supermin
stamp-supermin: make.sh packagelist
stamp-supermin: make.sh packagelist supermin.d/excludefiles
rm -f $@ supermin.d/base.tar.gz supermin.d/packages
./make.sh
$(MAKE) \
@@ -55,6 +65,9 @@ stamp-supermin: make.sh packagelist
supermin.d/udev-rules.tar.gz
touch $@
clean-supermin-appliance:
rm -f stamp-supermin
# This used to be a configure-generated file. However config.status
# always touches the destination file, which means the appliance got
# rebuilt too often.
@@ -66,9 +79,6 @@ make.sh: make.sh.in $(top_builddir)/config.log $(top_builddir)/config.status
rm -f $@-t
PACKAGELIST_CPP_FLAGS = -D$(DISTRO)=1 -DEXTRA_PACKAGES="$(EXTRA_PACKAGES)"
if VALGRIND_DAEMON
PACKAGELIST_CPP_FLAGS += -DVALGRIND_DAEMON=1
endif
packagelist: packagelist.in Makefile
m4 $(PACKAGELIST_CPP_FLAGS) $< | \
@@ -76,13 +86,11 @@ packagelist: packagelist.in Makefile
cmp -s $@ $@-t || mv $@-t $@
rm -f $@-t
supermin.d/daemon.tar.gz: ../daemon/guestfsd guestfsd.suppressions guestfs_lvm_conf.aug guestfs_shadow.aug
supermin.d/daemon.tar.gz: ../daemon/guestfsd guestfs_shadow.aug
rm -f $@ $@-t
rm -rf tmp-d
mkdir -p tmp-d$(DAEMON_SUPERMIN_DIR) tmp-d/etc tmp-d/usr/share/guestfs
ln ../daemon/guestfsd tmp-d$(DAEMON_SUPERMIN_DIR)/guestfsd
ln $(srcdir)/guestfsd.suppressions tmp-d/etc/guestfsd.suppressions
ln $(srcdir)/guestfs_lvm_conf.aug tmp-d/usr/share/guestfs/guestfs_lvm_conf.aug
ln $(srcdir)/guestfs_shadow.aug tmp-d/usr/share/guestfs/guestfs_shadow.aug
( cd tmp-d && tar zcf - * ) > $@-t
rm -r tmp-d
@@ -91,7 +99,7 @@ supermin.d/daemon.tar.gz: ../daemon/guestfsd guestfsd.suppressions guestfs_lvm_c
# Note we must avoid touching supermin.d if possible, so don't create
# the temporary files inside the supermin.d directory.
$@supermin.d/excludefiles: excludefiles.in Makefile
supermin.d/excludefiles: excludefiles.in Makefile
m4 $(PACKAGELIST_CPP_FLAGS) $< | \
grep -v '^[[:space:]]*$$' | grep -v '^#' > excludefiles-t
cmp -s $@ excludefiles-t || mv excludefiles-t $@
@@ -132,23 +140,20 @@ sbin_SCRIPTS = libguestfs-make-fixed-appliance
man_MANS = libguestfs-make-fixed-appliance.1
libguestfs-make-fixed-appliance.1 $(top_builddir)/html/libguestfs-make-fixed-appliance.1.html: stamp-libguestfs-make-fixed-appliance.pod
libguestfs-make-fixed-appliance.1 $(top_builddir)/website/libguestfs-make-fixed-appliance.1.html: stamp-libguestfs-make-fixed-appliance.pod
stamp-libguestfs-make-fixed-appliance.pod: libguestfs-make-fixed-appliance.pod
$(PODWRAPPER) \
--man libguestfs-make-fixed-appliance.1 \
--html $(top_builddir)/html/libguestfs-make-fixed-appliance.1.html \
--html $(top_builddir)/website/libguestfs-make-fixed-appliance.1.html \
--license GPLv2+ \
--warning safe \
$<
touch $@
# Make clean.
CLEANFILES = \
*~ \
libguestfs-make-fixed-appliance.1 \
stamp-libguestfs-make-fixed-appliance.pod
DISTCLEANFILES = \
stamp-supermin \
DISTCLEANFILES += \
make.sh \
packagelist \
supermin.d/*

View File

@@ -21,23 +21,41 @@ dnl Of course, this may break the appliance, so be careful.
dnl The right kernel modules are added back by supermin.
-/boot/*
-/lib/modules/*
-/usr/lib/modules/*
dnl Firmware blobs should not be required by a virtual machine.
dnl Because of UsrMove nonsense, we need to list both directories.
-/lib/firmware/*
-/usr/lib/firmware/*
-/usr/lib/locale/*
-/usr/share/cracklib/*
-/usr/share/doc/*
-/usr/share/fonts/*
-/usr/share/gnome/help/*
-/usr/share/i18n/*
-/usr/share/icons/*
-/usr/share/info/*
-/usr/share/locale/*
-/usr/share/man/*
-/usr/share/doc/*
-/usr/share/info/*
-/usr/share/gnome/help/*
-/usr/share/cracklib/*
-/usr/share/i18n/*
-/usr/share/pkgconfig/*
-/var/log/?tmp
-/var/log/*.gz
-/var/log/*.log*
-/var/log/cron*
-/var/log/lastlog*
-/var/log/maillog*
-/var/log/messages*
-/var/log/secure*
-/var/log/syslog*
-/var/log/tallylog*
-/var/log/*/*.gz
-/var/log/*/*.log*
-/var/log/*/syslog*
-/var/log/sa/*
dnl For Debian:
-/usr/share/lintian/*

View File

@@ -1,74 +0,0 @@
(*
Module: LVM
Parses LVM metadata.
Author: Gabriel de Perthuis <g2p.code+augeas@gmail.com>
About: License
This file is licensed under the LGPL v2+.
About: Configuration files
This lens applies to files in /etc/lvm/backup and /etc/lvm/archive.
About: Examples
The <Test_LVM> file contains various examples and tests.
*)
module Guestfs_LVM_conf =
autoload xfm
(* See lvm2/libdm/libdm-config.c for tokenisation;
* libdm uses a blacklist but I prefer the safer whitelist approach. *)
(* View: identifier
* The left hand side of a definition *)
let identifier = /[a-zA-Z0-9_-]+/
(* strings can contain backslash-escaped dquotes, but I don't know
* how to get the message across to augeas *)
let str = [label "str". Quote.do_dquote (store /([^\"]|\\\\.)*/)]
let int = [label "int". store Rx.relinteger]
(* View: flat_literal
* A literal without structure *)
let flat_literal = int|str
(* allow multiline and mixed int/str, used for raids and stripes *)
(* View: list
* A list containing flat literals *)
let list = [
label "list" . counter "list"
. del /\[[ \t\n]*/ "["
.([seq "list". flat_literal . del /,[ \t\n]*/ ", "]*
. [seq "list". flat_literal . del /[ \t\n]*/ ""])?
. Util.del_str "]"]
(* View: val
* Any value that appears on the right hand side of an assignment *)
let val = flat_literal | list
(* View: nondef
* A line that doesn't contain a statement *)
let nondef =
Util.empty
| Util.comment
(* Build.block couldn't be reused, because of recursion and
* a different philosophy of whitespace handling. *)
(* View: def
* An assignment, or a block containing definitions *)
let rec def = [
Util.indent . key identifier . (
del /[ \t]*\{\n/ " {\n"
.[label "dict".(nondef | def)*]
. Util.indent . Util.del_str "}\n"
|Sep.space_equal . val . Util.comment_or_eol)]
(* View: lns
* The main lens *)
let lns = (nondef | def)*
let filter =
incl "/etc/lvm/archive/*.vg"
. incl "/etc/lvm/backup/*"
. Util.stdexcl
let xfm = transform lns filter

View File

@@ -1,27 +0,0 @@
# This file is only used when libguestfs is configured with
#
# ./configure --enable-valgrind-daemon
#
# (only used for development, and only used in the regular supermin
# appliance, not libguestfs live).
#
# If there are any valgrind errors in the base libraries such as
# glibc, then we can suppress them here, so we only see errors in
# libguestfs daemon code.
# libdl
{
libdl_index_cond
Memcheck:Cond
fun:index
fun:expand_dynamic_string_token
fun:_dl_map_object
}
# aug_setm memory leak
{
aug_setm_leak
Memcheck:Leak
...
fun:aug_setm
}

View File

@@ -13,5 +13,6 @@ dnl SUSE=1 For OpenSUSE.
dnl FRUGALWARE=1 For Frugalware.
dnl MAGEIA=1 For Mageia.
/etc/ld.so.cache
/lib/lsb/*
/usr/share/augeas/lenses/*.aug

View File

@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
echo Starting /init script ...
@@ -10,9 +10,12 @@ RUNLEVEL=S
PREVLEVEL=N
export RUNLEVEL PREVLEVEL
# Make sure to find all the libraries, also those in non-standard place
# but with a proper ld.so configuration pointing at them
ldconfig
# Make sure /tmp /var/tmp are real directories, not symlinks.
if [ ! -d /tmp ] || [ ! -d /var/tmp ]; then
rm -f /tmp /var/tmp
mkdir /tmp /var/tmp
chmod 1777 /tmp /var/tmp
fi
# Try to print a stack trace for segfaults inside the appliance.
for d in /lib64 /lib; do
@@ -26,9 +29,32 @@ done
mkdir -p /sysroot
# Mount /proc.
if [ ! -d /proc ]; then rm -f /proc; fi
mkdir -p /proc
mount -t proc /proc /proc
# Parse the kernel command line early (must be after /proc is mounted).
cmdline=$(</proc/cmdline)
if [[ $cmdline == *guestfs_verbose=1* ]]; then
guestfs_verbose=1
set -x
fi
if [[ $cmdline == *guestfs_network=1* ]]; then
guestfs_network=1
fi
if [[ $cmdline == *guestfs_rescue=1* ]]; then
guestfs_rescue=1
fi
if [[ $cmdline == *guestfs_noreboot=1* ]]; then
guestfs_noreboot=1
fi
if [[ $cmdline == *guestfs_boot_analysis=1* ]]; then
guestfs_boot_analysis=1
fi
# Mount the other special filesystems.
if [ ! -d /sys ]; then rm -f /sys; fi
mkdir -p /sys
mount -t sysfs /sys /sys
@@ -38,52 +64,69 @@ mount -t tmpfs -o "nosuid,size=20%,mode=0755" tmpfs /run
mkdir -p /run/lock
ln -s ../run/lock /var/lock
# On Fedora 23, util-linux creates /etc/mtab in %post .. stupid
# and e2fsprogs fails if the link doesn't exist .. stupid stupid
if ! test -e /etc/mtab; then
ln -s /proc/mounts /etc/mtab
fi
# devtmpfs is required since udev 176
mount -t devtmpfs /dev /dev
mkdir -p /dev/pts
mount -t devpts /dev/pts /dev/pts
mkdir -p /dev/shm
mount -t tmpfs -o mode=1777 shmfs /dev/shm
if [[ $cmdline == *selinux=1* ]]; then
mount -t selinuxfs none /sys/fs/selinux
fi
# Static nodes must happen before udev is started.
# Set up kmod static-nodes (RHBZ#1011907).
mkdir -p /run/tmpfiles.d
kmod static-nodes --format=tmpfiles --output=/run/tmpfiles.d/kmod.conf
# Create a machine-id with a random UUID
machine_id=$(dd if=/dev/urandom bs=16 count=1 status=none | od -x -A n)
echo "${machine_id// /}" > /etc/machine-id
# Set up tmpfiles (must run after kmod.conf is created above).
systemd-tmpfiles --prefix=/dev --prefix=/run --prefix=/var/run --create --boot
# Find udevd and run it directly.
for f in /sbin/udevd /lib/udev/udevd \
/lib/systemd/systemd-udevd /usr/lib/systemd/systemd-udevd \
for f in /lib/systemd/systemd-udevd /usr/lib/systemd/systemd-udevd \
/sbin/udevd /lib/udev/udevd \
/usr/lib/udev/udevd; do
if [ -x "$f" ]; then UDEVD="$f"; fi
if [ -x "$f" ]; then UDEVD="$f"; break; fi
done
if [ -z "$UDEVD" ]; then
echo "udev not found! Things will probably not work ..."
echo "error: udev not found! Things will probably not work ..."
fi
$UDEVD --daemon #--debug
udevadm trigger
udevadm settle --timeout=600
if grep -sq selinux=1 /proc/cmdline; then
mount -t selinuxfs none /sys/fs/selinux
fi
# Set up kmod static-nodes (RHBZ#1011907).
mkdir -p /run/tmpfiles.d
kmod static-nodes --format=tmpfiles --output=/run/tmpfiles.d/kmod.conf
# Set up tmpfiles (must run after kmod.conf is created above).
systemd-tmpfiles --prefix=/dev --create
# Disk optimizations.
# Increase the SCSI timeout so we can read remote images.
shopt -s nullglob
for f in /sys/block/sd*/device/timeout; do echo 300 > $f; done
# https://access.redhat.com/site/solutions/5427
for f in /sys/block/{h,s,ub,v}d*/queue/scheduler; do echo noop > $f; done
# Update the system clock.
hwclock -u -s
shopt -u nullglob
# Set up the network.
ip addr add 127.0.0.1/8 brd + dev lo scope host
ip link set dev lo up
if grep -sq guestfs_network=1 /proc/cmdline; then
if test "$guestfs_network" = 1; then
iface=$(ls -I all -I default -I lo /proc/sys/net/ipv4/conf)
touch /etc/fstab # Workaround for Ubuntu.
if dhclient --version >/dev/null 2>&1; then
dhclient
dhclient $iface
else
dhcpcd
dhcpcd $iface
fi
fi
@@ -92,7 +135,6 @@ mdadm -As --auto=yes --run
# Scan for LVM.
modprobe dm_mod ||:
lvmetad ||:
lvm vgchange -aay --sysinit
@@ -100,7 +142,7 @@ lvm vgchange -aay --sysinit
ldmtool create all
# These are useful when debugging.
if grep -sq guestfs_verbose=1 /proc/cmdline; then
if test "$guestfs_verbose" = 1 && test "$guestfs_boot_analysis" != 1; then
uname -a
ls -lR /dev
cat /proc/mounts
@@ -109,6 +151,7 @@ if grep -sq guestfs_verbose=1 /proc/cmdline; then
lvm lvs
ip a
ip r
cat /etc/resolv.conf
lsmod
#hwclock -r
date
@@ -119,56 +162,89 @@ if grep -sq guestfs_verbose=1 /proc/cmdline; then
echo -n "uptime: "; cat /proc/uptime
fi
if ! grep -sq guestfs_rescue=1 /proc/cmdline; then
# Run the daemon.
# Run the daemon under valgrind if ./configure --enable-valgrind-daemon
if grep -sq guestfs_valgrind_daemon=1 /proc/cmdline; then
if [ -r /etc/guestfsd.suppressions ]; then
suppressions="--suppressions=/etc/guestfsd.suppressions"
fi
vg="valgrind --leak-check=full --error-exitcode=119 --max-stackframe=8388608 --child-silent-after-fork=yes $suppressions"
echo "enabling valgrind: $vg"
fi
# Run guestfsd, under valgrind if asked.
$vg guestfsd
if [ $? -eq 119 ]; then
echo "DAEMON VALGRIND FAILED"
# Sleep so valgrind messages are seen by the host. Note this
# only happens in non-production builds
# (--enable-valgrind-daemon) + on an error path.
sleep 10
fi
# Run the daemon.
cmd="guestfsd"
eval `grep -Eo 'guestfs_channel=[^[:space:]]+' /proc/cmdline`
if test "x$guestfs_channel" != "x"; then
cmd="$cmd --channel $guestfs_channel"
fi
if test "$guestfs_verbose" = 1; then
cmd="$cmd --verbose"
fi
if test "$guestfs_network" = 1; then
cmd="$cmd --network"
fi
if false; then
# To get a stack trace if the daemon crashes:
# (1) change this section to 'if true'
# (2) add 'gdb' to 'appliance/packagelist.in'
unset LD_PRELOAD
echo set pagination off > /tmp/gdb-script
echo run >> /tmp/gdb-script
echo info registers >> /tmp/gdb-script
echo 'x/16i $pc' >> /tmp/gdb-script
echo t a a bt >> /tmp/gdb-script
echo quit >> /tmp/gdb-script
cmd="gdb -batch -x /tmp/gdb-script --args $cmd"
fi
if ! test "$guestfs_rescue" = 1; then
echo $cmd
$cmd
else
# Run virt-rescue shell.
# Run virt-rescue shell.
# Remove LD_PRELOAD=libSegFault set above.
unset LD_PRELOAD
# We need a daemon, even in virt-rescue.
$cmd &
:> $HOME/.bashrc
grep -Eo 'TERM=[^[:space:]]+' /proc/cmdline >> $HOME/.bashrc
echo "PS1='><rescue> '" >> $HOME/.bashrc
echo "export TERM PS1" >> $HOME/.bashrc
# XXX This gives a bit of time for virt-rescue to connect to the
# daemon and mount any filesystems.
sleep 2
echo
echo "------------------------------------------------------------"
echo
echo "Welcome to virt-rescue, the libguestfs rescue shell."
echo
echo "Note: The contents of / are the rescue appliance."
echo "You have to mount the guest's partitions under /sysroot"
echo "before you can examine them."
echo
bash -i
echo
echo "virt-rescue: Syncing the disk now before exiting ..."
echo
# Get name of the serial port, from console= passed by libguestfs.
# XXX Consider using /proc/consoles
guestfs_serial=$(grep -Eo 'console=[^[:space:]]+' /proc/cmdline |
sed s/console=//)
# Remove LD_PRELOAD=libSegFault set above.
unset LD_PRELOAD
:> $HOME/.bashrc
grep -Eo 'TERM=[^[:space:]]+' /proc/cmdline >> $HOME/.bashrc
echo "PS1='><rescue> '" >> $HOME/.bashrc
echo "export TERM PS1" >> $HOME/.bashrc
# The shell is opened by default on /dev/console, which (on Linux)
# is not a controlling terminal, causing job control to fail. For
# how we work around this, see:
# https://busybox.net/FAQ.html#job_control
run_bash_with_ctty ()
{
setsid bash -c \
"exec bash </dev/$guestfs_serial >/dev/$guestfs_serial 2>&1"
}
echo
echo "------------------------------------------------------------"
echo
echo "Welcome to virt-rescue, the libguestfs rescue shell."
echo
echo "Note: The contents of / (root) are the rescue appliance."
if ! test -d "/sysroot/dev"; then
echo "You have to mount the guests partitions under /sysroot"
echo "before you can examine them."
else
echo "Use 'cd /sysroot' or 'chroot /sysroot' to see guest filesystems."
fi
echo
run_bash_with_ctty
echo
echo "virt-rescue: Syncing the disk now before exiting ..."
echo
fi
sync
if ! grep -sq guestfs_noreboot=1 /proc/cmdline; then
if ! test "$guestfs_noreboot" = 1; then
# qemu has the -no-reboot flag, so issuing a reboot here actually
# causes qemu to exit gracefully.
reboot -f

View File

@@ -38,8 +38,8 @@ L<guestfs-performance(1)>).
=back
For deeper understanding of why you might need this tool, read the
section L</FIXED APPLIANCE> below.
For deeper understanding of why you might need this tool, read
L<guestfs-internals(1)/FIXED APPLIANCE>.
Instead of running this tool, you can download fixed appliances from
L<http://libguestfs.org/download/binaries/appliance/>. These
@@ -112,7 +112,7 @@ Display the version number and exit.
Instead of creating the appliance in an output directory, create a
compressed tarball of the appliance in the current directory called
C<appliance-I<VERSION>.tar.xz> where C<VERSION> is the version of
F<appliance-I<VERSION>.tar.xz> where C<VERSION> is the version of
libguestfs.
Using I<--xz> can take some time. If working normally, the tool is
@@ -120,30 +120,6 @@ completely silent when it is running.
=back
=head1 FIXED APPLIANCE
When libguestfs (or libguestfs tools) are run, they search a path
looking for an appliance. The path is built into libguestfs, or can
be set using the C<LIBGUESTFS_PATH> environment variable.
Normally a supermin appliance is located on this path (see
L<supermin(1)/SUPERMIN APPLIANCE>). libguestfs reconstructs this
into a full appliance by running C<supermin --build>.
However, a simpler "fixed appliance" can also be used. libguestfs
detects this by looking for a directory on the path containing four
files called C<kernel>, C<initrd>, C<root> and C<README.fixed> (note
the C<README.fixed> file must be present as well).
If the fixed appliance is found, libguestfs skips supermin entirely
and just runs qemu with the kernel, initrd and root disk from the
fixed appliance.
Thus the fixed appliance can be used when a platform or Linux distro
does not support supermin. You build the fixed appliance on a
platform that does support supermin, and copy it over, and use that
to run libguestfs.
=head1 LICENSING
The fixed appliance is a complete Linux binary distro. If you
@@ -175,4 +151,4 @@ Richard W.M. Jones (C<rjones at redhat dot com>)
=head1 COPYRIGHT
Copyright (C) 2009-2014 Red Hat Inc.
Copyright (C) 2009-2017 Red Hat Inc.

View File

@@ -1,6 +1,6 @@
#!/bin/bash -
# @configure_input@
# Copyright (C) 2009-2014 Red Hat Inc.
# Copyright (C) 2009-2017 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

View File

@@ -24,12 +24,9 @@ ifelse(UBUNTU,1,`define(`DEBIAN',1)')
ifelse(REDHAT,1,
augeas-libs
btrfs-progs
cryptsetup
cryptsetup-luks dnl old name used before Fedora 17
dhclient
dnl e4fsprogs only exists on RHEL 5, will be ignored everywhere else.
e4fsprogs
genisoimage
gfs-utils
gfs2-utils
@@ -40,12 +37,14 @@ ifelse(REDHAT,1,
iputils
kernel
libcap
libldm dnl only Fedora for now, others later
libldm
libtirpc
nilfs-utils
ntfsprogs
ntfs-3g
openssh-clients
pcre
policycoreutils
reiserfs-utils
libselinux
syslinux-extlinux
@@ -53,11 +52,13 @@ ifelse(REDHAT,1,
vim-minimal
xz
yajl
yara
zfs-fuse
)
ifelse(DEBIAN,1,
bsdmainutils
dnl old name used in Jessie and earlier
btrfs-tools
cryptsetup
extlinux
@@ -75,6 +76,7 @@ dnl iproute has been renamed to iproute2
iputils-arping
iputils-tracepath
isc-dhcp-client
ldmtool
libaugeas0
libc-bin
libcap2
@@ -83,7 +85,9 @@ dnl iproute has been renamed to iproute2
libsystemd0
libsystemd-id128-0
libsystemd-journal0
libtirpc1
libyajl2
libyara3
linux-image
dnl syslinux 'suggests' mtools, but in reality it's a hard dependency:
mtools
@@ -97,12 +101,13 @@ dnl iproute has been renamed to iproute2
vim-tiny
xz-utils
zfs-fuse
uuid-runtime
)
ifelse(ARCHLINUX,1,
augeas
btrfs-progs
cdrkit
cdrtools
cryptsetup
dhcpcd
gptfdisk
@@ -111,13 +116,14 @@ ifelse(ARCHLINUX,1,
iproute2
iputils
libcap
libtirpc
linux
lrzip
dnl syslinux has mtools as optional dependency, but in reality it's
dnl a hard one:
mtools
multipath-tools dnl for kpartx
nilfs-utils
ntfsprogs
ntfs-3g
pcre
reiserfsprogs
@@ -125,7 +131,7 @@ ifelse(ARCHLINUX,1,
vim
xz
yajl
zfs-fuse
yara
)
ifelse(SUSE,1,
@@ -133,26 +139,36 @@ ifelse(SUSE,1,
dnl It seems no other augeas package depends on it.
augeas-lenses
btrfsprogs
cdrkit-cdrtools-compat
cryptsetup
dhcpcd
dhcp-client
genisoimage
glibc-locale
gptfdisk
hivex
initviocons
iproute2
iputils
libcap2
libhivex0
libselinux1
libtirpc3
libyajl2
libyara3
mkisofs
ntfsprogs
ntfs-3g
reiserfs
squashfs
systemd
vim
xz
yara
)
ifelse(FRUGALWARE,1,
augeas
btrfs-progs
cryptsetup-luks
cdrkit
dhclient
@@ -162,6 +178,7 @@ ifelse(FRUGALWARE,1,
iputils
kernel
libcap
libtirpc
ntfsprogs
ntfs-3g
openssh
@@ -178,7 +195,6 @@ ifelse(FRUGALWARE,1,
ifelse(MAGEIA,1,
augeas
btrfs-progs
cryptsetup
chkconfig /* for /etc/init.d */
cdrkit-genisoimage
@@ -192,6 +208,9 @@ ifelse(MAGEIA,1,
iproute2
iputils
libcap
libldm
libtirpc
libyajl
dnl syslinux uses mtools without depending on it
mtools
nilfs-utils
@@ -211,12 +230,14 @@ acl
attr
bash
binutils
btrfs-progs
bzip2
coreutils
cpio
diffutils
dosfstools
e2fsprogs
f2fs-tools
file
findutils
gawk
@@ -237,12 +258,15 @@ dnl Enabling this pulls out 140 extra packages
dnl into the appliance:
dnl ocfs2-tools
parted
pciutils
procps
procps-ng
psmisc
rsync
scrub
sed
sleuthkit
squashfs-tools
strace
syslinux
tar
@@ -252,7 +276,39 @@ util-linux-ng
xfsprogs
zerofree
ifelse(VALGRIND_DAEMON,1,valgrind)
dnl tools needed by virt-dib
ifelse(REDHAT,1,
qemu-img
which
)
ifelse(DEBIAN,1,
qemu-utils
)
ifelse(ARCHLINUX,1,
qemu
which
)
ifelse(SUSE,1,
qemu-tools
which
)
ifelse(FRUGALWARE,1,
qemu
which
)
ifelse(MAGEIA,1,
qemu-img
which
)
curl
kpartx
dnl (virt-dib) tools optionally used for elements
debootstrap
dnl exFAT is not usually available in free software repos
exfat-fuse
exfat-utils
fuse-exfat
dnl Define this by doing: ./configure --with-extra-packages="..."
EXTRA_PACKAGES

View File

@@ -1,5 +1,5 @@
# libguestfs
# Copyright (C) 2013 Red Hat Inc.
# Copyright (C) 2013-2017 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
@@ -21,64 +21,73 @@ scripts = \
guestfish \
guestmount \
virt-alignment-scan \
virt-rescue \
virt-v2v \
virt-v2v-copy-to-local
# Some of the scripts are simply symbolic links.
symlinks = \
guestunmount \
virt-builder \
virt-cat \
virt-copy-in \
virt-copy-out \
virt-customize \
virt-diff \
virt-df \
virt-dib \
virt-edit \
virt-filesystems \
virt-format \
virt-get-kernel \
virt-inspector \
virt-log \
virt-ls \
virt-rescue \
virt-p2v-make-disk \
virt-p2v-make-kickstart \
virt-p2v-make-kiwi \
virt-resize \
virt-sparsify \
virt-sysprep
virt-sysprep \
virt-tail \
virt-tar-in \
virt-tar-out \
virt-win-reg
# Note: Don't distribute the symbolic links, only the real files.
EXTRA_DIST = \
README \
guestfish \
guestmount \
virt-alignment-scan \
virt-rescue \
virt-resize
$(scripts) \
$(TESTS)
# Some of the scripts are simply symbolic links.
virt-cat:
CLEANFILES += \
$(symlinks)
# Any tool that has --short-options and --long-options only is handled
# by this common script.
virt-win-reg:
rm -f $@
$(LN_S) virt-alignment-scan $@
virt-df:
rm -f $@
$(LN_S) virt-alignment-scan $@
virt-edit:
rm -f $@
$(LN_S) virt-alignment-scan $@
virt-filesystems:
rm -f $@
$(LN_S) virt-alignment-scan $@
virt-format:
rm -f $@
$(LN_S) virt-alignment-scan $@
virt-inspector:
rm -f $@
$(LN_S) virt-alignment-scan $@
virt-log:
rm -f $@
$(LN_S) virt-alignment-scan $@
virt-ls:
rm -f $@
$(LN_S) virt-alignment-scan $@
virt-sysprep:
$(LN_S) virt-v2v-copy-to-local $@
# Any tool that has --short-options and --long-options and a few
# common options like -d is handled by this common script. However
# this script cannot deal with commands that use --ro/--rw
# (eg. virt-rescue), nor commands that have lots of exceptions
# (eg. guestfish). Those tools have to be handled individually.
guestunmount \
virt-builder virt-cat virt-customize virt-df virt-dib virt-diff \
virt-edit virt-filesystems virt-format virt-get-kernel virt-inspector \
virt-log virt-ls \
virt-p2v-make-disk virt-p2v-make-kickstart virt-p2v-make-kiwi \
virt-resize virt-sparsify virt-sysprep \
virt-tail:
rm -f $@
$(LN_S) virt-alignment-scan $@
virt-builder:
# guestfish is handled specially.
virt-copy-in virt-copy-out virt-tar-in virt-tar-out:
rm -f $@
$(LN_S) virt-resize $@
virt-sparsify:
rm -f $@
$(LN_S) virt-resize $@
$(LN_S) guestfish $@
if HAVE_BASH_COMPLETION
@@ -87,10 +96,24 @@ if HAVE_BASH_COMPLETION
bashcompletiondir = $(BASH_COMPLETIONS_DIR)
#bashcompletion_DATA = $(scripts)
all-local: $(scripts)
all-local: $(scripts) $(symlinks)
-test $(srcdir) != $(builddir) && cd $(srcdir) && cp $(scripts) $(abs_builddir)/
install-data-local: $(scripts)
install-data-local:
$(mkdir_p) $(DESTDIR)$(bashcompletiondir)
cp -d $(scripts) $(DESTDIR)$(bashcompletiondir)
cp -d $(scripts) $(symlinks) $(DESTDIR)$(bashcompletiondir)
clean-local:
-test $(srcdir) != $(builddir) && rm -f $(scripts)
endif
# Tests.
TESTS_ENVIRONMENT = \
scripts="$(scripts)" \
symlinks="$(scripts)" \
commands="$(scripts) $(symlinks)" \
$(top_builddir)/run --test
TESTS = \
test-complete-in-script.sh

View File

@@ -1,3 +1,6 @@
This directory contains the scripts for tab-completing commands in
bash. Note these new-style demand-loaded scripts require
'bash-completion' >= 1.99.
Tip: To test the bash completions without having to install them,
simply start a new shell and 'source ./virt-foo'.

View File

@@ -1,5 +1,5 @@
# guestfish bash completion script -*- shell-script -*-
# Copyright (C) 2010-2014 Red Hat Inc.
# Copyright (C) 2010-2017 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
@@ -31,12 +31,10 @@ _guestfs_virsh_list ()
_guestfish ()
{
local cur prev words cword split
local longopts flag_ro=0 c=1 word cmds doms
local shortopts longopts flag_ro=0 c=1 word cmds doms
_init_completion -s || return
longopts="$(guestfish --long-options)"
# See if user has specified certain options anywhere on the
# command line before the current word.
while [ $c -lt $COMP_CWORD ]; do
@@ -60,13 +58,27 @@ _guestfish ()
case "$cur" in
--*)
# --options
longopts="$(guestfish --long-options)"
COMPREPLY=( $(compgen -W "$longopts" -- "$cur") )
return ;;
-*)
# -o and --options
shortopts="$(guestfish --short-options)"
longopts="$(guestfish --long-options)"
COMPREPLY=( $(compgen -W "$shortopts $longopts" -- "$cur") )
return ;;
*)
# Might be a guestfish command.
cmds=$(guestfish -h| head -n -1 | tail -n +2 | awk '{print $1}')
COMPREPLY=( $(compgen -W "$cmds" -- "$cur") )
return ;;
esac
} &&
}
complete -o default -F _guestfish guestfish
# virt-copy-in etc are literally the same as guestfish
complete -o default -F _guestfish virt-copy-in
complete -o default -F _guestfish virt-copy-out
complete -o default -F _guestfish virt-tar-in
complete -o default -F _guestfish virt-tar-out

View File

@@ -1,5 +1,5 @@
# guestmount bash completion script -*- shell-script -*-
# Copyright (C) 2010-2014 Red Hat Inc.
# Copyright (C) 2010-2017 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
@@ -31,12 +31,10 @@ _guestfs_virsh_list ()
_guestmount ()
{
local cur prev words cword split
local longopts flag_ro=0 c=1 word doms
local shortopts longopts flag_ro=0 c=1 word doms
_init_completion -s || return
longopts="$(guestmount --long-options)"
# See if user has specified certain options anywhere on the
# command line before the current word.
while [ $c -lt $COMP_CWORD ]; do
@@ -57,8 +55,15 @@ _guestmount ()
case "$cur" in
--*)
# --options
longopts="$(guestmount --long-options)"
COMPREPLY=( $(compgen -W "$longopts" -- "$cur") )
return ;;
-*)
# -o and --options
shortopts="$(guestmount --short-options)"
longopts="$(guestmount --long-options)"
COMPREPLY=( $(compgen -W "$shortopts $longopts" -- "$cur") )
return ;;
*)
COMPREPLY=( $(compgen "$cur") )
return ;;

40
bash/test-complete-in-script.sh Executable file
View File

@@ -0,0 +1,40 @@
#!/bin/bash -
# libguestfs bash completion test script
# Copyright (C) 2016 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.
# Test that the correct 'complete' command is included in the script.
# Mainly prevents symlinking errors and some omissions.
$TEST_FUNCTIONS
skip_if_skipped
if [ -z "$commands" ]; then
echo "$0: \$commands is not defined. Use 'make check' to run this test."
exit 1
fi
for cmd in $commands; do
if [ ! -f $cmd ]; then
echo "$0: script or symlink '$cmd' is missing"
exit 1
fi
if ! grep "^complete.*$cmd\$" $cmd; then
echo "$0: script or symlink '$cmd' does not have"
echo "a 'complete' rule for '$cmd'"
exit 1
fi
done

View File

@@ -1,5 +1,5 @@
# virt-tools bash completion script -*- shell-script -*-
# Copyright (C) 2010-2014 Red Hat Inc.
# Copyright (C) 2010-2017 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
@@ -31,84 +31,182 @@ _guestfs_virsh_list ()
_guestfs_virttools ()
{
local cur prev words cword split
local longopts="$1" flag_ro="$2" doms
local shortopts longopts tool="$1" flag_ro="$2" doms
_init_completion -s || return
case "$prev" in
--align-first)
COMPREPLY=( $( compgen -W "never always auto" -- "$cur") )
return ;;
--check-tmpdir)
COMPREPLY=( $( compgen -W "ignore i continue cont c warn warning w fail f error" -- "$cur") )
return ;;
-d|--domain)
doms=$(_guestfs_virsh_list "$flag_ro")
COMPREPLY=( $(compgen -W "$doms" -- "$cur") )
return ;;
-D)
doms=$(_guestfs_virsh_list "$flag_ro")
COMPREPLY=( $(compgen -W "$doms" -- "$cur") )
return ;;
--list-format)
COMPREPLY=( $( compgen -W "short long json" -- "$cur") )
return ;;
--password-crypto)
COMPREPLY=( $( compgen -W "md5 sha256 sha512" -- "$cur") )
return ;;
--unknown-filesystems)
COMPREPLY=( $( compgen -W "ignore warn error" -- "$cur") )
return ;;
esac
case "$cur" in
--*)
# --options
longopts="$($tool --long-options)"
COMPREPLY=( $(compgen -W "$longopts" -- "$cur") )
return ;;
-*)
# -o and --options
shortopts="$($tool --short-options)"
longopts="$($tool --long-options)"
COMPREPLY=( $(compgen -W "$shortopts $longopts" -- "$cur") )
return ;;
*)
COMPREPLY=( $(compgen "$cur") )
return ;;
esac
}
_guestunmount ()
{
_guestfs_virttools "guestunmount" 1
} &&
complete -o default -F _guestunmount guestunmount
_virt_alignment_scan ()
{
_guestfs_virttools "$(virt-alignment-scan --long-options)" 1
_guestfs_virttools "virt-alignment-scan" 1
} &&
complete -o default -F _virt_alignment_scan virt-alignment-scan
_virt_builder ()
{
_guestfs_virttools "virt-builder" 0
} &&
complete -o default -F _virt_builder virt-builder
_virt_cat ()
{
_guestfs_virttools "$(virt-cat --long-options)" 1
_guestfs_virttools "virt-cat" 1
} &&
complete -o default -F _virt_cat virt-cat
_virt_customize ()
{
_guestfs_virttools "virt-customize" 0
} &&
complete -o default -F _virt_customize virt-customize
_virt_dib ()
{
_guestfs_virttools "virt-dib" 0
} &&
complete -o default -F _virt_dib virt-dib
_virt_df ()
{
_guestfs_virttools "$(virt-df --long-options)" 1
_guestfs_virttools "virt-df" 1
} &&
complete -o default -F _virt_df virt-df
_virt_diff ()
{
_guestfs_virttools "virt-diff" 1
} &&
complete -o default -F _virt_diff virt-diff
_virt_edit ()
{
_guestfs_virttools "$(virt-edit --long-options)" 0
_guestfs_virttools "virt-edit" 0
} &&
complete -o default -F _virt_edit virt-edit
_virt_filesystems ()
{
_guestfs_virttools "$(virt-filesystems --long-options)" 1
_guestfs_virttools "virt-filesystems" 1
} &&
complete -o default -F _virt_filesystems virt-filesystems
_virt_format ()
{
_guestfs_virttools "$(virt-format --long-options)" 0
_guestfs_virttools "virt-format" 0
} &&
complete -o default -F _virt_format virt-format
_virt_get_kernel ()
{
_guestfs_virttools "virt-get-kernel" 1
} &&
complete -o default -F _virt_get_kernel virt-get-kernel
_virt_inspector ()
{
_guestfs_virttools "$(virt-inspector --long-options)" 1
_guestfs_virttools "virt-inspector" 1
} &&
complete -o default -F _virt_inspector virt-inspector
_virt_log ()
{
_guestfs_virttools "virt-log" 1
} &&
complete -o default -F _virt_log virt-log
_virt_ls ()
{
_guestfs_virttools "$(virt-ls --long-options)" 1
_guestfs_virttools "virt-ls" 1
} &&
complete -o default -F _virt_ls virt-ls
_virt_p2v_make_disk ()
{
_guestfs_virttools "virt-p2v-make-disk" 1
} &&
complete -o default -F _virt_p2v_make_disk virt-p2v-make-disk
_virt_p2v_make_kickstart ()
{
_guestfs_virttools "virt-p2v-make-kickstart" 1
} &&
complete -o default -F _virt_p2v_make_kickstart virt-p2v-make-kickstart
_virt_p2v_make_kiwi ()
{
_guestfs_virttools "virt-p2v-make-kiwi" 1
} &&
complete -o default -F _virt_p2v_make_kiwi virt-p2v-make-kiwi
_virt_resize ()
{
_guestfs_virttools "virt-resize" 0
} &&
complete -o default -F _virt_resize virt-resize
_virt_sparsify ()
{
_guestfs_virttools "virt-sparsify" 0
} &&
complete -o default -F _virt_sparsify virt-sparsify
_virt_sysprep ()
{
_guestfs_virttools "$(virt-sysprep --long-options)" 0
_guestfs_virttools "virt-sysprep" 0
} &&
complete -o default -F _virt_sysprep virt-sysprep
_virt_log ()
_virt_tail ()
{
_guestfs_virttools "$(virt-log --long-options)" 1
_guestfs_virttools "virt-tail" 1
} &&
complete -o default -F _virt_log virt-log
complete -o default -F _virt_tail virt-tail

View File

@@ -1,5 +1,5 @@
# virt-rescue bash completion script -*- shell-script -*-
# Copyright (C) 2010-2014 Red Hat Inc.
# Copyright (C) 2010-2017 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
@@ -31,12 +31,10 @@ _guestfs_virsh_list ()
_virt_rescue ()
{
local cur prev words cword split
local longopts flag_ro=0 c=1 word doms
local shortopts longopts flag_ro=0 c=1 word doms
_init_completion -s || return
longopts="$(virt-rescue --long-options)"
# See if user has specified certain options anywhere on the
# command line before the current word.
while [ $c -lt $COMP_CWORD ]; do
@@ -57,8 +55,15 @@ _virt_rescue ()
case "$cur" in
--*)
# --options
longopts="$(virt-rescue --long-options)"
COMPREPLY=( $(compgen -W "$longopts" -- "$cur") )
return ;;
-*)
# -o and --options
shortopts="$(virt-rescue --short-options)"
longopts="$(virt-rescue --long-options)"
COMPREPLY=( $(compgen -W "$shortopts $longopts" -- "$cur") )
return ;;
*)
COMPREPLY=( $(compgen "$cur") )
return ;;

View File

@@ -1,53 +0,0 @@
# virt-resize, virt-builder, virt-sparsify bash completion script
# -*- shell-script -*-
# Copyright (C) 2010-2014 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.
_guestfs_options_only ()
{
local cur prev words cword split
local longopts="$1"
_init_completion -s || return
case "$cur" in
--*)
# --options
COMPREPLY=( $(compgen -W "$longopts" -- "$cur") )
return ;;
*)
COMPREPLY=( $(compgen "$cur") )
return ;;
esac
}
_virt_builder ()
{
_guestfs_options_only "$(virt-builder --long-options)"
} &&
complete -o default -F _virt_builder virt-builder
_virt_resize ()
{
_guestfs_options_only "$(virt-resize --long-options)"
} &&
complete -o default -F _virt_resize virt-resize
_virt_sparsify ()
{
_guestfs_options_only "$(virt-sparsify --long-options)"
} &&
complete -o default -F _virt_sparsify virt-sparsify

59
bash/virt-v2v Normal file
View File

@@ -0,0 +1,59 @@
# virt-v2v bash completion script -*- shell-script -*-
# Copyright (C) 2014 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.
_virt_v2v ()
{
local cur prev words cword split
local shortopts longopts items
_init_completion -s || return
case "$prev" in
-i)
items="$(virt-v2v --machine-readable | awk -F':' '/input:/ {print $2;}')"
COMPREPLY=( $( compgen -W "$items" -- "$cur") )
return ;;
-o)
items="$(virt-v2v --machine-readable | awk -F':' '/output:/ {print $2;}')"
COMPREPLY=( $( compgen -W "$items" -- "$cur") )
return ;;
-oa)
COMPREPLY=( $( compgen -W "sparse preallocated" -- "$cur") )
return ;;
--vmtype)
COMPREPLY=( $( compgen -W "server desktop" -- "$cur") )
return ;;
esac
case "$cur" in
--*)
# --options
longopts="$(virt-v2v --long-options)"
COMPREPLY=( $(compgen -W "$longopts" -- "$cur") )
return ;;
-*)
# -o and --options
shortopts="$(virt-v2v --short-options)"
longopts="$(virt-v2v --long-options)"
COMPREPLY=( $(compgen -W "$shortopts $longopts" -- "$cur") )
return ;;
*)
COMPREPLY=( $(compgen "$cur") )
return ;;
esac
} &&
complete -o default -F _virt_v2v virt-v2v

View File

@@ -0,0 +1,53 @@
# virt-v2v-copy-to-local bash completion script -*- shell-script -*-
# Copyright (C) 2014-2017 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.
_guestfs_options_only ()
{
local cur prev words cword split
local shortopts longopts tool="$1"
_init_completion -s || return
case "$cur" in
--*)
# --options
longopts="$($tool --long-options)"
COMPREPLY=( $(compgen -W "$longopts" -- "$cur") )
return ;;
-*)
# -o and --options
shortopts="$($tool --short-options)"
longopts="$($tool --long-options)"
COMPREPLY=( $(compgen -W "$shortopts $longopts" -- "$cur") )
return ;;
*)
COMPREPLY=( $(compgen "$cur") )
return ;;
esac
}
_virt_v2v_copy_to_local ()
{
_guestfs_options_only "virt-v2v-copy-to-local"
} &&
complete -o default -F _virt_v2v_copy_to_local virt-v2v-copy-to-local
_virt_win_reg ()
{
_guestfs_options_only "virt-win-reg"
} &&
complete -o default -F _virt_win_reg virt-win-reg

View File

@@ -34,8 +34,6 @@ libtoolize --copy --install
gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
<$gnulib_tool || exit
(cd daemon && mkdir -p tests lib && ../$gnulib_tool --dir=.. --update)
modules='
accept4
areadlink
@@ -51,13 +49,13 @@ dup3
error
filevercmp
fstatat
fsusage
fts
full-read
full-write
futimens
getaddrinfo
getline
getprogname
gitlog-to-changelog
glob
gnu-make
@@ -67,6 +65,7 @@ hash-pjw
human
iconv
ignore-value
intprops
lock
maintainer-makefile
manywarnings
@@ -75,6 +74,7 @@ mkdtemp
mkstemps
netdb
netinet_in
nonblocking
openat
perror
pipe2
@@ -92,12 +92,15 @@ strerror
strndup
symlinkat
sys_select
sys_types
sys_wait
tls
vasprintf
vc-list-files
warnings
xalloc
xalloc-die
xgetcwd
xstrtol
xstrtoll
xvasprintf

View File

@@ -1,6 +1,6 @@
#!/bin/bash -
# bugs-in-changelog.sh
# Copyright (C) 2009-2014 Red Hat Inc.
# Copyright (C) 2009-2017 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

141
build-aux/guestfs-test-driver Executable file
View File

@@ -0,0 +1,141 @@
#! /bin/sh
# test-driver - basic testsuite driver script.
scriptversion=2013-07-13.22; # UTC
# Copyright (C) 2011-2017 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 2, 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 <http://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
# Make unconditional expansion of undefined variables an error. This
# helps a lot in preventing typo-related bugs.
set -u
usage_error ()
{
echo "$0: $*" >&2
print_usage >&2
exit 2
}
print_usage ()
{
cat <<END
Usage:
test-driver --test-name=NAME --log-file=PATH --trs-file=PATH
[--expect-failure={yes|no}] [--color-tests={yes|no}]
[--enable-hard-errors={yes|no}] [--]
TEST-SCRIPT [TEST-SCRIPT-ARGUMENTS]
The '--test-name', '--log-file' and '--trs-file' options are mandatory.
END
}
test_name= # Used for reporting.
log_file= # Where to save the output of the test script.
trs_file= # Where to save the metadata of the test run.
expect_failure=no
color_tests=no
enable_hard_errors=yes
while test $# -gt 0; do
case $1 in
--help) print_usage; exit $?;;
--version) echo "test-driver $scriptversion"; exit $?;;
--test-name) test_name=$2; shift;;
--log-file) log_file=$2; shift;;
--trs-file) trs_file=$2; shift;;
--color-tests) color_tests=$2; shift;;
--expect-failure) expect_failure=$2; shift;;
--enable-hard-errors) enable_hard_errors=$2; shift;;
--) shift; break;;
-*) usage_error "invalid option: '$1'";;
*) break;;
esac
shift
done
missing_opts=
test x"$test_name" = x && missing_opts="$missing_opts --test-name"
test x"$log_file" = x && missing_opts="$missing_opts --log-file"
test x"$trs_file" = x && missing_opts="$missing_opts --trs-file"
if test x"$missing_opts" != x; then
usage_error "the following mandatory options are missing:$missing_opts"
fi
if test $# -eq 0; then
usage_error "missing argument"
fi
if test $color_tests = yes; then
# Keep this in sync with 'lib/am/check.am:$(am__tty_colors)'.
red='' # Red.
grn='' # Green.
lgn='' # Light green.
blu='' # Blue.
mgn='' # Magenta.
std='' # No color.
else
red= grn= lgn= blu= mgn= std=
fi
do_exit='rm -f $log_file $trs_file; (exit $st); exit $st'
trap "st=129; $do_exit" 1
trap "st=130; $do_exit" 2
trap "st=141; $do_exit" 13
trap "st=143; $do_exit" 15
# Test script is run here.
start_t="$(date +'%s')"
"$@" >$log_file 2>&1
estatus=$?
end_t="$(date +'%s')"
if test $enable_hard_errors = no && test $estatus -eq 99; then
tweaked_estatus=1
else
tweaked_estatus=$estatus
fi
case $tweaked_estatus:$expect_failure in
0:yes) col=$red res=XPASS recheck=yes gcopy=yes;;
0:*) col=$grn res=PASS recheck=no gcopy=no;;
77:*) col=$blu res=SKIP recheck=no gcopy=yes;;
99:*) col=$mgn res=ERROR recheck=yes gcopy=yes;;
*:yes) col=$lgn res=XFAIL recheck=no gcopy=yes;;
*:*) col=$red res=FAIL recheck=yes gcopy=yes;;
esac
# Report the test outcome and exit status in the logs, so that one can
# know whether the test passed or failed simply by looking at the '.log'
# file, without the need of also peaking into the corresponding '.trs'
# file (automake bug#11814).
echo "$res $test_name (exit status: $estatus)" >>$log_file
# Report outcome to console.
echo "${col}${res}${std}: $test_name"
# Register the test result, and other relevant metadata.
echo ":test-result: $res" > $trs_file
echo ":global-test-result: $res" >> $trs_file
echo ":recheck: $recheck" >> $trs_file
echo ":copy-in-global-log: $gcopy" >> $trs_file
echo ":guestfs-time: $(($end_t - $start_t))" >> $trs_file

View File

@@ -1,5 +1,5 @@
# libguestfs virt-builder tool
# Copyright (C) 2013 Red Hat Inc.
# Copyright (C) 2013-2017 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
@@ -18,216 +18,212 @@
include $(top_srcdir)/subdir-rules.mk
AM_YFLAGS = -d
AM_CFLAGS = \
-I$(shell $(OCAMLC) -where) \
-I$(top_srcdir)/gnulib/lib \
-I$(top_srcdir)/src \
-I$(top_srcdir)/fish \
-pthread \
$(LIBLZMA_CFLAGS)
EXTRA_DIST = \
$(SOURCES) \
$(SOURCES_MLI) $(SOURCES_ML) $(SOURCES_C) \
index_parser_tests.ml \
libguestfs.gpg \
opensuse.gpg \
test-console.sh \
test-index \
test-simplestreams/streams/v1/index.json \
test-simplestreams/streams/v1/net.cirros-cloud_released_download.json \
test-virt-builder.sh \
test-docs.sh \
test-virt-builder-list.sh \
test-virt-builder-list-simplestreams.sh \
test-virt-builder-planner.sh \
test-virt-index-validate.sh \
test-virt-index-validate-bad-1 \
test-virt-index-validate-good-1 \
test-virt-index-validate-good-2 \
test-virt-index-validate-good-3 \
test-virt-index-validate-good-4 \
virt-builder.pod \
virt-index-validate.pod
virt-index-validate.pod \
yajl_tests.ml
CLEANFILES = *~ *.cmi *.cmo *.cmx *.cmxa *.o virt-builder
# Alphabetical order.
SOURCES = \
architecture.ml \
builder.ml \
SOURCES_MLI = \
builder.mli \
cache.mli \
cache.ml \
cmdline.ml \
cmdline.mli \
downloader.mli \
downloader.ml \
get_kernel.mli \
get_kernel.ml \
index.mli \
index_parser.mli \
index_parser.ml \
index-parser-c.c \
ini_reader.mli \
ini_reader.ml \
languages.mli \
languages.ml \
list_entries.mli \
list_entries.ml \
paths.ml \
pxzcat.ml \
osinfo.mli \
osinfo_config.mli \
paths.mli \
pxzcat.mli \
pxzcat-c.c \
setlocale.ml \
setlocale.mli \
setlocale-c.c \
sigchecker.mli \
sigchecker.ml \
simplestreams_parser.mli \
sources.mli \
utils.mli \
yajl.mli
SOURCES_ML = \
yajl.ml \
utils.ml \
osinfo_config.ml \
osinfo.ml \
pxzcat.ml \
setlocale.ml \
index.ml \
ini_reader.ml \
paths.ml \
languages.ml \
cache.ml \
sources.ml \
uname.ml \
uname.mli \
uname-c.c \
utils.ml
downloader.ml \
sigchecker.ml \
index_parser.ml \
simplestreams_parser.ml \
list_entries.ml \
cmdline.ml \
builder.ml
SOURCES_C = \
index-scan.c \
index-struct.c \
index-parse.c \
index-parser-c.c \
pxzcat-c.c \
setlocale-c.c \
yajl-c.c
man_MANS =
noinst_DATA =
bin_PROGRAMS =
if HAVE_OCAML
# Note this list must be in dependency order.
deps = \
$(top_builddir)/mllib/libdir.cmx \
$(top_builddir)/mllib/config.cmx \
$(top_builddir)/mllib/common_gettext.cmx \
$(top_builddir)/mllib/tty-c.o \
$(top_builddir)/mllib/tTY.cmx \
$(top_builddir)/mllib/common_utils.cmx \
$(top_builddir)/mllib/fsync-c.o \
$(top_builddir)/mllib/fsync.cmx \
$(top_builddir)/mllib/planner.cmx \
$(top_builddir)/mllib/regedit.cmx \
$(top_builddir)/mllib/JSON.cmx \
$(top_builddir)/mllib/uri-c.o \
$(top_builddir)/mllib/uRI.cmx \
$(top_builddir)/mllib/mkdtemp-c.o \
$(top_builddir)/mllib/mkdtemp.cmx \
$(top_builddir)/customize/customize_utils.cmx \
$(top_builddir)/customize/urandom.cmx \
$(top_builddir)/customize/random_seed.cmx \
$(top_builddir)/customize/hostname.cmx \
$(top_builddir)/customize/timezone.cmx \
$(top_builddir)/customize/firstboot.cmx \
$(top_builddir)/customize/perl_edit-c.o \
$(top_builddir)/customize/perl_edit.cmx \
$(top_builddir)/customize/crypt-c.o \
$(top_builddir)/customize/crypt.cmx \
$(top_builddir)/customize/password.cmx \
$(top_builddir)/customize/customize_cmdline.cmx \
$(top_builddir)/customize/customize_run.cmx \
$(top_builddir)/fish/guestfish-uri.o \
$(top_builddir)/fish/guestfish-file-edit.o \
utils.cmx \
index-scan.o \
index-struct.o \
index-parse.o \
index-parser-c.o \
pxzcat-c.o \
pxzcat.cmx \
setlocale-c.o \
setlocale.cmx \
uname-c.o \
uname.cmx \
architecture.cmx \
ini_reader.cmx \
paths.cmx \
languages.cmx \
get_kernel.cmx \
cache.cmx \
sources.cmx \
downloader.cmx \
sigchecker.cmx \
index_parser.cmx \
list_entries.cmx \
cmdline.cmx \
builder.cmx
bin_PROGRAMS += virt-builder
if HAVE_OCAMLOPT
OBJECTS = $(deps)
else
OBJECTS = $(patsubst %.cmx,%.cmo,$(deps))
endif
virt_builder_SOURCES = $(SOURCES_C)
virt_builder_CPPFLAGS = \
-I. \
-I$(top_builddir) \
-I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \
-I$(shell $(OCAMLC) -where) \
-I$(top_srcdir)/gnulib/lib \
-I$(top_srcdir)/common/utils \
-I$(top_srcdir)/lib
virt_builder_CFLAGS = \
-pthread \
$(WARN_CFLAGS) $(WERROR_CFLAGS) \
-Wno-unused-macros \
$(LIBLZMA_CFLAGS) \
$(LIBTINFO_CFLAGS) \
$(LIBXML2_CFLAGS) \
$(YAJL_CFLAGS)
bin_SCRIPTS = virt-builder
BOBJECTS = $(SOURCES_ML:.ml=.cmo)
XOBJECTS = $(BOBJECTS:.cmo=.cmx)
# -I $(top_builddir)/src/.libs is a hack which forces corresponding -L
# -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 \
-I $(top_builddir)/src/.libs \
-I $(top_builddir)/common/utils/.libs \
-I $(top_builddir)/lib/.libs \
-I $(top_builddir)/gnulib/lib/.libs \
-I $(top_builddir)/ocaml \
-I $(top_builddir)/mllib \
-I $(top_builddir)/common/mlstdutils \
-I $(top_builddir)/common/mlutils \
-I $(top_builddir)/common/mlgettext \
-I $(top_builddir)/common/mlpcre \
-I $(top_builddir)/common/mltools \
-I $(top_builddir)/customize
OCAMLPACKAGES_TESTS =
if HAVE_OCAML_PKG_GETTEXT
OCAMLPACKAGES += -package gettext-stub
endif
if HAVE_OCAML_PKG_OUNIT
OCAMLPACKAGES_TESTS += -package oUnit
endif
OCAMLCFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR) $(OCAMLPACKAGES)
OCAMLOPTFLAGS = $(OCAMLCFLAGS)
OCAMLCLIBS = \
OCAMLCLIBS = \
-pthread -lpthread \
-lutils \
$(LIBTINFO_LIBS) \
$(LIBCRYPT_LIBS) \
$(LIBLZMA_LIBS) \
$(LIBXML2_LIBS) \
-L../src/.libs -lutils \
-L../gnulib/lib/.libs -lgnu \
-pthread -lpthread \
-lncurses -lcrypt
$(YAJL_LIBS) \
$(LIBINTL) \
-lgnu
if HAVE_OCAMLOPT
virt-builder: $(OBJECTS)
$(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) \
mlguestfs.cmxa -linkpkg $^ \
-cclib '$(OCAMLCLIBS)' \
-o $@
OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR)
if !HAVE_OCAMLOPT
OBJECTS = $(BOBJECTS)
else
virt-builder: $(OBJECTS)
$(OCAMLFIND) ocamlc $(OCAMLCFLAGS) \
mlguestfs.cma -linkpkg $^ \
-cclib '$(OCAMLCLIBS)' \
-custom \
-o $@
OBJECTS = $(XOBJECTS)
endif
.mli.cmi:
$(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@
.ml.cmo:
$(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@
if HAVE_OCAMLOPT
.ml.cmx:
$(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) -c $< -o $@
endif
OCAMLLINKFLAGS = \
mlgettext.$(MLARCHIVE) \
mlpcre.$(MLARCHIVE) \
mlstdutils.$(MLARCHIVE) \
mlguestfs.$(MLARCHIVE) \
mlcutils.$(MLARCHIVE) \
mltools.$(MLARCHIVE) \
customize.$(MLARCHIVE) \
$(LINK_CUSTOM_OCAMLC_ONLY)
virt_builder_DEPENDENCIES = \
$(OBJECTS) \
../common/mlpcre/mlpcre.$(MLARCHIVE) \
../common/mlgettext/mlgettext.$(MLARCHIVE) \
../common/mlstdutils/mlstdutils.$(MLARCHIVE) \
../common/mlutils/mlcutils.$(MLARCHIVE) \
../common/mltools/mltools.$(MLARCHIVE) \
../customize/customize.$(MLARCHIVE) \
$(top_srcdir)/ocaml-link.sh
virt_builder_LINK = \
$(top_srcdir)/ocaml-link.sh -cclib '$(OCAMLCLIBS)' -- \
$(OCAMLFIND) $(BEST) $(OCAMLFLAGS) $(OCAMLPACKAGES) $(OCAMLLINKFLAGS) \
$(OBJECTS) -o $@
# Manual pages and HTML files for the website.
man_MANS += virt-builder.1
noinst_DATA += $(top_builddir)/html/virt-builder.1.html
noinst_DATA += $(top_builddir)/website/virt-builder.1.html
virt-builder.1 $(top_builddir)/html/virt-builder.1.html: stamp-virt-builder.pod
virt-builder.1 $(top_builddir)/website/virt-builder.1.html: stamp-virt-builder.pod
stamp-virt-builder.pod: virt-builder.pod $(top_srcdir)/customize/customize-synopsis.pod $(top_srcdir)/customize/customize-options.pod
$(PODWRAPPER) \
--man virt-builder.1 \
--html $(top_builddir)/html/virt-builder.1.html \
--html $(top_builddir)/website/virt-builder.1.html \
--insert $(top_srcdir)/customize/customize-synopsis.pod:__CUSTOMIZE_SYNOPSIS__ \
--insert $(top_srcdir)/customize/customize-options.pod:__CUSTOMIZE_OPTIONS__ \
--license GPLv2+ \
--warning safe \
$<
touch $@
CLEANFILES += stamp-virt-builder.pod
# Tests.
TESTS_ENVIRONMENT = $(top_builddir)/run --test
disk_images := \
$(shell for f in debian fedora ubuntu windows; do if [ -s "../tests/guests/$$f.img" ]; then echo $$f.xz; fi; done) \
$(shell if [ -s "../tests/guests/fedora.img" ]; then echo fedora.qcow2 fedora.qcow2.xz; fi)
$(shell for f in debian fedora ubuntu windows; do if [ -s "../test-data/phony-guests/$$f.img" ]; then echo $$f.xz; fi; done) \
$(shell if [ -s "../test-data/phony-guests/fedora.img" ]; then echo fedora.qcow2 fedora.qcow2.xz; fi)
CLEANFILES += *.qcow2 *.xz
check_DATA = $(disk_images)
fedora.qcow2: ../tests/guests/fedora.img
osinfo_config.ml: Makefile
echo 'let libosinfo_db_path = "$(datadir)/libosinfo/db"' > $@-t
mv $@-t $@
fedora.qcow2: ../test-data/phony-guests/fedora.img
rm -f $@ $@-t
qemu-img convert -f raw -O qcow2 $< $@-t
mv $@-t $@
@@ -237,55 +233,152 @@ fedora.qcow2.xz: fedora.qcow2
xz --best -c $< > $@-t
mv $@-t $@
%.xz: ../tests/guests/%.img
%.xz: ../test-data/phony-guests/%.img
rm -f $@ $@-t
xz --best -c $< > $@-t
mv $@-t $@
yajl_tests_SOURCES = yajl-c.c
yajl_tests_CPPFLAGS = $(virt_builder_CPPFLAGS)
yajl_tests_BOBJECTS = \
yajl.cmo \
yajl_tests.cmo
yajl_tests_XOBJECTS = $(yajl_tests_BOBJECTS:.cmo=.cmx)
index_parser_tests_SOURCES = \
index-scan.c \
index-struct.c \
index-parser-c.c \
index-parse.c \
yajl-c.c
index_parser_tests_CPPFLAGS = $(virt_builder_CPPFLAGS)
index_parser_tests_BOBJECTS = \
yajl.cmo \
utils.cmo \
cache.cmo \
downloader.cmo \
sigchecker.cmo \
index.cmo \
ini_reader.cmo \
index_parser.cmo \
index_parser_tests.cmo
index_parser_tests_XOBJECTS = $(index_parser_tests_BOBJECTS:.cmo=.cmx)
# Can't call the following as <test>_OBJECTS because automake gets confused.
if HAVE_OCAMLOPT
yajl_tests_THEOBJECTS = $(yajl_tests_XOBJECTS)
yajl_tests.cmx: OCAMLPACKAGES += $(OCAMLPACKAGES_TESTS)
index_parser_tests_THEOBJECTS = $(index_parser_tests_XOBJECTS)
index_parser_tests.cmx: OCAMLPACKAGES += $(OCAMLPACKAGES_TESTS)
else
yajl_tests_THEOBJECTS = $(yajl_tests_BOBJECTS)
yajl_tests.cmo: OCAMLPACKAGES += $(OCAMLPACKAGES_TESTS)
index_parser_tests_THEOBJECTS = $(index_parser_tests_BOBJECTS)
index_parser_tests.cmo: OCAMLPACKAGES += $(OCAMLPACKAGES_TESTS)
endif
yajl_tests_DEPENDENCIES = \
$(yajl_tests_THEOBJECTS) \
../common/mlpcre/mlpcre.$(MLARCHIVE) \
../common/mlstdutils/mlstdutils.$(MLARCHIVE) \
../common/mlutils/mlcutils.$(MLARCHIVE) \
../common/mltools/mltools.$(MLARCHIVE) \
../customize/customize.$(MLARCHIVE) \
$(top_srcdir)/ocaml-link.sh
yajl_tests_LINK = \
$(top_srcdir)/ocaml-link.sh -cclib '$(OCAMLCLIBS)' -- \
$(OCAMLFIND) $(BEST) $(OCAMLFLAGS) $(OCAMLPACKAGES) $(OCAMLPACKAGES_TESTS) $(OCAMLLINKFLAGS) \
$(yajl_tests_THEOBJECTS) -o $@
index_parser_tests_DEPENDENCIES = \
$(index_parser_tests_THEOBJECTS) \
../common/mltools/mltools.$(MLARCHIVE) \
$(top_srcdir)/ocaml-link.sh
index_parser_tests_LINK = \
$(top_srcdir)/ocaml-link.sh -cclib '$(OCAMLCLIBS)' -- \
$(OCAMLFIND) $(BEST) $(OCAMLFLAGS) $(OCAMLPACKAGES) $(OCAMLPACKAGES_TESTS) $(OCAMLLINKFLAGS) \
$(index_parser_tests_THEOBJECTS) -o $@
TESTS = \
test-docs.sh \
test-virt-builder-list.sh \
test-virt-index-validate.sh
test-virt-index-validate.sh \
$(SLOW_TESTS)
check_PROGRAMS =
TESTS += test-virt-builder-list-simplestreams.sh
if ENABLE_APPLIANCE
TESTS += test-virt-builder.sh
endif ENABLE_APPLIANCE
if HAVE_OCAML_PKG_OUNIT
check_PROGRAMS += yajl_tests index_parser_tests
TESTS += yajl_tests index_parser_tests
endif
check-valgrind:
$(MAKE) VG="$(top_builddir)/run @VG@" check
$(MAKE) VG="@VG@" check
# Slow tests.
SLOW_TESTS = \
$(console_test_scripts) \
test-virt-builder-planner.sh
check-slow:
$(MAKE) TESTS="test-virt-builder-planner.sh" check
$(MAKE) check TESTS="$(SLOW_TESTS)" SLOW=1
# Dependencies.
depend: .depend
# Test that the supplied guests boot with a serial console.
#
# Note that in future we might decide to make the serial console a
# feature, eg. `virt-builder --add-serial-console' or `virt-builder
# --remove-serial-console', so don't assume that having these tests
# means that a serial console is a requirement.
console_test_scripts := \
test-console-centos-7.2.sh \
test-console-rhel-6.8.sh \
test-console-rhel-7.2.sh \
test-console-debian-7.sh \
test-console-debian-8.sh \
test-console-fedora-24.sh \
test-console-ubuntu-12.04.sh \
test-console-ubuntu-14.04.sh \
test-console-ubuntu-16.04.sh
.depend: $(wildcard $(abs_srcdir)/*.mli) $(wildcard $(abs_srcdir)/*.ml)
test-console-%.sh:
rm -f $@ $@-t
$(OCAMLFIND) ocamldep -I ../ocaml -I $(abs_srcdir) -I $(abs_top_builddir)/mllib -I $(abs_top_builddir)/customize $^ | \
$(SED) 's/ *$$//' | \
$(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
$(SED) -e 's,$(abs_srcdir)/,$(builddir)/,g' | \
sort > $@-t
f=`echo "$@" | $(SED) 's/test-console-\(.*\).sh/\1/'`; \
echo 'script=$@ exec $$srcdir/test-console.sh' "$$f" > $@-t
chmod 0755 $@-t
mv $@-t $@
CLEANFILES += \
$(console_test_scripts) \
console-*.img \
console-*.out
# OCaml dependencies.
.depend: *.mli *.ml osinfo_config.mli osinfo_config.ml
$(top_builddir)/ocaml-dep.sh $^
-include .depend
endif
DISTCLEANFILES = .depend
.PHONY: depend docs
.PHONY: docs
# virt-builder's default repository
repoconfdir = $(sysconfdir)/xdg/virt-builder/repos.d
repoconf_DATA = libguestfs.conf libguestfs.gpg
repoconf_DATA = libguestfs.conf libguestfs.gpg \
opensuse.conf opensuse.gpg
install-exec-hook:
$(LN_S) xdg/virt-builder $(DESTDIR)$(sysconfdir)/virt-builder
$(LN_S) -f xdg/virt-builder $(DESTDIR)$(sysconfdir)/virt-builder
# Build a small C index validator program.
bin_PROGRAMS = virt-index-validate
bin_PROGRAMS += virt-index-validate
virt_index_validate_SOURCES = \
index-parse.y \
@@ -295,38 +388,39 @@ virt_index_validate_SOURCES = \
index-validate.c
virt_index_validate_CPPFLAGS = \
-DLOCALEBASEDIR=\""$(datadir)/locale"\"
-DLOCALEBASEDIR=\""$(datadir)/locale"\" \
-I. \
-I$(top_builddir) \
-I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \
-I$(top_srcdir)/common/utils \
-I$(top_srcdir)/lib
virt_index_validate_CFLAGS = \
$(WARN_CFLAGS) $(WERROR_CFLAGS) \
-Wno-unused-macros
virt_index_validate_LDADD = \
$(LTLIBINTL) \
../gnulib/lib/libgnu.la
man_MANS += virt-index-validate.1
noinst_DATA += $(top_builddir)/html/virt-index-validate.1.html
noinst_DATA += $(top_builddir)/website/virt-index-validate.1.html
virt-index-validate.1 $(top_builddir)/html/virt-index-validate.1.html: stamp-virt-index-validate.pod
virt-index-validate.1 $(top_builddir)/website/virt-index-validate.1.html: stamp-virt-index-validate.pod
stamp-virt-index-validate.pod: virt-index-validate.pod
$(PODWRAPPER) \
--man virt-index-validate.1 \
--html $(top_builddir)/html/virt-index-validate.1.html \
--html $(top_builddir)/website/virt-index-validate.1.html \
--license GPLv2+ \
--warning safe \
$<
touch $@
CLEANFILES += \
index-parse.c \
index-parse.h \
index-scan.c \
stamp-virt-index-validate.pod
index-scan.c
if HAVE_OCAML
# Automake-generated makefile has a rule ".l.c:" but lacks a rule ".l.h:".
# Also it doesn't generate dependencies for the C files that include
# index-parse.h.
index-parser-c.c index-scan.c index-validate.c: index-parse.h
index-parse.h: index-parse.y
$(MAKE) index-parse.h
endif
BUILT_SOURCES = index-parse.h
# Apparently there's no clean way with Automake to not have them
# in the distribution, so just remove them from the distdir.

View File

@@ -1,41 +0,0 @@
(* virt-builder
* Copyright (C) 2014 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 Common_gettext.Gettext
open Common_utils
open Unix
let filter_arch = function
| "amd64" | "x86_64" | "x64" -> "x86_64"
| "powerpc" | "ppc" -> "ppc"
| arch -> arch
let arch_is_compatible nativearch otherarch =
let nativearch = filter_arch nativearch in
let otherarch = filter_arch otherarch in
match nativearch, otherarch with
| a, b when a = b -> true
| "x86_64", "i386" -> true
| "ppc64", "ppc" -> true
| "sparc64", "sparc" -> true
| a, b -> false
let current_arch =
try filter_arch ((Uname.uname ()).Uname.machine)
with Unix_error _ -> "unknown"

View File

@@ -1,5 +1,5 @@
(* virt-builder
* Copyright (C) 2013 Red Hat Inc.
* Copyright (C) 2013-2017 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
@@ -20,7 +20,9 @@ open Common_gettext.Gettext
module G = Guestfs
open Common_utils
open Std_utils
open Tools_utils
open Unix_utils
open Password
open Planner
open Utils
@@ -31,28 +33,33 @@ open Customize_cmdline
open Unix
open Printf
let prog = Filename.basename Sys.executable_name
let () = Random.self_init ()
let remove_duplicates index =
let compare_revisions rev1 rev2 =
match rev1, rev2 with
| Rev_int n1, Rev_int n2 -> compare n1 n2
| Rev_string s1, Rev_int n2 -> compare s1 (string_of_int n2)
| Rev_int n1, Rev_string s2 -> compare (string_of_int n1) s2
| Rev_string s1, Rev_string s2 -> compare s1 s2
in
(* Fill an hash with the higher revision of the available
* (name, arch) tuples, so it possible to ignore duplicates,
* and versions with a lower revision.
*)
let nseen = Hashtbl.create 13 in
List.iter (
fun (name, { Index_parser.arch = arch; revision = revision }) ->
fun (name, { Index.arch; revision }) ->
let id = name, arch in
try
let rev = Hashtbl.find nseen id in
if revision > rev then
if compare_revisions rev revision > 0 then
Hashtbl.replace nseen id revision
with Not_found ->
Hashtbl.add nseen id revision
) index;
List.filter (
fun (name, { Index_parser.arch = arch; revision = revision }) ->
fun (name, { Index.arch ; revision }) ->
let id = name, arch in
try
let rev = Hashtbl.find nseen (name, arch) in
@@ -70,40 +77,65 @@ let remove_duplicates index =
false
) index
(* Look for the specified os-version, resolving it as alias first. *)
let selected_cli_item cmdline index =
let arg =
(* Try to resolve the alias. *)
try
let item =
List.find (
fun (name, { Index.aliases }) ->
match aliases with
| None -> false
| Some l -> List.mem cmdline.arg l
) index in
fst item
with Not_found -> cmdline.arg in
let item =
try List.find (
fun (name, { Index.arch = a }) ->
name = arg && cmdline.arch = normalize_arch a
) index
with Not_found ->
error (f_"cannot find os-version %s with architecture %s.\nUse --list to list available guest types.")
arg cmdline.arch in
item
let main () =
(* Command line argument parsing - see cmdline.ml. *)
let mode, arg,
arch, attach, cache, check_signature, curl,
delete_on_failure, format, gpg, list_format, memsize,
network, ops, output, quiet, size, smp, sources, sync,
trace, verbose =
parse_cmdline () in
(* Timestamped messages in ordinary, non-debug non-quiet mode. *)
let msg fs = make_message_function ~quiet fs in
let cmdline = parse_cmdline () in
(* If debugging, echo the command line arguments and the sources. *)
if verbose then (
if verbose () then (
printf "command line:";
List.iter (printf " %s") (Array.to_list Sys.argv);
print_newline ();
iteri (
List.iteri (
fun i (source, fingerprint) ->
printf "source[%d] = (%S, %S)\n" i source fingerprint
) sources
) cmdline.sources
);
(* Handle some modes here, some later on. *)
let mode =
match mode with
match cmdline.mode with
| `Get_kernel -> (* --get-kernel is really a different program ... *)
Get_kernel.get_kernel ~trace ~verbose ?format ?output arg;
exit 0
let cmd = [ "virt-get-kernel" ] @
(if verbose () then [ "--verbose" ] else []) @
(if trace () then [ "-x" ] else []) @
(match cmdline.format with
| None -> []
| Some format -> [ "--format"; format ]) @
(match cmdline.output with
| None -> []
| Some output -> [ "--output"; output ]) @
[ "--add"; cmdline.arg ] in
exit (run_command cmd)
| `Delete_cache -> (* --delete-cache *)
(match cache with
(match cmdline.cache with
| Some cachedir ->
msg "Deleting: %s" cachedir;
message (f_"Deleting: %s") cachedir;
Cache.clean_cachedir cachedir;
exit 0
| None ->
@@ -117,56 +149,68 @@ let main () =
(* Check that gpg is installed. Optional as long as the user
* disables all signature checks.
*)
let cmd = sprintf "%s --help >/dev/null 2>&1" gpg in
if Sys.command cmd <> 0 then (
if check_signature then
error (f_"gpg is not installed (or does not work)\nYou should install gpg, or use --gpg option, or use --no-check-signature.")
else if verbose then
warning (f_"gpg program is not available")
if cmdline.check_signature then (
let cmd = sprintf "%s --help >/dev/null 2>&1" cmdline.gpg in
if cmdline.gpg = "" || shell_command cmd <> 0 then
error (f_"no GNU Privacy Guard (GnuPG, gpg) binary was found.\n\nEither gpg v1 or v2 can be installed to check signatures. Virt-builder looks for a binary called either gpg2 or gpg on the $PATH. You can also specify a binary using the --gpg option. If you don't want to check signatures, use --no-check-signature but note that this may make you vulnerable to Man-In-The-Middle attacks.")
);
(* Check that curl works. *)
let cmd = sprintf "%s --help >/dev/null 2>&1" curl in
if Sys.command cmd <> 0 then
let cmd = sprintf "%s --help >/dev/null 2>&1" cmdline.curl in
if shell_command cmd <> 0 then
error (f_"curl is not installed (or does not work)");
(* Check that virt-resize works. *)
let cmd = "virt-resize --help >/dev/null 2>&1" in
if Sys.command cmd <> 0 then
if shell_command cmd <> 0 then
error (f_"virt-resize is not installed (or does not work)");
(* Create the cache. *)
let cache =
match cache with
match cmdline.cache with
| None -> None
| Some dir ->
try Some (Cache.create ~verbose ~directory:dir)
try Some (Cache.create ~directory:dir)
with exn ->
warning (f_"cache %s: %s") dir (Printexc.to_string exn);
warning (f_"disabling the cache");
None
in
(* Create a single temporary directory for all the small-or-so
* temporary files that Downloader, Sigchecker, etc, are going
* create.
*)
let tmpdir = Mkdtemp.temp_dir "virt-builder." in
rmdir_on_exit tmpdir;
(* Download the sources. *)
let downloader = Downloader.create ~verbose ~curl ~cache in
let repos = Sources.read_sources ~prog ~verbose in
let downloader = Downloader.create ~curl:cmdline.curl ~cache ~tmpdir in
let repos = Sources.read_sources () in
let sources = List.map (
fun (source, fingerprint) ->
{
Sources.name = source; uri = source;
gpgkey = Utils.Fingerprint fingerprint;
proxy = Downloader.SystemProxy;
proxy = Curl.SystemProxy;
format = Sources.FormatNative;
}
) sources in
let sources = List.append repos sources in
let index : Index_parser.index =
) cmdline.sources in
let sources = List.append sources repos in
let index : Index.index =
List.concat (
List.map (
fun source ->
let sigchecker =
Sigchecker.create ~verbose ~gpg ~check_signature
~gpgkey:source.Sources.gpgkey in
Index_parser.get_index ~prog ~verbose ~downloader ~sigchecker source
Sigchecker.create ~gpg:cmdline.gpg
~check_signature:cmdline.check_signature
~gpgkey:source.Sources.gpgkey
~tmpdir in
match source.Sources.format with
| Sources.FormatNative ->
Index_parser.get_index ~downloader ~sigchecker source
| Sources.FormatSimpleStreams ->
Simplestreams_parser.get_index ~downloader ~sigchecker source
) sources
) in
let index = remove_duplicates index in
@@ -175,18 +219,24 @@ let main () =
let mode =
match mode with
| `List -> (* --list *)
List_entries.list_entries ~list_format ~sources index;
let sources, index =
match cmdline.arg with
| "" -> sources, index (* no template -> all the available ones *)
| arg -> (* just the specified template *)
let item = selected_cli_item cmdline index in
[], [item] in
List_entries.list_entries ~list_format:cmdline.list_format ~sources index;
exit 0
| `Print_cache -> (* --print-cache *)
(match cache with
| Some cache ->
let l = List.filter (
fun (_, { Index_parser.hidden = hidden }) ->
fun (_, { Index.hidden }) ->
hidden <> true
) index in
let l = List.map (
fun (name, { Index_parser.revision = revision; arch = arch }) ->
fun (name, { Index.revision; arch }) ->
(name, arch, revision)
) l in
Cache.print_item_status cache ~header:true l
@@ -201,12 +251,11 @@ let main () =
| Some _ ->
List.iter (
fun (name,
{ Index_parser.revision = revision; file_uri = file_uri;
proxy = proxy }) ->
let template = name, arch, revision in
msg (f_"Downloading: %s") file_uri;
let progress_bar = not quiet in
ignore (Downloader.download ~prog downloader ~template ~progress_bar
{ Index.revision; file_uri; proxy }) ->
let template = name, cmdline.arch, revision in
message (f_"Downloading: %s") file_uri;
let progress_bar = not (quiet ()) in
ignore (Downloader.download downloader ~template ~progress_bar
~proxy file_uri)
) index;
exit 0
@@ -215,33 +264,15 @@ let main () =
| (`Install|`Notes) as mode -> mode in
(* Which os-version (ie. index entry)? *)
let arg =
(* Try to resolve the alias. *)
try
let item =
List.find (
fun (name, { Index_parser.aliases = aliases }) ->
match aliases with
| None -> false
| Some l -> List.mem arg l
) index in
fst item
with Not_found -> arg in
let item =
try List.find (
fun (name, { Index_parser.arch = a }) ->
name = arg && arch = Architecture.filter_arch a
) index
with Not_found ->
error (f_"cannot find os-version '%s' with architecture '%s'.\nUse --list to list available guest types.")
arg arch in
let item = selected_cli_item cmdline index in
let arg = fst item in
let entry = snd item in
let sigchecker = entry.Index_parser.sigchecker in
let sigchecker = entry.Index.sigchecker in
(match mode with
| `Notes -> (* --notes *)
let notes =
Languages.find_notes (Languages.languages ()) entry.Index_parser.notes in
Languages.find_notes (Languages.languages ()) entry.Index.notes in
(match notes with
| notes :: _ ->
print_endline notes
@@ -256,15 +287,23 @@ let main () =
(* --- If we get here, we want to create a guest. --- *)
(* Warn if the user might be writing to a partition on a USB key. *)
(match cmdline.output with
| Some device when is_partition device ->
if cmdline.warn_if_partition then
warning (f_"output device (%s) is a partition. If you are writing to a USB key or external drive then you probably need to write to the whole device, not to a partition. If this warning is wrong then you can disable it with --no-warn-if-partition")
device;
| Some _ | None -> ()
);
(* Download the template, or it may be in the cache. *)
let template =
let template, delete_on_exit =
let { Index_parser.revision = revision; file_uri = file_uri;
proxy = proxy } = entry in
let template = arg, arch, revision in
msg (f_"Downloading: %s") file_uri;
let progress_bar = not quiet in
Downloader.download ~prog downloader ~template ~progress_bar ~proxy
let { Index.revision; file_uri; proxy } = entry in
let template = arg, cmdline.arch, revision in
message (f_"Downloading: %s") file_uri;
let progress_bar = not (quiet ()) in
Downloader.download downloader ~template ~progress_bar ~proxy
file_uri in
if delete_on_exit then unlink_on_exit template;
template in
@@ -273,17 +312,21 @@ let main () =
let () =
match entry with
(* New-style: Using a checksum. *)
| { Index_parser.checksum_sha512 = Some csum } ->
Sigchecker.verify_checksum sigchecker (Sigchecker.SHA512 csum) template
| { Index.checksums = Some csums } ->
(try Checksums.verify_checksums csums template
with Checksums.Mismatched_checksum (csum, csum_actual) ->
error (f_"%s checksum of template did not match the expected checksum!\n found checksum: %s\n expected checksum: %s\nTry:\n - Use the -v option and look for earlier error messages.\n - Delete the cache: virt-builder --delete-cache\n - Check no one has tampered with the website or your network!")
(Checksums.string_of_csum_t csum) csum_actual (Checksums.string_of_csum csum)
)
| { Index_parser.checksum_sha512 = None } ->
| { Index.checksums = None } ->
(* Old-style: detached signature. *)
let sigfile =
match entry with
| { Index_parser.signature_uri = None } -> None
| { Index_parser.signature_uri = Some signature_uri } ->
| { Index.signature_uri = None } -> None
| { Index.signature_uri = Some signature_uri } ->
let sigfile, delete_on_exit =
Downloader.download ~prog downloader signature_uri in
Downloader.download downloader signature_uri in
if delete_on_exit then unlink_on_exit sigfile;
Some sigfile in
@@ -295,7 +338,7 @@ let main () =
(* Planner: Input tags. *)
let itags =
let { Index_parser.size = size; format = format } = entry in
let { Index.size; format } = entry in
let format_tag =
match format with
| None -> []
@@ -311,7 +354,7 @@ let main () =
(* Planner: Goal. *)
let output_filename, output_format =
match output, format with
match cmdline.output, cmdline.format with
| None, None -> sprintf "%s.img" arg, "raw"
| None, Some "raw" -> sprintf "%s.img" arg, "raw"
| None, Some format -> sprintf "%s.%s" arg format, format
@@ -323,7 +366,7 @@ let main () =
let blockdev_getsize64 dev =
let cmd = sprintf "blockdev --getsize64 %s" (quote dev) in
let lines = external_command ~prog cmd in
let lines = external_command cmd in
assert (List.length lines >= 1);
Int64.of_string (List.hd lines)
in
@@ -333,10 +376,10 @@ let main () =
b, sz in
let output_size =
let { Index_parser.size = original_image_size } = entry in
let { Index.size = original_image_size } = entry in
let size =
match size with
match cmdline.size with
| Some size -> size
(* --size parameter missing, output to file: use original image size *)
| None when not output_is_block_dev -> original_image_size
@@ -351,18 +394,17 @@ let main () =
(human_size size) output_filename (human_size blockdev_size);
size in
let goal =
(* MUST *)
let goal_must = [
`Filename, output_filename;
`Size, Int64.to_string output_size;
`Format, output_format
] in
(* Goal: must *)
let must = [
`Filename, output_filename;
`Size, Int64.to_string output_size;
`Format, output_format
] in
(* MUST NOT *)
let goal_must_not = [ `Template, ""; `XZ, "" ] in
(* Goal: must not *)
let must_not = [ `Template, ""; `XZ, "" ] in
goal_must, goal_must_not in
let cache_dir = (open_guestfs ())#get_cachedir () in
(* Planner: Transitions. *)
let transitions itags =
@@ -370,34 +412,78 @@ let main () =
let is_not t = not (is t) in
let remove = List.remove_assoc in
let ret = ref [] in
let tr task weight otags = ret := (task, weight, otags) :: !ret in
(* XXX Weights are not very smartly chosen. At the moment I'm
* using a range [0..100] where 0 = free and 100 = expensive. We
* could estimate weights better by looking at file sizes.
(* The scheme for weights ranges from 0 = free to 100 = most expensive:
*
* 0 = free operations like renaming a file in the same directory
* 10 = in-place conversions (like [qemu-img resize])
* 20 = copy or move a file between two local filesystems
* 30 = copy and convert a file between two local filesystems
* 40 = copy a file within the same local filesystem
* 50 = copy and convert a file within the same local filesystem
* 80 = copy, move, convert if source or target is on network filesystem
* 100 = complex operations like virt-resize
*
* Copies and moves across different local filesystems are
* cheaper than copies within the same filesystem. The
* theory because less bandwith is available if both source
* and destination hit the same device (except in the special
* case of moving within a filesystem which is free).
*
* We could estimate weights better by looking at file sizes.
*)
let weight task otags =
let infile = List.assoc `Filename itags
and outfile = List.assoc `Filename otags in
(* If infile/outfile don't exist, get the containing directory. *)
let infile =
if Sys.file_exists infile then infile else Filename.dirname infile in
let outfile =
if Sys.file_exists outfile then outfile else Filename.dirname outfile in
match task with
| `Virt_resize -> 100 (* virt-resize is a special case*)
| (`Copy|`Move|`Pxzcat|`Disk_resize|`Convert) as task ->
if StatVFS.is_network_filesystem infile ||
StatVFS.is_network_filesystem outfile
then 80 (* NFS etc. *)
else (
let across = (lstat infile).st_dev <> (lstat outfile).st_dev in
match task, across with
| `Move, false -> 0 (* rename in same filesystem *)
| `Disk_resize, _ -> 10 (* in-place conversion *)
| `Move, true (* move or copy between two filesystems *)
| `Copy, true -> 20
| (`Pxzcat|`Convert), true -> 30 (* convert between two local fses*)
| `Copy, false -> 40 (* copy within same filesystem *)
| (`Pxzcat|`Convert), false -> 50 (* convert with same local fs*)
)
in
(* Add a transition to the returned list. *)
let tr task otags = push_front (task, weight task otags, otags) ret in
(* Since the final plan won't run in parallel, we don't only need
* to choose unique tempfiles per transition, so this is OK:
*)
let tempfile = Filename.temp_file "vb" ".img" in
let tempfile = Filename.temp_file ~temp_dir:cache_dir "vb" ".img" in
unlink_on_exit tempfile;
(* Always possible to copy from one place to another. The only
* thing a copy does is to remove the template tag (since it's always
* copied out of the cache directory).
*)
tr `Copy 50 ((`Filename, output_filename) :: remove `Template itags);
tr `Copy 50 ((`Filename, tempfile) :: remove `Template itags);
tr `Copy ((`Filename, output_filename) :: remove `Template itags);
tr `Copy ((`Filename, tempfile) :: remove `Template itags);
(* We can rename a file instead of copying, but don't rename the
* cache copy! (XXX Also this is not free if copying across
* filesystems)
* cache copy!
*)
if is_not `Template then (
if not output_is_block_dev then
tr `Rename 0 ((`Filename, output_filename) :: itags);
tr `Rename 0 ((`Filename, tempfile) :: itags);
tr `Move ((`Filename, output_filename) :: itags);
tr `Move ((`Filename, tempfile) :: itags)
);
if is `XZ then (
@@ -405,9 +491,9 @@ let main () =
* to the output file or to a temp file.
*)
if not output_is_block_dev then
tr `Pxzcat 80
tr `Pxzcat
((`Filename, output_filename) :: remove `XZ (remove `Template itags));
tr `Pxzcat 80
tr `Pxzcat
((`Filename, tempfile) :: remove `XZ (remove `Template itags));
)
else (
@@ -418,11 +504,11 @@ let main () =
let old_size = Int64.of_string (List.assoc `Size itags) in
let headroom = 256L *^ 1024L *^ 1024L in
if output_size >= old_size +^ headroom then (
tr `Virt_resize 100
tr `Virt_resize
((`Size, Int64.to_string output_size) ::
(`Filename, output_filename) ::
(`Format, output_format) :: (remove `Template itags));
tr `Virt_resize 100
tr `Virt_resize
((`Size, Int64.to_string output_size) ::
(`Filename, tempfile) ::
(`Format, output_format) :: (remove `Template itags))
@@ -439,18 +525,17 @@ let main () =
* Don't run 'qemu-img resize' on an auto format. This is to
* force an explicit conversion step to a real format.
*)
else if output_size > old_size && is_not `Template && List.mem_assoc `Format itags then (
tr `Disk_resize 60 ((`Size, Int64.to_string output_size) :: itags);
tr `Disk_resize 60 ((`Size, Int64.to_string output_size) :: itags);
);
else if output_size > old_size && is_not `Template
&& List.mem_assoc `Format itags then
tr `Disk_resize ((`Size, Int64.to_string output_size) :: itags);
(* qemu-img convert is always possible, and quicker. It doesn't
* resize, but it does change the format.
*)
tr `Convert 60
tr `Convert
((`Filename, output_filename) :: (`Format, output_format) ::
(remove `Template itags));
tr `Convert 60
tr `Convert
((`Filename, tempfile) :: (`Format, output_format) ::
(remove `Template itags));
);
@@ -460,16 +545,15 @@ let main () =
in
(* Plan how to create the disk image. *)
msg (f_"Planning how to build this image");
message (f_"Planning how to build this image");
let plan =
try plan ~max_depth:5 transitions itags goal
with
Failure "plan" ->
error (f_"no plan could be found for making a disk image with\nthe required size, format etc. This is a bug in libguestfs!\nPlease file a bug, giving the command line arguments you used.");
in
match plan ~max_depth:5 transitions itags ~must ~must_not with
| Some plan -> plan
| None ->
error (f_"no plan could be found for making a disk image with\nthe required size, format etc. This is a bug in libguestfs!\nPlease file a bug, giving the command line arguments you used.") in
(* Print out the plan. *)
if verbose then (
if verbose () then (
let print_tags tags =
(try
let v = List.assoc `Filename tags in printf " +filename=%s" v
@@ -485,14 +569,14 @@ let main () =
in
let print_task = function
| `Copy -> printf "cp"
| `Rename -> printf "mv"
| `Move -> printf "mv"
| `Pxzcat -> printf "pxzcat"
| `Virt_resize -> printf "virt-resize"
| `Disk_resize -> printf "qemu-img resize"
| `Convert -> printf "qemu-img convert"
in
iteri (
List.iteri (
fun i (itags, task, otags) ->
printf "%d: itags:" i;
print_tags itags;
@@ -510,7 +594,7 @@ let main () =
* if it's block device, or if --no-delete-on-failure is set.
*)
let delete_output_file =
ref (delete_on_failure && not output_is_block_dev) in
ref (cmdline.delete_on_failure && not output_is_block_dev) in
let delete_file () =
if !delete_output_file then
try unlink output_filename with _ -> ()
@@ -523,22 +607,20 @@ let main () =
| itags, `Copy, otags ->
let ifile = List.assoc `Filename itags in
let ofile = List.assoc `Filename otags in
msg (f_"Copying");
let cmd = sprintf "cp %s %s" (quote ifile) (quote ofile) in
if verbose then printf "%s\n%!" cmd;
if Sys.command cmd <> 0 then exit 1
message (f_"Copying");
let cmd = [ "cp"; ifile; ofile ] in
if run_command cmd <> 0 then exit 1
| itags, `Rename, otags ->
| itags, `Move, otags ->
let ifile = List.assoc `Filename itags in
let ofile = List.assoc `Filename otags in
let cmd = sprintf "mv %s %s" (quote ifile) (quote ofile) in
if verbose then printf "%s\n%!" cmd;
if Sys.command cmd <> 0 then exit 1
let cmd = [ "mv"; ifile; ofile ] in
if run_command cmd <> 0 then exit 1
| itags, `Pxzcat, otags ->
let ifile = List.assoc `Filename itags in
let ofile = List.assoc `Filename otags in
msg (f_"Uncompressing");
message (f_"Uncompressing");
Pxzcat.pxzcat ifile ofile
| itags, `Virt_resize, otags ->
@@ -549,42 +631,38 @@ let main () =
let osize = Int64.of_string (List.assoc `Size otags) in
let osize = roundup64 osize 512L in
let oformat = List.assoc `Format otags in
let { Index_parser.expand = expand; lvexpand = lvexpand } = entry in
msg (f_"Resizing (using virt-resize) to expand the disk to %s")
let { Index.expand; lvexpand } = entry in
message (f_"Resizing (using virt-resize) to expand the disk to %s")
(human_size osize);
let preallocation = if oformat = "qcow2" then Some "metadata" else None in
let () =
let g = new G.guestfs () in
if verbose then ( g#set_trace true; g#set_verbose true );
let g = open_guestfs () in
g#disk_create ?preallocation ofile oformat osize in
let cmd =
sprintf "virt-resize%s%s%s --output-format %s%s%s %s %s"
(if verbose then " --verbose" else " --quiet")
(if is_block_device ofile then " --no-sparse" else "")
(match iformat with
| None -> ""
| Some iformat -> sprintf " --format %s" (quote iformat))
(quote oformat)
(match expand with
| None -> ""
| Some expand -> sprintf " --expand %s" (quote expand))
(match lvexpand with
| None -> ""
| Some lvexpand -> sprintf " --lv-expand %s" (quote lvexpand))
(quote ifile) (quote ofile) in
if verbose then printf "%s\n%!" cmd;
if Sys.command cmd <> 0 then exit 1
let cmd = [ "virt-resize" ] @
(if verbose () then [ "--verbose" ] else [ "--quiet" ]) @
(if is_block_device ofile then [ "--no-sparse" ] else []) @
(match iformat with
| None -> []
| Some iformat -> [ "--format"; iformat ]) @
[ "--output-format"; oformat ] @
(match expand with
| None -> []
| Some expand -> [ "--expand"; expand ]) @
(match lvexpand with
| None -> []
| Some lvexpand -> [ "--lv-expand"; lvexpand ]) @
[ "--unknown-filesystems"; "error"; ifile; ofile ] in
if run_command cmd <> 0 then exit 1
| itags, `Disk_resize, otags ->
let ofile = List.assoc `Filename otags in
let osize = Int64.of_string (List.assoc `Size otags) in
let osize = roundup64 osize 512L in
msg (f_"Resizing container (but not filesystems) to expand the disk to %s")
message (f_"Resizing container (but not filesystems) to expand the disk to %s")
(human_size osize);
let cmd = sprintf "qemu-img resize %s %Ld%s"
(quote ofile) osize (if verbose then "" else " >/dev/null") in
if verbose then printf "%s\n%!" cmd;
if Sys.command cmd <> 0 then exit 1
(quote ofile) osize (if verbose () then "" else " >/dev/null") in
if shell_command cmd <> 0 then exit 1
| itags, `Convert, otags ->
let ifile = List.assoc `Filename itags in
@@ -592,33 +670,27 @@ let main () =
try Some (List.assoc `Format itags) with Not_found -> None in
let ofile = List.assoc `Filename otags in
let oformat = List.assoc `Format otags in
msg (f_"Converting %s to %s")
(match iformat with None -> "auto" | Some f -> f) oformat;
(match iformat with
| None -> message (f_"Converting to %s") oformat
| Some f -> message (f_"Converting %s to %s") f oformat
);
let cmd = sprintf "qemu-img convert%s %s -O %s %s%s"
(match iformat with
| None -> ""
| Some iformat -> sprintf " -f %s" (quote iformat))
(quote ifile) (quote oformat) (quote ofile)
(if verbose then "" else " >/dev/null 2>&1") in
if verbose then printf "%s\n%!" cmd;
if Sys.command cmd <> 0 then exit 1
(quote ifile) (quote oformat) (quote (qemu_input_filename ofile))
(if verbose () then "" else " >/dev/null 2>&1") in
if shell_command cmd <> 0 then exit 1
) plan;
(* Now mount the output disk so we can make changes. *)
msg (f_"Opening the new disk");
message (f_"Opening the new disk");
let g =
let g = new G.guestfs () in
if verbose then g#set_trace true;
let g = open_guestfs () in
(match memsize with None -> () | Some memsize -> g#set_memsize memsize);
(match smp with None -> () | Some smp -> g#set_smp smp);
g#set_network network;
(* Make sure to turn SELinux off to avoid awkward interactions
* between the appliance kernel and applications/libraries interacting
* with SELinux xattrs.
*)
g#set_selinux false;
Option.may g#set_memsize cmdline.memsize;
Option.may g#set_smp cmdline.smp;
g#set_network cmdline.network;
(* The output disk is being created, so use cache=unsafe here. *)
g#add_drive_opts ~format:output_format ~cachemode:"unsafe" output_filename;
@@ -627,7 +699,7 @@ let main () =
List.iter (
fun (format, file) ->
g#add_drive_opts ?format ~readonly:true file;
) attach;
) cmdline.attach;
g#launch ();
@@ -637,21 +709,13 @@ let main () =
let root =
match Array.to_list (g#inspect_os ()) with
| [root] ->
let mps = g#inspect_get_mountpoints root in
let cmp (a,_) (b,_) =
compare (String.length a) (String.length b) in
let mps = List.sort cmp mps in
List.iter (
fun (mp, dev) ->
try g#mount dev mp
with G.Error msg -> warning (f_"%s (ignored)") msg
) mps;
inspect_mount_root g root;
root
| _ ->
error (f_"no guest operating systems or multiboot OS found in this disk image\nThis is a failure of the source repository. Use -v for more information.")
in
Customize_run.run ~verbose ~quiet g root ops;
Customize_run.run g root cmdline.customize_ops;
(* Collect some stats about the final output file.
* Notes:
@@ -659,7 +723,7 @@ let main () =
* - Never fail here.
*)
let stats =
if not quiet then (
if not (quiet ()) then (
try
(* Calculate the free space (in bytes) across all mounted
* filesystems in the guest.
@@ -668,7 +732,7 @@ let main () =
let filesystems = List.map snd (g#mountpoints ()) in
let stats = List.map g#statvfs filesystems in
let stats = List.map (
fun { G.bfree = bfree; bsize = bsize; blocks = blocks } ->
fun { G.bfree; bsize; blocks } ->
bfree *^ bsize, blocks *^ bsize
) stats in
List.fold_left (
@@ -693,7 +757,7 @@ let main () =
else None in
(* Unmount everything and we're done! *)
msg (f_"Finishing off");
message (f_"Finishing off");
g#umount_all ();
g#shutdown ();
@@ -705,7 +769,7 @@ let main () =
* and therefore bypasses the host cache). In general you should not
* use cache=none.
*)
if sync then
if cmdline.sync then
Fsync.file output_filename;
(* Now that we've finished the build, don't delete the output file on
@@ -717,8 +781,6 @@ let main () =
Pervasives.flush Pervasives.stdout;
Pervasives.flush Pervasives.stderr;
match stats with
| None -> ()
| Some stats -> print_string stats
Option.may print_string stats
let () = run_main_and_handle_errors ~prog main
let () = run_main_and_handle_errors main

19
builder/builder.mli Normal file
View File

@@ -0,0 +1,19 @@
(* virt-builder
* Copyright (C) 2017 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.
*)
(* Nothing is exported. *)

View File

@@ -1,5 +1,5 @@
(* virt-builder
* Copyright (C) 2013-2014 Red Hat Inc.
* Copyright (C) 2013-2017 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
@@ -16,8 +16,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*)
open Std_utils
open Tools_utils
open Common_gettext.Gettext
open Common_utils
open Utils
@@ -25,24 +26,22 @@ open Unix
open Printf
let clean_cachedir dir =
let cmd = sprintf "rm -rf %s" (quote dir) in
ignore (Sys.command cmd);
let cmd = [ "rm"; "-rf"; dir ] in
ignore (run_command cmd);
type t = {
verbose : bool;
directory : string;
}
let create ~verbose ~directory =
let create ~directory =
if not (is_directory directory) then
mkdir directory 0o755;
mkdir_p directory 0o755;
{
verbose = verbose;
directory = directory;
}
let cache_of_name t name arch revision =
t.directory // sprintf "%s.%s.%d" name arch revision
t.directory // sprintf "%s.%s.%s" name arch (string_of_revision revision)
let is_cached t name arch revision =
let filename = cache_of_name t name arch revision in

View File

@@ -1,5 +1,5 @@
(* virt-builder
* Copyright (C) 2013-2014 Red Hat Inc.
* Copyright (C) 2013-2017 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
@@ -24,19 +24,19 @@ val clean_cachedir : string -> unit
type t
(** The abstract data type. *)
val create : verbose:bool -> directory:string -> t
val create : directory:string -> t
(** Create the abstract type. *)
val cache_of_name : t -> string -> string -> int -> string
val cache_of_name : t -> string -> string -> Utils.revision -> string
(** [cache_of_name t name arch revision] return the filename
of the cached file. (Note: It doesn't check if the filename
exists, this is just a simple string transformation). *)
val is_cached : t -> string -> string -> int -> bool
val is_cached : t -> string -> string -> Utils.revision -> bool
(** [is_cached t name arch revision] return whether the file with
specified name, architecture and revision is cached. *)
val print_item_status : t -> header:bool -> (string * string * int) list -> unit
val print_item_status : t -> header:bool -> (string * string * Utils.revision) list -> unit
(** [print_item_status t header items] print the status in the cache
of the specified items (which are tuples of name, architecture,
and revision).

View File

@@ -1,5 +1,5 @@
(* virt-builder
* Copyright (C) 2013 Red Hat Inc.
* Copyright (C) 2013-2017 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
@@ -18,8 +18,10 @@
(* Command line argument parsing. *)
open Std_utils
open Tools_utils
open Common_gettext.Gettext
open Common_utils
open Getopt.OptionName
open Customize_cmdline
@@ -30,12 +32,31 @@ module G = Guestfs
open Unix
open Printf
let parse_cmdline () =
let display_version () =
printf "virt-builder %s\n" Config.package_version;
exit 0
in
type cmdline = {
mode : [ `Cache_all | `Delete_cache | `Get_kernel | `Install | `List
| `Notes | `Print_cache ];
arg : string;
arch : string;
attach : (string option * string) list;
cache : string option;
check_signature : bool;
curl : string;
customize_ops : Customize_cmdline.ops;
delete_on_failure : bool;
format : string option;
gpg : string;
list_format : List_entries.format;
memsize : int option;
network : bool;
output : string option;
size : int64 option;
smp : int option;
sources : (string * string) list;
sync : bool;
warn_if_partition : bool;
}
let parse_cmdline () =
let mode = ref `Install in
let list_mode () = mode := `List in
let notes_mode () = mode := `Notes in
@@ -52,7 +73,7 @@ let parse_cmdline () =
| "auto" -> attach_format := None
| s -> attach_format := Some s
in
let attach_disk s = attach := (!attach_format, s) :: !attach in
let attach_disk s = push_front (!attach_format, s) attach in
let cache = ref Paths.xdg_cache_home in
let set_cache arg = cache := Some arg in
@@ -64,20 +85,24 @@ let parse_cmdline () =
let delete_on_failure = ref true in
let fingerprints = ref [] in
let add_fingerprint arg = fingerprints := arg :: !fingerprints in
let add_fingerprint arg = push_front arg fingerprints in
let format = ref "" in
let gpg = ref "gpg" in
let gpg =
try which "gpg2"
with Executable_not_found _ ->
try which "gpg"
with Executable_not_found _ ->
"" in
let gpg = ref gpg in
let list_format = ref `Short in
let list_set_long () = list_format := `Long in
let list_format = ref List_entries.Short in
let list_set_long () = list_format := List_entries.Long in
let list_set_format arg =
list_format := match arg with
| "short" -> `Short
| "long" -> `Long
| "json" -> `Json
| fmt ->
error (f_"invalid --list-format type '%s', see the man page") fmt in
(* Do not catch the Invalid_argument that list_format_of_string
* throws on invalid input, as it is already checked by the
* Getopt handling of Symbol. *)
list_format := List_entries.list_format_of_string arg in
let machine_readable = ref false in
@@ -87,91 +112,71 @@ let parse_cmdline () =
let network = ref true in
let output = ref "" in
let quiet = ref false in
let size = ref None in
let set_size arg = size := Some (parse_size ~prog arg) in
let set_size arg = size := Some (parse_size arg) in
let smp = ref None in
let set_smp arg = smp := Some arg in
let sources = ref [] in
let add_source arg = sources := arg :: !sources in
let add_source arg = push_front arg sources in
let sync = ref true in
let trace = ref false in
let verbose = ref false in
let warn_if_partition = ref true in
let formats = List_entries.list_formats
and formats_string = String.concat "|" List_entries.list_formats in
let argspec = [
"--arch", Arg.Set_string arch, "arch" ^ " " ^ s_"Set the output architecture";
"--attach", Arg.String attach_disk, "iso" ^ " " ^ s_"Attach data disk/ISO during install";
"--attach-format", Arg.String set_attach_format,
"format" ^ " " ^ s_"Set attach disk format";
"--cache", Arg.String set_cache, "dir" ^ " " ^ s_"Set template cache dir";
"--no-cache", Arg.Unit no_cache, " " ^ s_"Disable template cache";
"--cache-all-templates", Arg.Unit cache_all_mode,
" " ^ s_"Download all templates to the cache";
"--check-signature", Arg.Set check_signature,
" " ^ s_"Check digital signatures";
"--check-signatures", Arg.Set check_signature,
" " ^ s_"Check digital signatures";
"--no-check-signature", Arg.Clear check_signature,
" " ^ s_"Disable digital signatures";
"--no-check-signatures", Arg.Clear check_signature,
" " ^ s_"Disable digital signatures";
"--curl", Arg.Set_string curl, "curl" ^ " " ^ s_"Set curl binary/command";
"--delete-cache", Arg.Unit delete_cache_mode,
" " ^ s_"Delete the template cache";
"--no-delete-on-failure", Arg.Clear delete_on_failure,
" " ^ s_"Don't delete output file on failure";
"--fingerprint", Arg.String add_fingerprint,
"AAAA.." ^ " " ^ s_"Fingerprint of valid signing key";
"--format", Arg.Set_string format, "raw|qcow2" ^ " " ^ s_"Output format (default: raw)";
"--get-kernel", Arg.Unit get_kernel_mode,
"image" ^ " " ^ s_"Get kernel from image";
"--gpg", Arg.Set_string gpg, "gpg" ^ " " ^ s_"Set GPG binary/command";
"-l", Arg.Unit list_mode, " " ^ s_"List available templates";
"--list", Arg.Unit list_mode, " " ^ s_"List available templates";
"--long", Arg.Unit list_set_long, " " ^ s_"Shortcut for --list-format short";
"--list-format", Arg.String list_set_format,
"short|long|json" ^ " " ^ s_"Set the format for --list (default: short)";
"--long-options", Arg.Unit display_long_options, " " ^ s_"List long options";
"--machine-readable", Arg.Set machine_readable, " " ^ s_"Make output machine readable";
"-m", Arg.Int set_memsize, "mb" ^ " " ^ s_"Set memory size";
"--memsize", Arg.Int set_memsize, "mb" ^ " " ^ s_"Set memory size";
"--network", Arg.Set network, " " ^ s_"Enable appliance network (default)";
"--no-network", Arg.Clear network, " " ^ s_"Disable appliance network";
"--notes", Arg.Unit notes_mode, " " ^ s_"Display installation notes";
"-o", Arg.Set_string output, "file" ^ " " ^ s_"Set output filename";
"--output", Arg.Set_string output, "file" ^ " " ^ s_"Set output filename";
"--print-cache", Arg.Unit print_cache_mode,
" " ^ s_"Print info about template cache";
"--quiet", Arg.Set quiet, " " ^ s_"No progress messages";
"--size", Arg.String set_size, "size" ^ " " ^ s_"Set output disk size";
"--smp", Arg.Int set_smp, "vcpus" ^ " " ^ s_"Set number of vCPUs";
"--source", Arg.String add_source, "URL" ^ " " ^ s_"Set source URL";
"--no-sync", Arg.Clear sync, " " ^ s_"Do not fsync output file on exit";
"-v", Arg.Set verbose, " " ^ s_"Enable debugging messages";
"--verbose", Arg.Set verbose, " " ^ s_"Enable debugging messages";
"-V", Arg.Unit display_version, " " ^ s_"Display version and exit";
"--version", Arg.Unit display_version, " " ^ s_"Display version and exit";
"-x", Arg.Set trace, " " ^ s_"Enable tracing of libguestfs calls";
[ L"arch" ], Getopt.Set_string ("arch", arch), s_"Set the output architecture";
[ L"attach" ], Getopt.String ("iso", attach_disk), s_"Attach data disk/ISO during install";
[ L"attach-format" ], Getopt.String ("format", set_attach_format),
s_"Set attach disk format";
[ L"cache" ], Getopt.String ("dir", set_cache), s_"Set template cache dir";
[ L"no-cache" ], Getopt.Unit no_cache, s_"Disable template cache";
[ L"cache-all-templates" ], Getopt.Unit cache_all_mode,
s_"Download all templates to the cache";
[ L"check-signature"; L"check-signatures" ], Getopt.Set check_signature,
s_"Check digital signatures";
[ L"no-check-signature"; L"no-check-signatures" ], Getopt.Clear check_signature,
s_"Disable digital signatures";
[ L"curl" ], Getopt.Set_string ("curl", curl), s_"Set curl binary/command";
[ L"delete-cache" ], Getopt.Unit delete_cache_mode,
s_"Delete the template cache";
[ L"no-delete-on-failure" ], Getopt.Clear delete_on_failure,
s_"Dont delete output file on failure";
[ L"fingerprint" ], Getopt.String ("AAAA..", add_fingerprint),
s_"Fingerprint of valid signing key";
[ L"format" ], Getopt.Set_string ("raw|qcow2", format), s_"Output format (default: raw)";
[ L"get-kernel" ], Getopt.Unit get_kernel_mode,
s_"Get kernel from image";
[ L"gpg" ], Getopt.Set_string ("gpg", gpg), s_"Set GPG binary/command";
[ S 'l'; L"list" ], Getopt.Unit list_mode, s_"List available templates";
[ L"long" ], Getopt.Unit list_set_long, s_"Shortcut for --list-format long";
[ L"list-format" ], Getopt.Symbol (formats_string, formats, list_set_format),
s_"Set the format for --list (default: short)";
[ L"machine-readable" ], Getopt.Set machine_readable, s_"Make output machine readable";
[ S 'm'; L"memsize" ], Getopt.Int ("mb", set_memsize), s_"Set memory size";
[ L"network" ], Getopt.Set network, s_"Enable appliance network (default)";
[ L"no-network" ], Getopt.Clear network, s_"Disable appliance network";
[ L"notes" ], Getopt.Unit notes_mode, s_"Display installation notes";
[ S 'o'; L"output" ], Getopt.Set_string ("file", output), s_"Set output filename";
[ L"print-cache" ], Getopt.Unit print_cache_mode,
s_"Print info about template cache";
[ L"size" ], Getopt.String ("size", set_size), s_"Set output disk size";
[ L"smp" ], Getopt.Int ("vcpus", set_smp), s_"Set number of vCPUs";
[ L"source" ], Getopt.String ("URL", add_source), s_"Set source URL";
[ L"no-sync" ], Getopt.Clear sync, s_"Do not fsync output file on exit";
[ L"no-warn-if-partition" ], Getopt.Clear warn_if_partition,
s_"Do not warn if writing to a partition";
] in
let customize_argspec, get_customize_ops = Customize_cmdline.argspec () in
let customize_argspec =
List.map (fun (spec, _, _) -> spec) customize_argspec in
let argspec = argspec @ customize_argspec in
let argspec =
let cmp (arg1, _, _) (arg2, _, _) =
let arg1 = skip_dashes arg1 and arg2 = skip_dashes arg2 in
compare (String.lowercase arg1) (String.lowercase arg2)
in
List.sort cmp argspec in
let argspec = Arg.align argspec in
long_options := argspec;
let args = ref [] in
let anon_fun s = args := s :: !args in
let anon_fun s = push_front s args in
let usage_msg =
sprintf (f_"\
%s: build virtual machine images quickly
@@ -188,7 +193,8 @@ A short summary of the options is given below. For detailed help please
read the man page virt-builder(1).
")
prog in
Arg.parse argspec anon_fun usage_msg;
let opthandle = create_standard_options argspec ~anon_fun usage_msg in
Getopt.parse opthandle;
(* Dereference options. *)
let args = List.rev !args in
@@ -208,13 +214,11 @@ read the man page virt-builder(1).
let network = !network in
let ops = get_customize_ops () in
let output = match !output with "" -> None | s -> Some s in
let quiet = !quiet in
let size = !size in
let smp = !smp in
let sources = List.rev !sources in
let sync = !sync in
let trace = !trace in
let verbose = !verbose in
let warn_if_partition = !warn_if_partition in
(* No arguments and machine-readable mode? Print some facts. *)
if args = [] && machine_readable then (
@@ -234,25 +238,26 @@ read the man page virt-builder(1).
(match args with
| [arg] -> arg
| [] ->
error (f_"virt-builder os-version\nMissing 'os-version'. Use '--list' to list available template names.")
error (f_"virt-builder os-version\nMissing os-version. Use --list to list available template names.")
| _ ->
error (f_"too many parameters, expecting 'os-version'")
error (f_"too many parameters, expecting os-version")
)
| `List ->
if format <> None then
error (f_"virt-builder --list: use '--list-format', not '--format'");
error (f_"--list: use --list-format, not --format");
(match args with
| [arg] -> arg
| [] -> ""
| _ ->
error (f_"virt-builder --list does not need any extra arguments")
error (f_"too many parameters, at most one os-version is allowed for --list")
)
| `Notes ->
(match args with
| [arg] -> arg
| [] ->
error (f_"virt-builder --notes os-version\nMissing 'os-version'. Use '--list' to list available template names.")
error (f_"virt-builder --notes os-version\nMissing os-version. Use --list to list available template names.")
| _ ->
error (f_"virt-builder: too many parameters, expecting 'os-version'");
error (f_"--notes: too many parameters, expecting os-version");
)
| `Cache_all
| `Print_cache
@@ -260,15 +265,15 @@ read the man page virt-builder(1).
(match args with
| [] -> ""
| _ ->
error (f_"virt-builder --cache-all-templates/--print-cache/--delete-cache does not need any extra arguments")
error (f_"--cache-all-templates/--print-cache/--delete-cache does not need any extra arguments")
)
| `Get_kernel ->
(match args with
| [arg] -> arg
| [] ->
error (f_"virt-builder --get-kernel image\nMissing 'image' (disk image file) argument")
error (f_"virt-builder --get-kernel image\nMissing image (disk image file) argument")
| _ ->
error (f_"virt-builder --get-kernel: too many parameters")
error (f_"--get-kernel: too many parameters")
) in
(* Check source(s) and fingerprint(s). *)
@@ -280,13 +285,18 @@ read the man page virt-builder(1).
let nr_sources = List.length sources in
let fingerprints =
match fingerprints with
| [fingerprint] ->
(* You're allowed to have multiple sources and one fingerprint: it
* means that the same fingerprint is used for all sources.
*)
repeat fingerprint nr_sources
| xs -> xs in
if check_signature then (
match fingerprints with
| [fingerprint] ->
(* You're allowed to have multiple sources and one fingerprint: it
* means that the same fingerprint is used for all sources.
*)
repeat fingerprint nr_sources
| xs -> xs
) else
(* We are not checking signatures, so just ignore any fingerprint
* specified. *)
repeat "" nr_sources in
if List.length fingerprints <> nr_sources then
error (f_"source and fingerprint lists are not the same length");
@@ -297,27 +307,14 @@ read the man page virt-builder(1).
(* Check the architecture. *)
let arch =
match arch with
| "" -> Architecture.current_arch
| arch ->
let target_arch = Architecture.filter_arch arch in
if Architecture.arch_is_compatible Architecture.current_arch target_arch <> true then (
let requires_execute_on_guest = List.exists (
function
| `Command _ | `InstallPackages _ | `Script _ | `Update -> true
| `Delete _ | `Edit _ | `FirstbootCommand _ | `FirstbootPackages _
| `FirstbootScript _ | `Hostname _ | `Link _ | `Mkdir _
| `Password _ | `RootPassword _ | `Scrub _ | `Timezone _ | `Upload _
| `Write _ | `Chmod _ -> false
) ops.ops in
if requires_execute_on_guest then
error (f_"sorry, cannot run commands on a guest with a different architecture");
);
target_arch in
| "" -> Guestfs_config.host_cpu
| arch -> arch in
let arch = normalize_arch arch in
(* If user didn't elect any root password, that means we set a random
* root password.
*)
let ops =
let customize_ops =
let has_set_root_password = List.exists (
function `RootPassword _ -> true | _ -> false
) ops.ops in
@@ -327,8 +324,13 @@ read the man page virt-builder(1).
{ ops with ops = ops.ops @ [ `RootPassword pw ] }
) in
mode, arg,
arch, attach, cache, check_signature, curl,
delete_on_failure, format, gpg, list_format, memsize,
network, ops, output, quiet, size, smp, sources, sync,
trace, verbose
{ mode = mode; arg = arg;
arch = arch; attach = attach; cache = cache;
check_signature = check_signature; curl = curl;
customize_ops = customize_ops;
delete_on_failure = delete_on_failure; format = format;
gpg = gpg; list_format = list_format; memsize = memsize;
network = network; output = output;
size = size; smp = smp; sources = sources; sync = sync;
warn_if_partition = warn_if_partition;
}

45
builder/cmdline.mli Normal file
View File

@@ -0,0 +1,45 @@
(* virt-builder
* Copyright (C) 2013-2017 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.
*)
(** Command line argument parsing. *)
type cmdline = {
mode : [ `Cache_all | `Delete_cache | `Get_kernel | `Install | `List
| `Notes | `Print_cache ];
arg : string;
arch : string;
attach : (string option * string) list;
cache : string option;
check_signature : bool;
curl : string;
customize_ops : Customize_cmdline.ops;
delete_on_failure : bool;
format : string option;
gpg : string;
list_format : List_entries.format;
memsize : int option;
network : bool;
output : string option;
size : int64 option;
smp : int option;
sources : (string * string) list;
sync : bool;
warn_if_partition : bool;
}
val parse_cmdline : unit -> cmdline

View File

@@ -16,8 +16,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*)
open Std_utils
open Tools_utils
open Common_gettext.Gettext
open Common_utils
open Utils
@@ -28,35 +29,30 @@ type uri = string
type filename = string
type t = {
verbose : bool;
curl : string;
tmpdir : string;
cache : Cache.t option; (* cache for templates *)
}
type proxy_mode =
| UnsetProxy
| SystemProxy
| ForcedProxy of string
let create ~verbose ~curl ~cache = {
verbose = verbose;
let create ~curl ~tmpdir ~cache = {
curl = curl;
tmpdir = tmpdir;
cache = cache;
}
let rec download ~prog t ?template ?progress_bar ?(proxy = SystemProxy) uri =
let rec download t ?template ?progress_bar ?(proxy = Curl.SystemProxy) uri =
match template with
| None -> (* no cache, simple download *)
(* Create a temporary name. *)
let tmpfile = Filename.temp_file "vbcache" ".txt" in
download_to ~prog t ?progress_bar ~proxy uri tmpfile;
let tmpfile = Filename.temp_file ~temp_dir:t.tmpdir "vbcache" ".txt" in
download_to t ?progress_bar ~proxy uri tmpfile;
(tmpfile, true)
| Some (name, arch, revision) ->
match t.cache with
| None ->
(* Not using the cache at all? *)
download t ~prog ?progress_bar ~proxy uri
download t ?progress_bar ~proxy uri
| Some cache ->
let filename = Cache.cache_of_name cache name arch revision in
@@ -65,14 +61,14 @@ let rec download ~prog t ?template ?progress_bar ?(proxy = SystemProxy) uri =
* If not, download it.
*)
if not (Sys.file_exists filename) then
download_to ~prog t ?progress_bar ~proxy uri filename;
download_to t ?progress_bar ~proxy uri filename;
(filename, false)
and download_to ~prog t ?(progress_bar = false) ~proxy uri filename =
and download_to t ?(progress_bar = false) ~proxy uri filename =
let parseduri =
try URI.parse_uri uri
with Invalid_argument "URI.parse_uri" ->
with URI.Parse_failed ->
error (f_"error parsing URI '%s'. Look for error messages printed above.")
uri in
@@ -81,28 +77,42 @@ and download_to ~prog t ?(progress_bar = false) ~proxy uri filename =
* fails, we download to a random name in the cache and then
* atomically rename it to the final filename.
*)
let filename_new = filename ^ "." ^ string_random8 () in
let filename_new = filename ^ "." ^ String.random8 () in
unlink_on_exit filename_new;
(match parseduri.URI.protocol with
(* Download (ie. copy) from a local file. *)
| "file" ->
let path = parseduri.URI.path in
let cmd = sprintf "cp%s %s %s"
(if t.verbose then " -v" else "")
(quote path) (quote filename_new) in
let r = Sys.command cmd in
let cmd = [ "cp" ] @
(if verbose () then [ "-v" ] else []) @
[ path; filename_new ] in
let r = run_command cmd in
if r <> 0 then
error (f_"cp (download) command failed copying '%s'") path;
| _ as protocol -> (* Any other protocol. *)
let outenv = proxy_envvar protocol proxy in
error (f_"cp (download) command failed copying %s") path;
(* Any other protocol. *)
| _ ->
let common_args = [
"location", None; (* Follow 3xx redirects. *)
"url", Some uri; (* URI to download. *)
] in
let quiet_args = [ "silent", None; "show-error", None ] in
(* Get the status code first to ensure the file exists. *)
let cmd = sprintf "%s%s%s -g -o /dev/null -I -w '%%{http_code}' %s"
outenv
t.curl
(if t.verbose then "" else " -s -S")
(quote uri) in
if t.verbose then printf "%s\n%!" cmd;
let lines = external_command ~prog cmd in
let curl_h =
let curl_args = ref common_args in
if not (verbose ()) then append curl_args quiet_args;
append curl_args [
"output", Some "/dev/null"; (* Write output to /dev/null. *)
"head", None; (* Request only HEAD. *)
"write-out", Some "%{http_code}" (* HTTP status code to stdout. *)
];
Curl.create ~curl:t.curl ~tmpdir:t.tmpdir !curl_args in
let lines = Curl.run curl_h in
if List.length lines < 1 then
error (f_"unexpected output from curl command, enable debug and look at previous messages");
let status_code = List.hd lines in
@@ -116,36 +126,19 @@ and download_to ~prog t ?(progress_bar = false) ~proxy uri filename =
error (f_"failed to download %s: HTTP status code %s") uri status_code;
(* Now download the file. *)
let cmd = sprintf "%s%s%s -g -o %s %s"
outenv
t.curl
(if t.verbose then "" else if progress_bar then " -#" else " -s -S")
(quote filename_new) (quote uri) in
if t.verbose then printf "%s\n%!" cmd;
let r = Sys.command cmd in
if r <> 0 then
error (f_"curl (download) command failed downloading '%s'") uri;
let curl_h =
let curl_args = ref common_args in
push_back curl_args ("output", Some filename_new);
if not (verbose ()) then (
if progress_bar then push_back curl_args ("progress-bar", None)
else append curl_args quiet_args
);
Curl.create ~curl:t.curl ~tmpdir:t.tmpdir !curl_args in
ignore (Curl.run curl_h)
);
(* Rename the file if the download was successful. *)
rename filename_new filename
and proxy_envvar protocol = function
| UnsetProxy ->
(match protocol with
| "http" -> "env http_proxy= no_proxy=* "
| "https" -> "env https_proxy= no_proxy=* "
| "ftp" -> "env ftp_proxy= no_proxy=* "
| _ -> "env no_proxy=* "
)
| SystemProxy ->
(* No changes required. *)
""
| ForcedProxy proxy ->
let proxy = quote proxy in
(match protocol with
| "http" -> sprintf "env http_proxy=%s no_proxy= " proxy
| "https" -> sprintf "env https_proxy=%s no_proxy= " proxy
| "ftp" -> sprintf "env ftp_proxy=%s no_proxy= " proxy
| _ -> ""
)

View File

@@ -24,18 +24,10 @@ type filename = string
type t
(** The abstract data type. *)
(** Type of proxy. *)
type proxy_mode =
| UnsetProxy (* The proxy is forced off. *)
| SystemProxy (* The proxy is not changed (follows the
* system configuration).
*)
| ForcedProxy of string (* The proxy is forced to the specified URL. *)
val create : verbose:bool -> curl:string -> cache:Cache.t option -> t
val create : curl:string -> tmpdir:string -> cache:Cache.t option -> t
(** Create the abstract type. *)
val download : prog:string -> t -> ?template:(string*string*int) -> ?progress_bar:bool -> ?proxy:proxy_mode -> uri -> (filename * bool)
val download : t -> ?template:(string*string*Utils.revision) -> ?progress_bar:bool -> ?proxy:Curl.proxy -> uri -> (filename * bool)
(** Download the URI, returning the downloaded filename and a
temporary file flag. The temporary file flag is [true] iff
the downloaded file is temporary and should be deleted by the

View File

@@ -1,92 +0,0 @@
(* virt-builder
* 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.
*)
open Common_gettext.Gettext
open Common_utils
open Utils
module G = Guestfs
open Printf
(* Originally:
* http://rwmj.wordpress.com/2013/09/13/get-kernel-and-initramfs-from-a-disk-image/
*)
let rec get_kernel ~trace ~verbose ?format ?output disk =
let g = new G.guestfs () in
if trace then g#set_trace true;
if verbose then g#set_verbose true;
g#add_drive_opts ?format ~readonly:true disk;
g#launch ();
let roots = g#inspect_os () in
if Array.length roots = 0 then
error (f_"get-kernel: no operating system found");
if Array.length roots > 1 then
error (f_"get-kernel: dual/multi-boot images are not supported by this tool");
let root = roots.(0) in
(* Mount up the disks. *)
let mps = g#inspect_get_mountpoints root in
let cmp (a,_) (b,_) = compare (String.length a) (String.length b) in
let mps = List.sort cmp mps in
List.iter (
fun (mp, dev) ->
try g#mount_ro dev mp
with Guestfs.Error msg -> warning (f_"%s (ignored)") msg
) mps;
(* Get all kernels and initramfses. *)
let glob w = Array.to_list (g#glob_expand w) in
let kernels = glob "/boot/vmlinuz-*" in
let initrds = glob "/boot/initramfs-*" in
(* Old RHEL: *)
let initrds = if initrds <> [] then initrds else glob "/boot/initrd-*" in
(* Debian/Ubuntu: *)
let initrds = if initrds <> [] then initrds else glob "/boot/initrd.img-*" in
(* Sort by version to get the latest version as first element. *)
let kernels = List.rev (List.sort compare_version kernels) in
let initrds = List.rev (List.sort compare_version initrds) in
if kernels = [] then
error (f_"no kernel found");
(* Download the latest. *)
let outputdir =
match output with
| None -> Filename.current_dir_name
| Some dir -> dir in
let kernel_in = List.hd kernels in
let kernel_out = outputdir // Filename.basename kernel_in in
printf "download: %s -> %s\n%!" kernel_in kernel_out;
g#download kernel_in kernel_out;
if initrds <> [] then (
let initrd_in = List.hd initrds in
let initrd_out = outputdir // Filename.basename initrd_in in
printf "download: %s -> %s\n%!" initrd_in initrd_out;
g#download initrd_in initrd_out
);
(* Shutdown. *)
g#shutdown ();
g#close ()

View File

@@ -26,10 +26,19 @@
#include "index-struct.h"
#include "index-parse.h"
/* The generated code uses frames > 5000 bytes. */
#if defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wframe-larger-than="
#pragma GCC diagnostic ignored "-Wstack-usage="
#endif
#define YY_EXTRA_TYPE struct parse_context *
extern void yyerror (YYLTYPE * yylloc, yyscan_t scanner, struct parse_context *context, const char *msg);
extern int yylex (YYSTYPE * yylval, YYLTYPE * yylloc, yyscan_t scanner);
extern int do_parse (struct parse_context *context, FILE *in);
extern void scanner_init (yyscan_t *scanner, struct parse_context *context, FILE *in);
extern void scanner_destroy (yyscan_t scanner);
@@ -90,9 +99,7 @@ typedef void *yyscan_t;
%parse-param { yyscan_t scanner }
%parse-param { struct parse_context *context }
%destructor { section_free ($$); } <sections>
%destructor { section_free ($$); } <section>
%destructor { field_free ($$); } <fields>
%destructor { field_free ($$); } <field>
%%
@@ -104,10 +111,10 @@ index:
{ context->parsed_index = $2; }
sections:
section emptylines
{ $$ = $1; }
| section EMPTY_LINE emptylines sections
{ $$ = $1; $$->next = $4; }
emptylines section emptylines
{ $$ = $2; }
| emptylines section EMPTY_LINE emptylines sections
{ $$ = $2; $$->next = $5; }
| emptylines
{ $$ = NULL; }
@@ -150,7 +157,8 @@ emptylines:
void
yyerror (YYLTYPE * yylloc, yyscan_t scanner, struct parse_context *context, const char *msg)
{
int has_suffix = context->error_suffix != NULL && context->error_suffix[0] != 0;
const int has_suffix =
context->error_suffix != NULL && context->error_suffix[0] != 0;
fprintf (stderr, "%s%s%s%ssyntax error at line %d: %s%s%s\n",
context->progname ? context->progname : "",

View File

@@ -16,9 +16,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/* This file handles the interface between the C/lex/yacc index file
* parser, and the OCaml world. See index_parser.ml for the OCaml
* type definition.
/**
* This file handles the interface between the C/lex/yacc index file
* parser, and the OCaml world. See F<builder/index_parser.ml> for
* the OCaml type definition.
*/
#include <config.h>
@@ -32,19 +33,15 @@
#include <caml/fail.h>
#include <caml/memory.h>
#include <caml/mlvalues.h>
#ifdef HAVE_CAML_UNIXSUPPORT_H
#include <caml/unixsupport.h>
#else
#define Nothing ((value) 0)
extern void unix_error (int errcode, char * cmdname, value arg) Noreturn;
#endif
#include "index-struct.h"
#include "index-parse.h"
extern int do_parse (struct parse_context *context, FILE *in);
extern value virt_builder_parse_index (value progv, value error_suffixv, value filenamev);
value
virt_builder_parse_index (value progv, value error_suffixv, value filenamev)
{

View File

@@ -16,19 +16,43 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
%{
%top{
#include <config.h>
}
%{
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* Silence gcc warnings from the generated code. */
#if defined(__GNUC__)
#pragma GCC diagnostic push
/* flex creates macros that it doesn't use */
#pragma GCC diagnostic ignored "-Wunused-macros"
/* on aarch64, flex doesn't know that char is unsigned */
#pragma GCC diagnostic ignored "-Wsign-compare"
/* on debian-mipsel, flex doesn't create prototypes for all functions */
#pragma GCC diagnostic ignored "-Wmissing-prototypes"
#endif
#include "index-struct.h"
#include "index-parse.h"
#define YY_EXTRA_TYPE struct parse_context *
#define YY_USER_ACTION yylloc->first_line = yylloc->last_line = yylineno;
extern void scanner_init (yyscan_t *scanner, struct parse_context *context, FILE *in);
extern void scanner_destroy (yyscan_t scanner);
#if (YY_FLEX_MAJOR_VERSION > 2) \
|| ((YY_FLEX_MAJOR_VERSION == 2) && (YY_FLEX_MINOR_VERSION > 6)) \
|| ((YY_FLEX_MAJOR_VERSION == 2) && (YY_FLEX_MINOR_VERSION == 6) && (YY_FLEX_SUBMINOR_VERSION >= 1))
#define IS_EOF 0
#else
#define IS_EOF EOF
#endif
%}
%option nounput
@@ -54,8 +78,9 @@
^\n { return EMPTY_LINE; }
/* [...] marks beginning of a section. */
^"["[-A-Za-z0-9._]+"]"\n {
yylval->str = strndup (yytext+1, yyleng-3);
^"["[-A-Za-z0-9._]+"]"[[:blank:]]*\n {
const char *end = strrchr (yytext, ']');
yylval->str = strndup (yytext+1, end-yytext-1);
return SECTION_HEADER;
}
@@ -66,7 +91,7 @@
yylval->field->next = NULL;
yylval->field->key = strndup (yytext, i);
if (yytext[i] == '[') {
size_t j = strcspn (yytext+i+1, "]");
const size_t j = strcspn (yytext+i+1, "]");
yylval->field->subkey = strndup (yytext+i+1, j);
i += 1+j+1;
} else {
@@ -88,7 +113,7 @@
int c, prevnl = 0;
/* Eat everything to the first blank line. */
while ((c = input (yyscanner)) != EOF) {
while ((c = input (yyscanner)) != IS_EOF) {
if (c == '\n' && prevnl)
break;
prevnl = c == '\n';
@@ -100,7 +125,7 @@
/* Hack to eat the PGP epilogue. */
^"-----BEGIN PGP SIGNATURE-----\n" {
/* Eat everything to the end of the file. */
while (input (yyscanner) != EOF)
while (input (yyscanner) != IS_EOF)
;
return PGP_EPILOGUE;

View File

@@ -23,23 +23,25 @@
#include <string.h>
#include <limits.h>
#include <getopt.h>
#include <error.h>
#include <errno.h>
#include <locale.h>
#include <libintl.h>
#include <guestfs.h>
#include "guestfs-internal-frontend.h"
#include "getprogname.h"
#include "guestfs-utils.h"
#include "index-struct.h"
#include "index-parse.h"
extern int do_parse (struct parse_context *context, FILE *in);
static void
static void __attribute__((noreturn))
usage (int exit_status)
{
printf ("%s index\n", program_name);
printf ("%s index\n", getprogname ());
exit (exit_status);
}
@@ -47,7 +49,7 @@ int
main (int argc, char *argv[])
{
enum { HELP_OPTION = CHAR_MAX + 1 };
static const char *options = "V";
static const char options[] = "V";
static const struct option long_options[] = {
{ "help", 0, 0, HELP_OPTION },
{ "compat-1.24.0", 0, 0, 0 },
@@ -81,15 +83,16 @@ main (int argc, char *argv[])
compat_1_24_0 = compat_1_24_1 = 1;
else if (STREQ (long_options[option_index].name, "compat-1.24.1"))
compat_1_24_1 = 1;
else {
fprintf (stderr, _("%s: unknown long option: %s (%d)\n"),
program_name, long_options[option_index].name, option_index);
exit (EXIT_FAILURE);
}
else
error (EXIT_FAILURE, 0,
_("unknown long option: %s (%d)"),
long_options[option_index].name, option_index);
break;
case 'V':
printf ("%s %s\n", PACKAGE_NAME, PACKAGE_VERSION);
printf ("%s %s%s\n",
getprogname (),
PACKAGE_VERSION, PACKAGE_VERSION_EXTRA);
exit (EXIT_SUCCESS);
case HELP_OPTION:
@@ -106,30 +109,27 @@ main (int argc, char *argv[])
input = argv[optind++];
in = fopen (input, "r");
if (in == NULL) {
perror (input);
exit (EXIT_FAILURE);
}
if (in == NULL)
error (EXIT_FAILURE, errno, "fopen: %s", input);
ret = do_parse (&context, in);
if (fclose (in) == EOF) {
fprintf (stderr, _("%s: %s: error closing input file: %m (ignored)\n"),
program_name, input);
getprogname (), input);
}
if (ret != 0) {
parse_context_free (&context);
fprintf (stderr, _("%s: '%s' could not be validated, see errors above\n"),
program_name, input);
exit (EXIT_FAILURE);
error (EXIT_FAILURE, 0,
_("%s could not be validated, see errors above"), input);
}
if (compat_1_24_1 && context.seen_comments) {
parse_context_free (&context);
fprintf (stderr, _("%s: %s contains comments which will not work with virt-builder 1.24.1\n"),
program_name, input);
exit (EXIT_FAILURE);
error (EXIT_FAILURE, 0,
_("%s contains comments which will not work with virt-builder 1.24.1"),
input);
}
/* Iterate over the parsed sections, semantically validating it. */
@@ -140,9 +140,9 @@ main (int argc, char *argv[])
if (compat_1_24_0) {
if (strchr (sections->name, '_')) {
parse_context_free (&context);
fprintf (stderr, _("%s: %s: section [%s] has invalid characters which will not work with virt-builder 1.24.0\n"),
program_name, input, sections->name);
exit (EXIT_FAILURE);
error (EXIT_FAILURE, 0,
_("%s: section [%s] has invalid characters which will not work with virt-builder 1.24.0"),
input, sections->name);
}
}
@@ -151,18 +151,18 @@ main (int argc, char *argv[])
if (strchr (fields->key, '[') ||
strchr (fields->key, ']')) {
parse_context_free (&context);
fprintf (stderr, _("%s: %s: section [%s], field '%s' has invalid characters which will not work with virt-builder 1.24.0\n"),
program_name, input, sections->name, fields->key);
exit (EXIT_FAILURE);
error (EXIT_FAILURE, 0,
_("%s: section [%s], field %s has invalid characters which will not work with virt-builder 1.24.0"),
input, sections->name, fields->key);
}
}
if (compat_1_24_1) {
if (strchr (fields->key, '.') ||
strchr (fields->key, ',')) {
parse_context_free (&context);
fprintf (stderr, _("%s: %s: section [%s], field '%s' has invalid characters which will not work with virt-builder 1.24.1\n"),
program_name, input, sections->name, fields->key);
exit (EXIT_FAILURE);
error (EXIT_FAILURE, 0,
_("%s: section [%s], field %s has invalid characters which will not work with virt-builder 1.24.1"),
input, sections->name, fields->key);
}
}
if (STREQ (fields->key, "sig"))
@@ -171,9 +171,9 @@ main (int argc, char *argv[])
if (compat_1_24_0 && !seen_sig) {
parse_context_free (&context);
fprintf (stderr, _("%s: %s: section [%s] is missing a 'sig' field which will not work with virt-builder 1.24.0\n"),
program_name, input, sections->name);
exit (EXIT_FAILURE);
error (EXIT_FAILURE, 0,
_("%s: section [%s] is missing a sig field which will not work with virt-builder 1.24.0"),
input, sections->name);
}
}

81
builder/index.ml Normal file
View File

@@ -0,0 +1,81 @@
(* virt-builder
* Copyright (C) 2013-2017 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
open Utils
open Printf
open Unix
type index = (string * entry) list (* string = "os-version" *)
and entry = {
printable_name : string option; (* the name= field *)
osinfo : string option;
file_uri : string;
arch : string;
signature_uri : string option; (* deprecated, will be removed in 1.26 *)
checksums : Checksums.csum_t list option;
revision : Utils.revision;
format : string option;
size : int64;
compressed_size : int64 option;
expand : string option;
lvexpand : string option;
notes : (string * string) list;
hidden : bool;
aliases : string list option;
sigchecker : Sigchecker.t;
proxy : Curl.proxy;
}
let print_entry chan (name, { printable_name; file_uri; arch; osinfo;
signature_uri; checksums; revision; format;
size; compressed_size; expand; lvexpand;
notes; aliases; hidden }) =
let fp fs = fprintf chan fs in
fp "[%s]\n" name;
Option.may (fp "name=%s\n") printable_name;
Option.may (fp "osinfo=%s\n") osinfo;
fp "file=%s\n" file_uri;
fp "arch=%s\n" arch;
Option.may (fp "sig=%s\n") signature_uri;
Option.may (
List.iter (
fun c ->
fp "checksum[%s]=%s\n"
(Checksums.string_of_csum_t c) (Checksums.string_of_csum c)
)
) checksums;
fp "revision=%s\n" (string_of_revision revision);
Option.may (fp "format=%s\n") format;
fp "size=%Ld\n" size;
Option.may (fp "compressed_size=%Ld\n") compressed_size;
Option.may (fp "expand=%s\n") expand;
Option.may (fp "lvexpand=%s\n") lvexpand;
List.iter (
fun (lang, notes) ->
match lang with
| "" -> fp "notes=%s\n" notes
| lang -> fp "notes[%s]=%s\n" lang notes
) notes;
Option.may (fun l -> fp "aliases=%s\n" (String.concat " " l)) aliases;
if hidden then fp "hidden=true\n"

44
builder/index.mli Normal file
View File

@@ -0,0 +1,44 @@
(* virt-builder
* Copyright (C) 2013-2017 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.
*)
type index = (string * entry) list (* string = "os-version" *)
and entry = {
printable_name : string option; (* the name= field *)
osinfo : string option;
file_uri : string;
arch : string;
signature_uri : string option; (* deprecated, will be removed in 1.26 *)
checksums : Checksums.csum_t list option;
revision : Utils.revision;
format : string option;
size : int64;
compressed_size : int64 option;
expand : string option;
lvexpand : string option;
notes : (string * string) list;
hidden : bool;
aliases : string list option;
sigchecker : Sigchecker.t;
proxy : Curl.proxy;
}
val print_entry : out_channel -> (string * entry) -> unit
(** Debugging helper function dumping an index entry to a stream.
To write entries for non-debugging purpose, use the
[Index_parser.write_entry] function. *)

View File

@@ -16,110 +16,23 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*)
open Std_utils
open Tools_utils
open Common_gettext.Gettext
open Common_utils
open Utils
open Printf
open Unix
type index = (string * entry) list (* string = "os-version" *)
and entry = {
printable_name : string option; (* the name= field *)
osinfo : string option;
file_uri : string;
arch : string;
signature_uri : string option; (* deprecated, will be removed in 1.26 *)
checksum_sha512 : string option;
revision : int;
format : string option;
size : int64;
compressed_size : int64 option;
expand : string option;
lvexpand : string option;
notes : (string * string) list;
hidden : bool;
aliases : string list option;
sigchecker : Sigchecker.t;
proxy : Downloader.proxy_mode;
}
let print_entry chan (name, { printable_name = printable_name;
file_uri = file_uri;
arch = arch;
osinfo = osinfo;
signature_uri = signature_uri;
checksum_sha512 = checksum_sha512;
revision = revision;
format = format;
size = size;
compressed_size = compressed_size;
expand = expand;
lvexpand = lvexpand;
notes = notes;
aliases = aliases;
hidden = hidden }) =
let fp fs = fprintf chan fs in
fp "[%s]\n" name;
(match printable_name with
| None -> ()
| Some name -> fp "name=%s\n" name
);
(match osinfo with
| None -> ()
| Some id -> fp "osinfo=%s\n" id
);
fp "file=%s\n" file_uri;
fp "arch=%s\n" arch;
(match signature_uri with
| None -> ()
| Some uri -> fp "sig=%s\n" uri
);
(match checksum_sha512 with
| None -> ()
| Some uri -> fp "checksum[sha512]=%s\n" uri
);
fp "revision=%d\n" revision;
(match format with
| None -> ()
| Some format -> fp "format=%s\n" format
);
fp "size=%Ld\n" size;
(match compressed_size with
| None -> ()
| Some size -> fp "compressed_size=%Ld\n" size
);
(match expand with
| None -> ()
| Some expand -> fp "expand=%s\n" expand
);
(match lvexpand with
| None -> ()
| Some lvexpand -> fp "lvexpand=%s\n" lvexpand
);
List.iter (
fun (lang, notes) ->
match lang with
| "" -> fp "notes=%s\n" notes
| lang -> fp "notes[%s]=%s\n" lang notes
) notes;
(match aliases with
| None -> ()
| Some l -> fp "aliases=%s\n" (String.concat " " l)
);
if hidden then fp "hidden=true\n"
let get_index ~prog ~verbose ~downloader ~sigchecker
{ Sources.uri = uri; proxy = proxy } =
let get_index ~downloader ~sigchecker { Sources.uri; proxy } =
let corrupt_file () =
error (f_"The index file downloaded from '%s' is corrupt.\nYou need to ask the supplier of this file to fix it and upload a fixed version.") uri
error (f_"The index file downloaded from %s is corrupt.\nYou need to ask the supplier of this file to fix it and upload a fixed version.") uri
in
let rec get_index () =
(* Get the index page. *)
let tmpfile, delete_tmpfile = Downloader.download ~prog downloader ~proxy uri in
let tmpfile, _ = Downloader.download downloader ~proxy uri in
(* Check index file signature (also verifies it was fully
* downloaded and not corrupted in transit).
@@ -127,9 +40,7 @@ let get_index ~prog ~verbose ~downloader ~sigchecker
Sigchecker.verify sigchecker tmpfile;
(* Try parsing the file. *)
let sections = Ini_reader.read_ini ~prog tmpfile in
if delete_tmpfile then
(try Unix.unlink tmpfile with _ -> ());
let sections = Ini_reader.read_ini tmpfile in
(* Check for repeated os-version+arch combination. *)
let name_arch_map = List.map (
@@ -146,7 +57,7 @@ let get_index ~prog ~verbose ~downloader ~sigchecker
fun (n, arch) ->
let id = n, arch in
if Hashtbl.mem nseen id then (
eprintf (f_"%s: index is corrupt: os-version '%s' with architecture '%s' appears two or more times\n") prog n arch;
eprintf (f_"%s: index is corrupt: os-version %s with architecture %s appears two or more times\n") prog n arch;
corrupt_file ()
);
Hashtbl.add nseen id true
@@ -162,9 +73,9 @@ let get_index ~prog ~verbose ~downloader ~sigchecker
if Hashtbl.mem fseen hashkey then (
(match subkey with
| Some value ->
eprintf (f_"%s: index is corrupt: %s: field '%s[%s]' appears two or more times\n") prog n field value
eprintf (f_"%s: index is corrupt: %s: field %s[%s] appears two or more times\n") prog n field value
| None ->
eprintf (f_"%s: index is corrupt: %s: field '%s' appears two or more times\n") prog n field);
eprintf (f_"%s: index is corrupt: %s: field %s appears two or more times\n") prog n field);
corrupt_file ()
);
Hashtbl.add fseen hashkey true
@@ -183,12 +94,12 @@ let get_index ~prog ~verbose ~downloader ~sigchecker
let file_uri =
try make_absolute_uri (List.assoc ("file", None) fields)
with Not_found ->
eprintf (f_"%s: no 'file' (URI) entry for '%s'\n") prog n;
eprintf (f_"%s: no file (URI) entry for %s\n") prog n;
corrupt_file () in
let arch =
try List.assoc ("arch", None) fields
with Not_found ->
eprintf (f_"%s: no 'arch' entry for '%s'\n") prog n;
eprintf (f_"%s: no arch entry for %s\n") prog n;
corrupt_file () in
let signature_uri =
try Some (make_absolute_uri (List.assoc ("sig", None) fields))
@@ -199,11 +110,11 @@ let get_index ~prog ~verbose ~downloader ~sigchecker
try Some (List.assoc ("checksum", None) fields)
with Not_found -> None in
let revision =
try int_of_string (List.assoc ("revision", None) fields)
try Rev_int (int_of_string (List.assoc ("revision", None) fields))
with
| Not_found -> 1
| Failure "int_of_string" ->
eprintf (f_"%s: cannot parse 'revision' field for '%s'\n") prog n;
| Not_found -> Rev_int 1
| Failure _ ->
eprintf (f_"%s: cannot parse revision field for %s\n") prog n;
corrupt_file () in
let format =
try Some (List.assoc ("format", None) fields) with Not_found -> None in
@@ -211,18 +122,18 @@ let get_index ~prog ~verbose ~downloader ~sigchecker
try Int64.of_string (List.assoc ("size", None) fields)
with
| Not_found ->
eprintf (f_"%s: no 'size' field for '%s'\n") prog n;
eprintf (f_"%s: no size field for %s\n") prog n;
corrupt_file ()
| Failure "int_of_string" ->
eprintf (f_"%s: cannot parse 'size' field for '%s'\n") prog n;
| Failure _ ->
eprintf (f_"%s: cannot parse size field for %s\n") prog n;
corrupt_file () in
let compressed_size =
try Some (Int64.of_string (List.assoc ("compressed_size", None) fields))
with
| Not_found ->
None
| Failure "int_of_string" ->
eprintf (f_"%s: cannot parse 'compressed_size' field for '%s'\n")
| Failure _ ->
eprintf (f_"%s: cannot parse compressed_size field for %s\n")
prog n;
corrupt_file () in
let expand =
@@ -246,24 +157,29 @@ let get_index ~prog ~verbose ~downloader ~sigchecker
try bool_of_string (List.assoc ("hidden", None) fields)
with
| Not_found -> false
| Failure "bool_of_string" ->
eprintf (f_"%s: cannot parse 'hidden' field for '%s'\n")
| Failure _ ->
eprintf (f_"%s: cannot parse hidden field for %s\n")
prog n;
corrupt_file () in
let aliases =
let l =
try string_nsplit " " (List.assoc ("aliases", None) fields)
try String.nsplit " " (List.assoc ("aliases", None) fields)
with Not_found -> [] in
match l with
| [] -> None
| l -> Some l in
let entry = { printable_name = printable_name;
let checksums =
match checksum_sha512 with
| Some c -> Some [Checksums.SHA512 c]
| None -> None in
let entry = { Index.printable_name = printable_name;
osinfo = osinfo;
file_uri = file_uri;
arch = arch;
signature_uri = signature_uri;
checksum_sha512 = checksum_sha512;
checksums = checksums;
revision = revision;
format = format;
size = size;
@@ -278,9 +194,9 @@ let get_index ~prog ~verbose ~downloader ~sigchecker
n, entry
) sections in
if verbose then (
if verbose () then (
printf "index file (%s) after parsing (C parser):\n" uri;
List.iter (print_entry Pervasives.stdout) entries
List.iter (Index.print_entry Pervasives.stdout) entries
);
entries
@@ -291,12 +207,12 @@ let get_index ~prog ~verbose ~downloader ~sigchecker
eprintf (f_"%s: zero length path in the index file\n") prog;
corrupt_file ()
)
else if string_find path "://" >= 0 then (
eprintf (f_"%s: cannot use a URI ('%s') in the index file\n") prog path;
else if String.find path "://" >= 0 then (
eprintf (f_"%s: cannot use a URI (%s) in the index file\n") prog path;
corrupt_file ()
)
else if path.[0] = '/' then (
eprintf (f_"%s: you must use relative paths (not '%s') in the index file\n") prog path;
eprintf (f_"%s: you must use relative paths (not %s) in the index file\n") prog path;
corrupt_file ()
)
else (
@@ -310,3 +226,46 @@ let get_index ~prog ~verbose ~downloader ~sigchecker
in
get_index ()
let write_entry chan (name, { Index.printable_name; file_uri; arch; osinfo;
signature_uri; checksums; revision; format; size;
compressed_size; expand; lvexpand; notes;
aliases; hidden}) =
let fp fs = fprintf chan fs in
fp "[%s]\n" name;
Option.may (fp "name=%s\n") printable_name;
Option.may (fp "osinfo=%s\n") osinfo;
fp "file=%s\n" file_uri;
fp "arch=%s\n" arch;
Option.may (fp "sig=%s\n") signature_uri;
(match checksums with
| None -> ()
| Some checksums ->
List.iter (
fun c ->
fp "checksum[%s]=%s\n"
(Checksums.string_of_csum_t c) (Checksums.string_of_csum c)
) checksums
);
fp "revision=%s\n" (string_of_revision revision);
Option.may (fp "format=%s\n") format;
fp "size=%Ld\n" size;
Option.may (fp "compressed_size=%Ld\n") compressed_size;
Option.may (fp "expand=%s\n") expand;
Option.may (fp "lvexpand=%s\n") lvexpand;
let format_notes notes =
String.concat "\n " (String.nsplit "\n" notes) in
List.iter (
fun (lang, notes) ->
match lang with
| "" -> fp "notes=%s\n" (format_notes notes)
| lang -> fp "notes[%s]=%s\n" lang (format_notes notes)
) notes;
(match aliases with
| None -> ()
| Some l -> fp "aliases=%s\n" (String.concat " " l)
);
if hidden then fp "hidden=true\n";
fp "\n"

View File

@@ -16,26 +16,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*)
type index = (string * entry) list (* string = "os-version" *)
and entry = {
printable_name : string option; (* the name= field *)
osinfo : string option;
file_uri : string;
arch : string;
signature_uri : string option; (* deprecated, will be removed in 1.26 *)
checksum_sha512 : string option;
revision : int;
format : string option;
size : int64;
compressed_size : int64 option;
expand : string option;
lvexpand : string option;
notes : (string * string) list;
hidden : bool;
aliases : string list option;
val get_index : downloader:Downloader.t -> sigchecker:Sigchecker.t -> Sources.source -> Index.index
sigchecker : Sigchecker.t;
proxy : Downloader.proxy_mode;
}
val get_index : prog:string -> verbose:bool -> downloader:Downloader.t -> sigchecker:Sigchecker.t -> Sources.source -> index
val write_entry : out_channel -> (string * Index.entry) -> unit
(** [write_entry chan entry] writes the index entry to the chan output
stream.*)

View File

@@ -0,0 +1,130 @@
(* builder
* Copyright (C) 2017 SUSE 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 the Index_parser module. *)
open Printf
open OUnit2
open Std_utils
open Unix_utils
open Tools_utils
let tmpdir =
let tmpdir = Mkdtemp.temp_dir "guestfs-tests." in
rmdir_on_exit tmpdir;
tmpdir
let dummy_sigchecker = Sigchecker.create ~gpg:"gpg"
~check_signature:false
~gpgkey:Utils.No_Key
~tmpdir
let dummy_downloader = Downloader.create ~curl:"do-not-use-curl"
~cache:None ~tmpdir
(* Utils. *)
let write_entries file entries =
let chan = open_out (tmpdir // file) in
List.iter (Index_parser.write_entry chan) entries;
close_out chan
let read_file file =
read_whole_file (tmpdir // "out")
let parse_file file =
let source = { Sources.name = "input";
uri = tmpdir // file;
gpgkey = Utils.No_Key;
proxy = Curl.SystemProxy;
format = Sources.FormatNative } in
let entries = Index_parser.get_index ~downloader:dummy_downloader
~sigchecker:dummy_sigchecker
source in
List.map (
fun (id, e) -> (id, { e with Index.file_uri = Filename.basename e.Index.file_uri })
) entries
let format_entries entries =
let format_entry entry =
write_entries "out" [entry];
read_file "out" in
List.map format_entry entries
let assert_equal_string = assert_equal ~printer:(fun x -> sprintf "\"%s\"" x)
let assert_equal_list formatter =
let printer = (
fun x -> "(" ^ (String.escaped (String.concat "," (formatter x))) ^ ")"
) in
assert_equal ~printer
let test_write_complete ctx =
let entry =
("test-id", { Index.printable_name = Some "test_name";
osinfo = Some "osinfo_data";
file_uri = "image_path";
arch = "test_arch";
signature_uri = None;
checksums = Some [Checksums.SHA512 "512checksum"];
revision = Utils.Rev_int 42;
format = Some "qcow2";
size = Int64.of_int 123456;
compressed_size = Some (Int64.of_int 12345);
expand = Some "/dev/sda1";
lvexpand = Some "/some/lv";
notes = [ ("", "Notes split\non several lines\n\n with starting space ") ];
hidden = false;
aliases = Some ["alias1"; "alias2"];
sigchecker = dummy_sigchecker;
proxy = Curl.SystemProxy }) in
write_entries "out" [entry];
let actual = read_file "out" in
let expected = "[test-id]
name=test_name
osinfo=osinfo_data
file=image_path
arch=test_arch
checksum[sha512]=512checksum
revision=42
format=qcow2
size=123456
compressed_size=12345
expand=/dev/sda1
lvexpand=/some/lv
notes=Notes split
on several lines
with starting space
aliases=alias1 alias2
" in
assert_equal_string expected actual;
let parsed_entries = parse_file "out" in
assert_equal_list format_entries [entry] parsed_entries
let suite =
"builder Index_parser" >:::
[
"write.complete" >:: test_write_complete;
]
let () =
run_test_tt_main suite

View File

@@ -1,5 +1,5 @@
(* virt-builder
* Copyright (C) 2013-2014 Red Hat Inc.
* Copyright (C) 2013-2017 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
@@ -16,6 +16,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*)
open Std_utils
open Tools_utils
type sections = section list
and section = string * fields (* [name] + fields *)
and fields = field list
@@ -29,7 +32,7 @@ and c_fields = field array
(* Calls yyparse in the C code. *)
external parse_index : prog:string -> error_suffix:string -> string -> c_sections = "virt_builder_parse_index"
let read_ini ~prog ?(error_suffix = "") file =
let read_ini ?(error_suffix = "") file =
let sections = parse_index ~prog ~error_suffix file in
let sections = Array.to_list sections in
List.map (

View File

@@ -1,5 +1,5 @@
(* virt-builder
* Copyright (C) 2013-2014 Red Hat Inc.
* Copyright (C) 2013-2017 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
@@ -21,4 +21,4 @@ and section = string * fields (* [name] + fields *)
and fields = field list
and field = string * string option * string (* key + subkey + value *)
val read_ini : prog:string -> ?error_suffix:string -> string -> sections
val read_ini : ?error_suffix:string -> string -> sections

View File

@@ -1,5 +1,5 @@
(* virt-builder
* Copyright (C) 2013-2014 Red Hat Inc.
* Copyright (C) 2013-2017 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
@@ -16,24 +16,24 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*)
open Common_utils
open Std_utils
open Tools_utils
let re_locale =
PCRE.compile ~caseless:true "^([a-z]+)(_([a-z]+))?(\\.([a-z0-9-]+))?(@([a-z]+))?$"
let split_locale loc =
let regex = Str.regexp "^\\([A-Za-z]+\\)\\(_\\([A-Za-z]+\\)\\)?\\(\\.\\([A-Za-z0-9-]+\\)\\)?\\(@\\([A-Za-z]+\\)\\)?$" in
let l = ref [] in
if Str.string_match regex loc 0 then (
let match_or_empty n =
try Str.matched_group n loc with
| Not_found -> ""
in
let lang = Str.matched_group 1 loc in
if PCRE.matches re_locale loc then (
let match_or_empty n = try PCRE.sub n with Not_found -> "" in
let lang = PCRE.sub 1 in
let territory = match_or_empty 3 in
(match territory with
| "" -> ()
| territory -> l := (lang ^ "_" ^ territory) :: !l);
l := lang :: !l;
| territory -> push_front (lang ^ "_" ^ territory) l);
push_front lang l;
);
l := "" :: !l;
push_front "" l;
List.rev !l
let languages () =

View File

@@ -16,29 +16,38 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*)
open Std_utils
open Tools_utils
open Common_gettext.Gettext
open Common_utils
open Printf
type format =
| Short
| Long
| Json
let list_formats = [ "short"; "long"; "json" ]
let list_format_of_string = function
| "short" -> Short
| "long" -> Long
| "json" -> Json
| fmt -> invalid_arg fmt
let rec list_entries ~list_format ~sources index =
match list_format with
| `Short -> list_entries_short index
| `Long -> list_entries_long ~sources index
| `Json -> list_entries_json ~sources index
| Short -> list_entries_short index
| Long -> list_entries_long ~sources index
| Json -> list_entries_json ~sources index
and list_entries_short index =
List.iter (
fun (name, { Index_parser.printable_name = printable_name;
arch = arch;
hidden = hidden }) ->
fun (name, { Index.printable_name; arch; hidden }) ->
if not hidden then (
printf "%-24s" name;
printf " %-10s" arch;
(match printable_name with
| None -> ()
| Some s -> printf " %s" s
);
Option.may (printf " %s") printable_name;
printf "\n"
)
) index
@@ -47,7 +56,7 @@ and list_entries_long ~sources index =
let langs = Languages.languages () in
List.iter (
fun { Sources.uri = uri; gpgkey = gpgkey } ->
fun { Sources.uri; gpgkey } ->
printf (f_"Source URI: %s\n") uri;
(match gpgkey with
| Utils.No_Key -> ()
@@ -60,31 +69,19 @@ and list_entries_long ~sources index =
) sources;
List.iter (
fun (name, { Index_parser.printable_name = printable_name;
arch = arch;
size = size;
compressed_size = compressed_size;
notes = notes;
aliases = aliases;
hidden = hidden }) ->
fun (name, { Index.printable_name; arch; size; compressed_size;
notes; aliases; hidden }) ->
if not hidden then (
printf "%-24s %s\n" "os-version:" name;
(match printable_name with
| None -> ()
| Some name -> printf "%-24s %s\n" (s_"Full name:") name;
);
Option.may (printf "%-24s %s\n" (s_"Full name:")) printable_name;
printf "%-24s %s\n" (s_"Architecture:") arch;
printf "%-24s %s\n" (s_"Minimum/default size:") (human_size size);
(match compressed_size with
| None -> ()
| Some size ->
printf "%-24s %s\n" (s_"Download size:") (human_size size);
);
(match aliases with
| None -> ()
| Some l -> printf "%-24s %s\n" (s_"Aliases:")
(String.concat " " l);
);
Option.may (fun size ->
printf "%-24s %s\n" (s_"Download size:") (human_size size)
) compressed_size;
Option.may (
fun l -> printf "%-24s %s\n" (s_"Aliases:") (String.concat " " l)
) aliases;
let notes = Languages.find_notes langs notes in
(match notes with
| notes :: _ ->
@@ -99,7 +96,7 @@ and list_entries_long ~sources index =
and list_entries_json ~sources index =
let json_sources =
List.map (
fun { Sources.uri = uri; gpgkey = gpgkey } ->
fun { Sources.uri; gpgkey } ->
let item = [ "uri", JSON.String uri ] in
let item =
match gpgkey with
@@ -112,13 +109,8 @@ and list_entries_json ~sources index =
) sources in
let json_templates =
List.map (
fun (name, { Index_parser.printable_name = printable_name;
arch = arch;
size = size;
compressed_size = compressed_size;
notes = notes;
aliases = aliases;
hidden = hidden }) ->
fun (name, { Index.printable_name; arch; size; compressed_size;
notes; aliases; osinfo; hidden }) ->
let item = [ "os-version", JSON.String name ] in
let item =
match printable_name with
@@ -148,6 +140,10 @@ and list_entries_json ~sources index =
| Some l ->
let l = List.map (fun x -> JSON.String x) l in
("aliases", JSON.List l) :: item in
let item =
match osinfo with
| None -> item
| Some str -> ("osinfo", JSON.String str) :: item in
let item = ("hidden", JSON.Bool hidden) :: item in
JSON.Dict (List.rev item)
) index in

View File

@@ -16,4 +16,18 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*)
val list_entries : list_format:([ `Short | `Long | `Json ]) -> sources:Sources.source list -> Index_parser.index -> unit
type format =
| Short
| Long
| Json
val list_formats : string list
(** The string representation of the available formats. *)
val list_format_of_string : string -> format
(** Convert from a string to the corresponding format.
Throw [Invalid_argument] if the string does not match any
valid format. *)
val list_entries : list_format:format -> sources:Sources.source list -> Index.index -> unit

3
builder/opensuse.conf.in Normal file
View File

@@ -0,0 +1,3 @@
[opensuse.org]
uri=http://download.opensuse.org/repositories/Virtualization:/virt-builder-images/images/index
gpgkey=file://@SYSCONFDIR@/xdg/virt-builder/repos.d/opensuse.gpg

21
builder/opensuse.gpg Normal file
View File

@@ -0,0 +1,21 @@
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.5 (GNU/Linux)
mQENBFImAl0BCACkjaXGvVLHBGTVXVP0khtpUVHqFvCRtaIIMHaX/5oTr3nyehDQ
Ex9VLsSRcNa0QxtnCHFRQzjWWqe+i6pBginnSjucgmjnIKyJsF4l6R+rwAiinHQX
C4s6Lqg/wH9xDPRBrMYFqlc/7MVf0Glhk1+lAxgQjolMt+5AbbrWlBbwc/i+++zl
ES3MaeH8aiwup/ogjhmk0SbCQQ/ib21p3XWBwx2oz/KM6Voq9tKDvMczjzNRY3ZT
6Di3FsUSKI7kgljiNiuN+675YwqEqxWEJgdE5a7Zb67giH1Ik08b5wQiF5jSAICD
DxW7/ibWBvZJnqhqQT2xJpLC5VaJqwkN8o83ABEBAAG0PlZpcnR1YWxpemF0aW9u
IE9CUyBQcm9qZWN0IDxWaXJ0dWFsaXphdGlvbkBidWlsZC5vcGVuc3VzZS5vcmc+
iQE7BBMBAgAmBQJSJgJdAhsDBQkEHrAABgsJCAcDAgQVAggDBBYCAwECHgECF4AA
CgkQoZP7tXIXT8ITnwf3SVUUoVjVLFCjhIxdet8BL011cJDwr9TwKEQfq4Ybsq5L
5Y1/Zk86rTzrVOZrODLwNRIC3fMuegZV5f85KMggXu37Di+UvX+dQW9v1hte+hAT
+gsqb60kOnE/Yacgkb6D3xIzRudAB2q/xfvHl/hgfn416yGI8NvntT7n4Hk9wT28
9JSFkun0uaessg77aXlAdsqHwdugm9hELeva89OoYoiZ4d9r4ScTMSj0UkNgnh7g
CyIScZHYqiiOeosUtAX9u1PyUFfFsg9s5snfud7aF48EfXU0RTtZAGKtG4GPDv3q
bYc5TJ2pQzs9y5Bk/jAMR/QQw8CKglBsn1cjYkKViEYEExECAAYFAlImAl0ACgkQ
OzARt2udZSO5yACgr6Ei7QZ+PAmg4Mr5db+4M3aepAEAniU33RaTKBCGkwQi6kHr
4VaII2/E
=l8DH
-----END PGP PUBLIC KEY BLOCK-----

76
builder/osinfo.ml Normal file
View File

@@ -0,0 +1,76 @@
(* virt-builder
* Copyright (C) 2017 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 Osinfo_config
let rec fold fn base =
let locations =
(* (1) Try the shared osinfo directory, using either the
* $OSINFO_SYSTEM_DIR envvar or its default value.
*)
let dir =
try Sys.getenv "OSINFO_SYSTEM_DIR"
with Not_found -> "/usr/share/osinfo" in
((dir // "os"), read_osinfo_db_three_levels) ::
(* (2) Try the libosinfo directory, using the newer three-directory
* layout ($LIBOSINFO_DB_PATH / "os" / $group-ID / [file.xml]).
*)
let path = Osinfo_config.libosinfo_db_path // "os" in
(path, read_osinfo_db_three_levels) ::
(* (3) Try the libosinfo directory, using the old flat directory
* layout ($LIBOSINFO_DB_PATH / "oses" / [file.xml]).
*)
let path = Osinfo_config.libosinfo_db_path // "oses" in
(path, read_osinfo_db_flat) :: [] in
let files =
List.flatten (
filter_map (
fun (path, f) ->
if is_directory path then Some (f path)
(* This is not an error: RHBZ#948324. *)
else None
) locations
) in
List.fold_left fn base files
and read_osinfo_db_three_levels path =
debug "osinfo: loading 3-level-directories database from %s" path;
let entries = Array.to_list (Sys.readdir path) in
let entries = List.map ((//) path) entries in
(* Iterate only on directories. *)
let entries = List.filter is_directory entries in
List.flatten (List.map read_osinfo_db_directory entries)
and read_osinfo_db_flat path =
debug "osinfo: loading flat database from %s" path;
read_osinfo_db_directory path
and read_osinfo_db_directory path =
let entries = Sys.readdir path in
let entries = Array.to_list entries in
let entries = List.filter (fun x -> Filename.check_suffix x ".xml") entries in
let entries = List.map ((//) path) entries in
let entries = List.filter is_regular_file entries in
entries

22
builder/osinfo.mli Normal file
View File

@@ -0,0 +1,22 @@
(* virt-builder
* Copyright (C) 2017 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 fold : ('a -> string -> 'a) -> 'a -> 'a
(** [fold f base] folds function [f] over every file in the
osinfo-db/libosinfo database of OS definitions.
*)

21
builder/osinfo_config.mli Normal file
View File

@@ -0,0 +1,21 @@
(* virt-builder
* Copyright (C) 2017 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 libosinfo_db_path : string
(** The path to the libosinfo database. Note the path is generated
at runtime by [Makefile.am]. *)

View File

@@ -16,7 +16,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*)
open Common_utils
open Std_utils
open Tools_utils
let xdg_cache_home =
try Some (Sys.getenv "XDG_CACHE_HOME" // "virt-builder")
@@ -25,17 +26,17 @@ let xdg_cache_home =
with Not_found ->
None (* no cache directory *)
let xdg_config_home ~prog =
let xdg_config_home () =
try Some (Sys.getenv "XDG_CONFIG_HOME" // prog)
with Not_found ->
try Some (Sys.getenv "HOME" // ".config" // prog)
with Not_found ->
None (* no config directory *)
let xdg_config_dirs ~prog =
let xdg_config_dirs () =
let dirs =
try Sys.getenv "XDG_CONFIG_DIRS"
with Not_found -> "/etc/xdg" in
let dirs = string_nsplit ":" dirs in
let dirs = String.nsplit ":" dirs in
let dirs = List.filter (fun x -> x <> "") dirs in
List.map (fun x -> x // prog) dirs

28
builder/paths.mli Normal file
View File

@@ -0,0 +1,28 @@
(* virt-builder
* Copyright (C) 2014-2017 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 xdg_cache_home : string option
(** [$XDG_CACHE_HOME/virt-builder] or [$HOME/.cache/virt-builder] or [None]. *)
val xdg_config_home : unit -> string option
(** [$XDG_CONFIG_HOME/prog] or [$HOME/.config/prog] or [None]. *)
val xdg_config_dirs : unit -> string list
(** [$XDG_CONFIG_DIRS] (which is a colon-separated path), split. Empty
elements are removed from the list. If the environment variable
is not set [["/etc/xdg"]] is returned instead. *)

View File

@@ -20,6 +20,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
@@ -33,6 +34,10 @@
#include <caml/fail.h>
#include <caml/memory.h>
#include <caml/mlvalues.h>
#include <caml/unixsupport.h>
#include "guestfs.h"
#include "guestfs-utils.h"
#include "ignore-value.h"
@@ -40,21 +45,16 @@
#include <lzma.h>
#endif
#ifdef HAVE_CAML_UNIXSUPPORT_H
#include <caml/unixsupport.h>
#else
#define Nothing ((value) 0)
extern void unix_error (int errcode, char * cmdname, value arg) Noreturn;
#endif
#if defined (HAVE_LIBLZMA) && \
defined (HAVE_LZMA_INDEX_STREAM_FLAGS) && \
#if defined (HAVE_LIBLZMA) && \
defined (HAVE_LZMA_INDEX_STREAM_FLAGS) && \
defined (HAVE_LZMA_INDEX_STREAM_PADDING)
#define PARALLEL_XZCAT 1
#else
#define PARALLEL_XZCAT 0
#endif
extern value virt_builder_using_parallel_xzcat (value unitv);
value
virt_builder_using_parallel_xzcat (value unitv)
{
@@ -65,6 +65,8 @@ virt_builder_using_parallel_xzcat (value unitv)
static void pxzcat (value filenamev, value outputfilev, unsigned nr_threads);
#endif /* PARALLEL_XZCAT */
extern value virt_builder_pxzcat (value inputfilev, value outputfilev);
value
virt_builder_pxzcat (value inputfilev, value outputfilev)
{
@@ -98,13 +100,13 @@ virt_builder_pxzcat (value inputfilev, value outputfilev)
fd = open (String_val (outputfilev), O_WRONLY|O_CREAT|O_TRUNC|O_NOCTTY, 0666);
if (fd == -1)
unix_error (errno, "open", outputfilev);
unix_error (errno, (char *) "open", outputfilev);
pid = fork ();
if (pid == -1) {
int err = errno;
const int err = errno;
close (fd);
unix_error (err, "fork", Nothing);
unix_error (err, (char *) "fork", Nothing);
}
if (pid == 0) { /* child - run xzcat */
@@ -117,7 +119,7 @@ virt_builder_pxzcat (value inputfilev, value outputfilev)
close (fd);
if (waitpid (pid, &status, 0) == -1)
unix_error (errno, "waitpid", Nothing);
unix_error (errno, (char *) "waitpid", Nothing);
if (!WIFEXITED (status) || WEXITSTATUS (status) != 0)
caml_failwith (XZCAT " program failed, see earlier error messages");
@@ -141,8 +143,6 @@ virt_builder_pxzcat (value inputfilev, value outputfilev)
#define XZ_HEADER_MAGIC "\xfd" "7zXZ\0"
#define XZ_HEADER_MAGIC_LEN 6
#define XZ_FOOTER_MAGIC "YZ"
#define XZ_FOOTER_MAGIC_LEN 2
static int check_header_magic (int fd);
static lzma_index *parse_indexes (value filenamev, int fd);
@@ -158,7 +158,10 @@ pxzcat (value filenamev, value outputfilev, unsigned nr_threads)
/* Open the file. */
fd = open (String_val (filenamev), O_RDONLY);
if (fd == -1)
unix_error (errno, "open", filenamev);
unix_error (errno, (char *) "open", filenamev);
guestfs_int_fadvise_noreuse (fd);
guestfs_int_fadvise_random (fd);
/* Check file magic. */
if (!check_header_magic (fd)) {
@@ -179,45 +182,47 @@ pxzcat (value filenamev, value outputfilev, unsigned nr_threads)
*/
ofd = open (String_val (outputfilev), O_WRONLY|O_CREAT|O_NOCTTY, 0644);
if (ofd == -1) {
int err = errno;
const int err = errno;
close (fd);
unix_error (err, "open", outputfilev);
unix_error (err, (char *) "open", outputfilev);
}
guestfs_int_fadvise_random (ofd);
if (ftruncate (ofd, 1) == -1) {
int err = errno;
const int err = errno;
close (fd);
unix_error (err, "ftruncate", outputfilev);
unix_error (err, (char *) "ftruncate", outputfilev);
}
if (lseek (ofd, 0, SEEK_SET) == -1) {
int err = errno;
const int err = errno;
close (fd);
unix_error (err, "lseek", outputfilev);
unix_error (err, (char *) "lseek", outputfilev);
}
if (write (ofd, "\0", 1) == -1) {
int err = errno;
const int err = errno;
close (fd);
unix_error (err, "write", outputfilev);
unix_error (err, (char *) "write", outputfilev);
}
if (ftruncate (ofd, size) == -1) {
int err = errno;
const int err = errno;
close (fd);
unix_error (err, "ftruncate", outputfilev);
unix_error (err, (char *) "ftruncate", outputfilev);
}
/* Tell the kernel we won't read the output file. */
ignore_value (posix_fadvise (fd, 0, 0, POSIX_FADV_RANDOM|POSIX_FADV_DONTNEED));
/* Iterate over blocks. */
iter_blocks (idx, nr_threads, filenamev, fd, outputfilev, ofd);
lzma_index_end (idx, NULL);
if (close (fd) == -1)
unix_error (errno, "close", filenamev);
unix_error (errno, (char *) "close", filenamev);
if (close (ofd) == -1)
unix_error (errno, (char *) "close", outputfilev);
}
static int
@@ -242,8 +247,8 @@ parse_indexes (value filenamev, int fd)
{
lzma_ret r;
off_t pos, index_size;
uint8_t footer[LZMA_STREAM_HEADER_SIZE];
uint8_t header[LZMA_STREAM_HEADER_SIZE];
CLEANUP_FREE uint8_t *footer = NULL;
CLEANUP_FREE uint8_t *header = NULL;
lzma_stream_flags footer_flags;
lzma_stream_flags header_flags;
lzma_stream strm = LZMA_STREAM_INIT;
@@ -252,11 +257,18 @@ parse_indexes (value filenamev, int fd)
lzma_index *this_index = NULL;
lzma_vli stream_padding = 0;
size_t nr_streams = 0;
CLEANUP_FREE uint8_t *buf = NULL;
footer = malloc (sizeof (uint8_t) * LZMA_STREAM_HEADER_SIZE);
header = malloc (sizeof (uint8_t) * LZMA_STREAM_HEADER_SIZE);
buf = malloc (sizeof (uint8_t) * BUFSIZ);
if (footer == NULL || header == NULL || buf == NULL)
caml_raise_out_of_memory ();
/* Check file size is a multiple of 4 bytes. */
pos = lseek (fd, 0, SEEK_END);
if (pos == (off_t) -1)
unix_error (errno, "lseek", filenamev);
unix_error (errno, (char *) "lseek", filenamev);
if ((pos & 3) != 0)
caml_invalid_argument ("input not an xz file: size is not a multiple of 4 bytes");
@@ -269,10 +281,10 @@ parse_indexes (value filenamev, int fd)
caml_invalid_argument ("corrupted xz file");
if (lseek (fd, -LZMA_STREAM_HEADER_SIZE, SEEK_CUR) == -1)
unix_error (errno, "lseek", filenamev);
unix_error (errno, (char *) "lseek", filenamev);
if (read (fd, footer, LZMA_STREAM_HEADER_SIZE) != LZMA_STREAM_HEADER_SIZE)
unix_error (errno, "read", filenamev);
unix_error (errno, (char *) "read", filenamev);
/* Skip stream padding. */
if (footer[8] == 0 && footer[9] == 0 &&
@@ -290,7 +302,7 @@ parse_indexes (value filenamev, int fd)
/* Does the stream footer look reasonable? */
r = lzma_stream_footer_decode (&footer_flags, footer);
if (r != LZMA_OK) {
fprintf (stderr, "invalid stream footer - error %d\n", r);
fprintf (stderr, "invalid stream footer - error %u\n", r);
caml_invalid_argument ("invalid stream footer");
}
@@ -304,25 +316,23 @@ parse_indexes (value filenamev, int fd)
/* Seek backwards to the index of this stream. */
if (lseek (fd, pos, SEEK_SET) == -1)
unix_error (errno, "lseek", filenamev);
unix_error (errno, (char *) "lseek", filenamev);
/* Decode the index. */
r = lzma_index_decoder (&strm, &this_index, UINT64_MAX);
if (r != LZMA_OK) {
fprintf (stderr, "invalid stream index - error %d\n", r);
fprintf (stderr, "invalid stream index - error %u\n", r);
caml_invalid_argument ("invalid stream index");
}
do {
uint8_t buf[BUFSIZ];
strm.avail_in = index_size;
if (strm.avail_in > BUFSIZ)
strm.avail_in = BUFSIZ;
n = read (fd, &buf, strm.avail_in);
n = read (fd, buf, strm.avail_in);
if (n == -1)
unix_error (errno, "read", filenamev);
unix_error (errno, (char *) "read", filenamev);
index_size -= strm.avail_in;
@@ -331,7 +341,7 @@ parse_indexes (value filenamev, int fd)
} while (r == LZMA_OK);
if (r != LZMA_STREAM_END) {
fprintf (stderr, "could not parse index - error %d\n", r);
fprintf (stderr, "could not parse index - error %u\n", r);
caml_invalid_argument ("could not parse index");
}
@@ -341,21 +351,21 @@ parse_indexes (value filenamev, int fd)
/* Read and decode the stream header. */
if (lseek (fd, pos, SEEK_SET) == -1)
unix_error (errno, "lseek", filenamev);
unix_error (errno, (char *) "lseek", filenamev);
if (read (fd, header, LZMA_STREAM_HEADER_SIZE) != LZMA_STREAM_HEADER_SIZE)
unix_error (errno, "read stream header", filenamev);
unix_error (errno, (char *) "read stream header", filenamev);
r = lzma_stream_header_decode (&header_flags, header);
if (r != LZMA_OK) {
fprintf (stderr, "invalid stream header - error %d\n", r);
fprintf (stderr, "invalid stream header - error %u\n", r);
caml_invalid_argument ("invalid stream header");
}
/* Header and footer of the stream should be equal. */
r = lzma_stream_flags_compare (&header_flags, &footer_flags);
if (r != LZMA_OK) {
fprintf (stderr, "header and footer of stream are not equal - error %d\n",
fprintf (stderr, "header and footer of stream are not equal - error %u\n",
r);
caml_invalid_argument ("header and footer of stream are not equal");
}
@@ -363,7 +373,7 @@ parse_indexes (value filenamev, int fd)
/* Store the decoded stream flags in this_index. */
r = lzma_index_stream_flags (this_index, &footer_flags);
if (r != LZMA_OK) {
fprintf (stderr, "cannot read stream_flags from index - error %d\n", r);
fprintf (stderr, "cannot read stream_flags from index - error %u\n", r);
caml_invalid_argument ("cannot read stream_flags from index");
}
@@ -372,14 +382,14 @@ parse_indexes (value filenamev, int fd)
*/
r = lzma_index_stream_padding (this_index, stream_padding);
if (r != LZMA_OK) {
fprintf (stderr, "cannot set stream_padding in index - error %d\n", r);
fprintf (stderr, "cannot set stream_padding in index - error %u\n", r);
caml_invalid_argument ("cannot set stream_padding in index");
}
if (combined_index != NULL) {
r = lzma_index_cat (this_index, combined_index, NULL);
if (r != LZMA_OK) {
fprintf (stderr, "cannot combine indexes - error %d\n", r);
fprintf (stderr, "cannot combine indexes - error %u\n", r);
caml_invalid_argument ("cannot combine indexes");
}
}
@@ -393,24 +403,6 @@ parse_indexes (value filenamev, int fd)
return combined_index;
}
/* Return true iff the buffer is all zero bytes.
*
* Note that gcc is smart enough to optimize this properly:
* http://stackoverflow.com/questions/1493936/faster-means-of-checking-for-an-empty-buffer-in-c/1493989#1493989
*/
static inline int
is_zero (const unsigned char *buffer, size_t size)
{
size_t i;
for (i = 0; i < size; ++i) {
if (buffer[i] != 0)
return 0;
}
return 1;
}
struct global_state {
/* Current iterator. Threads update this, but it is protected by a
* mutex, and each thread takes a copy of it when working on it.
@@ -446,17 +438,22 @@ iter_blocks (lzma_index *idx, unsigned nr_threads,
value filenamev, int fd, value outputfilev, int ofd)
{
struct global_state global;
struct per_thread_state per_thread[nr_threads];
pthread_t thread[nr_threads];
CLEANUP_FREE struct per_thread_state *per_thread = NULL;
CLEANUP_FREE pthread_t *thread = NULL;
unsigned u, nr_errors;
int err;
void *status;
per_thread = malloc (sizeof (struct per_thread_state) * nr_threads);
thread = malloc (sizeof (pthread_t) * nr_threads);
if (per_thread == NULL || thread == NULL)
caml_raise_out_of_memory ();
lzma_index_iter_init (&global.iter, idx);
global.iter_finished = 0;
err = pthread_mutex_init (&global.iter_mutex, NULL);
if (err != 0)
unix_error (err, "pthread_mutex_init", Nothing);
unix_error (err, (char *) "pthread_mutex_init", Nothing);
global.filename = String_val (filenamev);
global.fd = fd;
@@ -472,7 +469,7 @@ iter_blocks (lzma_index *idx, unsigned nr_threads,
for (u = 0; u < nr_threads; ++u) {
err = pthread_create (&thread[u], NULL, worker_thread, &per_thread[u]);
if (err != 0)
unix_error (err, "pthread_create", Nothing);
unix_error (err, (char *) "pthread_create", Nothing);
}
/* Wait for the threads to exit. */
@@ -491,6 +488,24 @@ iter_blocks (lzma_index *idx, unsigned nr_threads,
caml_invalid_argument ("some threads failed, see earlier errors");
}
static int
xpwrite (int fd, const void *bufvp, size_t count, off_t offset)
{
const char *buf = bufvp;
ssize_t r;
while (count > 0) {
r = pwrite (fd, buf, count, offset);
if (r == -1)
return -1;
count -= r;
offset += r;
buf += r;
}
return 0;
}
/* Iterate over the blocks and uncompress. */
static void *
worker_thread (void *vp)
@@ -500,19 +515,29 @@ worker_thread (void *vp)
lzma_index_iter iter;
int err;
off_t position, oposition;
uint8_t header[LZMA_BLOCK_HEADER_SIZE_MAX];
CLEANUP_FREE uint8_t *header = NULL;
ssize_t n;
lzma_block block;
lzma_filter filters[LZMA_FILTERS_MAX + 1];
CLEANUP_FREE lzma_filter *filters = NULL;
lzma_ret r;
lzma_stream strm = LZMA_STREAM_INIT;
uint8_t buf[BUFFER_SIZE];
unsigned char outbuf[BUFFER_SIZE];
CLEANUP_FREE uint8_t *buf = NULL;
CLEANUP_FREE uint8_t *outbuf = NULL;
size_t i;
lzma_bool iter_finished;
state->status = -1;
header = malloc (sizeof (uint8_t) * LZMA_BLOCK_HEADER_SIZE_MAX);
filters = malloc (sizeof (lzma_filter) * (LZMA_FILTERS_MAX + 1));
buf = malloc (sizeof (uint8_t) * BUFFER_SIZE);
outbuf = malloc (sizeof (uint8_t) * BUFFER_SIZE);
if (header == NULL || filters == NULL || buf == NULL || outbuf == NULL) {
perror ("malloc");
return &state->status;
}
for (;;) {
/* Get the next block. */
err = pthread_mutex_lock (&global->iter_mutex);
@@ -563,7 +588,7 @@ worker_thread (void *vp)
/* Now read and decode the block header. */
n = pread (global->fd, &header[1], block.header_size-1, position);
if (n >= 0 && n != block.header_size-1) {
if (n >= 0 && n != (ssize_t) block.header_size-1) {
fprintf (stderr,
"%s: read: unexpected end of file reading block header\n",
global->filename);
@@ -577,7 +602,7 @@ worker_thread (void *vp)
r = lzma_block_header_decode (&block, NULL, header);
if (r != LZMA_OK) {
fprintf (stderr, "%s: invalid block header (error %d)\n",
fprintf (stderr, "%s: invalid block header (error %u)\n",
global->filename, r);
return &state->status;
}
@@ -588,7 +613,7 @@ worker_thread (void *vp)
r = lzma_block_compressed_size (&block, iter.block.unpadded_size);
if (r != LZMA_OK) {
fprintf (stderr,
"%s: cannot calculate compressed size (error %d)\n",
"%s: cannot calculate compressed size (error %u)\n",
global->filename, r);
return &state->status;
}
@@ -599,21 +624,21 @@ worker_thread (void *vp)
/* Read the block data and uncompress it. */
r = lzma_block_decoder (&strm, &block);
if (r != LZMA_OK) {
fprintf (stderr, "%s: invalid block (error %d)\n", global->filename, r);
fprintf (stderr, "%s: invalid block (error %u)\n", global->filename, r);
return &state->status;
}
strm.next_in = NULL;
strm.avail_in = 0;
strm.next_out = outbuf;
strm.avail_out = sizeof outbuf;
strm.avail_out = BUFFER_SIZE;
for (;;) {
lzma_action action = LZMA_RUN;
if (strm.avail_in == 0) {
strm.next_in = buf;
n = pread (global->fd, buf, sizeof buf, position);
n = pread (global->fd, buf, BUFFER_SIZE, position);
if (n == -1) {
perror (global->filename);
return &state->status;
@@ -627,29 +652,28 @@ worker_thread (void *vp)
r = lzma_code (&strm, action);
if (strm.avail_out == 0 || r == LZMA_STREAM_END) {
size_t wsz = sizeof outbuf - strm.avail_out;
size_t wsz = BUFFER_SIZE - strm.avail_out;
/* Don't write if the block is all zero, to preserve output file
* sparseness. However we have to update oposition.
*/
if (!is_zero (outbuf, wsz)) {
if (pwrite (global->ofd, outbuf, wsz, oposition) != wsz) {
/* XXX Handle short writes. */
perror (global->filename);
if (!is_zero ((char *) outbuf, wsz)) {
if (xpwrite (global->ofd, outbuf, wsz, oposition) == -1) {
perror (global->outputfile);
return &state->status;
}
}
oposition += wsz;
strm.next_out = outbuf;
strm.avail_out = sizeof outbuf;
strm.avail_out = BUFFER_SIZE;
}
if (r == LZMA_STREAM_END)
break;
if (r != LZMA_OK) {
fprintf (stderr,
"%s: could not parse block data (error %d)\n",
"%s: could not parse block data (error %u)\n",
global->filename, r);
return &state->status;
}

View File

@@ -37,6 +37,8 @@ static const int lc_string_table[7] = {
#define Val_none (Val_int (0))
extern value virt_builder_setlocale (value val_category, value val_name);
value
virt_builder_setlocale (value val_category, value val_name)
{

View File

@@ -16,8 +16,10 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*)
open Std_utils
open Tools_utils
open Unix_utils
open Common_gettext.Gettext
open Common_utils
open Utils
@@ -25,82 +27,110 @@ open Printf
open Unix
type t = {
verbose : bool;
gpg : string;
fingerprint : string;
subkeys_fingerprints : string list;
check_signature : bool;
gpghome : string;
tmpdir : string;
}
(* Import the specified key file. *)
let import_keyfile ~gpg ~gpghome ~verbose keyfile =
let status_file = Filename.temp_file "vbstat" ".txt" in
unlink_on_exit status_file;
let import_keyfile ~gpg ~gpghome ~tmpdir ?(trust = true) keyfile =
let status_file = Filename.temp_file ~temp_dir:tmpdir "vbstat" ".txt" in
let cmd = sprintf "%s --homedir %s --status-file %s --import %s%s"
gpg gpghome (quote status_file) (quote keyfile)
(if verbose then "" else " >/dev/null 2>&1") in
if verbose then printf "%s\n%!" cmd;
let r = Sys.command cmd in
(if verbose () then "" else " >/dev/null 2>&1") in
let r = shell_command cmd in
if r <> 0 then
error (f_"could not import public key\nUse the '-v' option and look for earlier error messages.");
status_file
error (f_"could not import public key\nUse the -v option and look for earlier error messages.");
let status = read_whole_file status_file in
let status = String.nsplit "\n" status in
let key_id = ref "" in
let fingerprint = ref "" in
List.iter (
fun line ->
let line = String.nsplit " " line in
match line with
| "[GNUPG:]" :: "IMPORT_OK" :: _ :: fp :: _ -> fingerprint := fp
| "[GNUPG:]" :: "IMPORTED" :: key :: _ -> key_id := key
| _ -> ()
) status;
if trust then (
let cmd = sprintf "%s --homedir %s --trusted-key %s --list-keys%s"
gpg gpghome (quote !key_id)
(if verbose () then "" else " >/dev/null 2>&1") in
let r = shell_command cmd in
if r <> 0 then
error (f_"GPG failure: could not trust the imported key\nUse the -v option and look for earlier error messages.");
);
let subkeys =
(* --with-fingerprint is specified twice so gpg outputs the full
* fingerprint of the subkeys. *)
let cmd = sprintf "%s --homedir %s --with-colons --with-fingerprint --with-fingerprint --list-keys %s"
gpg gpghome !fingerprint in
let lines = external_command cmd in
let current = ref None in
let subkeys = ref [] in
List.iter (
fun line ->
let line = String.nsplit ":" line in
match line with
| "sub" :: ("u"|"-") :: _ :: _ :: id :: _ ->
current := Some id
| "fpr" :: _ :: _ :: _ :: _ :: _ :: _ :: _ :: _ :: id :: _ ->
(match !current with
| None -> ()
| Some k ->
if String.is_suffix id k then push_front id subkeys;
current := None
)
| _ -> ()
) lines;
!subkeys in
!fingerprint, subkeys
let rec create ~verbose ~gpg ~gpgkey ~check_signature =
let rec create ~gpg ~gpgkey ~check_signature ~tmpdir =
(* Create a temporary directory for gnupg. *)
let tmpdir = Mkdtemp.temp_dir "vb.gpghome." "" in
rmdir_on_exit tmpdir;
let gpgtmpdir = Mkdtemp.temp_dir ~base_dir:tmpdir "vb.gpghome." in
(* Make sure we have no check_signature=true with no actual key. *)
let check_signature, gpgkey =
match check_signature, gpgkey with
| true, No_Key -> false, No_Key
| x, y -> x, y in
let fingerprint =
let fingerprint, subkeys =
if check_signature then (
(* Run gpg so it can setup its own home directory, failing if it
* cannot.
*)
let cmd = sprintf "%s --homedir %s --list-keys%s"
gpg tmpdir (if verbose then "" else " >/dev/null 2>&1") in
if verbose then printf "%s\n%!" cmd;
let r = Sys.command cmd in
gpg gpgtmpdir (if verbose () then "" else " >/dev/null 2>&1") in
let r = shell_command cmd in
if r <> 0 then
error (f_"GPG failure: could not run GPG the first time\nUse the '-v' option and look for earlier error messages.");
error (f_"GPG failure: could not run GPG the first time\nUse the -v option and look for earlier error messages.");
match gpgkey with
| No_Key ->
assert false
| KeyFile kf ->
let status_file = import_keyfile gpg tmpdir verbose kf in
let status = read_whole_file status_file in
let status = string_nsplit "\n" status in
let fingerprint = ref "" in
List.iter (
fun line ->
let line = string_nsplit " " line in
match line with
| "[GNUPG:]" :: "IMPORT_OK" :: _ :: fp :: _ -> fingerprint := fp
| _ -> ()
) status;
!fingerprint
import_keyfile gpg gpgtmpdir tmpdir kf
| Fingerprint fp ->
let filename = Filename.temp_file "vbpubkey" ".asc" in
unlink_on_exit filename;
let filename = Filename.temp_file ~temp_dir:tmpdir "vbpubkey" ".asc" in
let cmd = sprintf "%s --yes --armor --output %s --export %s%s"
gpg (quote filename) (quote fp)
(if verbose then "" else " >/dev/null 2>&1") in
if verbose then printf "%s\n%!" cmd;
let r = Sys.command cmd in
(if verbose () then "" else " >/dev/null 2>&1") in
let r = shell_command cmd in
if r <> 0 then
error (f_"could not export public key\nUse the '-v' option and look for earlier error messages.");
ignore (import_keyfile gpg tmpdir verbose filename);
fp
error (f_"could not export public key\nUse the -v option and look for earlier error messages.");
import_keyfile gpg gpgtmpdir tmpdir filename
) else
"" in
"", [] in
{
verbose = verbose;
gpg = gpg;
fingerprint = fingerprint;
subkeys_fingerprints = subkeys;
check_signature = check_signature;
gpghome = tmpdir;
gpghome = gpgtmpdir;
tmpdir = tmpdir;
}
(* Compare two strings of hex digits ignoring whitespace and case. *)
@@ -127,6 +157,9 @@ and getxdigit = function
| 'A'..'F' as c -> Some (Char.code c - Char.code 'A')
| _ -> None
let verifying_signatures t =
t.check_signature
let rec verify t filename =
if t.check_signature then (
let args = quote filename in
@@ -137,63 +170,52 @@ and verify_detached t filename sigfile =
if t.check_signature then (
match sigfile with
| None ->
error (f_"there is no detached signature file\nThis probably means the index file is missing a sig=... line.\nYou can use --no-check-signature to ignore this error, but that means\nyou are susceptible to man-in-the-middle attacks.\n")
error (f_"there is no detached signature file\nThis probably means the index file is missing a sig=... line.\nYou can use --no-check-signature to ignore this error, but that means you are susceptible to man-in-the-middle attacks.")
| Some sigfile ->
let args = sprintf "%s %s" (quote sigfile) (quote filename) in
do_verify t args
)
and do_verify t args =
let status_file = Filename.temp_file "vbstat" ".txt" in
unlink_on_exit status_file;
and verify_and_remove_signature t filename =
if t.check_signature then (
(* Copy the input file as temporary file with the .asc extension,
* so gpg recognises that format. *)
let asc_file = Filename.temp_file ~temp_dir:t.tmpdir "vbfile" ".asc" in
let cmd = [ "cp"; filename; asc_file ] in
if run_command cmd <> 0 then exit 1;
let out_file = Filename.temp_file ~temp_dir:t.tmpdir "vbfile" "" in
let args = sprintf "--yes --output %s %s" (quote out_file) (quote filename) in
do_verify ~verify_only:false t args;
Some out_file
) else
None
and do_verify ?(verify_only = true) t args =
let status_file = Filename.temp_file ~temp_dir:t.tmpdir "vbstat" ".txt" in
let cmd =
sprintf "%s --homedir %s --verify%s --status-file %s %s"
sprintf "%s --homedir %s %s%s --status-file %s %s"
t.gpg t.gpghome
(if t.verbose then "" else " -q --logger-file /dev/null")
(if verify_only then "--verify" else "")
(if verbose () then "" else " --batch -q --logger-file /dev/null")
(quote status_file) args in
if t.verbose then printf "%s\n%!" cmd;
let r = Sys.command cmd in
let r = shell_command cmd in
if r <> 0 then
error (f_"GPG failure: could not verify digital signature of file\nTry:\n - Use the '-v' option and look for earlier error messages.\n - Delete the cache: virt-builder --delete-cache\n - Check no one has tampered with the website or your network!");
error (f_"GPG failure: could not verify digital signature of file\nTry:\n - Use the -v option and look for earlier error messages.\n - Delete the cache: virt-builder --delete-cache\n - Check no one has tampered with the website or your network!");
(* Check the fingerprint is who it should be. *)
let status = read_whole_file status_file in
let status = string_nsplit "\n" status in
let status = String.nsplit "\n" status in
let fingerprint = ref "" in
List.iter (
fun line ->
let line = string_nsplit " " line in
let line = String.nsplit " " line in
match line with
| "[GNUPG:]" :: "VALIDSIG" :: fp :: _ -> fingerprint := fp
| _ -> ()
) status;
if not (equal_fingerprints !fingerprint t.fingerprint) then
if not (equal_fingerprints !fingerprint t.fingerprint) &&
not (List.exists (equal_fingerprints !fingerprint) t.subkeys_fingerprints) then
error (f_"fingerprint of signature does not match the expected fingerprint!\n found fingerprint: %s\n expected fingerprint: %s")
!fingerprint t.fingerprint
type csum_t = SHA512 of string
let verify_checksum t (SHA512 csum) filename =
let csum_file = Filename.temp_file "vbcsum" ".txt" in
unlink_on_exit csum_file;
let cmd = sprintf "sha512sum %s | awk '{print $1}' > %s"
(quote filename) (quote csum_file) in
if t.verbose then printf "%s\n%!" cmd;
let r = Sys.command cmd in
if r <> 0 then
error (f_"could not run sha512sum command to verify checksum");
let csum_actual = read_whole_file csum_file in
let csum_actual =
let len = String.length csum_actual in
if len > 0 && csum_actual.[len-1] = '\n' then
String.sub csum_actual 0 (len-1)
else
csum_actual in
if csum <> csum_actual then
error (f_"checksum of template did not match the expected checksum!\n found checksum: %s\n expected checksum: %s\nTry:\n - Use the '-v' option and look for earlier error messages.\n - Delete the cache: virt-builder --delete-cache\n - Check no one has tampered with the website or your network!")
csum_actual csum

View File

@@ -18,7 +18,11 @@
type t
val create : verbose:bool -> gpg:string -> gpgkey:Utils.gpgkey_type -> check_signature:bool -> t
val create : gpg:string -> gpgkey:Utils.gpgkey_type -> check_signature:bool -> tmpdir:string -> t
val verifying_signatures : t -> bool
(** Return whether signatures are being verified by this
Sigchecker.t. *)
val verify : t -> string -> unit
(** Verify the file is signed (if check_signature is true). *)
@@ -27,8 +31,6 @@ val verify_detached : t -> string -> string option -> unit
(** Verify the file is signed against the detached signature
(if check_signature is true). *)
type csum_t = SHA512 of string
val verify_checksum : t -> csum_t -> string -> unit
(** Verify the checksum of the file. This is always verified even if
check_signature if false. *)
val verify_and_remove_signature : t -> string -> string option
(** If check_signature is true, verify the file is signed and extract
the content of the file (i.e. without the signature). *)

View File

@@ -0,0 +1,154 @@
(* virt-builder
* Copyright (C) 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*)
open Std_utils
open Tools_utils
open Common_gettext.Gettext
open Yajl
open Utils
open Printf
let ensure_trailing_slash str =
if String.length str > 0 && str.[String.length str - 1] <> '/' then str ^ "/"
else str
let get_index ~downloader ~sigchecker { Sources.uri; proxy } =
let uri = ensure_trailing_slash uri in
let download_and_parse uri =
let tmpfile, _ = Downloader.download downloader ~proxy uri in
let file =
if Sigchecker.verifying_signatures sigchecker then (
let tmpunsigned =
Sigchecker.verify_and_remove_signature sigchecker tmpfile in
match tmpunsigned with
| None -> assert false (* only when not verifying signatures *)
| Some f -> f
) else
tmpfile in
yajl_tree_parse (read_whole_file file) in
let downloads =
let uri_index =
if Sigchecker.verifying_signatures sigchecker then
uri ^ "streams/v1/index.sjson"
else
uri ^ "streams/v1/index.json" in
let tree = download_and_parse uri_index in
let format = object_get_string "format" tree in
if format <> "index:1.0" then
error (f_"%s is not a Simple Streams (index) v1.0 JSON file (format: %s)")
uri format;
let index = Array.to_list (object_get_object "index" tree) in
filter_map (
fun (_, desc) ->
let format = object_get_string "format" desc in
let datatype = object_get_string "datatype" desc in
match format, datatype with
| "products:1.0", "image-downloads" ->
Some (object_get_string "path" desc)
| _ -> None
) index in
let scan_product_list path =
let tree = download_and_parse (uri ^ path) in
let format = object_get_string "format" tree in
if format <> "products:1.0" then
error (f_"%s is not a Simple Streams (products) v1.0 JSON file (format: %s)")
uri format;
let products_node = object_get_object "products" tree in
let products = Array.to_list products_node in
filter_map (
fun (prod, prod_desc) ->
let arch = object_get_string "arch" prod_desc in
let prods = Array.to_list (object_get_object "versions" prod_desc) in
let prods = filter_map (
fun (rel, rel_desc) ->
let pubname = objects_get_string "pubname" [rel_desc; prod_desc] in
let items = object_find_object "items" rel_desc in
let disk_items = object_find_objects (
function
| (("disk.img"|"disk1.img"), v) -> Some v
| _ -> None
) items in
(match disk_items with
| [] -> None
| disk_item :: _ ->
let printable_name = Some pubname in
let file_uri = uri ^ (object_get_string "path" disk_item) in
let checksums =
let checksums = object_find_objects (
function
(* Since this catches all the keys, and not just
* the ones related to checksums, explicitly filter
* the supported checksums.
*)
| ("sha256"|"sha512" as t, Yajl_string c) ->
Some (Checksums.of_string t c)
| _ -> None
) disk_item in
match checksums with
| [] -> None
| x -> Some x in
let revision = Rev_string rel in
let size = object_get_number "size" disk_item in
let aliases = Some [pubname;] in
let entry = { Index.printable_name = printable_name;
osinfo = None;
file_uri = file_uri;
arch = arch;
signature_uri = None;
checksums = checksums;
revision = revision;
format = None;
size = size;
compressed_size = None;
expand = None;
lvexpand = None;
notes = [];
hidden = false;
aliases = aliases;
sigchecker = sigchecker;
proxy = proxy; } in
Some (rel, (prod, entry))
)
) prods in
(* Select the disk image with the bigger version (i.e. usually
* the most recent one. *)
let reverse_revision_compare (rev1, _) (rev2, _) = compare rev2 rev1 in
let prods = List.sort reverse_revision_compare prods in
match prods with
| [] -> None
| (_, entry) :: _ -> Some entry
) products in
let entries = List.flatten (List.map scan_product_list downloads) in
if verbose () then (
printf "simplestreams tree (%s) after parsing:\n" uri;
List.iter (Index.print_entry Pervasives.stdout) entries
);
entries

View File

@@ -0,0 +1,19 @@
(* virt-builder
* Copyright (C) 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*)
val get_index : downloader:Downloader.t -> sigchecker:Sigchecker.t -> Sources.source -> Index.index

View File

@@ -16,8 +16,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*)
open Std_utils
open Tools_utils
open Common_gettext.Gettext
open Common_utils
open Printf
open Unix
@@ -26,16 +27,16 @@ type source = {
name : string;
uri : string;
gpgkey : Utils.gpgkey_type;
proxy : Downloader.proxy_mode;
proxy : Curl.proxy;
format : source_format;
}
and source_format =
| FormatNative
| FormatSimpleStreams
module StringSet = Set.Make (String)
let parse_conf ~prog ~verbose file =
if verbose then (
printf (f_"%s: trying to read %s\n") prog file;
);
let sections = Ini_reader.read_ini ~prog ~error_suffix:"[ignored]" file in
let parse_conf file =
debug "trying to read %s" file;
let sections = Ini_reader.read_ini ~error_suffix:"[ignored]" file in
let sources = List.fold_right (
fun (n, fields) acc ->
@@ -44,48 +45,54 @@ let parse_conf ~prog ~verbose file =
let uri =
try List.assoc ("uri", None) fields
with Not_found as ex ->
eprintf (f_"%s: no 'uri' entry for '%s' in %s, skipping it\n") prog n file;
eprintf (f_"%s: no uri entry for %s in %s, skipping it\n") prog n file;
raise ex in
let gpgkey =
let k =
try Some (URI.parse_uri (List.assoc ("gpgkey", None) fields)) with
| Not_found -> None
| Invalid_argument "URI.parse_uri" as ex ->
if verbose then (
printf (f_"%s: '%s' has invalid gpgkey URI\n") prog n;
);
raise ex in
| URI.Parse_failed as ex ->
debug "'%s' has invalid gpgkey URI" n;
raise ex in
match k with
| None -> Utils.No_Key
| Some uri ->
(match uri.URI.protocol with
| "file" -> Utils.KeyFile uri.URI.path
| _ ->
if verbose then (
printf (f_"%s: '%s' has non-local gpgkey URI\n") prog n;
);
Utils.No_Key
debug "'%s' has non-local gpgkey URI" n;
Utils.No_Key
) in
let proxy =
try
(match (List.assoc ("proxy", None) fields) with
| "no" | "off" -> Downloader.UnsetProxy
| "system" -> Downloader.SystemProxy
| _ as proxy -> Downloader.ForcedProxy proxy
| "no" | "off" -> Curl.UnsetProxy
| "system" -> Curl.SystemProxy
| _ as proxy -> Curl.ForcedProxy proxy
)
with
Not_found -> Downloader.SystemProxy in
Not_found -> Curl.SystemProxy in
let format =
try
(match (List.assoc ("format", None) fields) with
| "native" | "" -> FormatNative
| "simplestreams" -> FormatSimpleStreams
| fmt ->
debug "unknown repository type '%s' in %s, skipping it" fmt file;
invalid_arg fmt
)
with
Not_found -> FormatNative in
{
name = n; uri = uri; gpgkey = gpgkey; proxy = proxy;
format = format;
}
in
try (give_source n fields) :: acc
with Not_found | Invalid_argument _ -> acc
) sections [] in
if verbose then (
printf (f_"%s: ... read %d sources\n") prog (List.length sources);
);
debug "read %d sources" (List.length sources);
sources
@@ -101,10 +108,10 @@ let merge_sources current_sources new_sources =
let filter_filenames filename =
Filename.check_suffix filename ".conf"
let read_sources ~prog ~verbose =
let dirs = Paths.xdg_config_dirs ~prog in
let read_sources () =
let dirs = Paths.xdg_config_dirs () in
let dirs =
match Paths.xdg_config_home ~prog with
match Paths.xdg_config_home () with
| None -> dirs
| Some dir -> dir :: dirs in
let dirs = List.map (fun x -> x // "repos.d") dirs in
@@ -118,7 +125,7 @@ let read_sources ~prog ~verbose =
List.fold_left (
fun acc file ->
try (
let s = merge_sources acc (parse_conf ~prog ~verbose (dir // file)) in
let s = merge_sources acc (parse_conf (dir // file)) in
(* Add the current file name to the set only if its parsing
* was successful.
*)
@@ -126,14 +133,10 @@ let read_sources ~prog ~verbose =
s
) with
| Unix_error (code, fname, _) ->
if verbose then (
printf (f_"%s: file error: %s: %s\n") prog fname (error_message code)
);
acc
debug "file error: %s: %s\n" fname (error_message code);
acc
| Invalid_argument msg ->
if verbose then (
printf (f_"%s: internal error: invalid argument: %s\n") prog msg
);
acc
debug "internal error: invalid argument: %s" msg;
acc
) acc files
) [] dirs

View File

@@ -20,7 +20,11 @@ type source = {
name : string;
uri : string;
gpgkey : Utils.gpgkey_type;
proxy : Downloader.proxy_mode;
proxy : Curl.proxy;
format : source_format;
}
and source_format =
| FormatNative
| FormatSimpleStreams
val read_sources : prog:string -> verbose:bool -> source list
val read_sources : unit -> source list

View File

@@ -0,0 +1,46 @@
# libguestfs virt-builder tool
# Copyright (C) 2013-2017 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
index_fragments = $(wildcard *.index-fragment)
EXTRA_DIST = \
$(index_fragments) \
*.ks \
*.virt-install-cmd \
debian.preseed \
make-template.ml \
ubuntu.preseed \
validate.sh
# Create the index file under the top level website/ directory.
noinst_DATA = $(top_builddir)/website/download/builder/index
$(top_builddir)/website/download/builder/index: $(index_fragments)
rm -f $@ $@-t
LANG=C sh -c 'cat *.index-fragment' > $@-t
mv $@-t $@
@echo "NOTE: $@.asc must be updated by running:"
@echo " gpg --clearsign --armor $@"
# Validates the index file.
TESTS_ENVIRONMENT = $(top_builddir)/run --test
TESTS = validate.sh
check-valgrind:
$(MAKE) VG="@VG@" check

View File

@@ -0,0 +1,23 @@
[centos-6]
name=CentOS 6.6
osinfo=centos6.6
arch=x86_64
file=centos-6.xz
revision=6
checksum=fc403ea3555a5608a25ad30ce2514b67288311a7197ddf9fb664475820f26db2bd95a86be9cd6e3f772187b384a02e0965430456dd518d343a80457057bc5441
format=raw
size=6442450944
compressed_size=199265736
expand=/dev/sda3
notes=CentOS 6.6
This CentOS image contains only unmodified @Core group packages.
It is thus very minimal. The kickstart and install script can be
found in the libguestfs source tree:
builder/website/centos.sh
Note that virt-builder centos-6 will always install the latest
6.x release.

View File

@@ -0,0 +1,19 @@
[centos-7.0]
name=CentOS 7.0
osinfo=centos7.0
arch=x86_64
file=centos-7.0.xz
checksum=cf9ae295f633fbd04e575eeca16f372e933c70c3107c44eb06864760d04354aa94b4f356bfc9a598c138e687304a52e96777e4467e7db1ec0cb5b2d2ec61affc
format=raw
size=6442450944
compressed_size=213203844
expand=/dev/sda3
notes=CentOS 7.0
This CentOS image contains only unmodified @Core group packages.
It is thus very minimal. The kickstart and install script can be
found in the libguestfs source tree:
builder/website/centos.sh

View File

@@ -0,0 +1,19 @@
[centos-7.1]
name=CentOS 7.1
osinfo=centos7.1
arch=x86_64
file=centos-7.1.xz
checksum=4bd2536710daa27a70ff69a96d8a694bde1ecf48d811e75d5e6881cfdcd214c0af6949d5a8252ace06e4e8b33337f65ccb16305c85ff88156d49ac559e840b5c
format=raw
size=6442450944
compressed_size=238579176
expand=/dev/sda3
notes=CentOS 7.1
This CentOS image contains only unmodified @Core group packages.
It is thus very minimal. The kickstart and install script can be
found in the libguestfs source tree:
builder/website/centos.sh

View File

@@ -0,0 +1,19 @@
[centos-7.2]
name=CentOS 7.2 (aarch64)
osinfo=centos7.2
arch=aarch64
file=centos-7.2-aarch64.xz
checksum=e61c5381026c419110ec42626c1cbb0e081240ae4d8c70f5bac2c80d771d5159b72dd3723068cf3cc9339e095b05b62d29ba9c22ef199f53a4e89c07e5615ca3
format=raw
size=6442450944
compressed_size=248167668
expand=/dev/sda4
notes=CentOS 7.2 (aarch64)
This CentOS image contains only unmodified @Core group packages.
It is thus very minimal. The kickstart and install script can be
found in the libguestfs source tree:
builder/website/centos-aarch64.sh

View File

@@ -0,0 +1,19 @@
[centos-7.2]
name=CentOS 7.2
osinfo=centos7.2
arch=x86_64
file=centos-7.2.xz
checksum=b32e6003d1f15e3a97e3644e35bb3fdc345a9b2e7448655d951ec331af6cd2b5548d6acfc9d92f09ac3a8a6439069c27fa539997118cb8a3f77d3bfa45c659d0
format=raw
size=6442450944
compressed_size=252158848
expand=/dev/sda3
notes=CentOS 7.2
This CentOS image contains only unmodified @Core group packages.
It is thus very minimal. The kickstart and install script can be
found in the libguestfs source tree:
builder/website/centos.sh

View File

@@ -0,0 +1,21 @@
[centos-7.3]
name=CentOS 7.3
osinfo=centos7.3
arch=x86_64
file=centos-7.3.xz
revision=2
checksum[sha512]=07c8941506b1104a2571912060dc275455924415222397316fe28efd5501979c75a23c59b946acad481160b5260f61585c64777a4a9fe6f8365f9fa29df68e6c
format=raw
size=6442450944
compressed_size=294531760
expand=/dev/sda2
lvexpand=/dev/cl/root
notes=CentOS 7.3
This CentOS image contains only unmodified @Core group packages.
This template was generated by a script in the libguestfs source tree:
builder/templates/make-template.ml
Associated files used to prepare this template can be found in the
same directory.

View File

@@ -0,0 +1,28 @@
# Kickstart file for centos-7.3
# Generated by libguestfs.git/builder/templates/make-template.ml
install
text
reboot
lang en_US.UTF-8
keyboard us
network --bootproto dhcp
rootpw builder
firewall --enabled --ssh
timezone --utc America/New_York
selinux --enforcing
bootloader --location=mbr --append="console=tty0 console=ttyS0,115200 rd_NO_PLYMOUTH"
zerombr
clearpart --all --initlabel
autopart --type=lvm
# Halt the system once configuration has finished.
poweroff
%packages
@core
%end
# EOF

View File

@@ -0,0 +1,19 @@
[centos-7.4]
name=CentOS 7.4
osinfo=centos7.4
arch=x86_64
file=centos-7.4.xz
checksum[sha512]=593a0c2534b097ddb7bcf55f64d0095c6042f9d611ee297d56e8cf37d31e9c72df77bcbdd1580d704cef25b063df43935c8bf05c79fca362a89e3a633616ea6d
format=raw
size=6442450944
compressed_size=309453024
expand=/dev/sda3
notes=CentOS 7.4
This CentOS image contains only unmodified @Core group packages.
This template was generated by a script in the libguestfs source tree:
builder/templates/make-template.ml
Associated files used to prepare this template can be found in the
same directory.

View File

@@ -0,0 +1,28 @@
# Kickstart file for centos-7.4
# Generated by libguestfs.git/builder/templates/make-template.ml
install
text
reboot
lang en_US.UTF-8
keyboard us
network --bootproto dhcp
rootpw builder
firewall --enabled --ssh
timezone --utc America/New_York
selinux --enforcing
bootloader --location=mbr --append="console=tty0 console=ttyS0,115200 rd_NO_PLYMOUTH"
zerombr
clearpart --all --initlabel
autopart --type=plain
# Halt the system once configuration has finished.
poweroff
%packages
@core
%end
# EOF

View File

@@ -0,0 +1,19 @@
[cirros-0.3.1]
name=CirrOS 0.3.1
arch=x86_64
file=cirros-0.3.1.xz
checksum=096209f00eb62d5722accf3d22ca3a4ee5baaac6d7d4ce0be93b56bbd1c8ab2e3eb4f5db1deffcb570e2c3d41f4d721798a1c499675346cee9546554a4b10388
format=raw
size=41126400
compressed_size=11419004
expand=/dev/sda1
notes=CirrOS 0.3.1
CirrOS is a commonly used test image, ideal because it is very
small and boots into a minimally usable Linux system.
Note this is not a real Linux distribution, and several virt-builder
features such as installing packages will not (and cannot) work.
This CirrOS image comes from https://launchpad.net/cirros

View File

@@ -0,0 +1,21 @@
[cirros-0.3.5]
name=CirrOS 0.3.5
arch=x86_64
file=cirros-0.3.5.xz
checksum=77f74203aa26e843e83f522ba44d765c6ba9ab595c19c14d629064c71f875158beb7e93e7b6ac5e6895c6e3b6daa8b94d7286230b9fdf166ae65d0d6e9c9329a
format=raw
size=41126400
compressed_size=11479284
expand=/dev/sda1
notes=CirrOS 0.3.5
CirrOS is a commonly used test image, ideal because it is very
small and boots into a minimally usable Linux system.
Note this is not a real Linux distribution, and several virt-builder
features such as installing packages will not (and cannot) work.
This CirrOS image comes from https://download.cirros-cloud.net/0.3.5/
and was prepared by running qemu-img convert .. -O raw followed by
xz --best.

View File

@@ -0,0 +1,32 @@
[debian-6]
name=Debian 6 (Squeeze)
osinfo=debian6
arch=x86_64
file=debian-6.xz
revision=2
checksum=bff9c28da0375fde65fa238d7a2ea644cbfad0ea3246783a2f44a98f2374850987679c3f1032a632d3c6238de8d9e43291d07a82efc1e824945000e206b9f6cc
format=raw
size=4294967296
compressed_size=139615908
expand=/dev/sda1
notes=Debian 6 (Squeeze).
This is a default Debian install.
The preseed and virt-install scripts that produced this image
can be found in the libguestfs source tree:
builder/website/debian.preseed
builder/website/debian.sh
This image is so very minimal that it only includes an ssh
server and no virtual consoles. To enable virtual consoles
use this virt-builder option:
virt-builder debian-6 \
--edit '/etc/inittab: s,^#([1-9].*respawn.*/sbin/getty.*),$1,'
This image does not contain SSH host keys. To regenerate them use:
--firstboot-command "dpkg-reconfigure openssh-server"

View File

@@ -0,0 +1,35 @@
[debian-7]
name=Debian 7 (Wheezy) (sparc64)
osinfo=debian7
arch=sparc64
file=debian-7-sparc64.xz
checksum=a81530ec2335d578e54fcf3c62b979a2985faee8e6480a49e7d24269097c89585f39a04b00d99e82aca00f3304c44dfbed843ce6ce5dcd7828256a51219b701f
format=raw
size=4294967296
compressed_size=96292208
expand=/dev/sda3
notes=Debian 7 (Wheezy).
This is a Debian 7 (Wheezy) sparc64 image. This was not built using
a reproducible script, but by installing Debian by hand, so don't use
this in production.
There is also a 'debian' account which you should be aware of and
may need to remove.
To build the image, use:
virt-builder [...] \
--edit '/etc/inittab: s,^#([1-9].*respawn.*/sbin/getty.*),$1,' \
--firstboot-command "dpkg-reconfigure openssh-server"
Resizing the image will not work because virt-builder does not
understand the partition format.
To boot the image:
qemu-system-sparc64 -drive file=debian-7.img,format=raw -serial stdio
Console messages are lost after the bootconsole is disabled, but it
is still booting and will eventually give you a login prompt.

View File

@@ -0,0 +1,25 @@
[debian-7]
name=Debian 7 (wheezy)
osinfo=debian7
arch=x86_64
file=debian-7.xz
revision=3
checksum[sha512]=428d5867009c49bdffe3e752c68da7aa17fac415a308dffe1a0863376325aed93945500afedc0dd14b06f1b1e86598c0445c63c3bc3be91aafe4de7a0aefcbdd
format=raw
size=6442450944
compressed_size=200048080
expand=/dev/sda1
notes=Debian 7 (wheezy)
This is a minimal Debian install.
This image is so very minimal that it only includes an ssh server
This image does not contain SSH host keys. To regenerate them use:
--firstboot-command "dpkg-reconfigure openssh-server"
This template was generated by a script in the libguestfs source tree:
builder/templates/make-template.ml
Associated files used to prepare this template can be found in the
same directory.

Some files were not shown because too many files have changed in this diff Show More