Compare commits

...

3381 Commits

Author SHA1 Message Date
Richard W.M. Jones
9e0bb093e3 Version 1.59.2. 2026-01-26 15:00:54 +00:00
Richard W.M. Jones
45d0e66d02 tests/disks/debug-qemu.sh: Fix test for update QMP test
Commit f7a24b2ea8 ("lib/qemu.c: Use machine type none when inspecting
QMP properties") changed the number of command line parameters used
before the '-qmp stdio' option when libguestfs queries qemu features.
This broke some tests which rely on the exact order of parameters.

Fixes: commit f7a24b2ea8
Updates: commit 5da8102f5f
2026-01-26 14:59:13 +00:00
Richard W.M. Jones
7833461af7 generator: Deprecate xfs_info (replaced by xfs_info2)
Deprecate this function, and suggest using xfs_info2 as its
replacement.
2026-01-26 14:40:39 +00:00
Richard W.M. Jones
e1deb358ce daemon: Reimplement xfs_info using xfs_info2
Remove all the complicated old C parsing code and reimplement xfs_info
using xfs_info2.  Note that this function will be deprecated.
2026-01-26 14:40:39 +00:00
Richard W.M. Jones
dfd2700616 New API: xfs_info2
Reimplement xfs_info by returning a hash table of values (rather than
a limited struct), and by writing it in OCaml with PCRE which makes
string parsing a lot simpler.  This will now flexibly return all the
fields from the underlying xfs_info command, even (hopefully) future
fields.

Note the field values are returned as strings, because the actual
fields in xfs_info output are fairly random and free-form.  There is a
trade off here between returning as much information as we can, and
requiring the user to do a bit of (simple) field parsing.

Fixes: https://issues.redhat.com/browse/RHEL-143673
2026-01-26 14:40:39 +00:00
Richard W.M. Jones
1c9c03bcd4 generator: Fix description of xfs_info
The returned struct contains filesystem metadata, not "geometry
information" (whatever that means).
2026-01-26 14:40:39 +00:00
Richard W.M. Jones
6166304be6 generator: Fix description of xfs_growfs
This function does not return "geometry information".  Remove
the bogus description.
2026-01-26 14:40:39 +00:00
Richard W.M. Jones
f7a24b2ea8 lib/qemu.c: Use machine type none when inspecting QMP properties
Dan mentioned that there is a special machine type ("none") we can use
when querying for KVM.  It has no CPU, memory, etc and does not run,
but you can still enable KVM for it.

Note we have to remove the -cpu parameter, otherwise qemu prints this
error:

  qemu-kvm: apic-id property was not initialized properly

Updates: commit 5da8102f5f
Suggested-by: Daniel P. Berrangé <berrange@redhat.com>
2026-01-26 14:32:30 +00:00
Hosted Weblate
8dc104c2f0 Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/
2026-01-22 10:48:55 +00:00
Nathan
589066f2b1 Translated using Weblate (Italian)
Currently translated at 1.4% (205 of 14137 strings)

Translation: libguestfs/libguestfs-docs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-docs-master/it/
2026-01-22 10:48:55 +00:00
Richard W.M. Jones
1b79e22be4 generator/daemon.ml: Avoid not available macro for OCaml functions
Reported-by: Toolybird
Fixes: https://github.com/libguestfs/libguestfs/issues/290
2026-01-19 22:19:27 +00:00
Richard W.M. Jones
8b3fc15190 website/index.html.in: Fix stable/development branch links 2026-01-19 19:43:56 +00:00
Richard W.M. Jones
9ffe190fbe Version 1.59.1. 2026-01-19 19:42:01 +00:00
Richard W.M. Jones
da70ed1360 po: Keep LINGUAS files sorted 2026-01-19 18:51:36 +00:00
Nathan
bb649ff0ba Added translation using Weblate (Italian) 2026-01-19 18:51:01 +00:00
Temuri Doghonadze
f887d3cb54 Translated using Weblate (Georgian)
Currently translated at 16.6% (160 of 962 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/ka/
2026-01-19 18:51:01 +00:00
Hosted Weblate
0443ba7778 Update translation files
Updated by "Update LINGUAS file" hook in Weblate.

Translation: libguestfs/libguestfs-docs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-docs-master/

Update translation files

Updated by "Update LINGUAS file" hook in Weblate.

Translation: libguestfs/libguestfs-docs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-docs-master/

Update translation files

Updated by "Update LINGUAS file" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/
2026-01-19 18:51:01 +00:00
Languages add-on
b6bb5b96c2 Added translation using Weblate (Italian)
Added translation using Weblate (Telugu)

Added translation using Weblate (Tamil)

Added translation using Weblate (Russian)

Added translation using Weblate (Polish)

Added translation using Weblate (Punjabi)

Added translation using Weblate (Odia)

Added translation using Weblate (Marathi)

Added translation using Weblate (Malayalam)

Added translation using Weblate (Kannada)

Added translation using Weblate (Georgian)

Added translation using Weblate (Hindi)

Added translation using Weblate (Gujarati)

Added translation using Weblate (Portuguese (Brazil))
2026-01-19 18:51:01 +00:00
Richard W.M. Jones
548af2929e daemon/selinux.c: Fix compilation when no libselinux
/usr/bin/ld: /tmp/ccvSGq6E.ltrans7.ltrans.o:(.data.rel.ro+0x1f8): undefined reference to `optgroup_selinuxrelabel_available'

The reason is that we didn't include optgroup_selinuxrelabel_available
on the fallback / no libselinux code path.

Reported-by: David Runge
Thanks: Toolybird
Fixes: https://github.com/libguestfs/libguestfs/issues/290
Fixes: commit ed40333a23
2026-01-19 14:53:12 +00:00
Richard W.M. Jones
29162f5fe5 lib/appliance-cpu.c: Use -cpu max for RISC-V
Reported-by: https://github.com/Apache553
Fixes: https://github.com/libguestfs/libguestfs/issues/292
2026-01-19 14:53:00 +00:00
Anders Roxell
7fee08e53f tar_in: add keepdirlink option for --keep-directory-symlink
Add a new optional boolean argument 'keepdirlink' to tar_in that passes
--keep-directory-symlink to tar. This preserves existing symlinks to
directories when extracting, which is important for usrmerge systems
where /lib is a symlink to /usr/lib.

Without this option, extracting a tarball containing lib/modules/...
to / would replace the /lib symlink with a real directory, breaking
the system.

Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
2026-01-19 12:39:59 +00:00
Richard W.M. Jones
5da8102f5f lib/qemu.c: Don't start the guest when checking QMP properties
When checking for QMP properties, we run a qemu command and interact
with the QMP console.  However we also start the guest running (there
is no actual guest in this situation).  This occasionally causes this
line to be printed:

  libguestfs: generic_qmp_test: 3: {"timestamp": {"seconds": 1768823946, "microseconds": 898287}, "event": "GUEST_PANICKED", "data": {"action": "poweroff", "info": {"core": 0, "psw-addr": 0, "reason": "disabled-wait", "psw-mask": 562956395872256, "type": "s390"}}}\r\n

which confuses our parser.

As there is no reason to start the non-existent guest, add the -S
option which causes qemu to start up in a paused state.

For some reason this only happens on s390x but I think it could happen
on all architectures, so it may be a timing issue or something
particular about s390x firmware.
2026-01-19 12:03:59 +00:00
Richard W.M. Jones
bbbc982bf5 lib/qemu.c: Add debugging to generic_qmp_test()
This function fails sometimes on s390x, but it's hard to tell what is
going on because of insufficient debugging.
2026-01-19 10:27:24 +00:00
Richard W.M. Jones
0fe8c0492c lib/qemu.c: Turn debug messages which are really errors into error()
Commit 669eda1e24 ("lib/launch-direct.c: Simplify test for KVM, remove
qemu caching") made it so that failure of generic_qmp_test() will
cause launch to fail.  However we still used debug messages to print
the error, so unless you have debugging enabled you wouldn't see any
error message if this function fails.

Updates: commit 669eda1e24
2026-01-19 10:20:55 +00:00
Hosted Weblate
d16be4592b Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/
2026-01-06 12:57:49 +00:00
Andi Chandler
aeebfc34c3 Translated using Weblate (English (United Kingdom))
Currently translated at 55.7% (7384 of 13236 strings)

Translation: libguestfs/libguestfs-docs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-docs-master/en_GB/
2026-01-06 12:57:49 +00:00
Richard W.M. Jones
d618d8eb0c Version 1.58.0. 2026-01-05 16:19:15 +00:00
Richard W.M. Jones
522c564298 docs/guestfs-release-notes-1.58.pod: Update for 1.58 release 2026-01-05 16:16:43 +00:00
Richard W.M. Jones
c7b204bce3 daemon/device-name-translation.c: Fix btrfs volume reverse translation
Devices associated with btrfs volumes are not reverse-translated
(e.g., btrfsvol:/dev/sdX to sdY).

Forward translation occurs, creating a path mismatch.  This causes
errors in subsequent btrfs commands.

Thanks: Arye Yurkovsky
2025-12-10 12:31:15 +00:00
Arye Yurkovsky
62b0e2ab64 daemon: lvm_utils: Further narrow stat failure to ENOENT
Missed the 2nd stat
2025-12-08 17:40:59 +00:00
Arye Yurkovsky
6aebf70e18 daemon: lvm_utils: Narrow stat failure to ENOENT
And remove redundant parantheses.
To only catch the failure we want to catch.
2025-12-08 17:40:59 +00:00
Arye Yurkovsky
c7228cd1ce daemon: lvm_utils: Handle stat errors
lvm returns logical volumes even if they're broken, for instance when a
physical volume is missing in their volume group.
In such cases, stat would fail to resolve the provided path.
Handle such cases by skipping such failures when finding the matching
lvm device.
2025-12-08 17:40:59 +00:00
Richard W.M. Jones
c56e6ff39b Version 1.57.7. 2025-12-04 13:16:56 +00:00
Susant Sahani
3c73a71626 tests: drop test-btrfs-misc perl file
Fixes: commit c27f3d41b1

Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-12-04 10:53:07 +00:00
Susant Sahani
1387e7f6a8 tests: nbd - convert to python
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-12-03 15:39:41 +00:00
Susant Sahani
fff03b7135 tests: selinux-label - convert to python
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-12-03 15:35:19 +00:00
Susant Sahani
1f739979bb tests: lvm-mapping - convert to python
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-12-03 15:32:56 +00:00
Susant Sahani
8f187bf97b tests: console-debug - convert to python
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-12-03 15:30:54 +00:00
Susant Sahani
bab46df1c6 tests: disk-labels - convert to python
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-12-03 15:29:26 +00:00
Susant Sahani
7f7eeb6668 tests: btrfs - subvolume-default convert to python
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-12-02 10:44:23 +00:00
Susant Sahani
c27f3d41b1 tests: btrfs - test-btrfs-misc convert to python
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-12-02 10:44:23 +00:00
Susant Sahani
7df1e9c359 tests: journal - convert to python
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-12-02 10:42:43 +00:00
Susant Sahani
817fb83742 tests: xfs - convert to python
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-12-02 10:37:05 +00:00
Susant Sahani
bd75288c5a fuse: use modern sigaction initialization for ignored signals
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-12-01 16:28:12 +00:00
Susant Sahani
19c40e5f34 tests: tmpdirs - convert to python
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-12-01 16:17:19 +00:00
Richard W.M. Jones
40fdcd0146 fish: Fix const correctness in strrchr
In C23, strchr or strrchr on a const parameter now returns a const
pointer.  We saw this error:

destpaths.c: In function ‘complete_dest_paths_generator’:
destpaths.c:165:9: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
  165 |       p = strrchr (text, '/');
      |         ^
2025-12-01 14:00:57 +00:00
Fco. Javier F. Serrador
fa7a18ed36 Translated using Weblate (Spanish)
Currently translated at 4.1% (551 of 13236 strings)

Translation: libguestfs/libguestfs-docs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-docs-master/es/

Translated using Weblate (Spanish)

Currently translated at 62.8% (605 of 962 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/es/
2025-12-01 12:01:42 +00:00
Susant Sahani
4349548c83 lib/create: explicitly close fd and report close(2) errors
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-11-27 13:15:11 +00:00
Susant Sahani
192e086f66 lib/create: fix indentation in guestfs_impl_disk_create()
Convert tabs to spaces and align parameters correctly.

Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-11-27 11:04:10 +00:00
Susant Sahani
a3a4fc2ba9 lib/create: use bool for is_power_of_2() return type
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-11-27 11:03:19 +00:00
Susant Sahani
60f60e9f4e lib/create: use compound initializer for BLKDISCARD range 2025-11-27 11:02:06 +00:00
Susant Sahani
7d22402500 lib: Use bool type for allocated flag in disk creation
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-11-27 08:48:25 +00:00
Susant Sahani
3aaaf4f667 lib: Use compound initialization for buffer in disk creation
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-11-27 08:48:02 +00:00
Susant Sahani
cf6ac9aeba lib: Add automatic file descriptor cleanup using CLEANUP_CLOSE attrib
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-11-27 08:46:51 +00:00
Susant Sahani
40e549294e drives: Modernize guestfs_impl_add_drive_opts initialization
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-11-26 15:17:50 +00:00
Susant Sahani
b4d795c13d lib: Modernize guestfs_int_drive_protocol_to_string to use static array
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-11-26 15:17:50 +00:00
Susant Sahani
19b208777a fuse: Modernize mount_local_readdir with compound literal struct stat init
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-11-26 15:16:56 +00:00
Susant Sahani
257bfad817 appliance: Modernize guestfs_int_build_appliance with compound literal
No functional change.

Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-11-26 15:15:33 +00:00
Susant Sahani
0a8d1aefef daemon: tsk - Fix memory leak
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-11-24 11:15:23 +00:00
Susant Sahani
b5000cf547 daemon: send_dirent_info: Use designated compound literal for tsk_dirent
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-11-24 11:15:23 +00:00
Richard W.M. Jones
56da6b36d3 daemon: btrfs: Simplify snapshot code and fix invalid memory access
The existing code had a bug which you can demonstrate by doing:

  $ guestfish -N fs:btrfs:10G -m /dev/sda1 \
  btrfs-subvolume-create /sub :
  btrfs-subvolume-snapshot /sub /snap1 : \
  btrfs-subvolume-snapshot /sub /snap123 : \
  btrfs-subvolume-snapshot /sub /snap123456 : \
  btrfs-subvolume-show /sub
  ...
  libguestfs: error: appliance closed the connection unexpectedly.
  This usually means the libguestfs appliance crashed.

As the code for parsing the output and creating the comma-separated
list of snapshots was unncessarily complicated in the first place,
simplify it.  This also fixes the bug.

This also adds a regression test.

Thanks: Arye Yurkovsky
Link: https://lists.libguestfs.org/archives/list/guestfs@lists.libguestfs.org/thread/QV5VDHIH7WRUNAE54K6OEOKJMWL6M7EM/
2025-11-24 10:44:44 +00:00
Susant Sahani
6c8e3992fc fuse: Modernize mount_local_getattr with compound literal stat init
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-11-24 10:14:37 +00:00
Susant Sahani
b0f3d711cb lib: fuse - Replace strdup + safe_malloc with safe_strdup/safe_memdup in copy_xattr_list
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-11-24 10:14:37 +00:00
Susant Sahani
c3ccd2164f fuse: Modernize mount_local_statfs using compound literal statvfs init
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-11-24 10:14:37 +00:00
Susant Sahani
8ce7e08e1b drive-create: Modernize create_drive_file using compound literal
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-11-24 10:09:03 +00:00
Susant Sahani
0bd33f87ce daemon: stat_to_statns: Modernize with designated initializer
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-11-24 09:58:22 +00:00
Susant Sahani
0c437e52d6 daemon: bind_mount: Initialize struct bind_state with compound literal
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-11-24 09:58:05 +00:00
Susant Sahani
799b04fe3e daemon: Convert do_set_uuid_random to table-driven dispatch
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-11-24 09:49:03 +00:00
Susant Sahani
174014933a daemon: use table-driven dispatch in do_set_uuid
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-11-24 09:49:03 +00:00
Susant Sahani
301b9bc481 daemon: set-label: Convert to table-driven dispatch
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-11-24 09:47:21 +00:00
Susant Sahani
276897c4df daemon: Use modern compound literal for SIGPIPE ignore
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-11-21 18:58:00 +00:00
Susant Sahani
25485036a6 fuse: Modernize SIGPIPE handler using compound literal
No functional change.

Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-11-21 14:04:23 +00:00
Susant Sahani
4f19d68565 daemon: Use designated initializer for struct sockaddr_un
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-11-21 14:02:14 +00:00
Susant Sahani
3940b79041 parted: Modernize check_parttype() with table-driven mapping
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-11-21 13:57:26 +00:00
Richard W.M. Jones
18d9769dc3 python: Include <Python.h> first
Python is broken and requires that we include <Python.h> before all
other headers so it can make inadvisable definitions of
_POSIX_C_SOURCE and other things.  This wasn't a problem before, but a
recent change to glibc makes this necessary now.

See also a similar commit in nbdkit:
f924c3c34b

I also removed the -Wcast-align suppression as that is no longer
needed.
2025-11-20 21:00:29 +00:00
Susant Sahani
e04a450ec7 daemon: modernize program_of_csum() using table lookup
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-11-20 13:11:47 +00:00
Susant Sahani
3c56167615 daemon: use compound literal in send_error()
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-11-20 11:22:56 +00:00
Susant Sahani
4b81c6f2b1 daemon: use compound literal for reply header
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-11-20 11:22:56 +00:00
Susant Sahani
b983586eb3 daemon: modernize send_file_write() with compound literal
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-11-20 11:22:56 +00:00
Susant Sahani
bad58301fb daemon: use compound literal for zero timeval in check_for_library_cancellation
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-11-20 11:22:56 +00:00
Susant Sahani
60c06f3287 daemon: modernize send_file_end() with compound literal
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-11-20 11:22:56 +00:00
Susant Sahani
a0c9b41d35 daemon: modernize notify_progress_no_ratelimit: compound literal
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-11-20 10:36:57 +00:00
Susant Sahani
23257770a8 daemon: modernize pulse_mode_start with compound literals
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-11-20 08:47:44 +00:00
Susant Sahani
6c8763dcb5 daemon: modernize pulse_mode_cancel with compound literals
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-11-20 08:47:44 +00:00
Susant Sahani
0326b61157 fish: Modernize signal handler setup using compound literals
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-11-19 20:32:46 +00:00
Richard W.M. Jones
f2dbcdcce9 github: Use ./configure --enable-werror
We should test with compiler warnings turned into errors, to avoid
warnings being inadvertently introduced in new code.
2025-11-19 19:37:47 +00:00
Susant Sahani
9a871a1948 fish: Initialize more CLEANUP_FREE variables to NULL
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-11-19 15:14:39 +00:00
Susant Sahani
7e5ace69bc fish: use compound literal to reset SIGPIPE handler
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-11-19 15:14:24 +00:00
Richard W.M. Jones
bb4c105554 docs: Add another release note that was missed in previous commit
Fixes: commit 9d278d858f
2025-11-19 14:15:47 +00:00
Richard W.M. Jones
9d278d858f docs: Add outline release notes for libguestfs 1.58
This will be released some time in December.
2025-11-19 13:43:56 +00:00
Richard W.M. Jones
f1c9ed7556 docs/guestfs-building.pod: Require libvirt >= 11.10.0
This (actually unreleased) version of libvirt is required because of
bugs in parallel relabelling of the kernel and initrd.  For details
see:

https://github.com/libguestfs/libguestfs/issues/234
https://lists.libvirt.org/archives/list/devel@lists.libvirt.org/thread/AZCDGCUYCRM3TLFIWSS5P2UMCAFRDNJ4/

Thanks: Cole Robinson
2025-11-19 13:18:47 +00:00
Yuri Chornoivan
13a6674a2b Translated using Weblate (Ukrainian)
Currently translated at 100.0% (962 of 962 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/uk/
2025-11-18 22:12:33 +00:00
Susant Sahani
da0239382a fish: Use size_t instead of int for iteration over an array
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-11-18 16:44:25 +00:00
Susant Sahani
042d1f829a fish: Initialize variable to NULL
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-11-18 14:40:49 +00:00
Weblate
1ba1b2abfc Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/
2025-11-18 08:22:08 +00:00
Pavel Borecki
8ecfb35346 Translated using Weblate (Czech)
Currently translated at 46.3% (445 of 960 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/cs/
2025-11-18 08:22:08 +00:00
Weblate
f39cf9fcb4 Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/
2025-11-18 08:22:08 +00:00
Ettore Atalan
8f871229f1 Translated using Weblate (German)
Currently translated at 33.9% (326 of 960 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/de/
2025-11-18 08:22:08 +00:00
Susant Sahani
f057044480 fish: Use size_t instead of int for iteration over an array
Signed-off-by: Susant Sahani <ssahani@redhat.com>
2025-11-13 16:59:48 +00:00
Richard W.M. Jones
1aff72549c tests/protocol/test-both-ends-cancel.sh: Delete this test
It tests a corner case that we don't experience in real life (although
it can happen).  Moreover the test often hangs, so we're not proving
anything except that there's a very obscure bug that we haven't fixed
and probably won't ever fix.
2025-11-06 18:35:50 +00:00
Cole Robinson
fde79f7c91 tests: test-network.sh: check guest gets expected IP
I wanted to confirm that some selinux AVCs I was seeing were not
causing runtime issues

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2025-11-05 14:41:49 -05:00
Cole Robinson
e209e14f4c tests: test-nbd.pl: label unix socket svirt_image_t
Part of this test uses `qemu-nbd -k SOCKPATH`, and passes
that socket to libvirt. SOCKPATH will have label user_home_t,
which svirt_t can't access, so running with selinux enforcing this
test will always fail.

Manually change the socket label to svirt_image_t which makes
selinux happy.

Note: libvirt does not relabel most (all?) externally managed socket
paths. I think this is correct, since in theory this could be a
socket shared with other processes, so its up to the user to ensure
DAC/MAC permissions are acceptable for their usecase.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2025-11-05 14:41:49 -05:00
Cole Robinson
50bd1fc4c2 tests: gdisk: skip if sgdisk not found on host
really what we need is sgdisk in the appliance, but for test suite
purposes this check is enough IMO

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2025-11-05 14:41:49 -05:00
Cole Robinson
005e701b77 tests: don't print absolute paths in test output
To match other non-libtool tests.

Before: PASS: /path/to/libguestfs.git/tests/c-api/.libs/test-config
After:  PASS: c-api/.libs/test-config

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2025-11-05 14:41:49 -05:00
Richard W.M. Jones
28bc6ca6b9 lib/match.c: Emit a debug message if pcre2_match returns an unexpected error
When iterating on commit 3c1554e7f2 ("lib: Add new app2_class field
for classifying applications") in early versions I was accidentally
passing NULL to match().  Unexpectedly this returned 1 (ie. matching).
This happened because we did not correctly handle other errors apart
from PCRE2_ERROR_NOMATCH from pcre2_match.

Emit a debug message when this happens, and return no match.

To test this I ran these commands, and there was no output:

  $ make && LIBGUESTFS_DEBUG=1 LIBGUESTFS_TRACE=1 make check
  $ find -name '*.log' | xargs grep 'match.*unexpected error'
2025-11-05 15:23:12 +00:00
Richard W.M. Jones
07079ea6fc Version 1.57.6. 2025-11-04 16:20:10 +00:00
Richard W.M. Jones
a419076bd3 build: Remove config.rpath from EXTRA_DIST
Fixes: commit a497a24ecf
2025-11-04 16:19:08 +00:00
Richard W.M. Jones
476a78c75f Update common submodule
Add this generated change:

  Richard W.M. Jones (1):
      structs/structs-print.c: Update this generated file
2025-11-04 15:59:02 +00:00
Richard W.M. Jones
1db2b7837f daemon: inspect_get_windows_group_policy
Windows group policy objects (GPOs) are restrictions that can be added
by an administrator to Windows to lock down various operations.  From
our point of view the ones that matter involve restricting the ability
to inject device drivers.

Previously virt-v2v detected group policy here:

9bb2e7d470/convert/convert_windows.ml (L69)

We would like to report group policy through the libguestfs API and
tools such as virt-inspector, so move the code that is used to detect
group policy to libguestfs.  A new API is introduced that returns
whether group policy was found (only for Windows guests) during
inspection of the software registry.

Fixes: https://issues.redhat.com/browse/RHEL-125846
2025-11-04 15:56:33 +00:00
Richard W.M. Jones
355f8a5413 daemon/inspect_fs_windows.ml: Debug number of children
Just adds a useful debugging statement.
2025-11-04 15:56:33 +00:00
Richard W.M. Jones
344d96e158 lib/inspect-apps.c: Match name, display name and publisher across all regexs
For McAfee VirusScan, the name is bogus and the display name is the
actual name:

  <application>
    <name>{CE15D1B6-19B6-4D4D-8F43-CF5D2C3356FF}</name>
    <display_name>McAfee VirusScan Enterprise</display_name>
    <version>8.8.04001</version>
    <install_path>C:Program Files (x86)McAfeeVirusScan Enterprise\</install_path>
    <publisher>McAfee, Inc.</publisher>
    <url>http://www.mcafeesecurity.com/</url>
  </application>

Simplify the existing ad hoc code so we just match name, display name
and publisher (if present) against all the virus scanning strings.
2025-11-04 15:56:33 +00:00
Richard W.M. Jones
3c1554e7f2 lib: Add new app2_class field for classifying applications
Existing virt-v2v code uses some simple heuristics for detecting
Windows anti-virus software:

7520185504/convert/windows.ml

Replicate exactly this code as a new field in the struct returned by
guestfs_inspect_get_applications2.  Because of limitations with the
API, we must use one of the existing spare fields in the struct, and
it must have the same type (a string), so we are limited in the design
of this new API.  I chose to return a primary classification for the
application, with the only classification possible so far being
"antivirus" (or "" if not).  This allows the possibility of future
expansion of use of this field if we need to in future.

Fixes: https://issues.redhat.com/browse/RHEL-125846
2025-11-04 15:56:33 +00:00
Cole Robinson
04705f2aba gobject: skip test run-tests-retvalues
This is currently broken, and gobject bits are slated to be
removed entirely, so just disable this test.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2025-11-03 15:54:03 -05:00
Cole Robinson
967587b061 ruby: fix deprecation warnings
Convert to TypedData_Get_Struct which has been in ruby since 2009

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2025-11-03 15:53:50 -05:00
Cole Robinson
a497a24ecf build: remove config.rpath
It was added in d4a1c3a778 for gnulib, but since then gnulib
is no longer a submodule, and it does not seem to be required
for the build anylonger.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2025-10-29 09:58:28 -04:00
Cole Robinson
12acfa7de3 build: replace AM_GNU_GETTEXT with simpler LIBINTL check
This reverts "m4: Add junk required to make 'AM_GNU_GETTEXT' work"
commit b9f75ca5b8

And replaces AM_GNU_GETTEXT call with a simpler LIBINTL check
(recommended by claude).

For linux builds on glibc it doesn't appear we need anything
from autotools here, since libintl.h is always available.

For some other cases like macos I think this new minimal check
covers us in the common case.

There are definitely more obscure corner cases that gettext
m4 magic covers but I suspect none of them really matter for
any platforms libguestfs already functions on.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2025-10-29 09:58:28 -04:00
Cole Robinson
4d3197c3c9 tests: python: fix test820RHBZ912499.py
This tests adding a running libvirt domain to libguestfs.
This was never really a safe real-world example AFAICT because it
creates qemu overlays on top of disks that are opened writeable
by the source guest.

Nowadays qemu uses write locks to reject this type of behavior,
and the test fails.

Adjust things so the source VM opens its storage readonly, but
we are still confirming that add_libvirt_dom doesn't mess up
selinux labels.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2025-10-23 11:22:55 +01:00
Cole Robinson
1b791fdcd3 lib/launch-libvirt.c: avoid libvirt svirt validation error
If a user passes a custom hv, and uses add_libvirt_dom (like
in test820RHBZ912499.py) , this hits a bogus libvirt validation
check which rejects disabling svirt at both domain and disk level.

Work around it by skipping the redundant disk override when
svirt is disabled at the domain level.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2025-10-23 11:22:55 +01:00
Cole Robinson
acb785fede lib/launch-libvirt.c: check if g->hv symlink matches libvirt default
On fedora, ./configure will set QEMU=qemu-kvm, but libvirt
domcaps will default to qemu-system-x86_64. The former is a symlink
to the latter, but libguestfs doesn't know that, so determines
the user requested a non-default hv override and changes some
settings as a result (like disabling svirt).

Check for the symlink case and consider it a non-custom config
if realpath matches libvirt's default

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2025-10-23 11:22:55 +01:00
Cole Robinson
55ea21d4b3 lib/launch-libvirt.c: debug is_custom_hv result
Add debugging about is_custom_hv result.
cache the initial call so we are only hitting the debug() once.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2025-10-23 11:22:55 +01:00
Cole Robinson
81e9f81a6e lib/launch-libvirt.c: simplify is_custom_hv
g->hv is always set in lib/handle.c

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2025-10-23 11:22:55 +01:00
Cole Robinson
e051891347 lib/launch-libvirt.c: make model='selinux' disabling explicit
Using `<seclabel type='none'/>` implies `model=selinux`, so lets fill it
in to be explicit.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2025-10-23 11:22:55 +01:00
Cole Robinson
949679993e lib/launch-libvirt.c: Simplify root socket permissions
libvirt has DAC relabeled sockets for us for a decade, so we don't
need to do chowning here anymore

The chmod calls are still required, otherwise our created sockets
may be too permissive.

Update the comment to try and preserve the still relevant info,
though now it's a bit awkwardly placed.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2025-10-23 11:22:55 +01:00
Cole Robinson
62309ab40c lib/launch-libvirt.c: don't write <seclabel><imagelabel>
<imagelabel> is an output-only XML element. setting it when
defining XML does nothing

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2025-10-23 11:22:55 +01:00
Richard W.M. Jones
f6a63d08d4 Version 1.57.5. 2025-10-17 10:43:32 +01:00
Richard W.M. Jones
7398fdc77c lib/launch-direct.c: Remove workaround that disabled 5-level page tables
https://bugzilla.redhat.com/2082806 is a private kernel bug (sigh) for
RHEL 8, where some missing backports caused 5-level page tables to
fail when qemu emulated them.  This was fixed back in 2023, so let's
remove this workaround now.
2025-10-17 09:57:53 +01:00
Richard W.M. Jones
ac1cb3cd7c lib/qemu.c: Add -cpu max when testing for KVM via QMP
On RHEL 10.2 aarch64 (only) we see:

  $ echo '{ "execute": "qmp_capabilities" }' '{ "execute": "query-kvm" }' '{ "execute": "quit" }'  | QEMU_AUDIO_DRV=none "/usr/libexec/qemu-kvm" -display none -machine "virt,accel=kvm:hvf:tcg" -qmp stdio
  qemu-kvm: invalid accelerator hvf
  qemu-kvm: falling back to KVM
  {"QMP": {"version": {"qemu": {"micro": 0, "minor": 1, "major": 9}, "package": "qemu-kvm-9.1.0-15.el10_0.4"}, "capabilities": ["oob"]}}
  qemu-kvm: warning: CPU model cortex-a57-arm-cpu is deprecated -- use 'host' / 'max'
  qemu-kvm: kvm_init_vcpu: kvm_arch_init_vcpu failed (0): Invalid argument

Unfortunately we cannot use guestfs_int_get_cpu_model (as that
requires us to already know if KVM is supported), so we just have to
guess that -cpu max will work, at least enough for QMP to work.

Fixes: https://issues.redhat.com/browse/RHEL-121076
Reported-by: Xiang Hua Chen
2025-10-17 09:57:14 +01:00
Cole Robinson
d42227e083 generator: deprecate and remove --sm-* options
virt-customize and friends have the following options:

--sm-register
--sm-unregister
--sm-attach
--sm-remove
--sm-credentials

These run `subscription-manager` commands inside the VM, which
is often necessary to get working package install for RHEL VMs.

These were added in 2015ish. Conceptually I understand why we
might want native support in the tools: virt-customize and
virt-builder have package management knowledge, and
for some distros subscription-manager is necessary.

But this support doesn't add much convenience over calling the commands
directly with `--run-command`. And on RHEL10, subscription-manager was
reworked and complete drops the backing commands for `--sm-attach` and
`--sm-remove`.

We _could_ make this code smarter, try to detect that situation,
and not error when subscription-manager is new enough. But if
subscription-manager itself doesn't care about maintaining that kind
of compat, I'm not sure why we should care either.

Instead we decided to just rip it all out and document the
alternatives.

common module is updated to sync related changes:

  Cole Robinson (1):
        mlcustomize: deprecate and remove --sm-* options

  Richard W.M. Jones (3):
        mlstdutils: Export List.find_opt
        daemon, generator: Use power of 2 for initial size of Hashtbl.create
        mlcustomize/inject_virtio_win.ml: Use viostor.inf instead of guestor

https://issues.redhat.com/browse/RHEL-113397
https://issues.redhat.com/browse/RHEL-113398

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2025-10-14 18:47:30 +01:00
Cole Robinson
630628af78 tests: increase guestunmount retries for test-parallel-mount-local
test-parallel-mount-local reliably fails when my machines are
under load (like running the test suite in parallel). The
issue is /usr/libexec/gvfs-udisks2-volume-monitor fiddling with
the fuse mounts, preventing them from being unmounted.

./fuse/guestunmount defaults to 5 unmount retries with increasing
time backoff, but apparently that isn't enough. Bumping it to
use 10 retries makes things more reliable for me.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2025-10-14 18:26:45 +01:00
Richard W.M. Jones
e75018a534 fuse/guestunmount.c: Include <signal.h>
On macOS this fails with:

  guestunmount.c:170:5: error: call to undeclared function 'sigaction'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    170 |     sigaction (SIGINT, &sa, NULL);
        |     ^
  1 error generated.

Reported-by: Mohamed Akram
Related: https://github.com/libguestfs/libguestfs/pull/188
2025-10-07 14:06:46 +01:00
Richard W.M. Jones
63a2ed92b4 fuse: Ignore extra options parameter on macOS
macOS macfuse has an extra options parameter for the setxattr and
getxattr FUSE callbacks.  The possible options are documented below.
However the underlying libguestfs APIs don't allow us to act on these
flags, so we ignore them for now.

(from https://manp.gs/mac/2/setxattr)

  XATTR_NOFOLLOW
    do not follow symbolic links. setxattr() normally sets attributes
    on the target of path if it is a symbolic link. With this option,
    setxattr() will act on the link itself.
  XATTR_NOFOLLOW_ANY
    do not follow any symbolic links encountered during pathname
    resolution. An error is returned if a symlink is encountered
    before the last component of path.
  XATTR_CREATE
    fail if the named attribute already exists.
  XATTR_REPLACE
    fail if the named attribute does not exist. Failure to specify
    XATTR_REPLACE or XATTR_CREATE allows creation and replacement.

Reported-by: Mohamed Akram
Fixes: https://github.com/libguestfs/libguestfs/issues/180
Related: https://github.com/macfuse/macfuse/issues/1065
2025-10-07 14:06:46 +01:00
Richard W.M. Jones
84e15e784f Version 1.57.4. 2025-09-30 10:06:44 +01:00
Richard W.M. Jones
669eda1e24 lib/launch-direct.c: Simplify test for KVM, remove qemu caching
Previously we tested if KVM was available, and cached that for the
qemu binary.  I think this was actually wrong.  For example, if the
machine restarts, then the cache is still around, but KVM might be
enabled or disabled because of a new host kernel.

In any case, let's radically simplify this.

Test for KVM on each run.  Consequently we can remove all the qemu
test caching stuff as it is no longer used anywhere.

I also tightened up the code that runs the QMP query-kvm command, so
now any unexpected output will cause a runtime failure.  This command
ought to work, and if it breaks we ought to know about it and fix it.
2025-09-29 16:49:03 +01:00
Richard W.M. Jones
cfbdf9bcc7 lib/qemu.c: Remove guestfs_int_qemu_supports_device
Previously we ran 'qemu -device ?' to list devices, using the output
to test if qemu supported particular devices.  This was extensively
used in the past, but after recent commits there are no further users
of this code, so we can remove it all completely.
2025-09-29 16:49:03 +01:00
Richard W.M. Jones
4872c0cf09 lib/launch-direct.c: Assume virtio-rng
It's always a good idea to provide proper entropy to the libguestfs
appliance (eg. for any cryptographic operations).  We already assume
virtio, so we can assume virtio-rng is present.
2025-09-29 16:49:03 +01:00
Richard W.M. Jones
d8b08eac38 lib/launch-libvirt.c: Don't store libvirt_version in handle
We no longer use the libvirt version anywhere, except when reporting
the version.  Remove this from the handle.

Simplify the remaining code.  In particular:

* don't bother parsing the libvirt version, just print what
  virGetVersion gives us

* guestfs_int_version_from_libvirt is dead code, so it can be removed
2025-09-29 16:49:03 +01:00
Richard W.M. Jones
48bad58024 lib/launch-libvirt.c: Assume libvirt >= 9.0.0 and passt support
Libvirt 9.0.0 was released in January 2023, and it seems safe to
assume that if you're enabling the non-default backend, you can at
least use a new version of libvirt.

If you're using new libvirt, might as well also assume passt is
available.
2025-09-29 16:49:03 +01:00
Richard W.M. Jones
d730fc8b7c lib/launch-libvirt.c: Remove a workaround for libvirt < 3.8.0
This version of libvirt was released in 2017.
2025-09-29 16:49:03 +01:00
Richard W.M. Jones
a68f3eee15 lib/launch-libvirt.c: Add virtio-rng unconditionally
This tested for an ancient version of libvirt, but we can assume we
are always using something more recent.
2025-09-29 16:49:03 +01:00
Richard W.M. Jones
1a45db7465 lib/qemu.c: Remove qemu -help invocation
Previously we parsed qemu -help output to get the version of qemu and
to test for other features.  After prior commits, this is no longer
done, so we can remove the qemu -help invocation and associated code
completely.
2025-09-29 16:49:03 +01:00
Richard W.M. Jones
593a382840 lib: Remove guestfs_int_qemu_version
This function is now only used in one place, to print the version of
qemu in direct mode, when debugging is enabled.

Remove this function and replace with a direct command invocation
('qemu --version').  We only need to run this command when debugging
is enabled, and we copy all of the output to the debug channel.

I have made the assumption here that qemu -version does not try to
create a display device.  (The previous invocation of qemu -help
actually ran 'qemu -display none -help' indicating that this was not
always the case.)

This is actually an improvement on before, since now we get to see the
full output of 'qemu --version'.  The new output looks like:

  libguestfs: begin testing qemu features
  libguestfs: command: run: /usr/bin/qemu-kvm
  libguestfs: command: run: \ -version
  libguestfs: qemu: QEMU emulator version 10.1.0 (qemu-10.1.0-8.fc44)
  libguestfs: qemu: Copyright (c) 2003-2025 Fabrice Bellard and the QEMU Project developers
2025-09-29 16:49:03 +01:00
Richard W.M. Jones
788a1e4993 lib/launch-direct.c: Don't store qemu_version in handle
As we no longer use this field, no longer store it in the handle
struct.
2025-09-29 16:49:03 +01:00
Richard W.M. Jones
99921de6e0 lib/launch-direct.c: Move baseline to qemu 7.2.0 and assume passt support
We already effectively assume that qemu is much newer than the 1.3.0
baseline previously documented.  As one example, commit 47857751a7
("lib: direct: Remove test for qemu mandatory locking") assumes that
qemu >= 2.10.  Because passt support is desirable in general, let's
assume that qemu is at least version 7.2.0, and document it.

qemu 7.2.0 was released in December 2022, nearly 3 years ago, and RHEL
9 is currently on qemu 9.1.0.

This keeps the SLIRP fallback path in case passt isn't installed, but
we should remove that fallback in future too.
2025-09-29 16:49:03 +01:00
Richard W.M. Jones
dce5ce605d lib/launch-direct.c: Set lost_tick_policy=discard unconditionally
We already assume qemu version is must greater than 1.3.0 so we do not
need this qemu version test.
2025-09-29 16:49:03 +01:00
Richard W.M. Jones
ec47331b12 lib/launch-libvirt.c: Don't store qemu_version in handle
After previous commits, we no longer use the qemu version elsewhere
(after simply reporting it).  Remove all the code for storing the qemu
version.
2025-09-29 16:49:03 +01:00
Richard W.M. Jones
02d82a3c3a lib: Remove qemu version when testing for discard feature
We can assume much more recent qemu, so we don't need to have special
cases for qemu 1.5/1.6.
2025-09-29 16:49:03 +01:00
Richard W.M. Jones
5df7da7e81 lib/qemu.c: Remove int_qemu_supports function
This function, which grepped the qemu -help output to see if a command
line option was supported, is no longer used and can be removed.
2025-09-29 16:49:03 +01:00
Richard W.M. Jones
fc243a36bd lib/launch-direct.c: Remove unnecessary tests for ancient qemu features
We can safely assume that qemu supports -nodefaults and
-no-user-config, since these have been supported since forever.

-no-hpet was deprecated in qemu 8.0 and the option removed in early
2024, replaced with -machine hpet=off.  HPET defaults to 'on' in
upstream qemu, and to 'off' in downstream RHEL rebuilds.

Since (for libguestfs) we can assume an up to date Linux kernel is
running inside the guest, and that the kernel will do the right thing
with regards to timers, we don't need to mess with qemu defaults.  In
practice, Linux chooses kvm-clock.

Thanks: Thomas Huth, Daniel Berrange
2025-09-29 16:49:03 +01:00
Richard W.M. Jones
1f1ac69b11 lib/qemu.c: Remove qmp_schema
We used to read the QMP schema so we could see if the binary supported
qemu mandatory locking.  However after commit 47857751a7 ("lib:
direct: Remove test for qemu mandatory locking") this is dead code, so
remove it.

Updates: commit 47857751a7
2025-09-29 16:49:03 +01:00
Richard W.M. Jones
bc431d9b64 tests/regressions/rhbz790721.c: Remove this test
This was a test for a 13 year old problem to do with problems
launching libguestfs appliances in parallel.  That problem does not
affect current code.

Testing build/launch of libguestfs appliances is a valuable thing to
test.  However we start libguestfs in parallel in both the current
test suite and in higher level tools, and this test was dubious (and
breaks with recent changes).  Therefore remove the test.
2025-09-29 16:49:03 +01:00
Richard W.M. Jones
495f71affc daemon, generator: Use power of 2 for initial size of Hashtbl.create
Before 2011 it was recommended to use a prime number for the initial
size.  In 2011 the OCaml hash table was reimplemented using a hash
function based on Murmur 3.  Hashtbl.create now adjusts the initial
size to the next power of 2 (minimum 16).  So replace obsolete
'Hashtbl.create 13' with 'Hashtbl.create 16'.
2025-09-12 08:37:58 +01:00
Richard W.M. Jones
30ccb9a3e6 daemon/selinux.ml: Use setfiles -A option to reduce memory usage
In filesystems that have many millions of files, the default behaviour
of setfiles is to build a huge hash table containing every filename.
This uses up lots of memory which prevents relabelling from happening
in the reduced memory environment of the libguestfs appliance.

I added the setfiles -A option to change this default behaviour.  If
setfiles has the option then use it.

Fixes: https://issues.redhat.com/browse/RHEL-114292
Related: https://issues.redhat.com/browse/RHEL-111165
Related: https://issues.redhat.com/browse/RHEL-111505
2025-09-11 21:03:37 +01:00
Richard W.M. Jones
5f47af7f3e Version 1.57.3. 2025-09-09 19:18:04 +01:00
Richard W.M. Jones
a5b7de4a71 github: Add workflows file to EXTRA_DIST
Fixes: commit e218dd73cc
2025-09-09 19:11:31 +01:00
Richard W.M. Jones
365e7d79f7 github: Don't test on Ubuntu 24.04 twice
It turns out that ubuntu-latest is the same as 24.04, so we're just
testing on the same version twice.  Remove the duplication.

Thanks: Stephen Gallagher
Fixes: commit e218dd73cc
2025-09-09 17:34:15 +01:00
Cole Robinson
a2e7dfc73b New API: ntfs_chmod
Add an API to do the equivalent of `chmod [-r] MODE PATH` for
NTFS filesystems.

Files created on a linux ntfs-3g mount can not change permissions
directly. New files and directories are created with rough windows
equivalent of `chmod 777`. These wide open permissions can generate
security warnings on windows after virt-v2v installs bits into
`Program Files\Guestfs`.

Behind the scenes we use `ntfssecaudit(8)` from `ntfsprogs`
which is already part of the appliance. We only expose the chmod-style
feature; the rest of `ntfssecaudit` is concerned reporting and
managing fine grained windows security info which is way more than
we need.

Also note, `ntfssecaudit` needs to run on an unmounted partition
so using this is more complicated than a traditional `chmod` call.

Related: https://issues.redhat.com/browse/RHEL-104352

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2025-09-09 16:29:13 +01:00
Richard W.M. Jones
e218dd73cc github: Add basic github CI tests
This builds libguestfs and runs the in-tree tests, ie. the basic
'./configure && make && make check'.

We're using the "free for public repositories" plan.  We run the tests
directly on an Ubuntu VM, versions 24.04 & latest.  Also on Fedora 42,
43 in a container (running on the Ubuntu VM).

The tests are run on pushes to the master branch, and on pull
requests to the master branch.

GObject is not built, since the tests fail and anyway there are some
deep problems with the GObject bindings and they probably will be
removed.

Thanks: Stephen Gallagher, Cole Robinson
2025-09-09 13:40:49 +01:00
Richard W.M. Jones
e7b36e0eba generator: Use quoted string literals for regexps
The output of the generator is identical after this change.
2025-09-02 09:11:38 +01:00
Richard W.M. Jones
02b64d5cec generator: Use quoted string literals in many places
This change was done almost entirely automatically using the script
below.  This uses the OCaml lexer to read the source files and extract
the strings and locations.  Strings which are "candidates" (in this
case, longer than 3 lines) are replaced in the output with quoted
string literals.

Since the OCaml lexer is used, it already substitutes all escape
sequences correctly.  I diffed the output of the generator and it is
identical after this change, except for UUIDs, which change because of
how Utils.stable_uuid is implemented.

Thanks: Nicolas Ojeda Bar

$ ocamlfind opt -package unix,compiler-libs.common find_strings.ml \
                -o find_strings.opt -linkpkg
$ for f in $( git ls-files -- \*.ml ) ; do ./find_strings.opt $f ; done

open Printf

let read_whole_file path =
  let buf = Buffer.create 16384 in
  let chan = open_in path in
  let maxlen = 16384 in
  let b = Bytes.create maxlen in
  let rec loop () =
    let r = input chan b 0 maxlen in
    if r > 0 then (
      Buffer.add_substring buf (Bytes.to_string b) 0 r;
      loop ()
    )
  in
  loop ();
  close_in chan;
  Buffer.contents buf

let count_chars c str =
  let count = ref 0 in
  for i = 0 to String.length str - 1 do
    if c = String.unsafe_get str i then incr count
  done;
  !count

let subs = ref []

let consider_string str loc =
  let nr_lines = count_chars '\n' str in
  if nr_lines > 3 then
    subs := (str, loc) :: !subs

let () =
  Lexer.init ();
  let filename = Sys.argv.(1) in
  let content = read_whole_file filename in
  let lexbuf = Lexing.from_string content in
  let rec loop () =
    let token = Lexer.token lexbuf in
    (match token with
     | Parser.EOF -> ();
     | STRING (s, loc, sopt) ->
        consider_string s loc; (* sopt? *)
        loop ();
     | token ->
        loop ();
    )
  in
  loop ();

  (* The list of subs is already reversed, which is convenient
   * because we must the file substitutions in reverse order.
   *)
  let subs = !subs in
  let new_content = ref content in
  List.iter (
    fun (str, loc) ->
      let { Location.loc_start = { pos_cnum = p1 };
            loc_end = { pos_cnum = p2 } } = loc in
      let len = String.length !new_content in
      let before = String.sub !new_content 0 (p1-1) in
      let after = String.sub !new_content (p2+1) (len - p2 - 1) in
      new_content := before ^ "{|" ^ str ^ "|}" ^ after
  ) subs;

  let new_content = !new_content in

  if content <> new_content then (
    (* Update the file in place. *)
    let new_filename = filename ^ ".new"
    and backup_filename = filename ^ ".bak" in
    let chan = open_out new_filename in
    fprintf chan "%s" new_content;
    close_out chan;
    Unix.rename filename backup_filename;
    Unix.rename new_filename filename
  )
2025-09-01 17:08:52 +01:00
Richard W.M. Jones
b4a98fe13a generator/actions_core.ml: Fix typo in description of read_file 2025-09-01 16:54:43 +01:00
Richard W.M. Jones
32b911a061 daemon/inspect_fs_windows.ml: Use {|..|} string literal 2025-09-01 13:59:56 +01:00
Richard W.M. Jones
f857f39a2d daemon/selinux.ml: Simplify setfiles option testing
Updates: commit 1c0b56158a
2025-08-30 14:05:34 +01:00
Richard W.M. Jones
91ee98523e daemon/selinux.ml: Fix typo in comment
Fixes: commit d0d8e67384
2025-08-27 10:43:00 +01:00
Richard W.M. Jones
e6f93dfb9f Update common submodule
Pulls in the commits listed below.  This has no effect as all changes
are confined to the common/mlcustomize subdirectory which we do not
use or ship.

  Richard W.M. Jones (4):
      mlcustomize/SELinux_relabel.ml: Add comment
      mlcustomize/SELinux_relabel.ml: Use new guestfs_setfiles API
      mlcustomize/SELinux_relabel.ml: Relabel every mountpoint
      mlcustomize/firstboot.ml: Use quoted string literals for firstboot

  Vadim Rozenfeld (1):
      Modify the firstboot script to check the scripts execution return status
2025-08-20 10:36:48 +01:00
Richard W.M. Jones
6b19b97aa6 website: Remove very old stable branches from the index page
There's no point linking to anything other than the current stable
branch.
2025-08-15 21:37:30 +01:00
Richard W.M. Jones
82764f1b3a Version 1.57.2. 2025-08-15 10:56:08 +01:00
Richard W.M. Jones
1c00248ac1 daemon/inspect_fs_windows.ml: Ignore blank disks in drive mapping
If HKLM\System\MountedDevices references a blank disk, then when we
try to search for the actual backing device we will get an error from
parted:

  parted: /dev/sdb: parted exited with status 1: Error: /dev/sdb: unrecognised disk label: Invalid argument

Just ignore these errors instead of failing inspection.

Fixes: https://issues.redhat.com/browse/RHEL-108803
Reported-by: Ameen Barakat
Thanks: Ming Xie
2025-08-14 15:45:59 +01:00
Richard W.M. Jones
5c7e15cfae daemon/inspect_fs_windows.ml: Add debugging when we start registry analysis
Add some debugging when we begin the process of analyzing the Windows
registry of a guest.
2025-08-14 15:45:59 +01:00
Richard W.M. Jones
e18bd72c8e daemon/inspect_fs_windows.ml: Add debugging for MBR drive mappings
The function 'map_registry_disk_blob_gpt' immediately below this one
has a debugging statement.  Add the equivalent to the function
'map_registry_disk_blob_mbr'.

The output looks like:

  map_registry_disk_blob_mbr: searching for MBR disk ID 31 32 33 34
  map_registry_disk_blob_mbr: searching for MBR partition offset 00 00 00 10 00 00 00 00
2025-08-14 15:45:59 +01:00
Richard W.M. Jones
f6267d5f71 Version 1.57.1. 2025-08-13 17:06:15 +01:00
Richard W.M. Jones
1c0b56158a daemon: Deprecate guestfs_selinux_relabel, replace with guestfs_setfiles
The guestfs_selinux_relabel function was very hard to use.  In
particular it didn't just do an SELinux relabel as you might expect.
Instead you have to write a whole bunch of code around it (example[1])
to make it useful.

Another problem is that it doesn't let you pass multiple paths to the
setfiles command, but the command itself does permit that (and, as it
turns out, will require it).  There is no backwards compatible way to
extend the existing definition to allow a list parameter without
breaking API.

So deprecate guestfs_selinux_relabel.  Reimplement it as
guestfs_setfiles.  The new function is basically the same as the old
one, but allows you to pass a list of paths.  The old function calls
the new function with a single path parameter.

[1] https://github.com/libguestfs/libguestfs-common/blob/master/mlcustomize/SELinux_relabel.ml
2025-08-13 16:08:28 +01:00
Richard W.M. Jones
e4d9ee3fbc generator: Allow StringList(Pathname) parameters
This was previously not implemented.  It just requires us to call
ABS_PATH on each parameter.  ABS_PATH checks the parameter is an
absolute path.
2025-08-13 16:08:28 +01:00
Richard W.M. Jones
fd4db60cff generator: Implement StringList for OCaml functions
No existing OCaml functions have a StringList parameter, but we would
like to add one.

The original plan seems to have been to map these to 'string array'
types, but 'string list' is more natural, albeit marginally less
efficient.  The implementation here just has to convert the 'char **'
into the OCaml linked list of values.
2025-08-13 16:08:28 +01:00
Richard W.M. Jones
ed40333a23 daemon: Reimplement guestfs_selinux_relabel in OCaml
No change, just reimplement the existing C implementation in OCaml.
2025-08-13 16:08:28 +01:00
Richard W.M. Jones
c931ab3bc8 daemon: sysroot: Avoid copying the path every time we call sysroot ()
This path never changes once the daemon has started up, so we don't
need to call into C code and copy the string every time.
2025-08-13 16:08:28 +01:00
Richard W.M. Jones
1e0099671a daemon: sysroot: Avoid double-/ when creating sysroot paths in OCaml
Previously calling 'sysroot_path "/dev"' for example would return the
string "/sysroot//dev".  While this is not wrong, it confuses some
external programs (hello, setfiles), and it's not very "clean".  Be a
bit more careful to avoid doubling the '/' character in the common case.
2025-08-13 16:08:28 +01:00
Cole Robinson
06db19c56c daemon: inspect: check /etc/crypttab for /dev/mapper/*
Encrypted root fs on SUSE distros will present itself like so:

```
/dev/mapper/cr_root                         /                   btrfs   defaults                0 0
UUID=588905f9-bfa4-47b5-9fe8-893cb8ad4a0b   /var                btrfs   subvol=/@/var           0 0
... more subvols here ...
UUID=8a278363-3042-4dea-a878-592f5e1b7381   swap                btrfs   defaults                0 0
/dev/mapper/cr_root                         /.snapshots         btrfs   subvol=/@/.snapshots    0 0

cr_root  UUID=5289379a-a707-41b5-994c-c383f7ed54cc  none  x-initrd.attach
```

This breaks `-i` inspection, since libguestfs doesn't know what
/dev/mapper/cr_root is supposed to be, and nothing in the appliance
will autopopulate that path. This isn't a problem on Fedora, where
it uses UUID= instead of a /dev/mapper path.

Currently when we see /dev/mapper as a mount prefix, we only attempt
to do some LVM name mapping. This extends libguestfs to check
/etc/crypttab first. If we find an entry for the mapper path, and it
points to the encrypted luks UUID, we use that UUID to build the
associated /dev/disk/by-id/dm-uuid-CRYPT-* path, which is a symlink
to the unencrypted /dev/dm-X path

Resolves: https://issues.redhat.com/browse/RHEL-93584

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2025-08-12 17:55:06 +01:00
Cole Robinson
701667b6f5 docs: Fix dead ntfs-3g doc links 2025-08-04 15:49:50 +01:00
Richard W.M. Jones
217823da95 appliance/init: Add lsblk and blkid output to verbose log
This is useful for debugging.  The output looks like:

  + lsblk
  NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
  sda           8:0    0    1G  0 disk
  |-sda1        8:1    0  512M  0 part
  `-sda2        8:2    0  512M  0 part
    |-VG-Root 252:0    0   32M  0 lvm
    |-VG-LV1  252:1    0   32M  0 lvm
    |-VG-LV2  252:2    0   32M  0 lvm
    `-VG-LV3  252:3    0   64M  0 lvm
  sdb           8:16   0    4G  0 disk /
  + blkid
  /dev/mapper/VG-LV1: UUID="cc8a3437-4169-4b1c-b432-ee8adc563f6d" BLOCK_SIZE="4096" TYPE="ext2"
  /dev/sdb: UUID="30c70ddc-d00b-4620-a408-025890e59aa6" BLOCK_SIZE="4096" TYPE="ext2"
  /dev/mapper/VG-LV2: UUID="747009aa-e183-46ba-a034-0c437b15cebc" BLOCK_SIZE="1024" TYPE="ext2"
  /dev/mapper/VG-Root: LABEL="ROOT" UUID="01234567-0123-0123-0123-012345678902" BLOCK_SIZE="4096" TYPE="ext2"
  /dev/sda2: UUID="DfEjc1-wRU6-vh8U-we7U-ivEl-FRwo-rG0ZuL" TYPE="LVM2_member" PARTUUID="184cbb43-02"
  /dev/sda1: LABEL="BOOT" UUID="01234567-0123-0123-0123-012345678901" BLOCK_SIZE="4096" TYPE="ext2" PARTUUID="184cbb43-01"
  /dev/mapper/VG-LV3: UUID="f9e5dc21-9a2a-45a0-85b0-e2889607139a" BLOCK_SIZE="2048" TYPE="ext2"

Fixes: https://issues.redhat.com/browse/RHEL-106490
2025-07-30 11:06:37 +01:00
Richard W.M. Jones
f4f84a8824 daemon: Add contents of /etc/fstab to verbose log
Also some mdadm configuration files.  This is useful for debugging.

The output looks like this:

  info: /etc/fstab in /dev/VG/Root
  LABEL=BOOT /boot ext2 default 0 0$
  LABEL=ROOT / ext2 default 0 0$

Fixes: https://issues.redhat.com/browse/RHEL-106490
2025-07-30 11:01:03 +01:00
Richard W.M. Jones
c7aaa89fba lib: libvirt: Sleep before retrying virDomainDestroyFlags
This saves us going into a loop if virDomainDestroyFlags keeps
returning -EBUSY quickly, which apparenrly can happen in containers.

The equivalent 'direct' backend code sleeps for 2 seconds in this case.
2025-07-25 09:42:39 +01:00
Richard W.M. Jones
0a91731356 lib: libvirt: Debug error from virDomainDestroyFlags
It's useful to see the error returned from virDomainDestroyFlags, so
make sure this gets written to debug output.
2025-07-25 09:41:27 +01:00
Richard W.M. Jones
dc218b25f0 appliance: Ignore sit0 network device in the guest
Reported-by: Srikanth Aithal <sraithal@amd.com>
Fixed-by: Stefano Brivio <sbrivio@redhat.com>
Tested-by: Srikanth Aithal <sraithal@amd.com>
See-also: https://lists.libguestfs.org/archives/list/guestfs@lists.libguestfs.org/thread/566LAY7RNM7T7EMQQQYIQA2VK5TXETK5/
2025-06-25 11:15:31 +01:00
Richard W.M. Jones
0991b4dc21 Version 1.56.1. 2025-06-16 16:54:37 +01:00
Cole Robinson
bcf204ad68 daemon: inspect: factor out resolve_dev_mapper function
This is just code movement.

Signed-off-by: Cole Robinson <crobinso@redhat.com>

RWMJ: Renamed and moved the function for consistency with surrounding
code.
2025-06-13 09:10:30 +01:00
Richard W.M. Jones
f6fe0611a8 lib: Make libvirt ACPI feature flag conditional on x86 or Arm
On ppc64 and s390x it failed with an error like:

  unsupported configuration: machine type 'pseries-10.0' does not support ACPI

Updates: commit 7cf0ed750e
Related: https://bugzilla.redhat.com/show_bug.cgi?id=2372329
2025-06-12 08:11:56 +01:00
Richard W.M. Jones
7cf0ed750e lib: Enable ACPI for the libvirt backend
Many years ago we used to pass acpi=off on the Linux kernel command
line.  In commit db1f811b2 we stopped doing that (around 2016).
However unless you also use:

  <features>
    <acpi/>
  </features>

then it turns out that libvirt disables ACPI generation at the qemu
level.  None of this mattered until SeaBIOS 1.17 changed its
behaviour, causing ACPI to be required for virtio devices to work.

Updates: commit db1f811b29
Related: https://bugzilla.redhat.com/show_bug.cgi?id=2372329
Thanks: Gerd Hoffmann
2025-06-11 22:50:07 +01:00
Richard W.M. Jones
fba52a41b5 Version 1.56.0. 2025-06-11 14:27:19 +01:00
Richard W.M. Jones
fc25860a7e Update common submodule
Just synch with the upstream libguestfs-common master branch, before
the 1.56 release.
2025-06-11 14:26:45 +01:00
Richard W.M. Jones
dc6882e8f4 docs: Finalize release notes for 1.56 2025-06-11 14:02:36 +01:00
Richard W.M. Jones
fc5edb1255 tests: Remove test-http.py
This test has never been run.  It was originally added in
commit 36d6df671e ("tests/http: Add a test of HTTP protocol.", 2013).
However even when it was added, it was commented out.

Updates: commit 36d6df671e
2025-06-11 14:02:36 +01:00
Richard W.M. Jones
57121dbb05 docs: Remove mention of ocaml-gettext as a dependency
This package is used by guestfs-tools and virt-v2v, where tools are
written in OCaml.  However no part of libguestfs uses this.
2025-06-11 14:02:36 +01:00
Richard W.M. Jones
f2f2825f01 docs: Remove mention of python-evtx as a dependency
It may be needed by virt-log, but that is not part of libguestfs
any longer.
2025-06-11 14:02:36 +01:00
Richard W.M. Jones
32bc8bcd1d docs: Remove mention of liblzma as a dependency
This is used by virt-builder, which is not part of libguestfs.
2025-06-11 14:02:36 +01:00
Richard W.M. Jones
42dd817a82 docs: Remove mention of GPG as a dependency
This is used by virt-builder only, not part of libguestfs.
2025-06-11 14:02:36 +01:00
Richard W.M. Jones
2160c540a5 docs: Remove mention of curl as a dependency
It is used by virt-builder, but that is no longer part of libguestfs.
2025-06-11 14:02:36 +01:00
Richard W.M. Jones
b58e2624db docs: Remove mention of nbdkit as a dependency
We don't use nbdkit.  It is used by virt-v2v, but that is no longer
part of libguestfs.
2025-06-11 14:02:36 +01:00
Richard W.M. Jones
df7616fb00 docs: Remove mention of glibc as a dependency
We removed the final uses of custom printf formatters in
commit 0b3c6cc0c0 ("daemon: Remove remaining uses of custom printf %Q
and %R", 2022).

Updates: commit 0b3c6cc0c0
2025-06-11 14:02:36 +01:00
Richard W.M. Jones
db46bcb535 lib/inspect-osinfo.c: Generate new osinfo shortname for SLES >= 15
libosinfo changes the naming scheme it uses for SUSE starting with
major version 15.  Previously it used names like "sles12" (or
"sles12sp1"), "sled12" for Server and Desktop variants.  In 15+ it
uses "sle15" as there are no variants any longer (instead the
installer asks you what variant you want to install).  We're only
interested in the Server variant.  Change the name that we return to
"sle15" or "sle15sp1".

See: b0fa386699
Fixes: https://issues.redhat.com/browse/RHEL-95791
Thanks: Ming Xie, Victor Toso
Related: https://issues.redhat.com/browse/RHEL-95540
2025-06-11 11:51:18 +01:00
Richard W.M. Jones
932d662483 docs: Update release notes for 1.56
For a potential release this week.
2025-06-10 11:57:55 +01:00
Richard W.M. Jones
9171e4502f docs: Update release notes for gettext fix
Updates: commit b9f75ca5b8

Cherry picked from
guestfs-tools commit 9b7410c220f1111e6acef88efbbaee3fea4019b8
and
guestfs-tools commit bf4fef4f2b45a2016c42094f8e4fe18abc8d90e2.
2025-06-10 11:57:55 +01:00
Richard W.M. Jones
a57f6b8e2c gobject: Mark the gobject bindings as deprecated
They will be removed in libguestfs 1.58 (the next but one version).
Currently they don't actually compile.  The larger problem is that
they don't handle 64 bit quantities properly (using floats instead),
meaning that any disk size or offset above a certain size will be
improperly passed through the API, usually rounded to the nearest
53 bits.
2025-06-10 11:57:55 +01:00
Richard W.M. Jones
ba916948ab Version 1.55.14. 2025-06-03 16:33:48 +01:00
Richard W.M. Jones
8f5e4f07ba inspection: Ignore btrfs snapshots of roots
In SLES guests in particular, btrfs snapshots seem to be used to allow
rollback of changes made to the filesystem.  Dozens of snapshots may
be present.  Technically therefore these are multi-boot guests.  The
libguestfs concept of "root" of an operating system does not map well
to this, causing problems in virt-inspector and virt-v2v.

In this commit we ignore these duplicates.  The test is quite narrow
to avoid false positives: We only remove a duplicate if it is a member
of a parent device, both are btrfs, both the snapshot and parent have
a root role, and the roles are otherwise very similar.

There may be a case for reporting this information separately in
future, although it's also easy to find this out now.  For example,
when you see a btrfs root device returned by inspect_os, you could
call btrfs_subvolume_list on the root device to list the snapshots.

Fixes: https://issues.redhat.com/browse/RHEL-93109
2025-05-27 17:01:09 +01:00
Richard W.M. Jones
ebaba43221 daemon/inspect.ml: Fix comment
Back in commit 8289aa1ad6 ("New APIs for guest inspection.", 2010)
when inspection was first added, we did inspection in the library, so
it was accurate to say that inspection information was stored "in the
handle".  Much later, in commit 394d11be49 and commit 3a00c4d179
(2017) we moved inspection to the daemon, but left the comment the
same.

Fixes: commit 3a00c4d179
2025-05-27 17:01:09 +01:00
Richard W.M. Jones
b2ec671abd daemon/inspect.ml: Pipeline style when mapping and filtering filesystems
No actual change in the functionality, just make it clear that this is
a pipeline of transformations on the list of filesystems.
2025-05-27 17:01:09 +01:00
Richard W.M. Jones
7ac190ed20 daemon/listfs.ml: Add more debugging to list_filesystems
This function is used from other parts of the daemon, especially for
example with inspection.  However it was difficult to follow exactly
what filesystems it was returning because of insufficient debugging
information.
2025-05-27 17:01:09 +01:00
Richard W.M. Jones
833e5e63b3 lib/create.c: Fix string passed to printf-like function
create.c: In function 'disk_create_qcow2':
  create.c:372:5: error: format not a string literal and no format arguments [-Werror=format-security]
    372 |     debug (g, cmd_stdout);
        |     ^~~~~

Fixes: commit 606aa1d182
2025-05-22 09:48:14 +01:00
Cole Robinson
606aa1d182 lib/create.c: Capture and raise qemu-img stderr
https://issues.redhat.com/browse/RHEL-92239

After this, output looks like

   $ ./run guestfish --ro --format=qcow2 -a test.img
   libguestfs: error: qemu-img: qemu-img: /home/crobinso/src/libguestfs/tmp/libguestfsFlxnb0/overlay1.qcow2: Image is not in qcow2 format Could not open backing image. : qemu-img exited with error status 1.
   To see full error messages you may need to enable debugging.
   ...

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2025-05-21 16:46:16 +01:00
Cole Robinson
406588d4a0 lib: flatten extra output when external command fails
Otherwise string output looks quite awkward

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2025-05-21 16:46:16 +01:00
Richard W.M. Jones
3c1aebff81 Version 1.55.13. 2025-05-20 14:57:59 +01:00
Richard W.M. Jones
b98cc96129 daemon: Implement e2fsck -n flag (as FORCENO option)
Fixes: https://issues.redhat.com/browse/RHEL-92599
2025-05-20 14:40:58 +01:00
Richard W.M. Jones
b9f75ca5b8 m4: Add junk required to make 'AM_GNU_GETTEXT' work
Run gettextize, revert most of its changes, but add the m4/* files
that might be required.

This is a short term fix.  A better / longer-term fix is described by
Dan here:

https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/message/2AZNWQQ6CBRFZCAADVYQHU5UN5J2JT2F/
2025-05-19 16:17:32 +01:00
Richard W.M. Jones
1f74666429 Version 1.55.12. 2025-05-19 14:07:14 +01:00
Richard W.M. Jones
ea3dd97f1d New API: Replace btrfs-fsck with btrfs-scrub-full
The old btrfs-fsck API used "btrfs check" which appears to be broken
or deprecated.  The real tool you should use is "btrfs scrub".  We
have already implemented that API, but it is very awkward to use from
libguestfs.  In particular there's no existing way to run the scrub
and wait for it to finish.

Fix this by deprecating btrfs-fsck.  Implement a new API
btrfs-scrub-full which runs btrfs scrub in the foreground, waits for
it to finish, and handles errors.  It's much more like fsck tools in
other filesystems.

Thanks: Eric Sandeen
Fixes: https://issues.redhat.com/browse/RHEL-91936
2025-05-19 13:42:44 +01:00
Richard W.M. Jones
1c2b94f095 docs: Update release notes for 1.56 2025-05-13 13:14:00 +01:00
Richard W.M. Jones
f9edfc9a18 Update common submodule
This pulls in the commits below, requiring us to replace all uses of
String.is_prefix and String.is_suffix.

Mostly done with Perl like this, and carefully checked by hand
afterwards since this doesn't get everything right:

  $ perl -pi.bak -e 's/String.is_prefix ([^[:space:]\)]+) ([^[:space:]\)]+)/String.starts_with \2 \1/g' -- `git ls-files`

  Richard W.M. Jones (3):
      mlstdutils: Fix comment that still referred to the old function names
      mldrivers: Link to gettext-stub if ocaml-gettext is enabled
      mlstdutils: Rename String.is_prefix -> starts_with, is_suffix -> ends_with
2025-05-11 21:29:23 +01:00
Richard W.M. Jones
464b8915e9 ocaml-dep.sh.in: Remove mlgettext subdirectory
Libguestfs does not use ocaml-gettext at all.
2025-05-11 15:01:06 +01:00
Richard W.M. Jones
c4ebeee505 Update common submodule
Pull in these commits which require minor changes:

  Richard W.M. Jones (3):
      mlstdutils: Remove Std_utils.identity
      mlstdutils: Remove Std_utils.protect
      mlstdutils: Remove List.filter_map
2025-05-11 12:37:23 +01:00
Richard W.M. Jones
fcd169476f Update common submodule
Adds these commits:

  Richard W.M. Jones (5):
      mlstdutils: Modify List.take, List.drop to match OCaml 5.3
      mlstdutils: Rename List.dropwhile -> drop_while, takewhile -> take_while
      mlstdutils: Add List.last function
      mlstdutils: Move List module first
      mlstdutils: Add String.common_prefix, longest_common_prefix
2025-05-10 18:29:40 +01:00
Richard W.M. Jones
f6b1a7b57f appliance: Remove zfs-fuse
zfs-fuse has been unmaintained for a very long time.  In fact, the
website has gone.  This means that whatever we need for zfs (probably
some kind of license-compatible kernel module) is not going to be
provided by zfs-fuse.

See: https://bugzilla.redhat.com/show_bug.cgi?id=2214965
2025-05-09 15:52:30 +01:00
Richard W.M. Jones
61d7d16981 Version 1.55.11. 2025-05-09 15:43:11 +01:00
Richard W.M. Jones
5441d3dd0c daemon: inspect: Remove duplicate root mountpoints in /etc/fstab
A customer case was found where /etc/fstab contained multiple root
mountpoints, something like:

  LABEL=System / xfs ...
  LABEL=Boot /boot ext2 ...
  LABEL=System / xfs ...

This causes libguestfs and virt-v2v to fail.  Either (on RHEL 9) we
try to mount the second instance of / which gives an error.  Or (on
upstream kernels) we are able to mount the second instance but then
libguestfs gets confused when trying to unmount them.

In this case as the mounted devices are the same we can just delete
the duplicate.  It's also possible that there could be multiple
non-identical root mountpoints, in which case we have to pick one, and
this code arbitrarily picks the first[*] (but emits a warning).

We don't do anything for non-root mountpoints.

Update common submodule to add 'List.same' function from mlstdutils.

[*] Which one is "the first" depends on what version of ocaml-augeas
we are using.  ocaml-augeas version 0.6 Augeas.matches function
returns entries in reverse order (compared to augeas itself).  This is
fixed in version 0.7:
http://git.annexia.org/?p=ocaml-augeas.git;a=commitdiff;h=b703b92e3d26690aa6f7b822132049ce5435983e

Fixes: https://issues.redhat.com/browse/RHEL-90168
2025-05-08 21:14:23 +01:00
Richard W.M. Jones
8836c3d075 docs: Add outline release notes for libguestfs 1.56 2025-05-06 18:16:33 +01:00
Richard W.M. Jones
2424976a3c bugs-in-changelog.sh: Match at least 3 digits after RHEL- for Jira issue
We could match on 1- and 2-digit RHEL issues, thus matching strings
like "RHEL-9" and "RHEL-10".  No such Jira issues exist for us.

(cherry picked from commit 846ecb2b3840212c6f2cad6a15a6b33cd2e912bf)
2025-05-06 17:40:06 +01:00
Richard W.M. Jones
59bad26898 lib/create.c: Fix check after BLKDISCARD
We didn't correctly check for an error from the ioctl.  Thus when
using a raw block device you would often see a bogus warning in
debugging output.

Related: https://issues.redhat.com/browse/MTV-2441
2025-05-01 09:10:52 +01:00
Richard W.M. Jones
9b32056061 Fix miscellaneous spelling mistakes
$ git ls-files | xargs codespell
2025-04-29 19:05:07 +01:00
Richard W.M. Jones
ca87485eea daemon/fstrim.c: Run the fstrim command twice
In upstream kernels, for XFS, you may have to run fstrim twice for it
to be effective.

Fixes: https://issues.redhat.com/browse/RHEL-88508
Related: https://issues.redhat.com/browse/RHEL-88450
Thanks: Eric Sandeen
2025-04-28 10:07:34 +01:00
Richard W.M. Jones
7022b2a492 Version 1.55.10. 2025-04-26 11:27:19 +01:00
Richard W.M. Jones
a5fa81db03 ocaml: Link mlguestfs.cma and .cmxa with local libguestfs
Commit e11583a03a ("ocaml: Don't embed -L../lib/.libs in final
mlguestfs.cma or .cmxa") was correct in itself, but as a side effect
caused mlguestfs.cma to be linked to the system libguestfs.  If system
libguestfs was not installed, the build would fail entirely with:

  ocamlmklib -o mlguestfs \
    -ldopt '-Wl,-z,relro -Wl,--as-needed  -Wl,-z,pack-relative-relocs -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -Wl,--build-id=sha1  ' \
    libguestfsocaml_a-guestfs-c.o libguestfsocaml_a-guestfs-c-actions.o libguestfsocaml_a-guestfs-c-errnos.o ../common/utils/libguestfsocaml_a-cleanups.o ../common/utils/libguestfsocaml_a-stringlists-utils.o guestfs.cmo \
     \
    -lguestfs
  /usr/bin/ld: cannot find -lguestfs: No such file or directory

Fix (from Mohamed Akram) is to add -L../lib/.libs to the -ldopt flag.
This does not embed the option in the final mlguestfs.cma file, but
seems to only use it while building the library.

Updates: commit e11583a03a
Reported-by: Mohamed Akram
Fixes: https://github.com/libguestfs/libguestfs/issues/191
2025-04-26 09:56:56 +01:00
Richard W.M. Jones
137fde9f77 ocaml: Prefer -ccopt -L... instead of -cclib
Reported-by: Mohamed Akram
Fixes: https://github.com/libguestfs/libguestfs/issues/191
2025-04-26 09:41:08 +01:00
Richard W.M. Jones
e11583a03a ocaml: Don't embed -L../lib/.libs in final mlguestfs.cma or .cmxa
$ ocamlobjinfo /usr/lib64/ocaml/guestfs/mlguestfs.cma
File /usr/lib64/ocaml/guestfs/mlguestfs.cma
Force custom: no
Extra C object files: -lmlguestfs -L../lib/.libs -lguestfs
...

(and the same in mlguestfs.cmxa).  This was caused because we run
ocamlmklib with this -L parameter so that OCaml tests and examples
will link with the local libguestfs.so (instead of the
system-installed version), but for other reasons that doesn't actually
work either.
2025-04-26 09:41:08 +01:00
Richard W.M. Jones
e127edcafc daemon/fstrim.c: Issue sync_disks after fstrim
Thanks: Eric Sandeen
2025-04-25 15:24:43 +01:00
Richard W.M. Jones
4d5fe341c7 ocaml-link.sh.in: Remove redundant use of getopt
Also allow --cclib as an alternative, and improved error reporting
when parsing the parameters to the script.

Fixes: https://github.com/libguestfs/guestfs-tools/issues/16
Reported-by: Mohamed Akram
2025-04-23 22:39:44 +01:00
Richard W.M. Jones
e49d65a5fd bash: Replace 'cp -d' command with POSIX 'cp -P'
Comment from Eric Blake:

> We don't have any hard-links in our source. GNU cp -d is the same as
> cp -P --preserve=links, but --preserve=links only matters for hard
> links, so losing it doesn't hurt our usage. I'm inclined to just go
> with cp -P unconditionally rather than needing the configure.ac
> logic for $(CP_D).

Fixes: https://github.com/libguestfs/libguestfs/issues/183
Reported-by: Mohamed Akram
Thanks: Eric Blake
2025-04-22 18:41:51 +01:00
Richard W.M. Jones
166395914f daemon: Use $(OCAMLLIB) instead of ocamlc -where
OCAMLLIB is already set to the value of ocamlc -where that was found
at configure time, so there is no need to run that command again at
build time.
2025-04-22 12:37:40 +01:00
Richard W.M. Jones
0423f2cec3 build: Only require augeas and hivex if also building the daemon
These libraries are only needed if building the daemon (so not if
using ./configure --disable-daemon).  Move the tests so we only check
for these libraries if the daemon is enabled in the build.

The daemon also requires ocaml-augeas (it uses both the augeas C
library directly and the OCaml bindings for augeas, for reasons).
However that test is already disabled if the daemon is not being
built.

Reported-by: Mohamed Akram
Fixes: commit dfa9dee775
Fixes: commit 8a723ca62e
Fixes: commit 228d49bb84
Fixes: https://github.com/libguestfs/libguestfs/issues/184
2025-04-22 12:31:15 +01:00
Richard W.M. Jones
2b2be31af0 build: Remove test for libmagic
libmagic (part of the "file" command) was required in earlier versions
of libguestfs, but this requirement was effectively removed in
commit b48da89dd6 ("daemon: Reimplement ‘file_architecture’ API in
OCaml") back in 2017.  Or to be more precise, we now use the "file"
command inside the daemon, which may or may not use libmagic but we
no longer link to the library directly.

Reported-by: Mohamed Akram
Fixes: commit b48da89dd6
Related: https://github.com/libguestfs/libguestfs/issues/184
2025-04-22 12:14:04 +01:00
Richard W.M. Jones
632937d8fb m4: Stop autoconf whinging about AC_PROG_CC_STDC being obsolete
I tried using 'autoupdate' but it failed completely to do the right
thing.
2025-04-22 11:47:58 +01:00
Richard W.M. Jones
6bf8c05961 libtool-kill-dependency_libs.sh: Ensure this only runs on *.la files
Fixes: https://github.com/libguestfs/libguestfs/issues/182
Reported-by: Mohamed Akram
2025-04-22 11:18:40 +01:00
Richard W.M. Jones
84d86f42d9 Version 1.55.9. 2025-04-16 21:48:29 +01:00
Richard W.M. Jones
e43ca19129 daemon: inspect: Resolve Ubuntu 22+ /dev/disk/by-id/dm-uuid-LVM-... in fstab
Linux + LVM supports device names like /dev/disk/by-id/dm-uuid-LVM-
followed by two concatenated UUIDs, firstly for the volume group and
secondly for the logical volume.  We can reverse those to get the
device name (/dev/VG/LV).

fstab entries look like:

  # / was on /dev/vg0/lv-0 during curtin installation
  /dev/disk/by-id/dm-uuid-LVM-OzFWT6NHkstr1hcmrWRRMDGPn9xdZj1YOOycQ533186x288FdU6UubU3OlnWJz6D / ext4 defaults 0 1
  # /usr was on /dev/vg0/lv-1 during curtin installation
  /dev/disk/by-id/dm-uuid-LVM-OzFWT6NHkstr1hcmrWRRMDGPn9xdZj1YZu53m4ZssZ8Jeb3I14RAJwIj5YlHIb9P /usr ext4 defaults 0 1

The upshot of this fix is that we are now able to correctly inspect
and run virt-v2v on Ubuntu 22+ guests with split /usr.  In particular,
we correctly map /etc/fstab entries like the above to LV device names,
which means that /usr merging now works correctly.

Reported-by: Jaroslav Spanko
Thanks: Daniel Berrange
Fixes: https://issues.redhat.com/browse/RHEL-87493
2025-04-16 21:12:49 +01:00
Richard W.M. Jones
a73f248369 daemon: Rewrite {pvs,vgs,lvs}-full APIs in OCaml
These were previously written in very convoluted C which had to deal
with parsing the crazy output of the "lvm" command.  In fact the
parsing was so complex that it was generated by the generator.  It's
easier to do this in OCaml.

These are basically legacy APIs.  They cannot be expanded and LVM
already supports many more fields.  We should replace these with APIs
for getting single named fields from LVM.
2025-04-16 21:12:49 +01:00
Richard W.M. Jones
3f9078261c Update common submodule
Pulls in these commits:

  Richard W.M. Jones (2):
      mltools: Fix memory leak in OCaml binding of libosinfo
      mlstdutils: Implement String.implode
2025-04-16 21:12:49 +01:00
Richard W.M. Jones
bcd6b3ec3a generator: Fix implementation of FUUID for OCaml functions
This was implemented wrongly.  In the XDR protocol, UUIDs are fixed
buffers of length 32.  We can just use memcpy to copy from the OCaml
string to the UUID, but we have to ensure the string length returned
by OCaml is correct (if not we just assert, it's an internal error).

(It didn't even compile before, so we know it was never used).
2025-04-16 21:12:49 +01:00
Richard W.M. Jones
7a1ffd744b daemon: inspect: Resolve Ubuntu 22+ /dev/disk/by-uuid/ in fstab
Ubuntu 22= uses /dev/disk/by-uuid/ followed by a filesystem UUID in
fstab entries.  Resolve these to mountables.

A typical fstab entry looks like this:

  # /boot was on /dev/vda2 during curtin installation
  /dev/disk/by-uuid/b4e56462-5a64-4272-b76d-f5e58bd8f128 /boot ext4 defaults 0 1

The comment is generated by the installer and appears in the fstab.
This entry would be translated to /dev/sda2.
2025-04-16 21:12:49 +01:00
rwmjones
6fb268997e Merge pull request #186 from rwmjones/2025-fdevice
Implement struct FDevice type in the generator and use it for `pvs_full`
2025-04-16 21:11:57 +01:00
Richard W.M. Jones
5a16d1120f generator: Use new FDevice type for the pvs-full pv_name field
Remove the code which did explicit reverse device name translation,
and use the generator's code instead.
2025-04-16 12:27:07 +01:00
Richard W.M. Jones
0ff73a42c7 generator: Implement struct FDevice type
This acts just like FString except that we do reverse device name
translation on it.  The only use is in the 'pvs-full' API where we
will use it (in a subsequent commit) to reverse translate the pv_name
field (a device name) before returning it from the daemon.

Compare this to the 'pvs' API which also returns a list of device
names, but using the generator's 'RStructList (RDevice,...)'  return
type, where RDevice is similarly reverse translated.

Note in the library-side bindings, because the name has already been
translated in the daemon, we just treat it exactly the same as
FString.  The vast majority of this patch is this mechanical change.
2025-04-16 12:27:07 +01:00
Richard W.M. Jones
2d1e894130 daemon: inspect: Add some debugging of /usr merging 2025-04-16 10:28:41 +01:00
rwmjones
7d561ee6f0 Merge pull request #178 from crobinso/osinfo-doc-tweak
common: update submodule
2025-04-09 21:33:28 +01:00
Cole Robinson
abdec091c4 common: update submodule
Cole Robinson (2):
          mltools: decouple and simplify osinfo device support checks
          mlcustomize: disable `--inject-virtio-win osinfo`

    Richard W.M. Jones (3):
          mltools: Fix de-oUnit-ized tests
          mltools: Unreference various objects
          Revert "mltools: Unreference various objects"

And update customize docs to match

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2025-04-09 16:12:44 -04:00
rwmjones
945d4e0663 Merge pull request #177 from weblate/weblate-libguestfs-libguestfs-master
Translations update from Fedora Weblate
2025-04-04 11:10:10 +01:00
Weblate
8cad86d63c Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/
2025-04-04 12:06:26 +02:00
Ricky Tigg
1b27b7ed1a Translated using Weblate (Finnish)
Currently translated at 9.7% (94 of 960 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/fi/
2025-04-04 12:06:26 +02:00
Richard W.M. Jones
8f375320c3 Version 1.55.8. 2025-04-03 19:31:16 +01:00
Richard W.M. Jones
f523684a0b lib/launch-libvirt.c: Remove fallback <emulator> for Arm
This "hopefully temporary hack" was actually added 12 years ago in
commit 37e1e0da5a ("arm: launch: libvirt: Force <emulator>.")
2025-03-31 18:19:00 +01:00
rwmjones
3951893849 Merge pull request #176 from weblate/weblate-libguestfs-libguestfs-master
Translations update from Fedora Weblate
2025-03-31 15:16:09 +01:00
Ettore Atalan
4a8acbf87d Translated using Weblate (German)
Currently translated at 33.8% (325 of 960 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/de/
2025-03-31 13:53:35 +02:00
Richard W.M. Jones
85c8445e1e build: Remove use of oUnit
This added no value over just running ordinary tests.  This also
removes a complicated OCaml dependency.
2025-03-22 12:41:39 +00:00
rwmjones
2f0fa0fd23 Merge pull request #175 from weblate/weblate-libguestfs-libguestfs-master
Translations update from Fedora Weblate
2025-03-22 11:47:37 +00:00
Weblate
693465e057 Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/
2025-03-22 11:53:58 +01:00
Ricky Tigg
4d6387da3f Translated using Weblate (Finnish)
Currently translated at 1.1% (152 of 13341 strings)

Translation: libguestfs/libguestfs-docs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-docs-master/fi/
2025-03-22 11:53:58 +01:00
Richard W.M. Jones
090ea7656e build: Remove detection of lex and yacc
These are not required by libguestfs.  They were used by virt-builder,
but that tool has now been moved to a separate project
(guestfs-tools).

Fixes: commit 733d2182b6
2025-03-22 10:51:21 +00:00
Richard W.M. Jones
f7083e588e build: Add heading about basic build environment
(cherry picked from
virt-v2v commit c523c63a4916b5620666341dad54bf5d999c1fbe)
2025-03-16 13:58:56 +00:00
Richard W.M. Jones
21ae4c37b7 build: Only use ANSI colour sequences if stdout is a terminal
https://stackoverflow.com/a/10022396
2025-03-11 21:04:20 +00:00
Richard W.M. Jones
3a8947323b build: Colourize features
Print yes features in green and no features in red.
2025-03-11 15:31:17 +00:00
Richard W.M. Jones
cf75c12a9e build: Embolden headings in configure output
If using a colour terminal, display headings in bold.
2025-03-11 15:30:18 +00:00
Richard W.M. Jones
471d328b9e build: Add 'feature' and 'print' to display configured features.
Borrow 'feature' and 'print' functions from nbdkit and use these to
display configured features in a simpler and more consistent way.
2025-03-11 15:28:50 +00:00
Richard W.M. Jones
e765e31f3a Version 1.55.7. 2025-03-11 14:44:16 +00:00
Richard W.M. Jones
4176b2043f daemon: Fix loongarch64 detection on RHEL 9
$ rpm -q file
file-5.39-16.el9.x86_64
$ file ./test-data/binaries/bin-loongarch64-dynamic
./test-data/binaries/bin-loongarch64-dynamic: ELF 64-bit LSB pie executable, *unknown arch 0x102* version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-loongarch-lp64d.so.1, BuildID[sha1]=7622a1a70bf6e697851ac3790557e1ca686459b5, for GNU/Linux 5.19.0, stripped

Updates: commit 729d6d55ea
2025-03-11 13:40:14 +00:00
Richard W.M. Jones
bf4a6c2f85 build: Remove unused website/download/builder/ directory 2025-03-11 11:00:29 +00:00
Richard W.M. Jones
31fa712aa0 lib: Print kernel utsname in debug output
Useful for debugging problems caused by the host kernel.  In
particular we were looking at a problem with passt creating a user
namespace but didn't know what exact kernel was being used.
2025-03-10 18:56:39 +00:00
rwmjones
01909c51ff Merge pull request #174 from weblate/weblate-libguestfs-libguestfs-master
Translations update from Fedora Weblate
2025-03-05 12:34:03 +00:00
Yuri Chornoivan
58a72cb2aa Translated using Weblate (Ukrainian)
Currently translated at 100.0% (960 of 960 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/uk/
2025-03-05 07:38:45 +01:00
rwmjones
4401d81654 Merge pull request #173 from weblate/weblate-libguestfs-libguestfs-master
Translations update from Fedora Weblate
2025-03-04 08:39:52 +00:00
Weblate
8876360d97 Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/
2025-03-03 22:09:20 +01:00
Krascovict Petrov
f63f88a5bf Translated using Weblate (Portuguese (Brazil))
Currently translated at 0.1% (24 of 13337 strings)

Translation: libguestfs/libguestfs-docs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-docs-master/pt_BR/
2025-03-03 22:09:20 +01:00
denisecheng
0c70675aae support TencentOS
Signed-off-by: denisecheng <denisecheng@tencent.com>
Fixes: https://github.com/libguestfs/libguestfs/pull/172
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
2025-03-03 14:22:37 +00:00
Jacob Reger
f81444ccad libguestfs: Rust binding build error and warning fixes
Internal error type did not implement the necessary traits to be
treated as a proper Rust error. This would cause ergonomic issues
with manual error handling and with error handling crates like
anyhow. Implement the Display and Error trait for internal Error
type. This also fixes the build warnings.

Signed-off-by: Jacob Reger <regerjacob@gmail.com>
2025-02-25 22:00:12 +00:00
Jacob Reger
d7d5264ce8 libguestfs: Rust binding build error and warning fixes
Fixed break in Rust bindings where callback registering expected a
*const i8, but were provided with a *const c_char. Changed to be both
*const c_char in alignment with the libguestfs documentation.

Signed-off-by: Jacob Reger <regerjacob@gmail.com>
2025-02-25 21:53:36 +00:00
Richard W.M. Jones
95ed25aba6 Version 1.55.6. 2025-02-19 16:42:52 +00:00
Richard W.M. Jones
47ac4871b2 daemon: New command_out and sh_out APIs
These APIs allow you to capture output from guest commands that
generate more output than the protocol limit allows.

Thanks: Nijin Ashok
Fixes: https://issues.redhat.com/browse/RHEL-80159
2025-02-19 12:01:10 +00:00
Richard W.M. Jones
8d61b04dd6 ruby: Make sure all object files are cleaned up
There were several, large *.o files left over after 'make clean':

$ ls ruby/ext/guestfs/
actions-0.c  actions-2.c  actions-4.c  actions-6.c    handle.c
actions-0.o  actions-2.o  actions-4.o  actions-6.o    handle.o
actions-1.c  actions-3.c  actions-5.c  actions.h      module.c
actions-1.o  actions-3.o  actions-5.o  extconf.rb.in  module.o
2025-02-18 11:57:07 +00:00
Richard W.M. Jones
a1ecc0006c tests/syslinux/test-syslinux.pl: Send skip messages to stderr
Otherwise they won't appear in test-suite.log.
2025-02-18 11:55:07 +00:00
Richard W.M. Jones
3749443464 tests/syslinux/test-syslinux.pl: Fix disk image location
tests/Makefile.am assumes the test image is located in
tests/syslinux/, but we actually created it in tests/.  Fix the
location, and also ensure the test will clean it up after running
successfully.
2025-02-18 11:53:41 +00:00
Richard W.M. Jones
14e78e9ac8 Version 1.55.5. 2025-02-18 10:10:03 +00:00
Richard W.M. Jones
72cfaff5c5 Update copyright dates for 2025
Automated using this command:

perl -pi.bak -e 's/(20[012][0-9])-20[12][01234]/$1-2025/g' `git ls-files`
2025-02-16 17:00:46 +00:00
Richard W.M. Jones
1b7d905d43 logo: Restore year banner in logo
Fixes: commit e2c7bddf10
2025-02-16 16:57:43 +00:00
Richard W.M. Jones
32644856e7 build: Remove test-functions.sh which was moved and renamed
Fixes: commit b5fbc7e617
2025-02-16 15:39:31 +00:00
Richard W.M. Jones
b5fbc7e617 tests: Replace $TEST_FUNCTIONS
Replace strange $TEST_FUNCTIONS variable/expansion thing with
something more like what we use in nbdkit, a simple tests/functions.sh
script that gets sourced into each test script.

Update the common submodule to get:

  commit 8137d47d0e654065391151eb275e3b64f230f6f5
  Author: Richard W.M. Jones <rjones@redhat.com>
  Date:   Thu Feb 13 11:13:55 2025 +0000

    mlcustomize, mltools: Replace $TEST_FUNCTIONS

    TEST_FUNCTIONS is being removed from libguestfs and guestfs-tools (it
    was removed from virt-v2v a while back).  Make the same adjustment in
    the common submodule.

(and some other commits which are not relevant to libguestfs)
2025-02-13 11:15:34 +00:00
Daniel Gomez
82e2dea96a appliance: add support for sfdisk on Debian
Fixes virt-builder error:

virt-builder: error: libguestfs error: inspect_os: execvp: sfdisk: No
such file or directory

Signed-off-by: Daniel Gomez <da.gomez@samsung.com>
2025-02-06 08:26:20 +00:00
Daniel Gomez
91fab3f498 appliance: add dhcpcd support on Debian
Debian has replaced the deprecated isc-dhcp-client (dhclient) with
dhcpcd-base (dhcpcd) as the default DHCP client [1]. This causes network
issues in virt-builder since isc-dhcp-client is no longer installed
by default.

Add support for dhcpcd (dhcpcd-base package) in Debian.

[1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1041066

Signed-off-by: Daniel Gomez <da.gomez@samsung.com>
2025-02-06 08:26:20 +00:00
Richard W.M. Jones
2c6fb596b7 Version 1.55.4. 2025-02-05 13:33:39 +00:00
Richard W.M. Jones
6ba8449927 appliance/init: Fix /usr/sbin symlinks in Fedora 42+
Since Fedora 42 merged /usr/sbin and /usr/bin, /usr/sbin is usually
populated with symbolic links to binaries in /usr/bin.  These are
created by a complicated script in filesystem.spec that we don't run.
Emulate sort of what that script is doing instead.

This is a hack that we can eventually remove, hopefully.

See-also: https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/thread/PCU2WWLEGLGIOY4TCCBIHLYS6ZCZ4GSS/
2025-02-05 13:09:26 +00:00
rwmjones
0dee44bd36 Merge pull request #169 from weblate/weblate-libguestfs-libguestfs-master
Translations update from Fedora Weblate
2025-02-03 08:04:00 +00:00
Ricky Tigg
9cfa081a91 Translated using Weblate (Finnish)
Currently translated at 9.7% (94 of 960 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/fi/
2025-01-11 08:16:02 +01:00
rwmjones
16a407fc44 Merge pull request #168 from weblate/weblate-libguestfs-libguestfs-master
Translations update from Fedora Weblate
2025-01-09 09:13:25 +00:00
Weblate
19e2caf587 Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/
2025-01-09 09:38:45 +01:00
Ricky Tigg
1d7897aa63 Translated using Weblate (Finnish)
Currently translated at 1.4% (231 of 16048 strings)

Translation: libguestfs/libguestfs-docs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-docs-master/fi/
2025-01-09 09:38:44 +01:00
Richard W.M. Jones
ef64bb6a88 Version 1.55.3. 2025-01-08 17:43:19 +00:00
Richard W.M. Jones
2ec93578be po-docs/libguestfs-docs.pot: Rebuild this file from scratch
Reported-by: Ricky Tigg
Fixes: https://github.com/libguestfs/libguestfs/issues/167
2025-01-08 12:12:07 +00:00
Richard W.M. Jones
b875c5e6b0 dist: Force po-docs/libguestfs-docs.pot to be rebuilt
It's not ideal to delete this file, but it seems like the only way to
force make to really rebuild it.
2025-01-08 12:10:33 +00:00
Richard W.M. Jones
48d3264573 po-docs: Use po4a-updatepo
As far as I can tell using po4a-gettextize was wrong here.  The right
subtool for combining multiple documents into a .pot is po4a-updatepo,
so use that one instead.
2025-01-08 12:04:26 +00:00
Richard W.M. Jones
1aa883c50d docs/guestfs-release-notes-1.34.pod: Clarify confusing language
Reported-by: Ricky Tigg
Fixes: https://github.com/libguestfs/libguestfs/issues/167
2025-01-08 11:44:39 +00:00
rwmjones
0e982277fa Merge pull request #164 from rwmjones/issue162
daemon: Translate file 5.46 "Intel i386" to "i386"
2025-01-06 09:39:06 +00:00
Richard W.M. Jones
ed21af3b0a daemon: Translate file 5.46 "Intel i386" to "i386"
Fixes: https://github.com/libguestfs/libguestfs/issues/162
Reported-by: Toolybird
2025-01-02 16:13:35 +00:00
rwmjones
7008e2e350 Merge pull request #161 from weblate/weblate-libguestfs-libguestfs-master
Translations update from Fedora Weblate
2025-01-02 15:43:25 +00:00
Ricky Tigg
1e52c5b253 Translated using Weblate (Finnish)
Currently translated at 1.3% (211 of 16048 strings)

Translation: libguestfs/libguestfs-docs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-docs-master/fi/
2024-12-20 16:48:24 +01:00
Weblate
db0ad1f25d Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/
2024-12-20 10:39:13 +01:00
Ricky Tigg
0ffef7e655 Translated using Weblate (Finnish)
Currently translated at 1.2% (199 of 16048 strings)

Translation: libguestfs/libguestfs-docs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-docs-master/fi/

Translated using Weblate (Finnish)

Currently translated at 9.6% (93 of 960 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/fi/
2024-12-20 10:39:13 +01:00
Richard W.M. Jones
996dd8774f build: Move baseline OCaml to 4.08
OCaml 4.08.0 was released on 2019-06-14, over 5 years ago.  By
requiring a slightly later OCaml version, we can drop more
compatibility code which was only used by older versions.

Consistent with qemu & libvirt, this drops support for compiling
upstream libguestfs on RHEL 8 (ocaml-4.07.0-4.el8.x86_64).

Qemu policy:
https://www.qemu.org/docs/master/about/build-platforms.html

Libvirt policy:
https://libvirt.org/platforms.html

Update the common submodule, pulling in:

  Richard W.M. Jones (4):
      qemuopts: Add ability to add raw, unquoted output to qemu scripts
      qemuopts: Fix missing break statement
      mlstdutils: Remove Option module
      Remove test for caml_alloc_initialized_string
2024-11-21 14:30:44 +00:00
Richard W.M. Jones
453de98bda Version 1.55.2. 2024-11-18 14:39:38 +00:00
Richard W.M. Jones
4ebec324fe docs: recipes: Update xpath command
Link: https://lists.libguestfs.org/archives/list/guestfs@lists.libguestfs.org/thread/SOWJHHHJXDFAKSCCLXCNUE5X7W22VUEQ/
Reported-by: Emmanuel Kasper
2024-11-18 14:05:06 +00:00
Richard W.M. Jones
73186b154c generator: Remove common/mlv2v/uefi.ml{,i} files
Stop generating these files.  They are currently only used by virt-v2v
-o qemu mode, and there are better ways to locate the UEFI files
there.

Update the common submodule to bring in:

  Richard W.M. Jones (5):
      mlcustomize: Add heuristic support for Windows Server 2025
      mlcustomize/customize_run.ml: Move 'in' to new line
      mlstdutils/guestfs_config: Define host_os
      mlcustomize, mltools: Check guest OS is compatible before allowing --run
      Remove mlv2v/ subdirectory
2024-11-15 11:43:50 +00:00
rwmjones
8af8e15b44 Merge pull request #159 from twouters/bugfix/dhcpcd_resolvconf_symlink
Fix dhcpcd failing on systemd-resolved stub
2024-11-14 09:01:05 +00:00
Thomas Wouters
84d1cd0707 Fix dhcpcd failing on systemd-resolved stub
dhcpcd fails to update /etc/resolv.conf if is a dangling symlink, so remove it
if it is.

This happens on Arch Linux when systemd-resolved is enabled by symlinking
/etc/resolv.conf to /run/systemd/resolve/stub-resolv.conf. The symlink is copied
into the supermin appliance, but the target file is not and this causes dhcpcd to
fail when it tries to update /etc/resolv.conf.

The handling of /etc/resolv.conf could be improved in dhcpcd but it's not their
job to decide when to remove the symlink. We do have the authority to decide
whether or not to use systemd-resolved or resolvconf in the appliance, so we can
remove it.
2024-11-13 14:09:59 +01:00
rwmjones
7d551fa7db Merge pull request #158 from weblate/weblate-libguestfs-libguestfs-master
Translations update from Fedora Weblate
2024-11-06 12:22:03 +00:00
Weblate
2ce7b00e1e Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/
2024-11-06 13:16:54 +01:00
Léane GRASSER
ea86636649 Translated using Weblate (French)
Currently translated at 63.8% (614 of 961 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/fr/
2024-11-06 13:16:54 +01:00
Richard W.M. Jones
a47e2cf6a8 website: Fix link to latest development version
Fixes: commit 0edaea8f91
2024-10-22 17:44:06 +01:00
Richard W.M. Jones
7932b92379 Version 1.55.1. 2024-10-22 17:38:11 +01:00
Richard W.M. Jones
9255abee02 build: Remove Jansson dependency
After previous changes, this library is no longer used.  We have
switched to json-c, for better compatibility with libvirt.

(cherry picked from
guestfs-tools commit e6dcf7e3a7e9170978e57ce6df1b34f92fac5ae3)
2024-10-22 16:44:53 +01:00
Richard W.M. Jones
9e3c1f44ca lib/qemu.c: Replace jansson with json-c 2024-10-22 16:44:53 +01:00
Richard W.M. Jones
47857751a7 lib: direct: Remove test for qemu mandatory locking
We tested for QEMU >= 2.10 support for mandatory locking.  I believe
this is for all practical purposes always enabled now (and qemu 2.10
is ancient history) so simply assume it's true always.
2024-10-22 16:23:07 +01:00
Richard W.M. Jones
13e3222f34 lib/info.c: Replace jansson with json-c 2024-10-22 16:03:16 +01:00
Richard W.M. Jones
8e34b37bcd common: Update common submodule
Although we don't use JSON_parser in libguestfs, update the submodule
just to get rid of another Jansson dependency:

  Richard W.M. Jones (1):
      mltools: Replace jansson with json-c
2024-10-22 15:35:14 +01:00
Richard W.M. Jones
5ea1e899e0 daemon/ldm.c: Replace jansson with json-c 2024-10-22 11:02:38 +01:00
Richard W.M. Jones
53872a0a1a build: Add new dependency on json-c
This will eventually replace Jansson for all JSON parsing.  However
this commit simply introduces the new dependency in the configure
script and documents it.

I chose json-c 0.14 as the baseline since that is the version in RHEL 9.
Probably earlier versions would work.
2024-10-22 11:01:25 +01:00
Richard W.M. Jones
798e3e59b2 appliance: Refactor the TAR_COMMAND macro
No change, just make it easier to understand.

Updates: commit 53632b4b82
2024-10-22 09:15:56 +01:00
Richard W.M. Jones
53632b4b82 appliance: Use stable owner, group and mtime in appliance tarballs
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2320025
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
2024-10-21 12:14:03 +01:00
Richard W.M. Jones
e37768d889 build: Assume __attribute__((cleanup)) always works
All recent compilers support this (except MS compilers which we don't
care about).  Assume it is supported.  We test it in ./configure and
hard fail if it doesn't work.

We still define HAVE_ATTRIBUTE_CLEANUP but you can now assume it is
always defined and don't have to check it.
2024-10-18 21:55:21 +01:00
Richard W.M. Jones
0f489f8eec lib/inspect-osinfo.c: Add Windows Server 2025 osinfo
The guest was found to have these inspection fields:

    type: windows
    distro: windows
    product_name: Windows Server 2025 Standard
    product_variant: Server
    version: 10.0
    arch: x86_64
    hostname: WIN-84V4KKQ30SM
    build ID: 26080
    windows_systemroot: /Windows
    windows_software_hive: /Windows/System32/config/SOFTWARE
    windows_system_hive: /Windows/System32/config/SYSTEM
    windows_current_control_set: ControlSet001

Reported-by: Ming Xie
Fixes: https://issues.redhat.com/browse/RHEL-62935
2024-10-17 08:59:49 +01:00
Richard W.M. Jones
c25ff1a802 tests/gdisk/test-expand-gpt.pl: Implement SKIP rule for this test
Reported-by: David Runge
Related: https://github.com/libguestfs/libguestfs/issues/155
2024-10-14 10:43:08 +01:00
Richard W.M. Jones
0edaea8f91 website: Add links for 1.54 and 1.55 download locations 2024-10-08 14:53:38 +01:00
Richard W.M. Jones
3fb6ebb342 Version 1.54.0. 2024-10-08 14:37:12 +01:00
Richard W.M. Jones
e4691f66b7 docs: Finalize release notes for libguestfs 1.54 2024-10-08 13:41:43 +01:00
Richard W.M. Jones
715b5def13 Version 1.53.7. 2024-10-03 13:09:36 +01:00
Richard W.M. Jones
49f118e9da docs: Create outline release notes for 1.54 2024-10-02 16:13:52 +01:00
Richard W.M. Jones
e97c6f5933 bugs-in-changelog.sh: List Jira IDs and github issues in output 2024-10-02 16:02:43 +01:00
Richard W.M. Jones
a6639afb74 po-docs: Add mlcustomize POD to po-docs/podfiles
Add these two files from the common/ submodule:

common/mlcustomize/v2v-customize-options.pod
common/mlcustomize/v2v-customize-synopsis.pod

Updates: commit fe1ce09242
2024-10-02 15:48:41 +01:00
Richard W.M. Jones
e55eac12d4 docs: Update libguestfs email address in a couple more places
Reported-by: Julian Euler
2024-09-12 12:45:54 +01:00
Wang Guoquan
1d8924c343 libguestfs: Support openEuler
openEuler is simliar to CentOS, but the ID is not lower-case string,
as below:

    NAME="openEuler"
    VERSION="24.03 (LTS)"
    ID="openEuler"
    VERSION_ID="24.03"
    PRETTY_NAME="openEuler 24.03 (LTS)"
    ANSI_COLOR="0;31"

Signed-off-by: Wang Guoquan <wangguoquan03@foxmail.com>
2024-09-10 11:33:20 +01:00
rwmjones
82ffc1e66e Merge pull request #153 from weblate/weblate-libguestfs-libguestfs-master
Translations update from Fedora Weblate
2024-09-04 13:35:14 +01:00
Yuri Chornoivan
f2e5dbf0ef Translated using Weblate (Ukrainian)
Currently translated at 100.0% (961 of 961 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/uk/
2024-09-04 12:38:36 +02:00
rwmjones
faec06b6fb Merge pull request #152 from weblate/weblate-libguestfs-libguestfs-master
Translations update from Fedora Weblate
2024-09-02 15:00:44 +01:00
Weblate
6ed520dc00 Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/
2024-09-02 15:40:40 +02:00
Andi Chandler
82b538abae Translated using Weblate (English (United Kingdom))
Currently translated at 54.0% (8671 of 16047 strings)

Translation: libguestfs/libguestfs-docs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-docs-master/en_GB/

Translated using Weblate (English (United Kingdom))

Currently translated at 3.4% (33 of 970 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/en_GB/
2024-09-02 15:40:39 +02:00
Richard W.M. Jones
fe1ce09242 generator: Don't include virt-customize --inject* options in virt-v2v
Virt-v2v already includes facilities for injecting QEMU guest agent
etc.  We shouldn't add the virt-customize options for this.

Update common submodule to include:

Richard W.M. Jones (2):
      mlcustomize: Move virt-customize modules to mlcustomize/
      mlcustomize: Update generated options for virt-v2v
2024-08-20 21:22:30 +01:00
Richard W.M. Jones
ba6b5c71d4 Version 1.53.6. 2024-08-16 15:29:34 +01:00
Richard W.M. Jones
b607f97329 Update common submodule
Pull in some fixes from the common submodule.  None of these should be
applicable to libguestfs, they apply only to guestfs-tools and
virt-v2v.

Richard W.M. Jones (13):
      mlcustomize: Add Inject_virtio_win.inject_blnsvr implementation
      mlcustomize: firstboot: Use Linux path for Powershell script path
      mlcustomize: firstboot: Use powershell.exe instead of path
      mlcustomize: firstboot: Use Powershell -NoProfile flag
      mlcustomize: Revert delay installation of qemu-ga MSI
      mldrivers/linux_kernels.ml: Prefix general information with ^info:
      mlcustomize: Use Start-Process -Wait to run qemu-ga installer
      mlcustomize: Add Firstboot.firstboot_dir function
      mlcustomize: Place powershell scripts into <firstboot_dir>\Temp
      mlcustomize: Inject qemu-ga & blnsvr into <firstboot_dir>/Temp
      mlcustomize: Write qemu-ga log file name to log.txt
      mlcustomize: Add some comments to firstboot batch file
      mlcustomize: Reboot Windows between each firstboot script
2024-08-16 14:58:16 +01:00
Richard W.M. Jones
b2d682a473 appliance/init: Don't set impossible "noop" disk scheduler
Since RHEL 7.4, the noop scheduler is no longer a thing.  Trying to
set it results in the error:

  + echo noop
  /init: line 108: echo: write error: Invalid argument

The current recommendation (https://access.redhat.com/solutions/5427)
is to use mq-deadline, but that's also the default so we don't have to
do anything.

A bigger reason to remove these lines is that kernel 6.11.0 has
introduced a hang where -- rarely -- the ext4 filesystem hangs if you
try to change the scheduler while handing a page fault, even if you're
setting a scheduler that doesn't exist.  I couldn't get much detail
except for a couple of stack traces from different VMs:

  crash> set 234
      PID: 234
  COMMAND: "modprobe"
     TASK: ffff9f5ec3a22f40  [THREAD_INFO: ffff9f5ec3a22f40]
      CPU: 0
    STATE: TASK_UNINTERRUPTIBLE
  crash> bt
  PID: 234      TASK: ffff9f5ec3a22f40  CPU: 0    COMMAND: "modprobe"
   #0 [ffffb21e002e7840] __schedule at ffffffffa718f6d0
   #1 [ffffb21e002e78f8] schedule at ffffffffa7190a27
   #2 [ffffb21e002e7908] __bio_queue_enter at ffffffffa67e121c
   #3 [ffffb21e002e7968] blk_mq_submit_bio at ffffffffa67f358c
   #4 [ffffb21e002e79f0] __submit_bio at ffffffffa67e1e3c
   #5 [ffffb21e002e7a58] submit_bio_noacct_nocheck at ffffffffa67e2326
   #6 [ffffb21e002e7ac0] ext4_mpage_readpages at ffffffffa65ceafc
   #7 [ffffb21e002e7be0] read_pages at ffffffffa6381d17
   #8 [ffffb21e002e7c40] page_cache_ra_unbounded at ffffffffa6381ff5
   #9 [ffffb21e002e7ca8] filemap_fault at ffffffffa63761b5
  #10 [ffffb21e002e7d48] __do_fault at ffffffffa63d1892
  #11 [ffffb21e002e7d70] do_fault at ffffffffa63d2425
  #12 [ffffb21e002e7da0] __handle_mm_fault at ffffffffa63d8c6b
  #13 [ffffb21e002e7e88] handle_mm_fault at ffffffffa63d95c2
  #14 [ffffb21e002e7ec8] do_user_addr_fault at ffffffffa60b34ea
  #15 [ffffb21e002e7f28] exc_page_fault at ffffffffa7186e4e
  #16 [ffffb21e002e7f50] asm_exc_page_fault at ffffffffa72012a6
      RIP: 000055d16159f8d8  RSP: 00007ffdd4c1f340  RFLAGS: 00010206
      RAX: 00000000000bec82  RBX: 00007ff2fd00dc82  RCX: 000055d1615b492a
      RDX: 00007ffdd4c216b0  RSI: 00000000200bec82  RDI: 000055d185725960
      RBP: 00007ffdd4c1f5a0   R8: 0000000000000000   R9: 0000000000000000
      R10: 0000000000000000  R11: 0000000000000202  R12: 00000000200bec82
      R13: 000055d185725960  R14: 00007ffdd4c216b0  R15: 000055d1615b9708
      ORIG_RAX: ffffffffffffffff  CS: 0033  SS: 002b

  crash> set 230
      PID: 230
  COMMAND: "modprobe"
     TASK: ffff98ce03ca3040  [THREAD_INFO: ffff98ce03ca3040]
      CPU: 0
    STATE: TASK_UNINTERRUPTIBLE
  crash> bt
  PID: 230      TASK: ffff98ce03ca3040  CPU: 0    COMMAND: "modprobe"
   #0 [ffffaf9940307840] __schedule at ffffffff9618f6d0
   #1 [ffffaf99403078f8] schedule at ffffffff96190a27
   #2 [ffffaf9940307908] __bio_queue_enter at ffffffff957e121c
   #3 [ffffaf9940307968] blk_mq_submit_bio at ffffffff957f358c
   #4 [ffffaf99403079f0] __submit_bio at ffffffff957e1e3c
   #5 [ffffaf9940307a58] submit_bio_noacct_nocheck at ffffffff957e2326
   #6 [ffffaf9940307ac0] ext4_mpage_readpages at ffffffff955ceafc
   #7 [ffffaf9940307be0] read_pages at ffffffff95381d1a
   #8 [ffffaf9940307c40] page_cache_ra_unbounded at ffffffff95381ff5
   #9 [ffffaf9940307ca8] filemap_fault at ffffffff953761b5
  #10 [ffffaf9940307d48] __do_fault at ffffffff953d1895
  #11 [ffffaf9940307d70] do_fault at ffffffff953d2425
  #12 [ffffaf9940307da0] __handle_mm_fault at ffffffff953d8c6b
  #13 [ffffaf9940307e88] handle_mm_fault at ffffffff953d95c2
  #14 [ffffaf9940307ec8] do_user_addr_fault at ffffffff950b34ea
  #15 [ffffaf9940307f28] exc_page_fault at ffffffff96186e4e
  #16 [ffffaf9940307f50] asm_exc_page_fault at ffffffff962012a6
      RIP: 0000556b7a7468d8  RSP: 00007ffde2ffb560  RFLAGS: 00000206
      RAX: 00000000000bec82  RBX: 00007f5331a0dc82  RCX: 0000556b7a75b92a
      RDX: 00007ffde2ffd8d0  RSI: 00000000200bec82  RDI: 0000556ba8edf960
      RBP: 00007ffde2ffb7c0   R8: 0000000000000000   R9: 0000000000000000
      R10: 0000000000000000  R11: 0000000000000202  R12: 00000000200bec82
      R13: 0000556ba8edf960  R14: 00007ffde2ffd8d0  R15: 0000556b7a760708
      ORIG_RAX: ffffffffffffffff  CS: 0033  SS: 002b

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2303267
2024-08-16 08:32:40 +01:00
Antonio Caggiano
bbc58ed8fb ocaml: INSTALL_OCAMLLIB Makefile parameter
Add INSTALL_OCAMLLIB parameter for allowing ocaml install to a user
defined path. If not defined, fallback to `ocamlc -where`.

Signed-off-by: Antonio Caggiano <quic_acaggian@quicinc.com>
2024-08-13 14:00:42 +01:00
Antonio Caggiano
e17d794d11 configure: Use -map in script flags on darwin.
-M is not a valid flag for MacOS ld.

Signed-off-by: Antonio Caggiano <quic_acaggian@quicinc.com>
2024-08-12 14:05:01 +01:00
Antonio Caggiano
ad3ccf42ab qemu: Add HVF to the accelerators list.
This speeds up greatly QEMU when running on MacOS.

Signed-off-by: Antonio Caggiano <quic_acaggian@quicinc.com>
2024-08-12 11:28:50 +01:00
Antonio Caggiano
0bae769f78 lib: Fix environ on MacOS
On macOS, environ is not declared. Use the workaround suggested here:
https://www.gnu.org/software/gnulib/manual/html_node/environ.html

Signed-off-by: Antonio Caggiano <quic_acaggian@quicinc.com>
2024-08-12 11:24:07 +01:00
Antonio Caggiano
b25bb8b8ba build: Link libvirt-is-version with libgnu
This fixes building the tool on MacOS.

Signed-off-by: Antonio Caggiano <quic_acaggian@quicinc.com>
2024-08-12 11:24:07 +01:00
Richard W.M. Jones
3d2061b83c daemon/inspect_fs.ml: Sort lists of distros
No change, just tidying up the lists.
2024-07-11 13:12:41 +01:00
grass-lu
a429ab3319 Kylin is centos derivative
Acked-by: Richard W.M. Jones <rjones@redhat.com>
2024-07-11 13:12:24 +01:00
Richard W.M. Jones
e631d1a78c Version 1.53.5. 2024-07-08 16:27:32 +01:00
Richard W.M. Jones
6bf22df62a generator/actions_core.ml: Fix version field for new APIs
Fixes: commit 1816651f3c
2024-07-08 16:27:13 +01:00
Richard W.M. Jones
e616c8f286 inspection: Resolve PARTUUID= and PARTLABEL= in /etc/fstab
Fixes: https://issues.redhat.com/browse/RHEL-46596
2024-07-08 14:44:01 +01:00
Richard W.M. Jones
1816651f3c New APIs: findfs_partuuid and findfs_partlabel
These search for partitions by UUID or label (name).  They only work
for GPT.
2024-07-08 14:44:01 +01:00
Richard W.M. Jones
4c5c0782af daemon/findfs.ml: Fix whitespace 2024-07-08 14:37:06 +01:00
Richard W.M. Jones
5b8b7baefd Version 1.53.4. 2024-06-28 12:50:43 +01:00
Richard W.M. Jones
be06cb048b perl: Pass @CFLAGS@ through extra_linker_flags
The documentation for Module::Build is completely opaque on how you're
supposed to pass @CFLAGS@ correctly.  However I noticed that we were
not passing -g through when generating Guestfs.so:

gcc -lpthread -shared -Wl,-z,relro -Wl,--as-needed -Wl,-z,pack-relative-relocs -Wl,-z,now '-specs=/usr/lib/rpm/redhat/redhat-hardened-ld' '-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1' '-Wl,--build-id=sha1' -L/usr/local/lib -fstack-protector-strong -lperl -o blib/arch/auto/Sys/Guestfs/Guestfs.so lib/Sys/Guestfs.o -L../lib/.libs -lguestfs

This debuginfo was not always being generated correctly.  (For some
reason it still manages to be generated in Fedora and RHEL 9, but not
in RHEL 10, this part is still unclear to me.)

Anyway it seems we ought to pass at least -g to the linker, and we
might as well pass the full set of @CFLAGS@, hence this change.
2024-06-28 12:37:11 +01:00
Richard W.M. Jones
24c1f7b03a daemon: Fix parsing in part_get_gpt_attributes
The actual output of sfdisk --part-attrs is bizarre and doesn't match
the documentation.  After looking at the source from util-linux, fix
the parsing to match what sfdisk produces.

Reported-by: Yongkui Guo
Fixes: commit c6c266a85d
Fixes: https://issues.redhat.com/browse/RHEL-35998
2024-06-28 09:42:20 +01:00
Richard W.M. Jones
882ef4d93a generator/daemon: Don't truncate 64 bit results from OCaml functions
Commit d5b6f1df5f ("daemon: Allow parts of the daemon and APIs to be
written in OCaml.", 2017) contained a bug where in any OCaml function
that returns int64_t, the result was truncated to an int.  This
particularly affected part_get_gpt_attributes as that returns large 64
bit numbers, but probably affects other functions too, undetected.

Fixes: commit d5b6f1df5f
2024-06-28 09:39:59 +01:00
Richard W.M. Jones
06eff058a3 Version 1.53.3. 2024-06-27 16:40:55 +01:00
Richard W.M. Jones
8b3e8a9056 Remove tftp drive support
This was only theoretically supported, via curl.  It's unlikely that
it really worked as it was never tested.

If needed it's better to use nbdkit-curl-plugin instead (this applies
to http and ftp as well).
2024-06-27 16:27:06 +01:00
Richard W.M. Jones
b1db7847ee Remove sheepdog support
This was discontinued in qemu quite a long time ago.
2024-06-27 16:22:52 +01:00
Richard W.M. Jones
c080449511 Remove gluster support
Development on gluster has stopped upstream, see:

https://marc.info/?l=fedora-devel-list&m=171934833215726&w=2
2024-06-27 16:13:09 +01:00
Jürgen Hötzel
43946911c7 rust: Handle null pointer when creating slice
Starting with Rust 1.78 null assertions in the standard library are
now checked when compiling in test/debug mode.

Fixes: https://github.com/libguestfs/libguestfs/issues/145
2024-06-20 13:27:51 +01:00
rwmjones
893c05fc40 Merge pull request #147 from jonte/feature/cryptsetup_cipher
daemon: cryptsetup_open: Add --cipher
2024-06-20 10:43:47 +01:00
Jonatan Pålsson
465be22d9b daemon: cryptsetup_open: Add --cipher
This allows passing the --cipher argument to cryptsetup as an optional
parameter.
2024-06-20 07:42:55 +02:00
Richard W.M. Jones
12da1de0a8 lib: libvirt: Stop recommending LIBGUESTFS_BACKEND=direct
After many, many years, although libvirt does still often fail to
work, it's generally more secure to stick with libvirt than to try
running qemu directly.  The main issue here is that people have
cargo-culted LIBGUESTFS_BACKEND=direct everywhere (even when it's not
necessary).
2024-05-22 11:22:31 +01:00
Richard W.M. Jones
219845d5d0 generator/customize.ml: Add virt-customize --inject-blnsvr operation
Also updates the common submodule with the generated files.
2024-05-16 12:48:51 +01:00
Olaf Hering
4ef645778a appliance: only wait for resolv.conf update if dhcpcd succeeded
In case network was requested, but the host lacks both dhclient and
dhcpcd, skip the loop which waits for a resolv.conf update.

This reduces boot time by 10 seconds.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
2024-05-15 17:11:02 +01:00
Richard W.M. Jones
27deba4074 gobject: Add libguestfs-gobject-1.0.deps to main EXTRA_DIST line
Move this outside the 'if HAVE_INTROSPECTION' conditional so that we
get this object in the tarball even if using ./configure --disable-gobject
2024-05-13 14:52:21 +01:00
Richard W.M. Jones
c7fe9fd917 tests: btrfs: Remove another test that used qgroup 0/*
This was failing with recent Linux:

  libguestfs: error: btrfs_subvolume_snapshot: /dir/test3: /dir/test6: ERROR: cannot snapshot '/sysroot/dir/test3': Invalid argument

I tried to change the test to use 1/1000 instead, but that fails with
a different error which I don't understand at all.

As we're not meant to be testing btrfs here, only that libguestfs can
translate between the guestfs API and btrfs commands and we know it
can do that, I simply deleted the sub-test entirely.
2024-05-13 14:35:36 +01:00
Richard W.M. Jones
ff3dd6f91f Version 1.53.2. 2024-05-10 16:47:17 +01:00
Richard W.M. Jones
c6c266a85d daemon: Reimplement partition GPT functions using sfdisk
sfdisk can now do everything with GPT that sgdisk was needed for
before.  In particular we are able to reimplement the following
functions using sfdisk:

- part_set_disk_guid   (replace with sfdisk --disk-id)
- part_get_disk_guid
- part_set_disk_guid_random
- part_set_gpt_attributes           (sfdisk --part-attrs)
- part_get_gpt_attributes
- part_set_gpt_guid                 (sfdisk --part-uuid)
- part_get_gpt_guid
- part_set_gpt_type                 (sfdisk --part-type)
- part_get_gpt_type

This allows us to drop the requirement for gdisk in many cases.

There is only one API remaining which requires gdisk, part_expand_gpt,
which we do not use in our tools.  In a prior commit I already moved
this solitary function to a new source file (daemon/gdisk.c).

Fixes: https://issues.redhat.com/browse/RHEL-35998
2024-05-10 16:25:13 +01:00
Richard W.M. Jones
a25f419802 daemon: Add an OCaml binding for get_random_uuid function 2024-05-10 16:07:20 +01:00
Richard W.M. Jones
53eb96099a generator: Allow String(GUID) parameter in daemon OCaml bindings 2024-05-10 15:37:08 +01:00
Richard W.M. Jones
d5c6e15180 daemon: Move gdisk function to a new file
After subsequent commits, this will be the only remaining use of
gdisk, so put it in its own file now.
2024-05-10 15:36:03 +01:00
Richard W.M. Jones
2811e42b43 daemon: part_get_gpt_type: Remove unhelpful MBR fallback behaviour
This was an accident of the parted implementation, and wasn't really
used anywhere.  Remove it.
2024-05-10 15:29:07 +01:00
Richard W.M. Jones
857615d6d2 daemon/parted: Assume sfdisk --part-type exists
This "new" parameter was added in 2014:

  commit 8eab3194ce1737a167812d5e84d83b0dfc253fac
  Author: Karel Zak <kzak@redhat.com>
  Date:   Mon Sep 15 12:37:52 2014 +0200

    sfdisk: add --parttype

    The patch also makes --{id,change-id,print-id} deprecated in favour
    of --parttype. The original --id is too generic option name and the
    --print-id and --change-id are unnecessary and inconsistent with
    another sfdisk options (e.g. we don't have --change-bootable)

Also remove an extraneous / incorrect comment about parted.  As
history has played out, sfdisk proves to be the better tool and parted
is a PITA.
2024-05-10 15:29:07 +01:00
rwmjones
8c438e7442 Merge pull request #142 from weblate/weblate-libguestfs-libguestfs-master
Translations update from Fedora Weblate
2024-05-09 10:49:23 +01:00
Weblate
2234390442 Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/
2024-05-09 11:36:38 +02:00
zhanchun li
2a611c3a33 Translated using Weblate (Chinese (Simplified) (zh_CN))
Currently translated at 2.9% (29 of 970 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/zh_CN/
2024-05-09 11:36:37 +02:00
Richard W.M. Jones
c2f1825574 Version 1.53.1. 2024-04-25 13:43:28 +01:00
Richard W.M. Jones
e0ffe31e96 gobject: tests: Don't erase error messages 2024-04-25 13:17:02 +01:00
Richard W.M. Jones
665e0dde81 test-data/binaries: Regenerate LoongArch files with stripping
These were regenerated by Dan Berrange from a known good Debian
container image.  In addition they are stripped.  The commands were:

 $ podman run -it registry.gitlab.com/qemu-project/qemu/qemu/debian-loongarch-cross
 # echo 'int main(){}' > bin.c
 # loongarch64-unknown-linux-gnu-gcc bin.c -o bin-loongarch64
 # loongarch64-unknown-linux-gnu-strip --strip-all bin-loongarch64
 # echo '' > lib.c
 # loongarch64-unknown-linux-gnu-gcc -shared lib.c -o lib-loongarch64.so
 # loongarch64-unknown-linux-gnu-strip --strip-all lib-loongarch64.so

Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2024-04-25 13:00:55 +01:00
Richard W.M. Jones
574a87f889 test-data/binaries: Remove +x attribute
These binaries are not meant to be run, they are purely data files
used for testing.  Remove the +x attribute to prevent accidentally
running them.

However to avoid breaking the phony guests, we need to chmod +x the
files when we upload them into those guests.
2024-04-25 13:00:22 +01:00
Richard W.M. Jones
87b4d19f85 po-docs: Make sure guestmount.1 depends on includes
guestmount.1 depends on translated files blocksize-option.pod,
key-option.pod & keys-from-stdin-option.pod (via __INCLUDE__
directives).  If these are not yet translated by the time we try to
generate guestmount.1 then it will fail with:

podwrapper.pl: key-option.pod: cannot find input file on path at /builddir/build/BUILD/libguestfs-1.50.1/podwrapper.pl line 672.

This happens especially in parallel builds.  Fix this by writing the
guestmount.1 rule explicitly, with the correct dependencies.
2024-04-24 22:17:33 +01:00
Richard W.M. Jones
7968de46f1 Update common submodule
In particular pick this:

  commit 93a7f3af5c23ece6a8e092827ed5928a8973fd3c
  Author: Richard W.M. Jones <rjones@redhat.com>
  Date:   Wed Apr 24 12:08:01 2024 +0100

    options: Allow nbd+unix:// URIs
2024-04-24 12:23:34 +01:00
Richard W.M. Jones
6ba64125d9 website: Update link for forthcoming 1.53 development branch 2024-04-13 10:41:55 +01:00
Richard W.M. Jones
d755070346 po-docs: Run po4a-translate and sed commands separately
I noticed that 1-byte translated POD files were being generated in the
output directory (po-docs/ja/).  This seems to have happened because
po4a-translate was generating an error, but because we were
immediately pipeing the output into sed the error was suppressed.

By running them as two separate commands this cannot happen.

Fixes: commit bd896d68c0
2024-04-04 09:38:28 +01:00
Richard W.M. Jones
d829778529 po-docs: Rename guestfs-release-notes-historical to guestfs-release-notes
This was missed from earlier commit 25ddaefb03 ("docs: Recreate
guestfs-release-notes(1) page").

Fixes: commit 25ddaefb03
2024-04-04 09:28:43 +01:00
Richard W.M. Jones
1d760b0d8f python: Fix exception name in example
Fixes: https://github.com/libguestfs/libguestfs/issues/138
2024-03-12 14:08:24 +00:00
Richard W.M. Jones
37d2379be2 daemon: Fix file architecture translation for LoongArch
Fixes: commit 729d6d55ea
2024-03-07 16:50:29 +00:00
Richard W.M. Jones
7211aac047 tests: btrfs: Don't try to create qgroup 0/_
This used to work in kernel <= 6.7 but has been forbidden in later
kernels:
0c309d66da

Reported-by: David Runge
Thanks: Jan Alexander Steffens
Fixes: https://github.com/libguestfs/libguestfs/issues/136
2024-03-07 16:50:29 +00:00
Richard W.M. Jones
c8cefa6f0f daemon: parted: Print field we are extracting in error message 2024-03-07 14:17:45 +00:00
liuxiang
729d6d55ea Add support for LoongArch.
Signed-off-by: liuxiang <liuxiang@loongson.cn>
2024-02-21 10:50:07 +00:00
Bella Zhang
72f99817c7 Add detection support for Circle Linux 2024-02-06 12:22:00 +00:00
Alexey Shabalin
f878f72430 daemon: Add gost checksum command support
gostsum - generates or checks GOST R34.11-94 message digests
gost12sum - generates or checks GOST R34.11-2012 message digests

A reference implementation https://github.com/gost-engine/engine

Fixes: https://github.com/libguestfs/libguestfs/pull/132
Signed-off-by: Alexey Shabalin <shaba@altlinux.org>

[RWMJ: Added documentation, and added gostsum package to
the appliance]
2024-01-25 13:28:22 +00:00
Richard W.M. Jones
e9a728bb22 generator/customize.ml: Split --chown parameter on ':' character
The previous code split it on ',' which was completely wrong.
(It reveals the lack of testing however).

Fixes: commit c08032ebe2
Reported-by: Yongkui Guo
2024-01-19 13:24:37 +00:00
Richard W.M. Jones
836a977c16 Version 1.52.0. 2024-01-04 17:31:41 +00:00
Richard W.M. Jones
9bfd3f9b25 docs: Fix AUTHORS to account for changes to common submodule
Updates: commit 68fcf11456
2024-01-04 16:51:01 +00:00
Richard W.M. Jones
08f6140398 docs: Further small revisions to libguestfs 1.52 release notes
Updates: commit 68fcf11456
2024-01-04 16:44:17 +00:00
Richard W.M. Jones
7b7f326767 docs: Fix description of new LVM mapper in --key feature
Fixes: commit 68fcf11456
2024-01-04 16:36:13 +00:00
Richard W.M. Jones
68fcf11456 docs: Add outline release notes for libguestfs 1.52 2024-01-04 13:47:34 +00:00
Richard W.M. Jones
4e4801a2c3 bugs-in-changelog.sh: Use grep -E instead of egrep
New version of coreutils egrep whinges.
2024-01-04 13:43:15 +00:00
Richard W.M. Jones
465db54be3 Version 1.51.10. 2023-12-19 15:30:45 +00:00
Juergen Hoetzel
102e503648 daemon/btrfs: Use new syntax for balance command
Support for the obsolete short syntax 'btrfs balance /path' was
removed in btrfs-progs 6.6.
2023-12-14 16:53:50 +00:00
Richard W.M. Jones
40f43cc8ea tests: Test guestfish --key all:... selector 2023-12-14 09:15:08 +00:00
Richard W.M. Jones
7fd41b5a02 Update common submodule
The list of patches is below.  The one which matters for guestfish is
addition of --key all:... selector.

Andrey Drobyshev (1):
      mldrivers: look for bootloader config in /boot/grub/grub.cfg in case of UEFI

Richard W.M. Jones (5):
      mlxml: Include <libxml/parser.h> for xmlReadMemory
      options/keys.c: Rewrite confusing match statement
      options: Rewrite --key documentation fragment
      options: Allow --key all:SELECTOR to be used to match any device
      mltools/libosinfo-c.c: Fix off-by-one error

Fixes: https://issues.redhat.com/browse/RHEL-19367
2023-12-14 09:04:56 +00:00
Richard W.M. Jones
e93fd7e8ac ocaml: Nullify custom block before releasing runtime lock
Avoids a potential, though if possible then very rare, double free
path.

Suggested-by: Guillaume Munch-Maccagnoni
See: https://github.com/ocaml/ocaml/issues/12820
2023-12-14 08:35:46 +00:00
Richard W.M. Jones
61418535ad ocaml: Use Gc.finalise instead of a C finalizer
Since OCaml 5.1.1, changes to custom blocks caused C finalizers that
call caml_enter_blocking_section to stop working (if they ever did
before).  They are relatively inflexible compared to registering an
OCaml finalizer (Gc.finalise) to call Guestfs.close, so use that
instead.

Suggested-by: Guillaume Munch-Maccagnoni
See: https://github.com/ocaml/ocaml/issues/12820
See: db48794fa8
2023-12-13 22:55:03 +00:00
Richard W.M. Jones
e5788357cf Version 1.51.9. 2023-12-09 11:47:32 +00:00
Richard W.M. Jones
02c39dc5e8 lib: Include <libxml/parser.h> for xmlReadMemory
Since libxml2 2.12.1 including this header is required to have this
function declared.
2023-11-27 14:12:37 +00:00
rwmjones
0ea7684d28 Merge pull request #130 from weblate/weblate-libguestfs-libguestfs-master
Translations update from Fedora Weblate
2023-11-27 10:13:26 +00:00
Temuri Doghonadze
5ff1aca486 Translated using Weblate (Georgian)
Currently translated at 16.3% (159 of 970 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/ka/
2023-11-26 22:01:17 +01:00
rwmjones
5efea5ee8d Merge pull request #129 from weblate/weblate-libguestfs-libguestfs-master
Translations update from Fedora Weblate
2023-11-24 19:15:39 +00:00
Weblate
62a4df0989 Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/
2023-11-24 20:05:56 +01:00
Richard W.M. Jones
1dd3f3540e Version 1.51.8. 2023-11-16 13:27:49 +00:00
Richard W.M. Jones
b2f3994de2 New mailing list archives 2023-11-16 10:52:11 +00:00
Richard W.M. Jones
0b8b1e4b2d New mailing list email address 2023-11-16 10:38:59 +00:00
Richard W.M. Jones
f53859723e appliance: Wait for /etc/resolv.conf to be populated
Work around this issue with dhcpcd:
https://github.com/NetworkConfiguration/dhcpcd/issues/258

Fixes: commit 0e37e5feea
2023-11-16 10:17:35 +00:00
Richard W.M. Jones
0e37e5feea appliance: Allow dhcpcd to be used on Red Hat platforms
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2247057
Fixes: https://github.com/libguestfs/libguestfs/issues/121
2023-10-30 14:31:26 +00:00
Richard W.M. Jones
b5f7b0ec18 generator: Add new virt-customize --tar-in operation
Using 'virt-customize --tar-in some.tar:/dir -a disk.img' will unpack
'some.tar' into '/dir' in the guest.  Note that this will not work for
compressed tar files as written since the underlying guestfs_tar_in
function requires the compression type to be set explicitly and
defaults to no compression (it does not auto-detect or default to
compression).
2023-10-26 21:16:41 +01:00
Richard W.M. Jones
297db5cccc generator: Sort virt-customize options into alphabetical order 2023-10-26 21:07:57 +01:00
Richard W.M. Jones
f8cbd71400 daemon: Find -lcamlstr{nat,byt} and -lunix{nat,byt}, and require -lzstd
OCaml 5.1 changes the names of these libraries for some reason.

Also in OCaml 5.1, if using those libraries you must link with -lzstd.
Since zstd was already described as "required" (although we only used
it in the appliance), there is no official change to the requirements,
but I have added a configure time check for the library.

Thanks: Jerry James <loganjerry@gmail.com>
2023-10-06 11:23:52 +01:00
Richard W.M. Jones
62b1deb125 Version 1.51.7. 2023-09-21 15:35:01 +01:00
Richard W.M. Jones
ecf361d723 ruby: Get rid of old Test::Unit compatibility
See this commit in hivex:
6dbbc474d3
2023-09-21 15:21:18 +01:00
Richard W.M. Jones
d25a48e2dd ruby: Replace MiniTest with Minitest
See this commit in hivex:
fbcff7fbd8
2023-09-21 15:16:51 +01:00
Richard W.M. Jones
c95d8c4cf6 daemon: Omit 'file -S' option on older distros that lack support
OpenSUSE LEAP 15 lacks support for this option, so test for it before
using it.

See also:
https://listman.redhat.com/archives/libguestfs/2023-September/032613.html

Reported-by: Olaf Hering
Fixes: commit 23986d3c4f
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2023-09-21 15:09:14 +01:00
cunshunxia
188c5f7d93 support OpencloudOS
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
Fixes: https://github.com/libguestfs/libguestfs/pull/125
2023-09-19 11:02:23 +01:00
rwmjones
f76c871adb Merge pull request #123 from weblate/weblate-libguestfs-libguestfs-master
Translations update from Fedora Weblate
2023-08-07 13:05:44 +01:00
Weblate
a2f62ed3f4 Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/
2023-08-05 13:21:14 +02:00
Emilio Herrera
84ea870f07 Translated using Weblate (Spanish)
Currently translated at 2.1% (343 of 16046 strings)

Translation: libguestfs/libguestfs-docs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-docs-master/es/
2023-08-05 13:21:13 +02:00
Richard W.M. Jones
cc33c8185e Version 1.51.6. 2023-07-20 18:51:57 +01:00
Richard W.M. Jones
32cb5b45cf daemon: lvm: Do reverse device name translation on pvs_full device fields
Intermittent test failures in virt-filesystems showed that when using
the pvs_full API, the pv_name field in the returned list of structures
was not being reverse translated.  As a result internal partition
names could appear in the output of virt-filesystems.

See: https://listman.redhat.com/archives/libguestfs/2023-July/032058.html
2023-07-20 11:15:26 +01:00
Richard W.M. Jones
c08032ebe2 generator: customize: Add new StringTriplet for use by --chown
The just added --chown option previously used StringPair, splitting
the argument as ‘UID.GID:FILENAME’.  However this will not work if we
ever extend this with the ability to use user or group names, since
they may contain dot (but not colon).  Add a new StringTriplet type
and split the argument string three ways.  The new option becomes:

  virt-customize ... --chown UID:GID:FILENAME

Include the following commit from the common submodule:

  commit e70d89a58dae068be2e19c7c21558707261af96a
  Author: Richard W.M. Jones <rjones@redhat.com>
  Date:   Sat Jul 15 16:42:06 2023 +0100

    customize: Update generated files for --chown with StringTriplet

Updates: commit d8e48bff21
2023-07-15 16:45:57 +01:00
Richard W.M. Jones
e4b4787df1 Version 1.51.5. 2023-07-14 20:59:29 +01:00
Laszlo Ersek
02bbc9daa7 lib/launch-direct: support networking with passt
On QEMU 7.2.0+, if "passt" is available, ask QEMU for passt ("stream")
rather than SLIRP ("user") networking.

For this, we need to run passt ourselves. Given that passt daemonizes by
default, start it with our traditional function guestfs_int_cmd_run(). Ask
passt to save its PID file, because in case something goes wrong before
we're completely sure the appliance (i.e. QEMU) is up and running, we'll
need to kill passt, the *grandchild*, ourselves.

Pass "--one-off" to passt (same as libvirt). This way, once we have proof
that QEMU has connected to passt (because the appliance shows signs of
life), we need not clean up passt ourselves -- once QEMU exits, passt will
see an EOF on the unix domain socket, and exit as well.

Passt is way more flexible than SLIRP, and passt normally intends to
imitate the host environment in the guest as much as possible. This means
that, when switching from SLIRP to passt, the guest would see changes to
the following:

- guest IP address,

- guest subnet mask,

- host (= gateway) IP address,

- host (= gateway) MAC address.

Extract the SLIRP defaults into the new macros NETWORK_GW_IP and
NETWORK_GW_MAC, and pass them explicitly to passt. In particular,
"tests/rsync/test-rsync.sh" fails without setting the host address
(NETWORK_GW_IP) properly.

(These artifacts can be verified in the appliance with "virt-rescue
--network", by running "ip addr", "ip route", and "ip neighbor" at the
virt-rescue prompt. There are four scenarios: two libguest backends, times
passt being installed or not installed.)

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2184967
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20230714132213.96616-8-lersek@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
2023-07-14 17:57:20 +02:00
Laszlo Ersek
bd3e033e08 lib: introduce guestfs_int_make_pid_path()
Introduce a small function for creating pathnames for PID files.

guestfs_int_make_pid_path() is something of an amalgamation of
guestfs_int_make_temp_path() [1] and guestfs_int_create_socketname() [2]:

- it creates a pathname under sockdir, like [2],

- it uses the handle's unique counter, like [1],

- it takes a name like both [1] and [2], but the name is not size-limited
  like in [2], plus we hardcode the suffix from [1] as ".pid".

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2184967
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
Message-Id: <20230714132213.96616-7-lersek@redhat.com>
2023-07-14 17:57:19 +02:00
Laszlo Ersek
0b2ad40a09 lib: move guestfs_int_create_socketname() from "launch.c" to "tmpdirs.c"
Consider the following inverted call tree (effectively a dependency tree
-- callees are at the top and near the left margin):

  lazy_make_tmpdir()                  [lib/tmpdirs.c]
    guestfs_int_lazy_make_tmpdir()    [lib/tmpdirs.c]
      guestfs_int_make_temp_path()    [lib/tmpdirs.c]
    guestfs_int_lazy_make_sockdir()   [lib/tmpdirs.c]
      guestfs_int_create_socketname() [lib/launch.c]

lazy_make_tmpdir() is our common workhorse / helper function that
centralizes the mkdtemp() function call.

guestfs_int_lazy_make_tmpdir() and guestfs_int_lazy_make_sockdir() are the
next level functions, both calling lazy_make_tmpdir(), just feeding it
different dirname generator functions, and different "is_runtime_dir"
qualifications. These functions create temp dirs for various, more
specific, purposes (see the manual and "lib/guestfs-internal.h" for more
details).

On a yet higher level are guestfs_int_make_temp_path() and
guestfs_int_create_socketname() -- they serve for creating *entries* in
those specific temp directories.

The discrepancy here is that, although all the other functions live in
"lib/tmpdirs.c", guestfs_int_create_socketname() is defined in
"lib/launch.c". That makes for a confusing code reading; move the function
to "lib/tmpdirs.c", just below its sibling function
guestfs_int_make_temp_path().

While at it, correct the leading comment on
guestfs_int_create_socketname() -- the socket pathname is created in the
socket directory, not in the temporary directory.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2184967
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
Message-Id: <20230714132213.96616-6-lersek@redhat.com>
2023-07-14 17:57:17 +02:00
Laszlo Ersek
21ccddecf7 docs: clarify sockdir's separation
There's another reason for separating sockdir from tmpdir, beyond "shorter
pathnames needed": permissions. For example, passt drops privileges such
that it cannot access "/tmp", and that restricts both the unix domain
socket and the PID file of passt.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2184967
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
Message-Id: <20230714132213.96616-5-lersek@redhat.com>
2023-07-14 17:57:15 +02:00
Laszlo Ersek
b4a4b754c6 docs: fix broken link in the guestfs manual
Commit 55202a4d49 ("New API: get-sockdir", 2016-02-03) added identical
language to "fish/guestfish.pod" and "src/guestfs.pod", including an
internal link L</get-sockdir>. That's appropriate for
"fish/guestfish.pod", but the same API description is generated with a
different anchor for "src/guestfs.pod". Adapt the reference.

Fixes: 55202a4d49
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2184967
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
Message-Id: <20230714132213.96616-4-lersek@redhat.com>
2023-07-14 17:57:14 +02:00
Laszlo Ersek
190609377f lib/launch-libvirt: support networking with passt
We generate the <interface type="user"> element on libvirt 3.8.0+ already.

For selecting passt rather than SLIRP, we only need to insert the child
element <backend type='passt'>. Make that child element conditional on
libvirt 9.0.0+, plus "passt --help" being executable.

For the latter, place the new helper function guestfs_int_passt_runnable()
in "lib/launch.c" -- we're going to use the same function for the direct
backend as well.

This change exposes a number of (perceived) shortcomings in libvirt; I've
filed <https://bugzilla.redhat.com/show_bug.cgi?id=2222766> about those.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2184967
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
Message-Id: <20230714132213.96616-3-lersek@redhat.com>
2023-07-14 17:57:13 +02:00
Laszlo Ersek
85d361dd6a lib: fix NETWORK_ADDRESS: make it an actual IP address, not a subnet base
Currently we #define NETWORK_ADDRESS as "169.254.0.0". That's a bug in
libguestfs, but it's been invisible -- thus far it's been canceled out by
*independent* bugs in *both* QEMU and libvirt.

(1) With the direct backend, the current definition of NETWORK_ADDRESS
results in the following QEMU command line option:

  -netdev user,id=usernet,net=169.254.0.0/16

According to the QEMU documentation, the "net" property here is supposed
to specify the *exact* IP address that the guest will receive. The guest
however receives 169.254.2.15 (I've checked that with virt-rescue).

In other words, libguestfs doesn't do what the QEMU documentation says,
and QEMU doesn't do what the QEMU documentation says either. The end
result has been good enough -- but only until now.

(2) With the libvirt backend, the current definition of NETWORK_ADDRESS
results in the following domain XML snippet:

  <interface type="user">
    <model type="virtio"/>
    <ip family="ipv4" address="169.254.0.0" prefix="16"/>
  </interface>

which libvirt translates, in turn, to

  -netdev {"type":"user","net":"169.254.0.0/16","id":"hostnet0"}

According to the domain XML documentation, the @address attribute here is
again supposed to specify the *exact* IP address that the guest will
receive. However, the guest receives 169.254.2.15 (I've checked that with
virt-rescue).

In other words, libguestfs doesn't do what the libvirt documentation says,
and libvirt doesn't do what the libvirt documentation says either. The end
result has been good enough -- but only until now.

Where things break down though is the subsequent passt enablement, in the
rest of this series. For example, when using the libvirt backend together
with passt, libvirt translates the @address attribute to passt's
"--address" option, but passt takes the address *verbatim*, and not as a
subnet base address. That difference is visible in the appliance; for
example, when running virt-rescue on a Fedora 38 image, and issuing "ip
addr". Namely, after enabling passt for the libvirt backend, the
guest-visible IP address changes from 169.254.2.15 to 169.254.0.0, which
is an IP address that makes no sense for an endpoint.

Fix the latent bug by specifying the actual guest IP address we want, in
NETWORK_ADDRESS.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2184967
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
Message-Id: <20230714132213.96616-2-lersek@redhat.com>
2023-07-14 17:57:10 +02:00
Laszlo Ersek
13c7052ff9 lib: remove guestfs_int_cmd_clear_close_files()
The last (only?) caller of guestfs_int_cmd_clear_close_files() disappeared
in commit e4c3968880 ("lib/info: Remove /dev/fd hacking and pass a true
filename to qemu-img info.", 2018-01-23), part of v1.37.36.

Simplify the code by removing guestfs_int_cmd_clear_close_files().

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20230711113906.107340-1-lersek@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
2023-07-12 12:22:37 +02:00
rwmjones
f6fddee305 Merge pull request #122 from weblate/weblate-libguestfs-libguestfs-master
Translations update from Fedora Weblate
2023-07-11 15:17:25 +01:00
Weblate
2dcda6a76a Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/
2023-07-05 16:21:05 +02:00
Temuri Doghonadze
e8f4b1a247 Translated using Weblate (Georgian)
Currently translated at 16.1% (156 of 966 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/ka/
2023-07-05 16:21:05 +02:00
Richard W.M. Jones
d8e48bff21 generator: Add --chown option for virt-customize
Also this updates the common submodule to include the changes.

Fixes: https://github.com/rwmjones/guestfs-tools/issues/12
Acked-by: Laszlo Ersek <lersek@redhat.com>
2023-06-29 17:14:43 +01:00
Richard W.M. Jones
cade0b1aeb ocaml: Use Caml_state_opt in preference to caml_state
Link: https://discuss.ocaml.org/t/test-caml-state-and-conditionally-caml-acquire-runtime-system-good-or-bad/12489/7
Thanks: Guillaume Munch-Maccagnoni
2023-06-27 16:33:09 +01:00
Richard W.M. Jones
7d4e9c927e ocaml: Fix guestfs_065_implicit_close.ml for OCaml 5
Link: https://discuss.ocaml.org/t/ocaml-5-forcing-objects-to-be-collected-and-finalized/12492/3
Thanks: Josh Berdine
Thanks: Vincent Laviron
2023-06-27 16:25:14 +01:00
Richard W.M. Jones
27998ecb2f Revert "ocaml/t/guestfs_065_implicit_close.ml: Skip this test on OCaml 5"
This reverts commit 81093d5359.
2023-06-27 16:20:29 +01:00
Richard W.M. Jones
8470269582 Version 1.51.4. 2023-06-27 14:10:29 +01:00
Richard W.M. Jones
81093d5359 ocaml/t/guestfs_065_implicit_close.ml: Skip this test on OCaml 5
Link: https://discuss.ocaml.org/t/ocaml-5-forcing-objects-to-be-collected-and-finalized/12492/2
2023-06-27 13:28:15 +01:00
Richard W.M. Jones
16464878cf ocaml: Conditionally acquire the lock in callbacks
This fix was originally suggested by Jürgen Hötzel (link below) which
I have lightly modified so it works with OCaml <= 4 too.

Link: https://listman.redhat.com/archives/libguestfs/2023-May/031640.html
Link: https://discuss.ocaml.org/t/test-caml-state-and-conditionally-caml-acquire-runtime-system-good-or-bad/12489
2023-06-27 12:46:41 +01:00
Richard W.M. Jones
4a79c023e5 ocaml: Release runtime lock around guestfs_close
When finalizing the handle we call guestfs_close.  This function could
be long-running (eg. it may have to shut down the qemu subprocess), so
release the runtime lock.
2023-06-27 12:46:18 +01:00
Richard W.M. Jones
7e1d7c1330 ocaml: Replace old enter/leave_blocking_section calls
Since OCaml 4 the old and confusing caml_enter_blocking_section and
caml_leave_blocking_section calls have been replaced with
caml_release_runtime_system and caml_acquire_runtime_system (in that
order).  Use the new names.
2023-06-27 11:34:21 +01:00
Jürgen Hötzel
1274452d22 ocaml/implicit_close test: collect all currently unreachable blocks
Fixes failing implice_close test on OCaml 5.

RWMJ:

I adjusted this patch so that we continue to call Gc.compact on
exiting the test, to move all of the heap (hopefully revealing flaws
in the bindings).  This only works on OCaml <= 4, but Gc.compact may
be fixed/reimplemented later in the 5.x series.

Please see also the lengthy discussion of this patch upstream:
https://listman.redhat.com/archives/libguestfs/2023-May/thread.html#31639
https://listman.redhat.com/archives/libguestfs/2023-June/thread.html#31709
https://discuss.ocaml.org/t/ocaml-heap-fsck-and-forcing-collection-of-unreachable-objects/12281/1
2023-06-06 15:53:03 +01:00
rwmjones
7f35e37d75 Merge pull request #114 from weblate/weblate-libguestfs-libguestfs-master
Translations update from Fedora Weblate
2023-06-05 09:41:48 +01:00
Weblate
89ef6c3bd3 Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/
2023-05-30 18:21:04 +02:00
Tian Shixiong
b882458fb6 Translated using Weblate (Chinese (Simplified) (zh_CN))
Currently translated at 2.5% (25 of 966 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/zh_CN/
2023-05-30 18:21:04 +02:00
Pavel Borecki
e785a0bd88 Translated using Weblate (Czech)
Currently translated at 46.2% (447 of 966 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/cs/
2023-05-30 18:21:04 +02:00
Jan Kuparinen
dcca66f885 Translated using Weblate (Finnish)
Currently translated at 9.4% (91 of 966 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/fi/
2023-05-30 18:21:03 +02:00
grimst
fc1df0248a Translated using Weblate (French)
Currently translated at 16.6% (2666 of 16046 strings)

Translation: libguestfs/libguestfs-docs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-docs-master/fr/

Translated using Weblate (French)

Currently translated at 64.0% (619 of 966 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/fr/

Translated using Weblate (French)

Currently translated at 16.6% (2664 of 16046 strings)

Translation: libguestfs/libguestfs-docs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-docs-master/fr/
2023-05-30 18:21:03 +02:00
Richard W.M. Jones
ca20f27cb0 fuse: Don't call fclose(NULL) on error paths
Various errors like this:

In function ‘test_fuse’,
    inlined from ‘main’ at test-fuse.c:133:11:
test-fuse.c:274:5: error: argument 1 null where non-null expected [-Werror=nonnull]
  274 |     fclose (fp);
      |     ^~~~~~~~~~~
In file included from test-fuse.c:26:
/usr/include/stdio.h: In function ‘main’:
/usr/include/stdio.h:183:12: note: in a call to function ‘fclose’ declared ‘nonnull’
  183 | extern int fclose (FILE *__stream) __nonnull ((1));
      |            ^~~~~~
2023-05-22 17:21:07 +01:00
Richard W.M. Jones
3cb094083e Replace Pervasives.* with Stdlib.*
Since OCaml 4.07 (released 2018-07-10) the always-loaded standard
library module has been called Stdlib.  The old Pervasives module was
finally removed in OCaml 5.

$ perl -pi.bak -e 's/Pervasives\./Stdlib./g' -- `git ls-files`

OCaml >= 4.07 is now required.

Also update the common submodule with:

  commit d61cd820b49e403848d15c5deaccbf8dd7045370
  Author: Jürgen Hötzel
  Date:   Sat May 20 18:16:40 2023 +0200

    Add support for OCaml 5.0
2023-05-22 16:42:31 +01:00
Laszlo Ersek
32408a9c36 LUKS-on-LVM inspection test: test /dev/mapper/VG-LV translation
In the LUKS-on-LVM inspection test, call the "check_filesystems" function
yet another time, now with such "--key" options that exercise the recent
"/dev/mapper/VG-LV" -> "/dev/VG/LV" translation (unescaping) from
libguestfs-common.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2168506
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20230519140849.310774-4-lersek@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
2023-05-22 14:23:55 +02:00
Laszlo Ersek
58e2640233 LUKS-on-LVM inspection test: rename VGs and LVs
In preparation for a subsequent patch, rename "VG" to "Volume-Group", and
"LV<n>" to "Logical-Volume-<n>", in the LUKS-on-LVM inspection test.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2168506
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20230519140849.310774-3-lersek@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
2023-05-22 14:23:53 +02:00
Laszlo Ersek
83afd6d3d2 update common submodule
Laszlo Ersek (2):
      options/keys: key_store_import_key(): un-constify "key" parameter
      options/keys: introduce unescape_device_mapper_lvm()

Richard W.M. Jones (1):
      mlcustomize/SELinux_relabel.ml: Use Array.mem

Roman Kagan (1):
      mlcustomize: skip SELinux relabeling if it's disabled

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2168506
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20230519140849.310774-2-lersek@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
2023-05-22 14:23:44 +02:00
Zixun LI
692802bf96 daemon/tar: support more compression methods.
Add support for lzma and zstd compression methods.

Signed-off-by: Zixun LI <admin@hifiphile.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
2023-05-02 11:15:02 +01:00
Andrey Drobyshev
d0d8e67384 daemon/selinux-relabel: run setfiles with "-T 0", if supported
Since SELinux userspace v3.4 [1], setfiles command supports "-T nthreads"
option, which allows parallel execution.  "-T 0" allows using as many
threads as there're available CPU cores.  This might speed up the process
of filesystem relabeling in case the appliance is being run with multiple
vCPUs.  The latter is true for at least v2v starting from d2b64ecc67
("v2v: Set the number of vCPUs to same as host number of pCPUs.").

For instance, when running virt-v2v-in-place on my 12-core Xeon host
with SSD, with appliance being run with 8 vCPUs (the upper limit specified
in d2b64ecc67), and on the ~150GiB disk VM (physical size on the host),
I get the following results:

./in-place/virt-v2v-in-place -i libvirt fedora37-vm -v -x

Without this patch:
...
commandrvf: setfiles -F -e /sysroot/dev -e /sysroot/proc -e /sysroot/sys -m -C -r /sysroot -v /sysroot/etc/selinux/targeted/contexts/files/file_contexts /sysroot/^M
libguestfs: trace: v2v: selinux_relabel = 0
libguestfs: trace: v2v: rm_f "/.autorelabel"
guestfsd: => selinux_relabel (0x1d3) took 17.94 secs
...

With this patch:
...
commandrvf: setfiles -F -e /sysroot/dev -e /sysroot/proc -e /sysroot/sys -m -C -T 0 -r /sysroot -v /sysroot/etc/selinux/targeted/contexts/files/file_contexts /sysroot/^M
libguestfs: trace: v2v: selinux_relabel = 0
libguestfs: trace: v2v: rm_f "/.autorelabel"
guestfsd: => selinux_relabel (0x1d3) took 5.88 secs
...

So in my scenario it's getting 3 times faster.

[1] https://github.com/SELinuxProject/selinux/releases/tag/3.4

Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
2023-04-27 15:22:02 +01:00
Andrey Drobyshev
152d6e4bdf daemon/selinux-relabel: search for "invalid option" in setfiles output
'X' in the setiles' stderr doesn't necessarily mean that option 'X'
doesn't exist.  For instance, when passing '-T' we get: "setfiles:
option requires an argument -- 'T'".

Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
2023-04-27 15:21:54 +01:00
Andrey Drobyshev
9ced5fac8c daemon/selinux-relabel: don't exclude "/selinux" if it's non-existent
Since RHBZ#726528, filesystem.rpm doesn't include /selinux.  setfiles
then gives us the warning: "Can't stat exclude path "/sysroot/selinux",
No such file or directory - ignoring."

Though the warning is harmless, let's get rid of it by checking the
existence of /selinux directory.

Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
2023-04-27 15:21:35 +01:00
Richard W.M. Jones
7674d603e9 Version 1.51.3. 2023-04-19 13:03:03 +01:00
Laszlo Ersek
be11d25b3e update common submodule
HATAYAMA Daisuke (1):
      progress: fix segmentation fault when TERM variable is "dumb"

Laszlo Ersek (2):
      detect_kernels: tighten "try" scope
      detect_kernels: deal with RHEL's kernel-core / kernel-modules-core split

rwmjones (1):
      Merge pull request #5 from d-hatayama/fix_segfault_progress_bar

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2175703
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
2023-03-21 17:07:42 +01:00
Laszlo Ersek
7414ac40c7 update common submodule
Andrey Drobyshev (2):
      inject_virtio_win: add Virtio_SCSI to block_type
      inject_virtio_win: write the proper block controller PCI ID to Win registry

Richard W.M. Jones (2):
      mlcustomize: Fix overlong comment
      mlcustomize: Add accessors for block driver priority list

Roman Kagan (1):
      inject_virtio_win: match only vendor/device/revision

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
2023-03-14 14:15:29 +01:00
rwmjones
f372a37b30 Merge pull request #111 from weblate/weblate-libguestfs-libguestfs-master
Translations update from Fedora Weblate
2023-02-28 12:31:59 +00:00
Weblate
ff92849818 Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/
2023-02-25 11:20:43 +01:00
Temuri Doghonadze
4f51ca04c2 Translated using Weblate (Georgian)
Currently translated at 16.1% (156 of 966 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/ka/
2023-02-25 11:20:43 +01:00
Richard W.M. Jones
8c5df4110b Version 1.51.2. 2023-02-21 22:41:30 +00:00
Richard W.M. Jones
ab52362320 build: Set release date correctly in web page
This was not being set because of some impenetrable problem with
autoconf.  The actual line which set the shell variable was simply
being deleted for some reason.  Using an m4 definition works.

Updates: commit f68752462e
2023-02-21 20:55:48 +00:00
Richard W.M. Jones
b6a3689d89 website: Fix paths to development and stable releases on the website 2023-02-21 20:46:28 +00:00
rwmjones
89441f1626 Merge pull request #110 from weblate/weblate-libguestfs-libguestfs-master
Translations update from Fedora Weblate
2023-02-21 20:26:37 +00:00
Yuri Chornoivan
6abe575ef8 Translated using Weblate (Ukrainian)
Currently translated at 100.0% (966 of 966 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/uk/
2023-02-21 21:20:29 +01:00
rwmjones
47c0ca8e03 Merge pull request #109 from weblate/weblate-libguestfs-libguestfs-master
Translations update from Fedora Weblate
2023-02-20 21:08:07 +00:00
Weblate
9ef18ea048 Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/
2023-02-20 20:20:57 +01:00
Temuri Doghonadze
3588ad51c2 Translated using Weblate (Georgian)
Currently translated at 14.5% (141 of 967 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/ka/
2023-02-20 20:20:57 +01:00
Richard W.M. Jones
cfe7d39b40 Update common submodule to latest 2023-02-20 19:00:12 +00:00
Richard W.M. Jones
4ed83ffdbe valgrind: Add another libvirt suppression
It seems as if this is just a variation on the previous libvirt
suppression.

==2042391== 61 (48 direct, 13 indirect) bytes in 1 blocks are definitely lost in
 loss record 267 of 507
==2042391==    at 0x4846464: calloc (vg_replace_malloc.c:1340)
==2042391==    by 0x54EE318: g_malloc0 (gmem.c:163)
==2042391==    by 0x5017D4C: virClassNew (virobject.c:189)
==2042391==    by 0x523CCB9: virDataTypesOnce.lto_priv.0 (datatypes.c:111)
==2042391==    by 0x4D8BE42: __pthread_once_slow (pthread_once.c:116)
==2042391==    by 0x50345E1: virOnce (virthread.c:44)
==2042391==    by 0x523CD6A: virGetConnect (datatypes.c:121)
==2042391==    by 0x51FBC1F: virConnectOpenInternal (libvirt.c:893)
==2042391==    by 0x51FCC11: virConnectOpenAuth (libvirt.c:1271)
==2042391==    by 0x4A3ECAD: guestfs_int_open_libvirt_connection.constprop.0 (li
bvirt-auth.c:224)
==2042391==    by 0x4A1D62A: launch_libvirt.lto_priv.0 (launch-libvirt.c:389)
==2042391==    by 0x4993739: guestfs_launch (launch.c:114)

(cherry picked from guestfs-tools commit 8790af0266a808c8a04927bb5039be06cbc3da54)
2023-02-20 18:59:36 +00:00
Richard W.M. Jones
ede3632612 valgrind: Update suppression for PCRE2 transition
OCaml PCRE.compile doesn't free up regexps if they are stored in
globals.  However the valgrind suppression for this matched the old
function name, not the new PCRE2 name.  Valgrind errors looked like:

==1799651== 145 bytes in 1 blocks are possibly lost in loss record 2,927 of 4,168
==1799651==    at 0x484186F: malloc (vg_replace_malloc.c:381)
==1799651==    by 0x4D5F2E5: pcre2_compile_8 (pcre2_compile.c:10250)
==1799651==    by 0x29E077: guestfs_int_pcre_compile (pcre-c.c:196)
==1799651==    by 0x2B725F: camlOVA__entry (OVA.ml:392)
==1799651==    by 0x2859A8: caml_program (in /home/rjones/d/virt-v2v/v2v/virt-v2v)
==1799651==    by 0x40F9D8: caml_start_program (in /home/rjones/d/virt-v2v/v2v/virt-v2v)
==1799651==    by 0x40FD86: caml_startup_common (in /home/rjones/d/virt-v2v/v2v/virt-v2v)
==1799651==    by 0x40FDDC: caml_startup (in /home/rjones/d/virt-v2v/v2v/virt-v2v)
==1799651==    by 0x28523F: main (in /home/rjones/d/virt-v2v/v2v/virt-v2v)

(cherry picked from virt-v2v commit 2949109ff9f7a081b1a4b475b9f7bcbef5b45ee0)
2023-02-20 18:59:27 +00:00
Richard W.M. Jones
250ee85839 Rework Std_utils.Option so it works like the OCaml stdlib module
OCaml 4.08 introduces a stdlib Option module which looks a bit like
ours but has a number of differences.  In particular our functions
Option.may and Option.default have no corresponding functions in
stdlib, although there are close enough equivalents.

This change was automated using this command:

$ perl -pi.bak \
  -e 's/Option.may/Option.iter/g; s/Option.default /Option.value ~default:/g' \
  `git ls-files`

Update common module to include:

  commit cffa077323fafcdfcf78e230c022afa891a6b3ff
  Author: Richard W.M. Jones <rjones@redhat.com>
  Date:   Mon Feb 20 12:11:51 2023 +0000

    mlstdutils: Rework the Option module to be compatible with stdlib
2023-02-20 12:14:08 +00:00
Richard W.M. Jones
afa4d64fca python: Avoid leaking py_array and py_args in event callbacks
See also:

https://listman.redhat.com/archives/libguestfs/2023-February/030730.html
https://listman.redhat.com/archives/libguestfs/2023-February/030745.html
https://listman.redhat.com/archives/libguestfs/2023-February/030746.html

Fixes: commit 6ef5837e2d
Thanks: Laszlo Ersek, Eric Blake
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2023-02-20 11:21:33 +00:00
Richard W.M. Jones
e07304de86 Revert "python: fix call of Python handlers of events"
This reverts one part of commit 85235aec83 related to reference
counts.  Py_BuildValue always increments the reference count (when it
succeeds) and I could not reproduce the Python 3 problem that was
described there.

Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2023-02-20 11:21:14 +00:00
Richard W.M. Jones
f68752462e build: Remove RELEASES file
The presence of this file complicates ./configure and you also have to
remember to update it on each release.  Replace it with a simple
RELEASE_DATE set in ./configure when the version is updated.

I also had to make a minor change to the generator which was using
this file both to check it was run from the source directory and to
get an exclusive lock.  We now use podwrapper.pl.in for this.
2023-02-16 11:58:30 +00:00
Richard W.M. Jones
c7d54697ca rust: Don't fail 'make distclean' if cargo clean fails
It fails when run twice with:

  ../run cargo clean
  error: could not find `Cargo.toml` in `/home/rjones/d/libguestfs/rust` or any parent directory

As this is an optional step don't fail here.
2023-02-16 11:58:30 +00:00
Richard W.M. Jones
b9ccfe3e03 lib: Get rid of minimum libvirt version check
We require libvirt >= 0.10.2, and we included code to check this at
configure-, compile- and run-time.  Remove the checks at compile and
run time (keep the ./configure check).  Libvirt 0.10.2 was released
over 10 years ago so it's safe to assume that everyone has it by now.
2023-02-16 11:58:30 +00:00
Richard W.M. Jones
bbf396fc55 python: Use bytes instead of str for event callback buffer
The event callback gets a buffer parameter which is usually something
like a log message.  However as it comes from C it is not necessarily
well-formed (eg) UTF-8 but could contain any old sequence of bytes.

In the test case provided by the reporter, we failed to encode the
buffer as 'str' with this error:

  UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc3 in position 137: unexpected end of data

Use 'bytes' instead.  Strictly speaking this changes the type
signature of the callbacks, but our existing Python tests which just
print the buffer using '%s' don't fail and in any case we don't
guarantee the stability of non-C APIs.

Reported-by: Yonatan Shtarkman
See: https://listman.redhat.com/archives/libguestfs/2023-February/030653.html
2023-02-14 19:29:48 +00:00
Richard W.M. Jones
6ef5837e2d python: Avoid crash if callback parameters cannot be built
In the case that building the parameters to the Python event callback
fails, args was returned as NULL.  We immediately tried to call
Py_INCREF on this which crashed.  Returning NULL means the Python
function threw an exception, so print the exception and return (there
is no way to return an error here - the event is lost).

Reported-by: Yonatan Shtarkman
See: https://listman.redhat.com/archives/libguestfs/2023-February/030653.html
2023-02-14 18:42:40 +00:00
Richard W.M. Jones
43bb5c4306 Version 1.51.1. 2023-02-10 11:09:55 +00:00
Richard W.M. Jones
f0f8e6c5fe lib: Choose q35 machine type for x86-64
This machine type is more modern than the older 'pc' type and as most
qemu development is now focused there we expect it will perform and
behave better.  In almost all respects this change should make no
difference.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2168578
Acked-by: Laszlo Ersek <lersek@redhat.com>
See-also: https://listman.redhat.com/archives/libguestfs/2023-February/030645.html
2023-02-09 14:40:29 +00:00
Richard W.M. Jones
7503eeebed Remove virt-dib
The tool only supports an older version of the diskimage-builder
metadata, and we do not have the time or inclination to update it to a
newer version.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1910039
2023-02-07 13:30:35 +00:00
Richard W.M. Jones
ceb1cf50e6 Version 1.50.0. 2023-02-07 11:23:45 +00:00
Richard W.M. Jones
e2c7bddf10 Update copyright dates for 2023
Run this command across the source:

  perl -pi.bak -e 's/(20[012][0-9])-20[12][012]/$1-2023/g' `git ls-files`

and remove changes to po{,-docs}/*.po{,t} (these will be regenerated
later when we run 'make dist').
2023-02-07 10:50:48 +00:00
rwmjones
e4f0733bd7 Merge pull request #108 from weblate/weblate-libguestfs-libguestfs-master
Translations update from Fedora Weblate
2023-02-05 15:31:05 +00:00
Weblate
a1822fa1c6 Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/
2023-02-05 16:20:48 +01:00
Emilio Herrera
4bdefd23d3 Translated using Weblate (Spanish)
Currently translated at 2.0% (335 of 16046 strings)

Translation: libguestfs/libguestfs-docs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-docs-master/es/
2023-02-05 16:20:48 +01:00
Richard W.M. Jones
34d378cef2 docs: Add outline release notes for forthcoming 1.50 stable release 2023-01-31 15:54:46 +00:00
Richard W.M. Jones
4f58017a5e lib/guestfs-internal-all.h: Use __restrict__ keyword for very old GCC
RHEL 7 GCC 4.8.5 does not allow the restrict keyword.  Use the
permitted alternative.
2023-01-31 15:54:46 +00:00
Richard W.M. Jones
8f6b82bc45 lib/guestfs-internal-all.h: Fix whitespace 2023-01-31 15:54:46 +00:00
Richard W.M. Jones
973e26dbd8 Update common module
Update common module to 3253cd99d135d5eb788a0477459b43a269e8cca6

No significant changes that affect virt-v2v now, but it adds some
extra functions to Std_utils that might be used one day.

Cherry picked from virt-v2v commit c7c9dac4f84580190b0e4f7c2e68970192f4bad3
2023-01-28 15:06:33 +00:00
Richard W.M. Jones
09c2a5404a Version 1.49.9. 2023-01-19 23:29:00 +00:00
Richard W.M. Jones
ed8a960bb8 build: Ignore new common/mldrivers in maintainer-check-extra-dist
This directory is not distributed in the tarball.

Fixes: commit 1a6485001c
2023-01-19 23:28:14 +00:00
Richard W.M. Jones
1a6485001c Update common submodule 2023-01-19 23:00:36 +00:00
Richard W.M. Jones
fbf7fe8793 build: Remove bundled copy of ocaml-augeas
This is now an external dependency.
2023-01-19 23:00:23 +00:00
Richard W.M. Jones
e0d23c861c generator: customize: Add --inject-qemu-ga and --inject-virtio-win
Add the new flags / operations for virt-customize.
2023-01-17 11:59:00 +00:00
rwmjones
76599aae80 Merge pull request #107 from weblate/weblate-libguestfs-libguestfs-master
Translations update from Fedora Weblate
2023-01-13 20:23:51 +00:00
Temuri Doghonadze
f325b26e4b Translated using Weblate (Georgian)
Currently translated at 14.4% (140 of 967 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/ka/
2023-01-13 21:20:16 +01:00
rwmjones
c75a323bf0 Merge pull request #106 from weblate/weblate-libguestfs-libguestfs-master
Translations update from Fedora Weblate
2022-12-23 19:04:18 +00:00
Jan Kuparinen
7dea806091 Translated using Weblate (Finnish)
Currently translated at 0.8% (138 of 16048 strings)

Translation: libguestfs/libguestfs-docs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-docs-master/fi/
2022-12-23 19:20:01 +01:00
Temuri Doghonadze
c2d20611f2 Translated using Weblate (Georgian)
Currently translated at 14.3% (139 of 967 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/ka/
2022-12-23 19:20:01 +01:00
rwmjones
b258185eb4 Merge pull request #105 from weblate/weblate-libguestfs-libguestfs-master
Translations update from Fedora Weblate
2022-12-13 21:14:20 +00:00
Yuri Chornoivan
ad02353bf9 Translated using Weblate (Ukrainian)
Currently translated at 100.0% (967 of 967 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/uk/
2022-12-12 20:20:02 +01:00
rwmjones
23ae55a470 Merge pull request #104 from weblate/weblate-libguestfs-libguestfs-master
Translations update from Fedora Weblate
2022-12-11 19:26:10 +00:00
Weblate
56b1345399 Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/
2022-12-11 17:21:32 +01:00
Emilio Herrera
747ae003d5 Translated using Weblate (Spanish)
Currently translated at 2.0% (330 of 16046 strings)

Translation: libguestfs/libguestfs-docs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-docs-master/es/
2022-12-11 17:21:31 +01:00
Richard W.M. Jones
73fb8719d2 Version 1.49.8. 2022-12-10 12:17:12 +00:00
Andrey Drobyshev
188aa9947f m4/guestfs-appliance.m4: add VIRTUOZZO to RedHat-based distros
This allows to detect VzLinux guest.

Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
2022-12-09 19:01:00 +00:00
Richard W.M. Jones
a84ff62478 tests/nbd: Remove bogus sleep
This is no longer needed since qemu-nbd now supports pidfiles

Fixes: commit 1eb055bd46
2022-12-02 12:02:49 +00:00
Richard W.M. Jones
dc9bdda084 tests/nbd: Unlink pidfile before running qemu-nbd
It might be left over from a previous failed run.  Best to unlink the
old file before starting qemu-nbd, so there's no possibility of
getting confused later when we wait for the file to appear.
2022-12-02 11:57:16 +00:00
Richard W.M. Jones
98ab261a05 tests/nbd: Move temporary files into tests/nbd/ subdirectory
This test fails for reasons I have not fully understood yet.  However
one thing I noticed is that the Unix domain socket and PID file used
the tests are placed in the tests/ directory, not the tests/nbd/
subdirectory, so let's fix that:

Starting qemu-nbd fedora-nbd.img -t --pid-file /home/rjones/d/libguestfs-rhel-9.2/tests/nbd.pid --format raw -p 63668 ...
Starting qemu-nbd fedora-nbd.img -t --pid-file /home/rjones/d/libguestfs-rhel-9.2/tests/nbd.pid --format raw -p 60684 ...
Starting qemu-nbd fedora-nbd.img -t --pid-file /home/rjones/d/libguestfs-rhel-9.2/tests/nbd.pid --format raw -k /home/rjones/d/libguestfs-rhel-9.2/tests/unix.sock ...

Fixes: commit 6d32773e81
2022-12-02 11:38:17 +00:00
Richard W.M. Jones
824c745748 lib: Return correct osinfo field for Windows 11
For Windows Client, we can only distinguish between Windows 10 and
Windows 11 using the build ID.  The product name in both cases is
"Windows 10 <something>", apparently intentionally.

References:
https://learn.microsoft.com/en-us/answers/questions/586619/windows-11-build-ver-is-still-10022000194.html
a263fe0b26/winsup/cygwin/wincap.cc (L429)
https://en.wikipedia.org/wiki/List_of_Microsoft_Windows_versions

After this fix, the output of virt-inspector changes to this, which is
a bit odd, but correct:

    <name>windows</name>
    <arch>x86_64</arch>
    <distro>windows</distro>
    <product_name>Windows 10 Pro</product_name>
    <product_variant>Client</product_variant>
    <major_version>10</major_version>
    <minor_version>0</minor_version>
    <windows_systemroot>/Windows</windows_systemroot>
    <windows_current_control_set>ControlSet001</windows_current_control_set>
    <osinfo>win11</osinfo>

Thanks: Yaakov Selkowitz
Reported-by: Yongkui Guo
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2012658
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2022-12-02 10:16:57 +00:00
Richard W.M. Jones
f3dd67affe New API: inspect_get_build_id
Add an API to return the build ID of the guest.  This to allow a
future change to be able to distinguish between Windows 10 and Windows 11
which can only be done using the build ID.

For Windows we can read the CurrentBuildNumber key from the registry.
For Linux there happens to be a BUILD_ID field in /etc/os-release.
I've never seen a Linux distro that actually uses this.

Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2022-12-02 10:16:57 +00:00
rwmjones
6efb44c4ff Merge pull request #103 from weblate/weblate-libguestfs-libguestfs-master
Translations update from Fedora Weblate
2022-12-01 20:47:31 +00:00
Yuri Chornoivan
32467fc6d4 Translated using Weblate (Ukrainian)
Currently translated at 100.0% (966 of 966 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/uk/
2022-12-01 20:19:49 +01:00
rwmjones
6397dbca64 Merge pull request #102 from weblate/weblate-libguestfs-libguestfs-master
Translations update from Fedora Weblate
2022-11-30 19:25:54 +00:00
Weblate
5c864d1e80 Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/
2022-11-30 19:20:36 +01:00
Temuri Doghonadze
772d7cb61f Translated using Weblate (Georgian)
Currently translated at 14.3% (138 of 965 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/ka/
2022-11-30 19:20:35 +01:00
Richard W.M. Jones
55fdf761b1 Version 1.49.7. 2022-11-28 11:08:52 +00:00
Richard W.M. Jones
fa305b709a python: Fix code style ("missing whitespace after keyword") 2022-11-28 10:32:21 +00:00
Richard W.M. Jones
23986d3c4f file: Use -S option with -z
The file(1) manual suggests using -S (disable seccomp) with -z since
the set of system calls provided by the seccomp policy does not allow
the subprocess to run.  This is obvious when you use file -z on a
compressed file on a Linux distro that enables file's seccomp policy
(Arch does this, Fedora does not):

  $ file -zbsL lib-i586.so.zst
  Bad system call

I also fixed some incorrect text in the manual.

Thanks: Toolybird for pointing to this fix
Reported-by: David Runge
Fixes: https://github.com/libguestfs/libguestfs/issues/100
2022-11-28 10:21:00 +00:00
Richard W.M. Jones
e657e45b43 tests: Increase size of disk in xfs_growfs_0 test
I cannot reproduce the originally reported error:

libguestfs: error: mkfs: xfs: /dev/VG/LV: Filesystem must be larger than 300MB.

Thanks: David Runge
Related: https://github.com/libguestfs/libguestfs/issues/100
2022-11-22 16:32:08 +00:00
Richard W.M. Jones
6bfb73cdb0 gnulib/lib/c-ctype.h: Remove executable bit
$ ls -l `find -name c-ctype.h`
-rwxr-xr-x. 1 rjones rjones 9647 Dec  3  2021 ./gnulib/lib/c-ctype.h
$ chmod -x `find -name c-ctype.h`
$ ls -l `find -name c-ctype.h`
-rw-r--r--. 1 rjones rjones 9647 Dec  3  2021 ./gnulib/lib/c-ctype.h

RPM builds actually gave a warning about this which is how I noticed
the problem:

*** WARNING: ./usr/src/debug/guestfs-tools-1.48.2-2.fc36.x86_64/gnulib/lib/c-ctype.h is executable but has no shebang, removing executable bit

(cherry picked from
guestfs-tools commit 566267a3d447eb97b4a0637adbe3e45c09ba090f)
2022-11-21 21:13:37 +00:00
Richard W.M. Jones
1bcf0bc5dd Version 1.49.6. 2022-11-21 16:46:05 +00:00
Richard W.M. Jones
d5472a2219 appliance: Add back libldm (ldmtool) and libxml2 to package list
Commit 133a491677 ("Use guestfsd binary to auto-generate library
dependencies for appliance", October 2020) removed explicit
dependencies for various system packages that the daemon links
directly to, ie. all of these libraries:

$ objdump -p daemon/guestfsd | grep NEEDED | sort
  NEEDED               libacl.so.1
  NEEDED               libaugeas.so.0
  NEEDED               libcap.so.2
  NEEDED               libc.so.6
  NEEDED               libgcc_s.so.1
  NEEDED               libhivex.so.0
  NEEDED               libjansson.so.4
  NEEDED               libm.so.6
  NEEDED               libpcre2-8.so.0
  NEEDED               librpm.so.9
  NEEDED               libselinux.so.1
  NEEDED               libsystemd.so.0
  NEEDED               libtirpc.so.3
(plus libyara which I don't have installed.)

This avoids having to update these dependencies if they change, eg.
when we switched from PCRE to PCRE2 we did not need to update this
file.

However the same commit also incorrectly removed two apparent library
packages (libldm, libxml2) which the daemon does not link to, but
which we'd like to pull in because of tools they provide, in
particular ldmtool.

Re-add those two explicit dependencies.

Fixes: commit 133a491677
2022-11-07 12:44:07 +00:00
Richard W.M. Jones
26940f64a7 build: Replace Python distutils by sysconfig
This module has been deprecated in Python >= 3.10
(https://peps.python.org/pep-0632/).  Replace distutils.sysconfig with
sysconfig which is not quite a drop-in replacement.

This fix is incomplete as we still reference distutils in
python/setup.py.in.  However that is only used for PIP-style
distributions (make -C python sdist) which we don't really use or
recommend.

Thanks: Miro Hrončok
See-also: https://peps.python.org/pep-0632/
See-also: https://lists.fedoraproject.org/archives/list/python-devel@lists.fedoraproject.org/thread/N6ITYHLRWIDNYNXGPYG2ZHF3ZLQWZN7L/
2022-10-24 17:11:31 +01:00
Richard W.M. Jones
5c63ec2a53 gobject: Remove bogus NULL test for UUIDs
Many warnings such as:

src/session.c: In function 'guestfs_session_internal_test_rstruct':
src/session.c:14755:7: warning: the comparison will always evaluate as 'true' for the address of 'pv_uuid' will never be NULL [-Waddress]
14755 |   if (ret->pv_uuid) memcpy (s->pv_uuid, ret->pv_uuid, sizeof (s->pv_uuid));
      |       ^~~
In file included from src/session.c:40:
../include/guestfs.h:551:8: note: 'pv_uuid' declared here
  551 |   char pv_uuid[32]; /* this is NOT nul-terminated, be careful when printing */
      |        ^~~~~~~
2022-10-24 11:27:53 +01:00
Richard W.M. Jones
19c40e6717 gobject: Use G_ADD_PRIVATE
Deprecation warnings include:

src/optargs-xfs_growfs.c: In function 'guestfs_xfs_growfs_init':
src/optargs-xfs_growfs.c:311:13: warning: Deprecated pre-processor symbol: replace with "G_ADD_PRIVATE"
  311 |   o->priv = GUESTFS_XFS_GROWFS_GET_PRIVATE (o);
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This is based on the same change made here:

https://github.com/nzjrs/osm-gps-map/pull/78/files
2022-10-24 11:25:42 +01:00
Richard W.M. Jones
001683e885 appliance: Remove LD_PRELOAD=libSegFault.so
This feature was removed in glibc 2.35:
https://savannah.gnu.org/forum/forum.php?forum_id=10111
2022-10-24 10:41:09 +01:00
Richard W.M. Jones
3f5bdce111 Update common submodule
utils: Fix rogue include of nbdkit-plugin.h
2022-10-15 08:07:42 +01:00
Richard W.M. Jones
e1c9bbb3d1 lib: Avoid calling setenv between fork and exec
setenv can call malloc and is not safe to call here.  Glibc is usually
tolerant of this and we haven't had problems before, but if you use
GLIBC_TUNABLES glibc.malloc.check=1 (or any alternate malloc / libc
which serializes) then you would see hangs if starting multiple
libguestfs handles from different threads at the same time.

This commit also updates the common submodule to pick up:

  commit 3c64bcdeaf684f05f46f3928b55aadafdfe72720
  Author: Richard W.M. Jones <rjones@redhat.com>
  Date:   Fri Oct 14 11:07:21 2022 +0100

    utils: Add function for copying the environment and adding new entries

    libguestfs is currently calling setenv at an unsafe location between
    fork and exec.  To fix this we need a way to copy and modify the
    environment before fork and then we can pass the modified environ to
    execve-like functions.  nbdkit already does the same so use that code.

    This function is copied and adapted from here under a compatible license:
    https://gitlab.com/nbdkit/nbdkit/-/blob/master/common/utils/environ.c

Thanks: Siddhesh Poyarekar
2022-10-14 11:40:12 +01:00
Richard W.M. Jones
4004e8eb36 appliance: Create symlink /etc/crypto-policies/back-ends/opensslcnf.config
Downstream patched openssl in Fedora 37+ broke unless
/etc/crypto-policies/back-ends/opensslcnf.conf is present.  Files in
this directory are generated by %post rules that use scripting
languages so cannot easily be created by supermin.

Add a symlink to the DEFAULT policy file if the configuration file
doesn't exist.

A symptom of this problem is the error:

  Requested hash sha256 is not supported.
  Failed to set pbkdf parameters.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2133884
Updates: commit d6ba398825
2022-10-12 12:42:15 +01:00
Richard W.M. Jones
f73c653cc0 Revert "appliance: Copy in /etc/crypto-policies/back-ends/ files"
This reverts commit d6ba398825.
2022-10-12 10:08:14 +01:00
Richard W.M. Jones
d6ba398825 appliance: Copy in /etc/crypto-policies/back-ends/ files
Downstream patched openssl in Fedora 37+ broke unless
/etc/crypto-policies/back-ends/opensslcnf.conf is present.  Files in
this directory are generated by %post rules that use scripting
languages so cannot easily be created by supermin.

Force a copy of the host files into the appliance.  This is not ideal
and is hopefully a temporary fix until Fedora's openssl is fixed.

A symptom of this problem is the error:

  Requested hash sha256 is not supported.
  Failed to set pbkdf parameters.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2133884
2022-10-11 21:59:49 +01:00
Richard W.M. Jones
cf89757883 Version 1.49.5. 2022-10-11 14:54:08 +01:00
Richard W.M. Jones
c2dd84b263 daemon: Make vg_scan and lvm_scan no-ops if no LVM feature
If the LVM ("lvm2") feature is not available, these calls would fail.
Really they ought to be part of the "lvm2" optgroup which would cause
the generator to call reply_with_unavailable_feature and generate the
correct ENOTSUP error.  When vgscan was originally added in 2010 it
was not added to the optgroup, and when lvm_scan was later added in
2018 and deprecating vgscan, the same mistake was copied.

Before this commit they will try to run the lvm pvscan command which
will fail returning some other error (instead of ENOTSUP).

Fix this by turning the calls into no-ops if the LVM feature is not
available, since scanning for LVM objects when there is no LVM can be
safely turned into a no-op.

See also
https://listman.redhat.com/archives/libguestfs/2022-September/thread.html#29908

Also this updates the common module to pick up a related fix:

  commit 4b4a5b84647b1496d034bcdff910930ca5f5c486
  Author: Richard W.M. Jones <rjones@redhat.com>
  Date:   Fri Sep 23 15:18:43 2022 +0100

    options: Don't attempt to scan LVs if "lvm2" feature is not available

Reported-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Fixes: 55dfcb2211 ("New API: lvm_scan, deprecate vgscan")
Fixes: 9752039e52 ("New API: vgscan")
2022-09-27 15:53:48 +01:00
rwmjones
57d1812091 Merge pull request #97 from weblate/weblate-libguestfs-libguestfs-master
Translations update from Fedora Weblate
2022-09-06 13:00:53 +01:00
Weblate
b18a71ef1b Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/
2022-09-06 11:19:52 +02:00
Temuri Doghonadze
6501d78bd4 Translated using Weblate (Georgian)
Currently translated at 0.9% (9 of 965 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/ka/
2022-09-06 11:19:51 +02:00
Richard W.M. Jones
5e1f158c40 gnulib: Fix replacement functions for pipe2/accept4
gnulib itself has a replacement for <unistd.h> which redefines pipe2
as rpl_pipe2 (etc), which is why the apparently recursive call in the
implementation of pipe2 isn't actually recursive.  Since I didn't copy
that file, none of that worked and instead on platforms which have
pipe2 it recursed.

Reported-by: Laszlo Ersek
Fixes: commit 908e41e556
2022-08-17 14:58:52 +01:00
Richard W.M. Jones
e13a77e865 common: Update common submodule
commit 9d40590852e0755d4719adf97122758fa98e90f9
  Author: Richard W.M. Jones <rjones@redhat.com>
  Date:   Tue Aug 16 16:19:29 2022 +0100

    options/decrypt.c: Ignore #pragma GCC with clang
2022-08-16 16:31:34 +01:00
Richard W.M. Jones
03fadae09e common: Update common submodule
commit fd4062248271c1e026e3349fdcd4f9fc99e8f0c7
  Author: Richard W.M. Jones <rjones@redhat.com>
  Date:   Tue Aug 16 16:10:39 2022 +0100

    options/decrypt.c: Ignore probably bogus GCC -Werror=stringop-overflow

  commit 9d66f02807c7abdfbceba162a94c38cf474cf48b
  Author: Richard W.M. Jones <rjones@redhat.com>
  Date:   Tue Aug 16 15:56:46 2022 +0100

    windows/windows.c: Remove ignore -Wanalyzer-null-argument

  commit 0e4fdabcb6be5fc61dfc7b45cc5cb6db3d341494
  Author: Richard W.M. Jones <rjones@redhat.com>
  Date:   Tue Aug 16 15:46:22 2022 +0100

    mlpcre/pcre-c.c: Remove unused variable
2022-08-16 16:12:06 +01:00
Richard W.M. Jones
39d66abc04 fish/tilde.c: Remove ignore -Wanalyzer-null-argument
Added in 2021 as a workaround for GCC 11 and since fixed upstream.

On macOS (clang):

tilde.c:43:32: error: unknown warning group '-Wanalyzer-null-argument', ignored [-Werror,-Wunknown-warning-option]
                               ^
tilde.c:86:32: error: unknown warning group '-Wanalyzer-null-argument', ignored [-Werror,-Wunknown-warning-option]
                               ^
2 errors generated.
2022-08-16 16:00:09 +01:00
Richard W.M. Jones
8d50637741 gnulib: Copy in error(3) replacement from gnulib
This is available under a compatible license (LGPLv2+).
2022-08-16 16:00:09 +01:00
Richard W.M. Jones
347e875911 lib: Remove -Wanalyzer-file-leak ignores
These were added for GCC 11.  The problem has been fixed in GCC 12.
On macOS (clang) these produced errors like this:

tsk.c:75:32: error: unknown warning group '-Wanalyzer-file-leak', ignored [-Werror,-Wunknown-warning-option]
                               ^
2022-08-16 15:42:30 +01:00
Richard W.M. Jones
5fe33b685a lib/readdir.c: Include <rpc/types.h> before <rpc/xdr.h>
On macOS, several pages of errors like:

In file included from readdir.c:26:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/rpc/xdr.h:126:3: error: type name requires a specifier or qualifier
                bool_t  (*x_getlong)(struct __rpc_xdr *, int *);
                ^
2022-08-16 15:40:23 +01:00
Richard W.M. Jones
e7f28159fb lib/launch.c: Include <signal.h> for sigemptyset, etc
launch.c:191:3: error: implicit declaration of function 'sigemptyset' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
  sigemptyset (&sigset);
  ^
launch.c:192:3: error: implicit declaration of function 'sigaddset' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
  sigaddset (&sigset, SIGTERM);
  ^
launch.c:193:3: error: implicit declaration of function 'sigprocmask' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
  sigprocmask (SIG_UNBLOCK, &sigset, NULL);
  ^
3 errors generated.
2022-08-16 15:38:51 +01:00
Richard W.M. Jones
ef947a9d3b gnulib: Use system getprogname on macOS 2022-08-16 15:37:52 +01:00
Richard W.M. Jones
908e41e556 gnulib: Copy in pipe2 and accept4 replacements from gnulib
These are shipped under a compatible license (LGPLv2+ or LGPLv3+).
2022-08-16 15:37:52 +01:00
Richard W.M. Jones
6be5430314 common: Update common submodule
commit 1bf092f3c22e93c152de9dea3f5c13df23dc571c
  Author: Richard W.M. Jones <rjones@redhat.com>
  Date:   Tue Aug 16 15:08:40 2022 +0100

    utils: Include <stdio.h> for FILE*
2022-08-16 15:37:52 +01:00
Richard W.M. Jones
b018b35bd4 lib: Remove dtrace/systemtap probes
These were added in libguestfs 1.14, but never really used.  Only a
handful of probes were available.  When I was benchmarking libguestfs
in 2016 I didn't even use these probes because better/simpler
techniques were available.
2022-08-16 15:35:17 +01:00
Richard W.M. Jones
df5805df63 configure: Use AC_FUNC_STRERROR_R
Update common submodule to include modified strerror_r replacement
2022-08-16 14:15:11 +01:00
Richard W.M. Jones
6c0e5d7f8f protocol: Replace missing xdr_uint64_t on macOS
The macOS rpcgen actually generates calls to xdr_uint64_t but doesn't
define them.  Despite this we can just use xdr_int64_t instead since
it's just byte swapping.
2022-08-16 14:03:59 +01:00
Richard W.M. Jones
c51d1cfe9a m4: Check for GNU realpath program
It is a dependency of the ocaml-dep.sh script, required for all builds.
2022-08-16 13:45:14 +01:00
Richard W.M. Jones
be60075b16 m4: Don't check for DISTRO with --disable-appliance
It is only used when building the appliance and for nothing else.
2022-08-16 13:40:15 +01:00
Richard W.M. Jones
0b3c6cc0c0 daemon: Remove remaining uses of custom printf %Q and %R
We have traditionally used custom printf formatters %Q and %R, where
%Q replaces the argument with a shell-quoted string, and %R replaces
the argument with a sysroot-prefixed shell-quoted string.  They are
actually pretty useful, but unfortunately only supported by glibc.

We only used them in about a dozen places in the daemon (much code
having been replaced by OCaml which does not need them).

In every remaining case we were constructing a command using code like
this:

  asprintf_nowarn (&cmd,
         "cd %Q && find -print0 | %s -0 -o -H %s --quiet", ...);

We can replace this with:

  char *cmd;
  size_t cmd_size;
  fp = open_memstream (&cmd, &cmd_size);
  fprintf (fp, "cd ");
  shell_quote (dir, fp);
  fprintf (fp, " && find -print0 | %s -0 -o -H %s --quiet", ...);
  fclose (fp);
2022-08-16 10:39:01 +01:00
Richard W.M. Jones
ad8b1b09ee daemon: grub: Remove incorrect use of printf specifier %R
This code is attempting to construct a grub-install command like:

  grub-install --root-directory=/sysroot/boot /dev/sda

In fact it was adding quoting to the --root-directory parameter where
it was not needed (because our "command" function uses exec).

Remove use of %R here (to avoid the extra quoting) and just use the
sysroot prefix directly.
2022-08-16 10:21:33 +01:00
Richard W.M. Jones
0e784824e8 daemon: Add zstd support to guestfs_file_architecture
This is required so we can determine the file architecture of
zstd-compressed Linux kernel modules as used by OpenSUSE and maybe
other distros in future.

Note that zstd becomes a required package, but it is widely available
in current Linux distros.

The package names come from https://pkgs.org/download/zstd and my own
research.
2022-08-09 19:04:41 +01:00
Richard W.M. Jones
d8fce89eca Version 1.49.4. 2022-08-01 15:15:55 +01:00
rwmjones
6f8e014958 Merge pull request #93 from weblate/weblate-libguestfs-libguestfs-master
Translations update from Fedora Weblate
2022-08-01 13:49:31 +01:00
Yuri Chornoivan
7dbd49d1aa Translated using Weblate (Ukrainian)
Currently translated at 100.0% (965 of 965 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/uk/
2022-08-01 14:19:07 +02:00
Piotr Drąg
1fbdc4386a Translated using Weblate (Polish)
Currently translated at 53.8% (520 of 965 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/pl/
2022-08-01 14:19:06 +02:00
Weblate
0d4b8de8b1 Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/
2022-08-01 14:19:06 +02:00
Temuri Doghonadze
f968e9b955 Translated using Weblate (Georgian)
Currently translated at 0.8% (8 of 956 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/ka/
2022-08-01 14:19:05 +02:00
Richard W.M. Jones
4a517601c7 daemon: Parse /etc/hostname files containing comments
Thanks: Dawid Zamirski
Link: https://www.freedesktop.org/software/systemd/man/hostname.html
Acked-by: Laszlo Ersek <lersek@redhat.com>
2022-07-20 13:22:39 +01:00
Richard W.M. Jones
adfaf25a12 m4: Fix ./configure --disable-ocaml
OCaml is required to compile libguestfs, however we should still be
able to disable the OCaml bindings.  This didn't work because using
--disable-ocaml caused various configure tests to be skipped which are
required to compile the daemon.  In particular the check for
caml_alloc_initialized_string, resulting in this error:

pcre-c.c:47:1: error: static declaration of ‘caml_alloc_initialized_string’ follows non-static declaration
 caml_alloc_initialized_string (mlsize_t len, const char *p)
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Also OCaml gettext is not required by libguestfs.  There are no *.ml
files used by libguestfs which require translation.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2108425
Fixes: https://bugs.gentoo.org/820053
Fixes: commit 733d2182b6
2022-07-20 10:11:09 +01:00
Richard W.M. Jones
7149312632 lib: Don't use -cpu max on RISC-V
qemu (7.0) does not support -cpu max for TCG.

Note this change is necessary but not sufficient for getting
libguestfs to run on RISC-V, because there is also currently no
working path to make -kernel work.
2022-07-15 17:10:56 +01:00
Richard W.M. Jones
d68d1b2780 Version 1.49.3. 2022-07-01 15:27:25 +01:00
Richard W.M. Jones
1342626b33 valgrind: Add new suppressions for OCaml 4.14 2022-07-01 15:22:46 +01:00
Richard W.M. Jones
f16fcdcfa2 fuse/test-fuse.c: Partially disable test because of caching
Previously we noted in a comment that stat("hello.txt") is cached (and
not called again), so the test of the link count failed.  Something
has changed, possibly in the kernel, but it results in even more
aggressive caching so that an earlier, similar test also fails in the
same way.  I checked by enabling debugging that the stat call doesn't
result in guestfs_lstatns being called, and the old value for the
statbuf was being returned.
2022-07-01 15:12:23 +01:00
Laszlo Ersek
6a5b44f538 guestfish, guestmount: enable networking for "--key ID:clevis"
Call the C-language helper key_store_requires_network() in guestfish and
guestmount.

(Short log for the "common" submodule, commit range
35467027f657..af6cb55bc58a:

Laszlo Ersek (12):
      options: fix UUID comparison logic bug in get_keys()
      mltools/tools_utils: remove unused function "key_store_to_cli"
      mltools/tools_utils: allow multiple "--key" options for OCaml tools too
      options: replace NULL-termination with number-of-elements in get_keys()
      options: wrap each passphrase from get_keys() into a struct
      options: add back-end for LUKS decryption with Clevis+Tang
      options: introduce selector type "key_clevis"
      options: generalize "--key" selector parsing for C-language utilities
      mltools/tools_utils-c: handle internal type error with abort()
      mltools/tools_utils: generalize "--key" selector parsing for OCaml utils
      options, mltools/tools_utils: parse "--key ID:clevis" options
      options, mltools/tools_utils: add helper for network dependency
).

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1809453
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
Message-Id: <20220630122048.19335-4-lersek@redhat.com>
2022-07-01 15:11:06 +02:00
Laszlo Ersek
9a3e9a6c03 introduce the "clevis_luks_unlock" API
Introduce a new guestfs API called "clevis_luks_unlock". At the libguestfs
level, it is quite simple; it wraps the "clevis luks unlock" guest command
(implemented by the "clevis-luks-unlock" executable, which is in fact a
shell script).

The complexity is instead in the network-based disk encryption
(Clevis/Tang) scheme. Useful documentation:

- https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html-single/security_hardening/index#configuring-automated-unlocking-of-encrypted-volumes-using-policy-based-decryption_security-hardening
- https://github.com/latchset/clevis#clevis
- https://github.com/latchset/tang#tang

The package providing "clevis-luks-unlock" is usually called
"clevis-luks", occasionally "clevis". Some distros don't package clevis at
all. Add the new API under a new option group (which may not be available)
called "clevisluks".

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1809453
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20220630122048.19335-3-lersek@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
2022-07-01 15:07:26 +02:00
Laszlo Ersek
99844660b4 docs/guestfs-security: document CVE-2022-2211
Short log for the common submodule, commit range
f8de5508fe75..35467027f657:

Laszlo Ersek (2):
      mlcustomize: factor out pkg install/update/uninstall from guestfs-tools
      options: fix buffer overflow in get_keys() [CVE-2022-2211]

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1809453
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2100862
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20220628115418.5376-2-lersek@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
2022-06-29 15:29:37 +02:00
rwmjones
4159f72bb7 Merge pull request #91 from weblate/weblate-libguestfs-libguestfs-master
Translations update from Fedora Weblate
2022-06-21 10:43:15 +01:00
Weblate
661c4f0bfb Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/
2022-06-18 19:45:25 +02:00
Temuri Doghonadze
2fdf19e49f Added translation using Weblate (Georgian) 2022-06-18 19:45:24 +02:00
Richard W.M. Jones
60e8ea0312 lib/readdir.c: Include unistd.h for unlink(2)
On riscv64:

readdir.c: In function ‘guestfs_impl_readdir’:
readdir.c:127:3: error: implicit declaration of function ‘unlink’ [-Werror=implicit-function-declaration]
  127 |   unlink (tmpfn);
      |   ^~~~~~

I also changed the #include lines to make them look a bit more
like use in other files.
2022-06-17 13:25:48 +01:00
Richard W.M. Jones
1087d314cc daemon: Remove workaround for -Wanalyzer-mismatching-deallocation
On older GCC:

debug.c:116:32: error: unknown option after ‘#pragma GCC diagnostic’ kind [-Werror=pragmas]
  116 | #pragma GCC diagnostic ignored "-Wanalyzer-mismatching-deallocation"
      |                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[3]: *** [Makefile:2039: guestfsd-debug.o] Error 1

The upstream bug (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99193)
has now been fixed so the workaround is not necessary with the latest
GCC, so just delete the workaround.
2022-06-17 13:24:19 +01:00
Geoff Amey
ec27979398 php: add arginfo to php bindings
Starting with PHP8, arginfo is mandatory for PHP extensions. This patch
updates the generator for the PHP bindings to generate the arginfo
structures, using the Zend API macros. Only basic arginfo is added,
without full documentation of argument and return types, in order to
ensure compatibility with as many versions of PHP as possible.
2022-06-15 22:29:28 +01:00
Laszlo Ersek
8fc4d16715 appliance, daemon: disable lvm2 devicesfile
In guestfs-tools commit 4fe8a03cd2d3 ('sysprep: remove lvm2's default
"system.devices" file', 2022-04-11), we disabled the use of LVM2's new
"devicesfile" feature, which could interfere with the cloning of virtual
machines.

We suspected in

  https://bugzilla.redhat.com/show_bug.cgi?id=2072493#c6

that the same lvm2 feature could affect the libguestfs appliance itself,
but decided in

  https://bugzilla.redhat.com/show_bug.cgi?id=2072493#c8
  https://bugzilla.redhat.com/show_bug.cgi?id=2072493#c10

that this would not be the case, because "appliance/init" already
constructed a pristine LVM_SYSTEM_DIR.

Unfortunately, that's not enough: due to the "use_devicesfile=1" default
(on RHEL9 anyway), some "lvm" invocation, possibly inside the
lvm-set-filter API, *creates* "$LVM_SYSTEM_DIR/devices/system.devices".
And then we get (minimally) warnings such as

> Please remove the lvm.conf global_filter, it is ignored with the devices
> file.
> Please remove the lvm.conf filter, it is ignored with the devices file.

when using the lvm-set-filter API.

Explicitly disable the "devices file" in "appliance/init", and also
whenever we rewrite "lvm.conf" -- that is, in set_filter()
[daemon/lvm-filter.c]. In the former, check for the feature by locating
the devicesfile-related utilities "lvmdevices" and "vgimportdevices". In
the C code, invoke the utilities with the "--help" option instead. (In
"appliance/init",  I thought it was best not to call any lvm2 utilities
even with "--help", with our lvm2.conf still under construction there.) If
either utility is available, set "use_devicesfile = 0".

Cc: David Teigland <teigland@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1965941
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20220530141027.16167-1-lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
[lersek@redhat.com: style fix: break "devicesfile_feature" in the function
 definition to a new line]
2022-05-31 08:47:58 +02:00
Richard W.M. Jones
7afbf5ee44 build: Pick first field in ID_LIKE
CentOS Stream has:

ID_LIKE="rhel fedora"

which confused the existing script.  If there are multiple "likes"
arbitrarily pick the first one in the list.

Fixes: commit 63b722b6c0
2022-05-26 14:11:01 +01:00
Richard W.M. Jones
4b1fd3f154 Version 1.49.2. 2022-05-26 11:17:09 +01:00
Richard W.M. Jones
a1b0c4162e build: Add .gitpublish to EXTRA_DIST
Found by: make dist && make maintainer-check-extra-dist

Fixes: commit 8487e906d4
2022-05-26 10:48:32 +01:00
Richard W.M. Jones
488245ed6c daemon: rpm: Check return values from librpm calls
We previously didn't bother to check the return values from any librpm
calls.  In some cases where possibly the RPM database is faulty, this
caused us to return a zero-length list of installed applications (but
no error indication).

One way to reproduce this is given below.  Note this reproducer will
only work when run on a RHEL 8 host (or more specifically, with
rpm <= 4.16):

$ virt-builder fedora-28
$ guestfish -a fedora-28.img -i rm /var/lib/rpm/Packages
$ guestfish --ro -a fedora-28.img -i inspect-list-applications /dev/sda4 -vx
...
chroot: /sysroot: running 'librpm'
error: cannot open Packages index using db5 - Read-only file system (30)
error: cannot open Packages database in
error: cannot open Packages index using db5 - Read-only file system (30)
error: cannot open Packages database in
librpm returned 0 installed packages
...

With this commit we get an error instead:

...
chroot: /sysroot: running 'librpm'
error: cannot open Packages index using db5 - Read-only file system (30)
error: cannot open Packages database in
ocaml_exn: 'internal_list_rpm_applications' raised 'Failure' exception
guestfsd: error: rpmtsInitIterator
guestfsd: => internal_list_rpm_applications (0x1fe) took 0.01 secs
libguestfs: trace: internal_list_rpm_applications = NULL (error)
libguestfs: error: internal_list_rpm_applications: rpmtsInitIterator
libguestfs: trace: inspect_list_applications2 = NULL (error)
libguestfs: trace: inspect_list_applications = NULL (error)
...

Not in this case, but in some cases of corrupt RPM databases it is
possible to recover them by running "rpmdb --rebuilddb" as a guest
command (ie. with guestfs_sh).

See-also: https://bugzilla.redhat.com/show_bug.cgi?id=2089623#c12
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2089623
Fixes: commit c9ee831aff
Reported-by: Xiaodai Wang
Reported-by: Ming Xie
Acked-by: Laszlo Ersek <lersek@redhat.com>
2022-05-26 10:16:21 +01:00
Laszlo Ersek
9e69a38d82 update common submodule
Shortlog for 48527b8768d7..f8de5508fe75:

Laszlo Ersek (1):
      mlcustomize: refresh generated files

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2089748
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
2022-05-25 13:01:57 +02:00
Laszlo Ersek
4b9ee1052a generator/customize: reintroduce "--selinux-relabel" as a compat option
Removing "--selinux-relabel" in commit 2f6a27f107 ("generator/customize:
invert SELinux relabeling default", 2022-05-11) breaks existing scripts
that invoke virt-customize and/or virt-sysprep with that option. Restore
the option, with no functionality tied to it.

Fixes: 2f6a27f107
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2089748
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20220525071958.9612-1-lersek@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
2022-05-25 12:58:51 +02:00
Richard W.M. Jones
63b722b6c0 build: When parsing distro from /etc/os-release, try $ID_LIKE first
The current code for working out the distro uses the ID entry from
/etc/os-release, and then we map those strings into a smaller set of
values (basically, what package manager to use).  However it was
suggested that we should try ID_LIKE first so that distros which act
like other distros would work.  On an Arch Linux 32 system:

ID=arch32
ID_LIKE=arch

See-also: https://github.com/libguestfs/libguestfs/issues/81
Thanks: S D Rausty
2022-05-22 18:36:11 +01:00
Richard W.M. Jones
4418e6345a appliance: Error out if QUERY_FILES_CMD cannot be set
Instead of continuing on regardless and failing with a weird error
later, error out early if we don't know about the distro and so cannot
set QUERY_FILES_CMD.  This avoids situations like
https://github.com/libguestfs/libguestfs/issues/81
2022-05-21 17:19:54 +01:00
Richard W.M. Jones
bf5fcdbc9b appliance: Print guestfsd.deps after generation
Sometimes generating this file fails.  To help with debugging these
situatons, print the guestfsd.deps file after it has been generated.
2022-05-21 11:11:59 +01:00
rwmjones
79010dec83 Merge pull request #88 from weblate/weblate-libguestfs-libguestfs-master
Translations update from Fedora Weblate
2022-05-20 21:19:00 +01:00
Jan Kuparinen
7bbd5f9394 Translated using Weblate (Finnish)
Currently translated at 9.4% (90 of 956 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/fi/
2022-05-20 20:18:43 +02:00
Laszlo Ersek
544bb0ff50 guestfs.pod: document encrypted RBD disk limitation
Under "REMOTE STORAGE", the "NETWORK BLOCK DEVICE" section already
documents some limitations. Turns out we need to describe a quirky
exception for accessing encrypted RBD disks, too.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2033247
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20220518083014.9890-1-lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
2022-05-19 14:11:43 +02:00
rwmjones
307757f850 Merge pull request #87 from weblate/weblate-libguestfs-libguestfs-master
Translations update from Fedora Weblate
2022-05-19 08:48:02 +01:00
Yuri Chornoivan
3f0c0a3a1a Translated using Weblate (Ukrainian)
Currently translated at 100.0% (956 of 956 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/uk/
2022-05-18 22:18:35 +02:00
Richard W.M. Jones
feaec2497f website: Fix typo in previous commit
Fixes: commit 53d6c000b4
2022-05-18 16:09:24 +01:00
Richard W.M. Jones
53d6c000b4 website: List only the 1.48 stable branch on the website 2022-05-18 16:08:22 +01:00
Kashyap Chamarthy
8487e906d4 git: Add 'git-publish' config file
The `git-publish`[1] tool is a wrapper around `git-format-patch` and
`git-send-email`.  It's a handy tool that automates some of the tedious
aspects of manual patch submission:

  - Submitting a patch to the list (with a small config in place) is as
    simple as `git publish`

  - On next revisions, it automatically increments version numbers

  - It auto-copies the list of To: and Cc: from your previous iteration

  - It lets you preview/edit emails before submission

  - You can also use standard `git-format-patch` and `git-send-email`
    options with `git publish`

  - You can send pull requests with `git publish --pull-request`

  - It also provides custom hooks ... and more[2]

[1] https://github.com/stefanha/git-publish
[2] https://github.com/stefanha/git-publish/blob/master/git-publish.pod

Signed-off-by: Kashyap Chamarthy <kchamart@redhat.com>
2022-05-18 16:03:18 +01:00
Kashyap Chamarthy
16cf069b61 website: Update 'git clone' protocol
GitHub dropped[1] support for git: protocol, so cloing with "git://"
will fail.  Use "https://" instead.

[1] https://github.blog/2021-09-01-improving-git-protocol-security-github/

Signed-off-by: Kashyap Chamarthy <kchamart@redhat.com>
2022-05-18 16:03:18 +01:00
rwmjones
8a111cb82a Merge pull request #86 from weblate/weblate-libguestfs-libguestfs-master
Translations update from Fedora Weblate
2022-05-17 21:22:35 +01:00
Weblate
856a87041c Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/
2022-05-17 21:20:01 +02:00
Jan Kuparinen
ae4ae83007 Translated using Weblate (Finnish)
Currently translated at 0.8% (137 of 16048 strings)

Translation: libguestfs/libguestfs-docs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-docs-master/fi/
2022-05-17 21:20:01 +02:00
Neil Hanlon
a3487ef4c5 build: Add ROCKY to REDHAT distros list 2022-05-16 09:48:05 +01:00
Richard W.M. Jones
59d7e6e017 lib: Disable 5-level page tables when using -cpu max
In https://bugzilla.redhat.com/show_bug.cgi?id=2082806 we've been
tracking an insidious qemu bug which intermittently prevents the
libguestfs appliance from starting.  The symptoms are that SeaBIOS
starts and displays its messages, but the kernel isn't reached.  We
found that the kernel does in fact start, but when it tries to set up
page tables and jump to protected mode it gets a triple fault which
causes the emulated CPU in qemu to reset (qemu exits).

This seems to only affect TCG (not KVM).

Yesterday I found that this is caused by using -cpu max which enables
the "la57" feature (5-level page tables[0]), and that we can make the
problem go away using -cpu max,la57=off.  Note that I still don't
fully understand the qemu bug, so this is only a workaround.

I chose to disable 5-level page tables for both TCG and KVM, partly to
make the patch simpler, and partly because I guess it's not a feature
(ie. 57 bit linear addresses) that is useful for the libguestfs
appliance case, where we have limited physical memory and no need to
run any programs with huge address spaces.

I tested this by running both the direct & libvirt paths overnight.  I
expect that this patch will fail with old qemu/libvirt which doesn't
understand the "la57" feature, but this is only intended as a
temporary workaround.

[0] Article about 5-level page tables as background:
https://lwn.net/Articles/717293/

Thanks: Laszlo Ersek
Fixes: https://answers.launchpad.net/ubuntu/+source/libguestfs/+question/701625
Acked-by: Laszlo Ersek <lersek@redhat.com>
2022-05-13 13:00:28 +01:00
Richard W.M. Jones
a4f668fad3 Version 1.49.1. 2022-05-12 14:45:14 +01:00
Laszlo Ersek
a39b79f607 daemon/selinux-relabel: tolerate relabeling errors
Option "-C" of setfiles(8) causes setfiles(8) to exit with status 1 rather
than status 255 if it encounters relabeling errors, but no other (fatal)
error. Pass "-C" to setfiles(8) in "selinux-relabel", because we don't
want the "selinux-relabel" API to fail if setfiles(8) only encounters
relabeling errors.

(NB even without "-C", setfiles(8) continues traversing the directory
tree(s) and relabeling files across relabeling errors, so this change is
specifically about the exit status.)

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1794518
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20220511122345.14208-3-lersek@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
2022-05-11 17:02:17 +02:00
Laszlo Ersek
5345d42635 daemon/selinux-relabel: generalize setfiles_has_m_option()
Allow the caller to pass in the option to check for, and to store the
result in a (usually static) variable of their choice.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1794518
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20220511122345.14208-2-lersek@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
2022-05-11 17:01:57 +02:00
Laszlo Ersek
08c4ac90f5 update common submodule
Laszlo Ersek (2):
      mlcustomize: refresh generated files
      remove non-generated "--selinux-relabel" options

Richard W.M. Jones (2):
      options/uri.c: Fix missing word in error message
      options/uri.c: Free variable on error path

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1554735
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2075718
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
2022-05-11 05:26:48 +02:00
Laszlo Ersek
2f6a27f107 generator/customize: invert SELinux relabeling default
Replace the "--selinux-relabel" option with "--no-selinux-relabel",
inverting the default behavior (for guests with SELinux support, that is
-- relabeling is always skipped for guests that don't support SELinux.)

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1554735
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2075718
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20220510102757.14466-3-lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
2022-05-11 05:16:32 +02:00
Laszlo Ersek
8541db057c generator/customize: document that "--selinux-relabel" checks for SELinux
The documentation currently says that the user should avoid passing
"--selinux-relabel" on the command line if the guest does not support
SELinux. However, the "is_selinux_guest" helper function in
"common/mlcustomize/SELinux_relabel.ml" already turns "--selinux-relabel"
into a no-op if some key SELinux files are absent from the guest, so there
is no need to caution the user.

This change is relevant because the subsequent patches will turn on
"--selinux-relabel" by default, and therefore "is_selinux_guest" will grow
in importance.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1554735
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2075718
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20220510102757.14466-2-lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
2022-05-11 05:16:17 +02:00
rwmjones
00b9ef2393 Merge pull request #83 from weblate/weblate-libguestfs-libguestfs-master
Translations update from Fedora Weblate
2022-05-10 16:36:15 +01:00
Emilio Herrera
7e9ff9e7f8 Translated using Weblate (Spanish)
Currently translated at 2.0% (328 of 16046 strings)

Translation: libguestfs/libguestfs-docs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-docs-master/es/
2022-05-10 17:18:34 +02:00
Laszlo Ersek
ddf276884c tests/regressions: remove "iface"-based restrictions
Now that "iface" is ignored by both backends, the regression tests for
RHBZ 690819 and 975797 can be enabled on all arches (regardless of
backend).

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1844341
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20220504134155.11832-5-lersek@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
2022-05-05 13:05:23 +02:00
Laszlo Ersek
c8e3caf9e6 lib: rename VALID_FORMAT_IFACE to VALID_FORMAT
We no longer use VALID_FORMAT_IFACE for validating "iface"; rename the
macro to reflect that we only check "format" with it.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1844341
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20220504134155.11832-4-lersek@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
2022-05-05 13:05:21 +02:00
Laszlo Ersek
f68eaee1d6 lib: drive_create_data, drive: remove field "iface"
Representing "iface" in the "drive_create_data" and "drive" structures is
now useless; the direct backend ignores "iface", while the libvirt one
rejects it unless it is empty. Unify both backends -- make them both
ignore "iface". (Which only relaxes the libvirt backend, so it cannot
cause compatibility problems.) This lets us remove the fields. Update the
documentation as well.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1844341
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20220504134155.11832-3-lersek@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
2022-05-05 13:05:19 +02:00
Laszlo Ersek
3eb830dbae lib: launch-direct: ignore drive "iface" parameter
Rich said in <https://bugzilla.redhat.com/show_bug.cgi?id=1844341#c1>:

> The libvirt backend has never allowed the iface parameter.  We should
> probably ignore it in the direct backend since it's never been possible
> to use this parameter correctly.

Remove the handling of "iface" in the direct (QEMU) backend. Refresh the
documentation regarding both backends.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1844341
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20220504134155.11832-2-lersek@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
2022-05-05 13:05:07 +02:00
Laszlo Ersek
4864d21cb8 guestfs_readdir(): minimize the number of send_file_write() calls
In guestfs_readdir(), the daemon currently sends each XDR-encoded
"guestfs_int_dirent" to the library with a separate send_file_write()
call.

Determine the largest encoded size (from the longest filename that a
"guestfs_int_dirent" could carry, from readdir()'s "struct dirent"), and
batch up the XDR encodings until the next encoding might not fit in
GUESTFS_MAX_CHUNK_SIZE. Call send_file_write() only then.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1674392
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20220502085601.15012-3-lersek@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
2022-05-03 10:54:00 +02:00
Laszlo Ersek
45b7f1736b guestfs_readdir(): rewrite with FileOut transfer, to lift protocol limit
Currently the guestfs_readdir() API can not list long directories, due to
it sending back the whole directory listing in a single guestfs protocol
response, which is limited to GUESTFS_MESSAGE_MAX (approx. 4MB) in size.

Introduce the "internal_readdir" action, for transferring the directory
listing from the daemon to the library through a FileOut parameter.
Rewrite guestfs_readdir() on top of this new internal function:

- The new "internal_readdir" action is a daemon action. Do not repurpose
  the "readdir" proc_nr (138) for "internal_readdir", as some distros ship
  the binary appliance to their users, and reusing the proc_nr could
  create a mismatch between library & appliance with obscure symptoms.
  Replace the old proc_nr (138) with a new proc_nr (511) instead; a
  mismatch would then produce a clear error message. Assume the new action
  will first be released in libguestfs-1.48.2.

- Turn "readdir" from a daemon action into a non-daemon one. Call the
  daemon action guestfs_internal_readdir() manually, receive the FileOut
  parameter into a temp file, then deserialize the dirents array from the
  temp file.

This patch sneakily fixes an independent bug, too. In the pre-patch
do_readdir() function [daemon/readdir.c], when readdir() returns NULL, we
don't distinguish "end of directory stream" from "readdir() failed". This
rewrite fixes this problem -- I didn't see much value separating out the
fix for the original do_readdir().

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1674392
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20220502085601.15012-2-lersek@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
2022-05-03 10:53:48 +02:00
Richard W.M. Jones
ac00e603f8 New API: guestfs_device_name returning the drive name
For each drive added, return the name.  For example calling this with
index 0 will return the string "/dev/sda".  I called it
guestfs_device_name (not drive_name) for consistency with the existing
guestfs_device_index function.

You don't really need to call this function.  You can follow the
advice here:
https://libguestfs.org/guestfs.3.html#block-device-naming
and assume that drives are added with predictable names like
"/dev/sda", "/dev/sdb", etc.

However it's useful to expose the internal guestfs_int_drive_name
function since especially handling names beyond index 26 is tricky
(https://rwmj.wordpress.com/2011/01/09/how-are-linux-drives-named-beyond-drive-26-devsdz/)

Fixes: https://github.com/libguestfs/libguestfs/issues/80
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2022-05-02 12:10:29 +01:00
Richard W.M. Jones
f9babf8c04 m4: Add support for Artix
Fixes: https://github.com/libguestfs/libguestfs/issues/81
2022-04-29 15:16:25 +01:00
Richard W.M. Jones
b4081d0275 api: Note that drive "name" field is no longer used
Before commit 3a00c4d179 ("Remove inspection from the C library and
switch to daemon/OCaml implementation") in 2017 the name parameter
passed to add_drive was used by inspection to override the device name
that is determined from fstab.  None of our tools ever actually used
this parameter, and when the inspection code was moved inside the
daemon we stopped using this hint field at all.

So it's no longer used, and likely hasn't been used ever.  Therefore
document that the field does nothing.

Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2022-04-29 11:23:45 +01:00
Richard W.M. Jones
bf8b876b68 Update common submodule
mltools/tools_utils-c.c: Free keystore after decryption
2022-04-28 16:08:20 +01:00
Richard W.M. Jones
0a2d43988f build: No longer check for ocamldep -one-line and -all options
These were added to ocamldep in Jan 2012, over 10 years ago.  They
were not present in RHEL 6, but we don't care about that now.

(cherry picked from virt-v2v commit f6108bbd661d3e922d07b47f00daa901ab846e59)
2022-04-28 15:38:56 +01:00
Richard W.M. Jones
0956e8e0c5 tests: Fix isoinfo test to recognise cdrtools iso_volume_id
cdrtools writes "CDROM" into the Volume Identifier field in the PVD,
whereas genisoimage and xorriso write "ISOIMAGE".  Recognise either
string as valid in the test.

Fixes: https://github.com/libguestfs/libguestfs/issues/79
Reported-by: David Runge
2022-04-28 08:43:10 +01:00
Andrey Drobyshev
ef8c6593eb appliance: don't read extfs signature from QCOW2 image directly
If the appliance is a QCOW2 image, function get_root_uuid_with_file()
fails to read ext filesystem signature (0x53EF at offset 0x438) from it.
This results in the following error:

libguestfs: error: /usr/lib64/guestfs/appliance/root: appliance is not
an extfs filesystem

The error itself is harmless, but misleading.  So let's skip retrieving
the signature and UUID in case the image contains QCOW2 header.  It's
safe because in this case we'll retrieve it later from RAW image dumped
from that QCOW2 by "qemu-img dd".

Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
2022-04-25 20:54:48 +01:00
Richard W.M. Jones
bc96e0b7d7 daemon: Fix compilation with older rpm that lacks RPMVSF_MASK_NOSIGNATURES
On RHEL 7 (rpm-devel-4.11.3-45.el7.x86_64):

rpm-c.c: In function ‘guestfs_int_daemon_rpm_start_iterator’:
rpm-c.c:97:44: error: ‘RPMVSF_MASK_NOSIGNATURES’ undeclared (first use in this function)
   rpmtsSetVSFlags (ts, rpmtsVSFlags (ts) | RPMVSF_MASK_NOSIGNATURES);
                                            ^
rpm-c.c:97:44: note: each undeclared identifier is reported only once for each function it appears in

Fixes: commit aa6f8038f8
2022-04-25 16:40:12 +01:00
rwmjones
03a18f5f31 Merge pull request #77 from weblate/weblate-libguestfs-libguestfs-master
Translations update from Fedora Weblate
2022-04-16 07:20:27 +01:00
Weblate
7c7b9f53c3 Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/
2022-04-15 22:17:29 +02:00
Pavel Borecki
1886a03acf Translated using Weblate (Czech)
Currently translated at 0.5% (5 of 955 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/cs/
2022-04-15 22:17:28 +02:00
Richard W.M. Jones
3d2f4e2ff3 Version 1.48.1. 2022-04-14 16:49:49 +01:00
Richard W.M. Jones
d64d2b7649 daemon/utils.ml: Replace Bytes.get_uint8 with native call
Bytes.get_uint8 was added in OCaml 4.08.  To support OCaml >= 4.04 (in
particular, RHEL 8 has OCaml 4.07) we have to replace this function
with the equivalent native call.  We can remove this commit once the
baseline OCaml moves up.

Updates: commit edfebee404
2022-04-14 11:32:35 +01:00
Laszlo Ersek
05419dbcec Update common submodule 2022-04-12 11:54:22 +02:00
Nikolay Shirokovskiy
af5ab47725 tests: fix rhbz1370424 to use proper path
Test fails as it cannot find .xml file. Turns out $pwd=./tests and
and not ./tests/regressions as supposed in script.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@openvz.org>
2022-04-08 16:03:00 +01:00
Nikolay Shirokovskiy
5552ef1c46 tests: fix rhbz1044014 to use proper paths
Test fails as it cannot find .in file. Turns out $srcdir=. (which is ./tests) and
and not ./tests/regressions as supposed in script. Same apply to
$abs_srcdir.

Also put .out file in ./tests/regressions too.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@openvz.org>
2022-04-08 16:03:00 +01:00
Richard W.M. Jones
3115726aca po-docs: Sort LINGUAS file 2022-03-31 16:36:53 +01:00
Jan Kuparinen
c2084acf06 Translated using Weblate (Finnish)
Currently translated at 9.2% (88 of 955 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/fi/
2022-03-27 09:32:33 +02:00
Yuri Chornoivan
02b3462097 Translated using Weblate (Ukrainian)
Currently translated at 100.0% (955 of 955 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/uk/
2022-03-20 18:17:01 +01:00
Weblate
83cd69e99c Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/
2022-03-19 17:17:07 +01:00
Emilio Herrera
1c04024d13 Translated using Weblate (Spanish)
Currently translated at 2.0% (325 of 16046 strings)

Translation: libguestfs/libguestfs-docs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-docs-master/es/
2022-03-19 17:17:04 +01:00
Jan Kuparinen
ffbcfb6659 Translated using Weblate (Finnish)
Currently translated at 8.9% (87 of 976 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/fi/
2022-03-19 17:17:04 +01:00
Weblate
c7b8f7e1e2 Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/
2022-03-19 17:17:04 +01:00
Jan Kuparinen
219f3a1a62 Translated using Weblate (Finnish)
Currently translated at 0.8% (135 of 16048 strings)

Translation: libguestfs/libguestfs-docs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-docs-master/fi/
2022-03-19 17:17:04 +01:00
Emilio Herrera
aaa3211ade Translated using Weblate (Spanish)
Currently translated at 1.9% (319 of 16046 strings)

Translation: libguestfs/libguestfs-docs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-docs-master/es/
2022-03-19 17:17:03 +01:00
Ettore Atalan
8e157f0b05 Translated using Weblate (German)
Currently translated at 7.4% (1188 of 16046 strings)

Translation: libguestfs/libguestfs-docs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-docs-master/de/
2022-03-19 17:17:03 +01:00
Ettore Atalan
ef605f400a Translated using Weblate (German)
Currently translated at 33.2% (325 of 976 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/de/
2022-03-19 17:17:03 +01:00
Jan Kuparinen
9a0a685304 Translated using Weblate (Finnish)
Currently translated at 8.8% (86 of 976 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/fi/

Translated using Weblate (Finnish)

Currently translated at 0.8% (130 of 16048 strings)

Translation: libguestfs/libguestfs-docs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-docs-master/fi/
2022-03-19 17:17:03 +01:00
Yuri Chornoivan
85c41f314c Translated using Weblate (Ukrainian)
Currently translated at 100.0% (976 of 976 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/uk/
2022-03-19 17:17:03 +01:00
Piotr Drąg
052fa92472 Translated using Weblate (Polish)
Currently translated at 53.6% (524 of 976 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/pl/
2022-03-19 17:17:03 +01:00
Ricky Tigg
483b6b50f2 Translated using Weblate (Finnish)
Currently translated at 0.7% (123 of 16048 strings)

Translation: libguestfs/libguestfs-docs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-docs-master/fi/
2022-03-19 17:17:03 +01:00
Jan Kuparinen
dd7107d1b9 Translated using Weblate (Finnish)
Currently translated at 8.7% (85 of 976 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/fi/

Translated using Weblate (Finnish)

Currently translated at 0.7% (121 of 16048 strings)

Translation: libguestfs/libguestfs-docs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-docs-master/fi/

Translated using Weblate (Finnish)

Currently translated at 8.6% (84 of 975 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/fi/

Translated using Weblate (Finnish)

Currently translated at 0.6% (109 of 16048 strings)

Translation: libguestfs/libguestfs-docs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-docs-master/fi/
2022-03-19 17:17:03 +01:00
Weblate
db28084ef0 Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/
2022-03-19 17:17:03 +01:00
Ricky Tigg
3d0f5c1f76 Translated using Weblate (Finnish)
Currently translated at 8.5% (83 of 975 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/fi/

Translated using Weblate (Finnish)

Currently translated at 0.1% (24 of 16048 strings)

Translation: libguestfs/libguestfs-docs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-docs-master/fi/

Translated using Weblate (Finnish)

Currently translated at 16.6% (292 of 1751 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/fi/

Added translation using Weblate (Finnish)
2022-03-19 17:17:03 +01:00
Weblate
8347a8a610 Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/
2022-03-19 17:17:03 +01:00
Hela Basa
a9f93154f4 Translated using Weblate (Sinhala)
Currently translated at 0.1% (2 of 16048 strings)

Translation: libguestfs/libguestfs-docs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-docs-master/si/

Added translation using Weblate (Sinhala)

Added translation using Weblate (Sinhala)
2022-03-19 17:17:02 +01:00
Emilio Herrera
88a219255f Translated using Weblate (Spanish)
Currently translated at 1.9% (312 of 16046 strings)

Translation: libguestfs/libguestfs-docs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-docs-master/es/

Translated using Weblate (Spanish)

Currently translated at 1.9% (305 of 16046 strings)

Translation: libguestfs/libguestfs-docs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-docs-master/es/

Translated using Weblate (Spanish)

Currently translated at 1.8% (296 of 16046 strings)

Translation: libguestfs/libguestfs-docs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-docs-master/es/

Translated using Weblate (Spanish)

Currently translated at 1.7% (287 of 16046 strings)

Translation: libguestfs/libguestfs-docs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-docs-master/es/
2022-03-19 17:17:02 +01:00
Piotr Drąg
abbe8ab88b Translated using Weblate (Polish)
Currently translated at 34.2% (600 of 1751 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/pl/

Translated using Weblate (Polish)

Currently translated at 34.0% (595 of 1749 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/pl/
2022-03-19 17:17:02 +01:00
Marcin Stanclik
b5c27c4dd4 Translated using Weblate (Polish)
Currently translated at 34.0% (595 of 1749 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/pl/
2022-03-19 17:17:02 +01:00
Ricky Tigg
58c4aea471 Translated using Weblate (Finnish)
Currently translated at 9.6% (169 of 1751 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/fi/

Translated using Weblate (Finnish)

Currently translated at 8.9% (156 of 1751 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/fi/

Translated using Weblate (Finnish)

Currently translated at 4.0% (71 of 1751 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/fi/
2022-03-19 17:17:02 +01:00
Weblate
f96eba6684 Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/
2022-03-19 17:17:02 +01:00
Yuri Chornoivan
d00b8ece5b Translated using Weblate (Ukrainian)
Currently translated at 100.0% (1751 of 1751 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/uk/
2022-03-19 17:17:02 +01:00
Weblate
b3a1b03e8f Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/
2022-03-19 17:17:02 +01:00
Jan Kuparinen
f996e22c94 Translated using Weblate (Finnish)
Currently translated at 2.2% (40 of 1749 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/fi/

Added translation using Weblate (Finnish)
2022-03-19 17:17:02 +01:00
Adolfo Jayme Barrientos
c14861bd2c Translated using Weblate (Spanish)
Currently translated at 1.7% (286 of 16047 strings)

Translation: libguestfs/libguestfs-docs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-docs-master/es/
2022-03-19 17:17:02 +01:00
Piotr Drąg
0999db62f6 Translated using Weblate (Polish)
Currently translated at 33.9% (594 of 1749 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/pl/

Translated using Weblate (Polish)

Currently translated at 33.7% (591 of 1749 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/pl/

Translated using Weblate (Polish)

Currently translated at 33.6% (589 of 1749 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/pl/

Translated using Weblate (Polish)

Currently translated at 33.4% (585 of 1749 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/pl/

Translated using Weblate (Polish)

Currently translated at 33.5% (587 of 1749 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/pl/

Translated using Weblate (Polish)

Currently translated at 30.4% (532 of 1749 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/pl/
2022-03-19 17:17:02 +01:00
Michał Smyk
c30c48a797 Translated using Weblate (Polish)
Currently translated at 30.4% (532 of 1749 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/pl/
2022-03-19 17:17:02 +01:00
Weblate
e560fcdf81 Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/
2022-03-19 17:17:02 +01:00
Yuri Chornoivan
daf9b060b6 Translated using Weblate (Ukrainian)
Currently translated at 100.0% (16047 of 16047 strings)

Translation: libguestfs/libguestfs-docs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-docs-master/uk/

Translated using Weblate (Ukrainian)

Currently translated at 100.0% (1749 of 1749 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/uk/

Translated using Weblate (Ukrainian)

Currently translated at 100.0% (1749 of 1749 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/uk/

Translated using Weblate (Ukrainian)

Currently translated at 100.0% (1749 of 1749 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/uk/

Translated using Weblate (Ukrainian)

Currently translated at 97.1% (15589 of 16047 strings)

Translation: libguestfs/libguestfs-docs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-docs-master/uk/

Translated using Weblate (Ukrainian)

Currently translated at 87.7% (1534 of 1749 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/uk/
2022-03-19 17:17:02 +01:00
Richard W.M. Jones
aa6f8038f8 daemon/rpm-c.c: Disable signature checking in librpm
Older distros (eg CentOS 6) used SHA-1 RPM package signatures which
some newer distros (eg RHEL 9.0) prevent us from verifying.

This resulted in packages with SHA-1 signatures being skipped by
librpm (there is a warning in debug output, but if you're not looking
at that then the package is silently ignored).  In some cases
essential packages like the kernel were skipped, which would be
visible as a failure of virt-v2v.  In other cases (eg virt-inspector)
you'd just see fewer installed packages in the <applications> list.

Since verifying package signatures is not essential for inspection,
disable this feature in librpm.

Reported-by: Xiaodai Wang
Thanks: Panu Matilainen
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2064182
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
2022-03-15 11:00:08 +00:00
Richard W.M. Jones
1b61ad0d3f Version 1.48.0. 2022-03-14 13:38:28 +00:00
Richard W.M. Jones
5bb4323fa2 docs/guestfs-release-notes-1.48.pod: Add fixed bugs to release notes
Updates: commit 2f4fb09de3
2022-03-12 22:48:42 +00:00
Richard W.M. Jones
466e7d3be3 docs: Show only libguestfs bugs in bugs-in-changelog.sh
Taken from commit ae8ff236ab.
2022-03-10 16:00:59 +00:00
Richard W.M. Jones
363c5af844 docs: Various fixes to bugs-in-changelog.sh
This script is used to prepare the list of fixed bugs for release
notes.  This commit contains miscellaneous fixes:

 - Recognise other bug formats such as direct links.

 - Ensure user is logged in so that BZ API doesn't silently truncate
   results.

(cherry picked from virt-v2v commit fac1e4fce0d7114bd044b274788de01569089e18)
2022-03-10 16:00:53 +00:00
Richard W.M. Jones
2a8a0672c4 Revert "bugs-in-changelog.sh: Various fixes to cope with new changelog format"
I fixed this in a better way in virt-v2v, so revert this change and
(next commit) use the virt-v2v commit instead.

This reverts commit ae8ff236ab.
2022-03-10 16:00:35 +00:00
Richard W.M. Jones
96a887a9bf docs: Update release notes for 1.48
Updates: commit 2f4fb09de3
2022-03-10 10:14:06 +00:00
Richard W.M. Jones
4256737227 lib: Remove drive hotplugging support
This was a feature that allowed you to add drives to the appliance
after launching it.  It was complicated to implement, and only worked
for the libvirt backend (not "direct", which is the default backend).

It also turned out to be a bad idea.  The original concept was that
appliance creation was slow, so to examine multiple guests you should
launch the handle once then hot-add the disks from each guest in turn
to manipulate them.  However this is terrible from a security point of
view, especially for multi-tenant, because the drives from one guest
might compromise the appliance and thus the filesystems/drives from
subsequent guests.

It also turns out that hotplugging is very slow.  Nowadays appliance
creation should be faster than hotplugging.

The main use case for this was virt-df, but virt-df no longer uses it
after we discovered the problems outlined above.
2022-03-09 09:28:02 +00:00
Richard W.M. Jones
55be87367d lib: Remove 9p APIs
These APIs were an experimental feature for passing through 9p
filesystems from the host to the libguestfs appliance.  It was never
possible to use this without hacking the qemu command line of the
appliance to add such drives by hand.  It also didn't fit the
libguestfs model very well.  And 9p is generally deprecated in
upstream qemu.

Note that for ABI reasons these APIs are not actually removed, they
have been changed so that they always return an error.  These APIs
were actually hard-removed from all versions of RHEL.

See-also: https://bugzilla.redhat.com/921710
2022-03-09 09:28:02 +00:00
Richard W.M. Jones
b9b0a90487 lib: Remove User-Mode Linux
User-Mode Linux was an alternative hypervisor that could run the
appliance, instead of using qemu.  It had many limitations including
lack of network, and UML support in Linux has been semi-broken for a
long time.  It was also slower than KVM on baremeal in general and had
various corner cases which were much slower including the emulated
serial port which made bulk uploads and downloads painful.  Also of
course it lacked qemu-specific features like qcow2 or any
network-backed disk, so many disk images could not be opened this way.

This was never supported in RHEL.

See-also: https://bugzilla.redhat.com/1144197
2022-03-09 09:28:02 +00:00
Richard W.M. Jones
dbc2fd8dc8 lib: Remove libguestfs live
This experimental feature allowed you (in theory) to connect to an
existing instance of the libguestfs daemon.  (Again, in theory) it
allowed you to attach to running guests.  This didn't work well in
practice.  If you want to do this, install qemu-guest-agent inside
your guest instead.

This also disables the --live options in guestfish and guestmount.
(The option now prints an error).

This was never supported in RHEL.

The daemon tests relied on this connection method to perform tests on
a bare daemon, so this removes those tests.  They were not especially
valuable.

See-also: https://bugzilla.redhat.com/798980
2022-03-09 09:27:19 +00:00
Richard W.M. Jones
aeb8286e60 Version 1.47.4. 2022-03-08 14:21:06 +00:00
Richard W.M. Jones
05561db5f6 po: Update PO files because of small change in common/ subdirectory 2022-03-08 12:26:09 +00:00
Richard W.M. Jones
1fb3aff908 tests: Fix tests which could use conflicting filenames
Commit 6d32773e81 ("tests: Run the tests in parallel.") makes all of
the tests run in the same directory.  Previously tests expected to be
run in their own subdirectories and so were freer about using generic
filenames.  When run in parallel these filenames now clash.  Fix
another case.

Fixes: commit 6d32773e81
2022-03-08 12:26:09 +00:00
Richard W.M. Jones
1b365bc605 tests: Fix TESTS continuation and duplicate EXTRA_DIST
Commit 6d32773e81 ("tests: Run the tests in parallel.") combined
multiple Makefiles into one.  During this conversion I accidentally
made several mistakes - duplicating the EXTRA_DIST entry for
mountable/test-mountable-inspect.sh and omitting the backslash
continuation of the TESTS line.

Fixes: commit 6d32773e81
2022-03-08 12:26:09 +00:00
Richard W.M. Jones
2f4fb09de3 docs: Add preliminary release notes for 1.48 2022-03-08 12:26:09 +00:00
Richard W.M. Jones
25ddaefb03 docs: Recreate guestfs-release-notes(1) page
Commit e9eaf4d889 ("docs: Split release notes by release.")  split the
old guestfs-release-notes(1) page by release, but left now-broken
links to guestfs-release-notes(1) in various places in the
documentation.

The easiest way to fix this is to recreate this page by renaming
guestfs-release-notes-historical(1) as guestfs-release-notes(1) and
adding links to the other release notes pages.

Fixes: commit e9eaf4d889
2022-03-08 11:05:04 +00:00
Laszlo Ersek
beba88e75b Update common submodule
$ git shortlog 2d8c0f8d40b5..60efc5407552

Laszlo Ersek (3):
      options: assume GUESTFS_HAVE_LUKS_UUID and GUESTFS_HAVE_CRYPTSETUP_OPEN
      options: remove stale comment about GUESTFS_CRYPTSETUP_OPEN_READONLY
      options: allocate the decrypted LUKS device name dynamically

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
2022-03-01 17:42:03 +01:00
Richard W.M. Jones
7d19cf66f2 Version 1.47.3. 2022-03-01 11:11:57 +00:00
Richard W.M. Jones
a8c4c4fc23 valgrind: Add suppression for dlopen in glibc 2.35
See: f6409b4137
2022-03-01 11:07:54 +00:00
Richard W.M. Jones
e74656a134 valgrind: Modify suppressions for extra stack frame
When running the OCaml bytecode tests, small but apparently
unimportant differences in the stack frames caused the existing
suppressions not to match.  Adding an extra "..." will ignore these
differences allowing the tests to pass.

Valgrind output before this commit (note "UnknownInlinedFun" frame):

==1733400== 79 (48 direct, 31 indirect) bytes in 1 blocks are definitely lost in loss record 320 of 518
==1733400==    at 0x484A464: calloc (vg_replace_malloc.c:1328)
==1733400==    by 0x59685D0: g_malloc0 (gmem.c:136)
==1733400==    by 0x531BB59: virClassNew (virobject.c:191)
==1733400==    by 0x553A3BF: UnknownInlinedFun (datatypes.c:110)
==1733400==    by 0x553A3BF: virDataTypesOnce (datatypes.c:121)
==1733400==    by 0x49EA0C8: __pthread_once_slow (pthread_once.c:116)
==1733400==    by 0x53312E9: virOnce (virthread.c:44)
==1733400==    by 0x553A74A: UnknownInlinedFun (datatypes.c:121)
==1733400==    by 0x553A74A: virGetConnect (datatypes.c:133)
==1733400==    by 0x54FA94F: virConnectOpenInternal (libvirt.c:895)
==1733400==    by 0x54FB883: virConnectOpenAuth (libvirt.c:1277)
==1733400==    by 0x50E842A: guestfs_int_open_libvirt_connection.constprop.0 (libvirt-auth.c:224)
==1733400==    by 0x50C6120: launch_libvirt.lto_priv.0 (launch-libvirt.c:390)
==1733400==    by 0x5040E30: UnknownInlinedFun (launch.c:114)
==1733400==    by 0x5040E30: guestfs_launch (actions-3.c:513)
==1733400==
==1733400== 256 bytes in 1 blocks are definitely lost in loss record 481 of 518
==1733400==    at 0x484586F: malloc (vg_replace_malloc.c:381)
==1733400==    by 0x137A0E: UnknownInlinedFun (memory.c:824)
==1733400==    by 0x137A0E: caml_executable_name (unix.c:367)
==1733400==    by 0x14C224: UnknownInlinedFun (startup_byt.c:502)
==1733400==    by 0x14C224: caml_main (startup_byt.c:457)
==1733400==    by 0x11CEE1: main (main.c:41)
2022-03-01 10:50:09 +00:00
Laszlo Ersek
b6ef56187f TODO: remove "Better support for encrypted devices"
LUKS support used to work best if the LUKS device resided on a partition,
and contained a Physical Volume for an LVM Volume Group. This scheme, also
called LVM-on-LUKS, is commonly created by installers of various Linux
distributions. (See RHBZ#1451665.)

Libguestfs now also supports the scheme wherein the LUKS device resides on
an LVM Logical Volume, and contains a filesystem. This is called
LUKS-on-LVM, it is the inverse of the above scheme, and is created by
installers of other Linux distributions. (See RHBZ#1658126.)

Both schemes are now decrypted by libguestfs-based utilities when
inspection is enabled (such as in "guestfish -i", virt-inspector,
virt-v2v), through the inspect_mount() function in utilities written in C,
and through the "inspect_decrypt" function in ones written in OCaml.

We don't seem to need an API like "list-luks-devices", as
"list-dm-devices" returns decrypted (i.e., opened) LUKS devices too; for
example, in the LUKS-on-LVM case:

> ><fs> list-dm-devices
> /dev/mapper/luks-0d619854-ccd5-43b1-8883-991fec5ef713
> /dev/mapper/luks-4e9e7a6f-a68c-42fd-92b4-8f4f2579a389

Thus, the subject TODO section is now out of date, and it's unclear what
remains "to do" there; let's just remove the section.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1658126
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20220223162120.16729-4-lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
2022-02-28 13:12:25 +01:00
Laszlo Ersek
3221133140 tests: add LUKS-on-LVM test
Create a new (fake) Fedora disk image with two partitions. /dev/sda1 is
the boot partition as usual, /dev/sda2 is used as an LVM PV. The VG has
four LVs, Root and LV1 through LV3.

Each LV holds a LUKS device (with a different key). Each decrypted LUKS
device holds an ext2 filesystem, with "/dev/mapper/Root-luks" holding the
root filesystem.

Each filesystem has a dedicated label (ROOT, LV1, LV2, LV3).

In the test case, run guestfish in inspector mode, twice.

In the first invocation, provide the LUKS passphrases by LV name. Also
specific to the first invocation, fetch the LUKS UUIDs by LV name.

In the second invocation, provide the LUKS passphrases by UUID.

In both invocations, after decryption, check the filesystem labels, the
/dev/mapper/* names generated for the decrypted LUKS block devices, and
the existence of "/etc/fedora-release" on the root filesystem.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1658126
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20220223162120.16729-3-lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
2022-02-28 13:12:21 +01:00
Laszlo Ersek
39a5bb6fda tests: rename "luks" to "lvm-on-luks"
Clarify that our current usage of "luks" stands for "lvm-on-luks" (IOW,
that the decrypted LUKS devices are Physical Volumes for LVM).

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1658126
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20220223162120.16729-2-lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
2022-02-28 13:11:56 +01:00
Laszlo Ersek
ed7e3462a2 Update common submodule
$ git shortlog 41126802097f..2d8c0f8d40b5

Laszlo Ersek (2):
      options: extract & refactor decryption of mountables (partitions)
      options: decrypt LUKS-on-LV devices

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
2022-02-28 13:08:43 +01:00
Laszlo Ersek
b92c026ddb md-create: specify that the "chunk" parameter should be absent for RAID1
Recently, mdadm has started (correctly) rejecting the "chunk" parameter
for RAID1; see e.g. <https://bugzilla.redhat.com/show_bug.cgi?id=1987170>.
Update the documentation accordingly, and in the mdadm test case, move the
"chunk:65536" parameter from a RAID1 creation command to a RAID5 one.

Suggested-by: Richard W.M. Jones <rjones@redhat.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20220217142944.8213-1-lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
2022-02-17 16:06:14 +01:00
Laszlo Ersek
19cc3dbcc4 Update common submodule
$ git shortlog 5b5fac3e0b10..41126802097f

Laszlo Ersek (3):
      Demote "Std_utils.wrap" to an internal function in Tools_utils
      Tools_utils.wrap: only wrap text for TTYs
      add common ("standard") option --wrap

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
2022-02-15 09:55:48 +01:00
Richard W.M. Jones
0553f90462 Update common submodule 2022-01-17 16:24:44 +00:00
Richard W.M. Jones
f019cc01b0 lib: Better handling for problems creating the socket path
GCC 12 gives a warning about our previous attempt to check the length
of the socket path.  In the ensuing discussion it was pointed out that
it is easier to get snprintf to do the hard work.  snprintf will
return an int >= UNIX_PATH_MAX if the path is too long, or < 0 if
there are other errors such as locale/encoding problems.  So we should
just check for those two cases instead.

https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/thread/NPKWMTSJ2A2ABNJJEH6WTZIAEFTX6CQY/

Thanks: Martin Sebor and Laszlo Ersek
2022-01-17 15:50:36 +00:00
Richard W.M. Jones
d1e7e1a323 Version 1.47.2. 2021-12-24 10:08:03 +00:00
Laszlo Ersek
5858c2cf6c launch-libvirt: add virtio-net via the standard <interface> element
Starting with version 3.8.0, libvirt allows us to specify the network
address and network mask (as prefix) for SLIRP directly via the
<interface> element in the domain XML:
<https://libvirt.org/formatdomain.html#userspace-slirp-stack>. This means
we don't need the <qemu:commandline> hack for virtio-net on such versions.

Restrict the hack in construct_libvirt_xml_qemu_cmdline() to
libvirt<3.8.0, and generate the proper <interface> element in
construct_libvirt_xml_devices() on libvirt>=3.8.0.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2034160
Suggested-by: Richard W.M. Jones <rjones@redhat.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20211223103701.12702-4-lersek@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
Tested-by: Richard W.M. Jones <rjones@redhat.com>
2021-12-23 13:22:38 +01:00
Laszlo Ersek
216de164e0 lib: extract NETWORK_ADDRESS and NETWORK_PREFIX as macros
The 169.254.0.0/16 network specification (for the appliance) is currently
duplicated between the direct backend and the libvirt backend. In a
subsequent patch, we're going to need the network specification in yet
another spot; extract it now to the NETWORK_ADDRESS and NETWORK_PREFIX
macros (simply as strings).

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2034160
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20211223103701.12702-3-lersek@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
Tested-by: Richard W.M. Jones <rjones@redhat.com>
2021-12-23 13:22:35 +01:00
Laszlo Ersek
5ce5ef6a97 launch-libvirt: place our virtio-net-pci device in slot 0x1e
The <qemu:commandline> trick we use for adding our virtio-net-pci device
in the libvirt backend can conflict with libvirtd's and QEMU's PCI address
assignment. Try to mitigate that by placing our device in slot 0x1e on the
root bus. In practice this could only conflict with a "dmi-to-pci-bridge"
device model, which libvirtd itself places in slot 0x1e. However, given
the XMLs we generate, and modern QEMU versions, libvirtd has no reason to
auto-add "dmi-to-pci-bridge". Refer to
<https://libvirt.org/formatdomain.html#controllers>.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2034160
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20211223103701.12702-2-lersek@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
Tested-by: Richard W.M. Jones <rjones@redhat.com>
2021-12-23 13:22:14 +01:00
Richard W.M. Jones
4af6d68e2d fish: Avoid valgrind test from creating fish/.cache
Work around for https://bugzilla.redhat.com/show_bug.cgi?id=2031135
2021-12-10 16:18:03 +00:00
Richard W.M. Jones
c6b25262ee valgrind: Update suppressions list
For OCaml 4.13, libvirt 7.7.
2021-12-10 14:53:43 +00:00
Richard W.M. Jones
1941593585 Disable OCaml warning 6 completely
Warning 6 "labels-omitted" is not useful.  It's fine to omit labels on
positional arguments.

Example:

  File "perl_edit.ml", line 30, characters 2-13:
  30 |   c_edit_file (verbose ()) g (Guestfs.c_pointer g) file expr
         ^^^^^^^^^^^
  Warning 6 [labels-omitted]: label verbose was omitted in the application of this function.

The function is specified as:

  external c_edit_file : verbose:bool -> Guestfs.t -> int64 -> string -> string -> unit

The complaint is that the verbose: label has been omitted from the
first argument when the function is called, but IMO this is a
stylistic thing, not a bug.

(cherry picked from
guestfs-tools commit 577f7aee4b1c720f4c4826115b49a0c3870b149e)
2021-12-10 10:30:17 +00:00
Richard W.M. Jones
0d05a229f3 customize: Suppress OCaml warning
In OCaml 4.13:

File "perl_edit.ml", line 30, characters 2-13:
30 |   c_edit_file (verbose ()) g (Guestfs.c_pointer g) file expr
       ^^^^^^^^^^^
Error (warning 6 [labels-omitted]): label verbose was omitted in the application of this function.

(cherry picked from
guestfs-tools commit a4930f5fad82e5358d565b8cf3610970e9646259)
2021-12-10 10:30:11 +00:00
Richard W.M. Jones
b64e9bffc1 generator: Replace more "noalloc" with [@@noalloc]
In some places in the generator we were still generating "noalloc".
It was hidden from the previous regexp I used to replace these because
of string escaping.

Updates: commit a69cde79ca
2021-12-10 09:58:12 +00:00
Richard W.M. Jones
1e60550c2a Update common submodule
Picks up this commit:

    mlstdutils/std_utils.mli: Remove export of deprecated String.copy

    Since OCaml strings are at long last immutable, the String.copy
    function is deprecated.  Stop exporting it from our Std_utils.String.
    Any places we use it are wrong and should be fixed.
2021-12-10 09:55:51 +00:00
Neil Hanlon
631962c0e8 Add detection support for Rocky Linux (CentOS/RHEL-like)
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2030709
Thanks: label@rockylinux.org

---

RWMJ notes: I fixed the original patch so it compiled.  This patch
sets osinfo to "rocky8", which doesn't exist in the osinfo db yet.
Arguably we might want to set this to "centos8", but we can see what
libosinfo decides to do.  Here is partial virt-inspector output on a
Rocky Linux disk image:

$ ./run virt-inspector -a disk.img
<?xml version="1.0"?>
<operatingsystems>
  <operatingsystem>
    <root>/dev/rl/root</root>
    <name>linux</name>
    <arch>x86_64</arch>
    <distro>rocky</distro>
    <product_name>Rocky Linux 8.5 (Green Obsidian)</product_name>
    <major_version>8</major_version>
    <minor_version>5</minor_version>
    <package_format>rpm</package_format>
    <package_management>dnf</package_management>
    <hostname>localhost.localdomain</hostname>
    <osinfo>rocky8</osinfo>
    <mountpoints>
      <mountpoint dev="/dev/rl/root">/</mountpoint>
      <mountpoint dev="/dev/sda1">/boot</mountpoint>
    </mountpoints>
    <filesystems>
      <filesystem dev="/dev/rl/root">
        <type>xfs</type>
        <uuid>fed8331f-9f25-40cd-883e-090cd640559d</uuid>
      </filesystem>
      <filesystem dev="/dev/rl/swap">
        <type>swap</type>
        <uuid>6da2c121-ea7d-49ce-98a3-14a37fceaadd</uuid>
      </filesystem>
      <filesystem dev="/dev/sda1">
        <type>xfs</type>
        <uuid>4efafe61-2d20-4d93-8055-537e09bfd033</uuid>
      </filesystem>
    </filesystems>
2021-12-10 09:09:47 +00:00
Richard W.M. Jones
d6773c102d Version 1.47.1. 2021-12-09 17:26:05 +00:00
Richard W.M. Jones
90eb3a4184 lib, lua: Fix usage of strerror_r
$ ./run guestfish -vx add-drive foo "readonly:true"
  libguestfs: trace: set_pgroup true
  libguestfs: trace: set_pgroup = 0
  libguestfs: trace: add_drive "foo" "readonly:true"
  libguestfs: error: foo:
  libguestfs: trace: add_drive = -1 (error)
  libguestfs: trace: close
  libguestfs: closing guestfs handle 0x55c0bacf12a0 (state 0)

Fix the usage of strerror_r by using the new wrapper defined in
libguestfs-common.  A similar fix is made in the Lua bindings.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2030396
Reported-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Tested-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2021-12-09 13:46:28 +00:00
Laszlo Ersek
d829f9ff9a daemon/listfs: don't call "sgdisk -i" on bogus MBR partition table entry
The "is_partition_can_hold_filesystem" function calls
"Parted.part_get_gpt_type" on the partition if:
- the partition table type is GPT,
- or the partition table type is MBR, and the partition is primary or
  logical.

The one entry in the fake MBR partition table described in the previous
patch passes the second branch of this check, therefore
"Parted.part_get_gpt_type" is reached, and it invokes "sgdisk -i 1" on the
disk.

Surprisingly (not), while "sgdisk -i" copes fine with valid MBR partition
tables, it chokes on the fake one. The output does not contain the
"Partition GUID code" line, and so "sgdisk_info_extract_field" throws an
exception.

Prevent calling "Parted.part_get_gpt_type" on a bogus MBR partition table,
similarly to the "extended entry in MBR partition table" case; the
difference is that the bogus primary entry, unlike a valid extended entry,
*can* hold a filesystem.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1931821
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
Message-Id: <20211125094954.9713-6-lersek@redhat.com>
2021-11-26 10:17:54 +01:00
Laszlo Ersek
edfebee404 daemon/parted: work around part table type misreporting by "parted"
"parted" incorrectly reports "loop" rather than "msdos" for the partition
table type, when the (fake) partition table comes from the "--mbr" option
of "mkfs.fat" (in dosfstools-4.2+), and the FAT variant in question is
FAT16 or FAT32. (See RHBZ#2026224.) Work this around by
- parsing the partition table ourselves, and
- overriding "loop" with "msdos" when appropriate.

Note that when the FAT variant is FAT12, "parted" fails to parse the fake
MBR partition table completely (see RHBZ#2026220), which we cannot work
around. However, FAT12 should be a rare corner case in libguestfs usage --
"mkfs.fat" auto-chooses FAT12 only below 9MB disk size, and even "-F 12"
can only be forced up to and including 255MB disk size.

Add the helper function "has_bogus_mbr" to the Utils module; we'll use it
elsewhere too.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1931821
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
Message-Id: <20211125094954.9713-5-lersek@redhat.com>
[lersek@redhat.com: drop "fun" keyword, and use partial application, in
 the definition of "sec0at" [Rich]]
2021-11-26 10:17:05 +01:00
Laszlo Ersek
c33c2a1d13 daemon/parted: simplify print_partition_table() prototype
Since commit 994ca1f8eb ("daemon: Reimplement 'part_get_mbr_part_type'
API in OCaml.", 2018-05-02), we've not had any calls to
print_partition_table() that would pass a "false" argument for the
"add_m_option" parameter.

Remove the parameter, and inside part_get_mbr_part_type(), remove the dead
branch.

Relatedly, update the comment on the
"print_partition_table_machine_readable" OCaml function, originally from
commit 32e661f421 ("daemon: Reimplement ‘part_list’ API in OCaml.",
2017-07-27). Because print_partition_table() now passes "-m" to "parted"
unconditionally, and there are no use cases left that would *forbid* "-m",
"print_partition_table_machine_readable" is almost equivalent to
print_partition_table() -- modulo the enforcement of the "BYT;" header.

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
Message-Id: <20211125094954.9713-4-lersek@redhat.com>
2021-11-26 10:16:06 +01:00
Laszlo Ersek
e3671362af daemon/9p: fix wrong pathname in error message
The directory that readdir() and closedir() work on is BUS_PATH
("/sys/bus/virtio/drivers/9pnet_virtio"), not "/sys/block". Fix the error
messages that are sent when readdir() or closedir() fails.

(The invalid "sys/block" pathname could be a leftover from when the
directory reading logic was (perhaps) copied from "daemon/sync.c".)

Fixes: 5f10c33503
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
Message-Id: <20211125094954.9713-3-lersek@redhat.com>
2021-11-26 10:16:05 +01:00
Laszlo Ersek
0ab9305055 daemon/mkfs: disable creation of fake MBR partition table with "mkfs.fat"
Search the usage output of "mkfs.fat" for "--mbr[="; cache the result for
further invocations. If the option is supported, pass "--mbr=n" to
"mkfs.fat". This will prevent the creation of a bogus partition table
whose first (and only) entry describes a partition that contains the
partition table.

(Such a bogus partition table breaks "parted", which is a tool used by
libguestfs extensively, both internally and in public libguestfs APIs.)

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1931821
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
Message-Id: <20211125094954.9713-2-lersek@redhat.com>
2021-11-26 10:16:05 +01:00
Richard W.M. Jones
e7f72ab146 xfs: Document lazy-counters setting cannot be changed in XFS version 5
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2024022
2021-11-22 15:11:20 +00:00
Richard W.M. Jones
9fda9110e6 Update common submodule
Removes old compat Bytes module.

Fixes: commit b536c61a6d
Thanks: Laszlo Ersek
2021-11-12 14:02:04 +00:00
Richard W.M. Jones
4fe8df48a7 tests/gdisk/test-expand-gpt.pl: Don't race with other tests
Another test was removing all disk_*.img files, which removed the file
used by this test.  This was ultimately caused by us using parallel
tests.

Put the disk image files back into the tests/gdisk/ subdirectory to
avoid this race.

Fixes: commit 6d32773e81
2021-11-09 11:49:06 +00:00
Richard W.M. Jones
30a3c72d51 tests/gdisk/test-expand-gpt.pl: Don't hide error message from qemu-img resize
In a test I ran qemu-img resize failed.  However because we redirected
stderr to /dev/null the error message was hidden.
2021-11-09 11:37:54 +00:00
Richard W.M. Jones
5da2b9f130 tests/gdisk/test-expand-gpt.pl: Fix some warnings
"my" variable $output masks earlier declaration in same scope at ./gdisk/test-expand-gpt.pl line 73.
"my" variable $end_sectors masks earlier declaration in same scope at ./gdisk/test-expand-gpt.pl line 78.
2021-11-09 11:36:50 +00:00
Richard W.M. Jones
60e9232f4e Move minimum OCaml version to 4.04.
Synchronize with common module which also requires 4.04.

Small adjustment to use of List.sort_uniq because the signature
changed slightly.
2021-11-09 10:21:30 +00:00
Richard W.M. Jones
a69cde79ca daemon: Replace "noalloc" with [@@noalloc] 2021-11-09 10:20:37 +00:00
Richard W.M. Jones
b536c61a6d m4: Remove test for OCaml Bytes module 2021-11-09 10:07:00 +00:00
Richard W.M. Jones
760d11ecfa rust: Use distclean to clean cache rather than make clean
Actually cargo caches downloaded libraries.  The previous change
caused cargo to download and rebuild these after make clean which is
overly aggressive.  Use make distclean instead.

Updates: commit 1834f19d20
2021-10-21 14:36:41 +01:00
Richard W.M. Jones
1834f19d20 rust: Wire up make clean so it runs cargo clean
Before this commit, after make clean:

$ du -sh rust
641M	rust

After:

776K	rust
2021-10-20 17:55:19 +01:00
Laszlo Ersek
305b02e7e7 daemon: inspection: Add support for Kylin (RHBZ#1995391).
Similar-to: cd08039d24
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20211013163023.21786-1-lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
2021-10-14 19:49:56 +02:00
Laszlo Ersek
f34bd6b12f build, docs: spell out minimum version (4.0.0) for the (optional) Yara lib
Commit e597fc5317 ("daemon/yara: fix undefined behavior due to Yara 4.0
API changes", 2021-10-12) prevents the daemon from using such a Yara
version that precedes 4.0.0.

If only yara < 4 is found, treat the library as absent, rather than
attempting and failing to compile the yara module of the daemon. Note the
version requirement in the documentation too.

Suggested-by: Eric Blake <eblake@redhat.com>
Suggested-by: Richard W.M. Jones <rjones@redhat.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20211013133611.21599-4-lersek@redhat.com>
Acked-by: Eric Blake <eblake@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
2021-10-14 19:45:07 +02:00
Laszlo Ersek
4daec34a01 build: eliminate the AC_CHECK_LIB / AC_CHECK_HEADER tests for Yara
Eliminate the AC_CHECK_LIB / AC_CHECK_HEADER tests for Yara, for the
following reasons:

- Upstream Yara has provided a pkg-config file since 2015, so the
  (now-fixed) pkg-config check should always find it, without the
  AC_CHECK_LIB / AC_CHECK_HEADER fallback branch.

- In a subsequent patch, we'll want to test for the incompatible Yara API
  changes described at
  <https://github.com/VirusTotal/yara/wiki/Backward-incompatible-changes-in-YARA-4.0-API>.

  That's easy to do with pkg-config, but impossible with AC_CHECK_*,
  without a custom test. Namely, both AC_CHECK_DECLS and AC_CHECK_TYPES
  appear unable to check the parameter list of a function pointer typedef
  (namely YR_CALLBACK_FUNC and YR_COMPILER_CALLBACK_FUNC). And writing a
  dedicated test for this is overkill.

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20211013133611.21599-3-lersek@redhat.com>
Acked-by: Eric Blake <eblake@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
2021-10-14 19:45:03 +02:00
Laszlo Ersek
54187b7f98 build: fix the pkg-config identifier of the (optional) Yara library
The upstream Yara project has always provided its "libyara/yara.pc.in"
file with "Name: yara" -- ever since its introduction in commit
334bd1a671ca ("Add support for pkg-config", 2015-01-08).

In spite of this, when the (optional) Yara dependency was added to
libguestfs in commit 2e24129da3 ("appliance: add yara dependency",
2017-05-02), PKG_CHECK_MODULES was invoked with [libyara] as
list-of-modules.

(That was clearly a bug. I'm unsure what Debian calls their Yara
pkg-config module, but calling it anything else than "yara" would be a
distribution bug: upstream projects provide pkg-config files specifically
so that dependent projects can find their dependencies *regardless of
distribution*.)

As a consequence, on Fedora today, the PKG_CHECK_MODULES macro always
fails, and only the AC_CHECK_LIB / AC_CHECK_HEADER branch finds Yara.

In a subsequent patch, we'll want to add a version requirement to the
PKG_CHECK_MODULES macro invocation, so at first, fix the pkg-config
identifier of Yara.

Fixes: 2e24129da3
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20211013133611.21599-2-lersek@redhat.com>
Acked-by: Eric Blake <eblake@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
2021-10-14 19:44:31 +02:00
Laszlo Ersek
e597fc5317 daemon/yara: fix undefined behavior due to Yara 4.0 API changes
Currently, the Yara test case ("yara/test-yara-scan.sh") fails, with the
following obscure error message:

> ><fs> yara-scan /text.txt
> libguestfs: error: deserialise_yara_detection_list:

Namely, the Yara rule match list serialization / de-serialization, between
the daemon and the library, is broken. It is caused by the following
incompatible pointer passing (i.e., undefined behavior), in function
do_internal_yara_scan(), file "daemon/yara.c":

>   r = yr_rules_scan_fd (rules, fd, 0, yara_rules_callback, (void *) path, 0);
                                        ^^^^^^^^^^^^^^^^^^^

The prototype of yara_rules_callback() is:

> static int
> yara_rules_callback (int code, void *message, void *data)

however, in Yara commit 2b121b166d25 ("Track string matches using
YR_SCAN_CONTEXT.", 2020-02-27), which was included in the upstream v4.0.0
release, the rules callback prototype was changed as follows:

> diff --git a/libyara/include/yara/types.h b/libyara/include/yara/types.h
> index cad095cd70c2..f415033c4aa6 100644
> --- a/libyara/include/yara/types.h
> +++ b/libyara/include/yara/types.h
> @@ -661,6 +644,7 @@ struct YR_MEMORY_BLOCK_ITERATOR
>
>
>  typedef int (*YR_CALLBACK_FUNC)(
> +    YR_SCAN_CONTEXT* context,
>      int message,
>      void* message_data,
>      void* user_data);

Therefore, the yara_rules_callback() function is entered with a mismatched
parameter list in the daemon, and so it passes garbage to
send_detection_info(), for serializing the match list.

This incompatible change was in fact documented by the Yara project:

  https://github.com/VirusTotal/yara/wiki/Backward-incompatible-changes-in-YARA-4.0-API#scanning-callback

Gcc too warns about the incompatible pointer type, under
"-Wincompatible-pointer-types". However, libguestfs is built without
"-Werror" by default, so the warning is easy to miss, and the bug only
manifests at runtime.

(The same problem exists for yr_compiler_set_callback() /
compile_error_callback():

  https://github.com/VirusTotal/yara/wiki/Backward-incompatible-changes-in-YARA-4.0-API#compiler-callback

except that this instance of the problem is not triggered by the test
case, as the rule list always compiles.)

Rather than simply fixing the parameter lists, consider the following
approach.

If Yara's YR_CALLBACK_FUNC and YR_COMPILER_CALLBACK_FUNC typedefs were not
for *pointer* types but actual *function* prototypes, then we could use
them directly in the declarations of our callback functions. Then any
future changes in the param lists would force a "conflicting types"
*compilation error* (not a warning). Illustration:

  /* this is *not* a pointer type */
  typedef int HELLO_FUNC (void);

  /* function declarations */
  static HELLO_FUNC my_hello_good;
  static HELLO_FUNC my_hello_bad;

  /* function definition, with explicit parameter list */
  static int my_hello_good (void) { return 1; }

  /* function definition with wrong param list -> compilation error */
  static int my_hello_bad (int i) { return i; }

Unfortunately, given that the Yara-provided typedefs are already pointers,
we can't do this, in standard C anyway. Type derivation only allows for
array, structure, union, function, and pointer type derivation; it does
not allow "undoing" previous derivations.

However, using gcc's "typeof" keyword, the idea is possible. Given
YR_CALLBACK_FUNC, the expression

  (YR_CALLBACK_FUNC)NULL

is a well-defined null pointer, and the function designator expression

  *(YR_CALLBACK_FUNC)NULL

has the desired function type.

Of course, evaluating this expression would be undefined behavior, but in
the GCC extension expression

  typeof (*(YR_CALLBACK_FUNC)NULL)

the operand of the "typeof" operator is never evaluated, as it does not
have a variably modified type. We can therefore use this "typeof" in the
same role as HELLO_FUNC had in the above example.

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20211011223627.20856-4-lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
[lersek@redhat.com: clean up whitespace in "YR_RULE *rule"]
2021-10-12 16:48:04 +02:00
Laszlo Ersek
98ed0243e7 lib/proto: suppress "may be used uninitialized" in send_file_complete()
gcc emits the following warning:

> proto.c: In function ‘send_file_complete’:
> proto.c:437:10: error: ‘buf’ may be used uninitialized
> [-Werror=maybe-uninitialized]
>   437 |   return send_file_chunk (g, 0, buf, 0);
>       |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In theory, passing the 1-byte array "buf", with indeterminate contents, to
xdr_bytes() ultimately, could be fine -- assuming xdr_bytes() never reads
the contents of the buffer, due to the buffer size being zero. However,
the xdr_bytes() manual does not seem to guarantee this (it also does not
explicitly permit passing a NULL buffer alongside size=0, which would be
even simpler for the caller).

In order to shut up the compiler, just zero-initialize the buffer --
that's simpler than adding diagnostics pragmas. The "maybe-uninitialized"
warning is otherwise very useful, so keep it globally enabled (per
WARN_CFLAGS / WERROR_CFLAGS).

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20211011223627.20856-3-lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
2021-10-12 16:48:01 +02:00
Laszlo Ersek
7915938b8e build: fix typo in "--enable-werror" help string
While <https://libguestfs.org/guestfs-building.1.html> correctly documents
the "--enable-werror" option, the "./configure" help text itself doesn't.
Replace "--enable-error" with "--enable-werror" now.

Fixes: 0f54df53d2
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20211011223627.20856-2-lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
2021-10-12 16:47:37 +02:00
Richard W.M. Jones
63c9cd933a m4/guestfs-ocaml.m4: Fix deprecated warning format
In OCaml 4.13:

Alert ocaml_deprecated_cli: Setting a warning with a sequence of lowercase or uppercase letters,
like 'CDEFLMPSUVYZX', is deprecated.
Use the equivalent signed form: +C+D+E+F+L+M+P+S+U+V+Y+Z+X+52-3.

(cherry picked from
guestfs-tools commit fa4f59e1d99c08d7e0bae2a7cb54f254a6506d67)
2021-10-05 21:08:07 +01:00
Laszlo Ersek
3f6f2fb8f6 daemon/inspect_fs_unix: recognize modern Pardus GNU/Linux releases
Recent Pardus releases seem to have abandoned the original
"/etc/pardus-release" file, which the current Pardus detection, from
commit 233530d354 ("inspect: Add detection of Pardus.", 2010-10-29), is
based upon.

Instead, Pardus apparently adopted the "/etc/os-release" specification
<https://www.freedesktop.org/software/systemd/man/os-release.html>, with
"ID=pardus". Extend the "distro_of_os_release_id" function accordingly.
Keep the original method for recognizing earlier releases.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1993842
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20211001125338.8956-1-lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
2021-10-01 15:34:25 +02:00
Laszlo Ersek
e2f8db27d0 Go bindings: fix "C array of strings" -- char** -- allocation
The current "arg_string_list" and "free_string_list" implementations go
back to commit b6f01f3260 ("Add Go (language) bindings.", 2013-07-03).
There are two problems with them:

- "free_string_list" doesn't actually free anything,

- at the *first* such g.Internal_test() call site that passes an
  Ostringlist member inside the Optargs argument, namely:

> g.Internal_test ("abc",
>                  string_addr ("def"),
>                  []string{},
>                  false,
>                  0,
>                  0,
>                  "123",
>                  "456",
>                  []byte{'a', 'b', 'c', '\000', 'a', 'b', 'c'},
>                  &guestfs.OptargsInternal_test{Ostringlist_is_set: true,
>                                                Ostringlist: []string{}
>                                               }
>                 )

  the "golang/run-bindtests" case crashes:

> panic: runtime error: cgo argument has Go pointer to Go pointer
>
> goroutine 1 [running]:
> libguestfs.org/guestfs.(*Guestfs).Internal_test.func7(0xc000018180,
> 0xadfb60, 0xadfb80, 0xc000010048, 0x0, 0x0, 0x0, 0xae3e10, 0xae3e30,
> 0xade3a0, ...)
>         golang/src/libguestfs.org/guestfs/guestfs.go:6729 +0xa9
> libguestfs.org/guestfs.(*Guestfs).Internal_test(0xc000018180, 0x4ee3a5,
> 0x3, 0xc000061be8, 0xc000061af8, 0x0, 0x0, 0xc000061a00, 0x0, 0x0, ...)
>         golang/src/libguestfs.org/guestfs/guestfs.go:6729 +0x3c9
> main.main()
>         golang/bindtests/bindtests.go:77 +0x151e
> exit status 2
> FAIL run-bindtests (exit status: 1)

In Daniel P. Berrangé's words [1],

> You're allowed to pass a Go pointer to C via CGo, but the memory that
> points to is not allowed to contained further Go pointers. So the struct
> fields must strictly use a C pointer.

One pattern to solve the problem has been shown on stackoverflow [2].
Thus, rewrite the "arg_string_list" and "free_string_list" functions
almost entirely in C, following that example.

While this approach is not the most idiomatic Go, as a solution exists
without C helper functions [3], it should still be acceptable, at least as
an incremental improvement, for letting "golang/run-bindtests" pass.

[1] https://listman.redhat.com/archives/libguestfs/2021-September/msg00118.html
[2] https://stackoverflow.com/questions/35924545/golang-cgo-panic-runtime-error-cgo-argument-has-go-pointer-to-go-pointer
[3] https://listman.redhat.com/archives/libguestfs/2021-September/msg00106.html

Cc: "Daniel P. Berrangé" <berrange@redhat.com>
Cc: "Richard W.M. Jones" <rjones@redhat.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20210921192939.32468-1-lersek@redhat.com>
Tested-by: "Richard W.M. Jones" <rjones@redhat.com>
Acked-by: "Richard W.M. Jones" <rjones@redhat.com>
2021-09-27 09:57:34 +02:00
Richard W.M. Jones
5c68392175 Version 1.46.0. 2021-09-23 14:52:46 +01:00
Richard W.M. Jones
5b432781e2 build: Remove BUGS file
Recent changes to Red Hat Bugzilla broke our ability to generate this
file.  In any case it's not very useful since a simple Bugzilla query
can be used instead:

https://bugzilla.redhat.com/buglist.cgi?component=libguestfs

Remove the file.  The generator used this file to ensure it was being
run from the correct directory and to take a lock.  Use RELEASES file
instead.

See also: https://github.com/python-bugzilla/python-bugzilla/issues/149
2021-09-23 14:52:46 +01:00
Richard W.M. Jones
ab2d624f46 docs: Finalize release notes for 1.46 release today 2021-09-23 09:44:08 +01:00
Laszlo Ersek
627f808e4b tests: xfs: remove lazy-counter disablement test
According to xfs_admin(8):

>        -c 0|1 Enable (1) or disable (0) lazy-counters in the  filesys‐
>               tem.
>
>               Lazy-counters  may  not  be  disabled  on  Version 5 su‐
>               perblock filesystems (i.e. those with metadata CRCs  en‐
>               abled).
>
>               [...]

According to mkfs.xfs(1):

>        -m global_metadata_options
>        Section Name: [metadata]
>               These  options  specify metadata format options that ei‐
>               ther apply to the entire  filesystem  or  aren't  easily
>               characterised  by  a  specific  functionality group. The
>               valid global_metadata_options are:
>
>                   [...]
>
>                    crc=value
>                           This  is  used  to create a filesystem which
>                           maintains and checks CRC information in  all
>                           metadata  objects  on disk. The value is ei‐
>                           ther 0 to disable the feature, or 1  to  en‐
>                           able the use of CRCs.
>
>                           [...]
>
>                           By  default,  mkfs.xfs  will enable metadata
>                           CRCs.

Consistently with the above, the first "xfs_admin" test case in
"generator/actions_core.ml", which attempts to disable lazy counters,
always fails:

> 534/550 test_xfs_admin_0
> libguestfs: error: xfs_admin: /dev/sda1: Cannot disable lazy-counters on V5 fs

We can resolve this test failure in three ways:

(1) Extend do_mkfs() [daemon/mkfs.c], possibly even introduce
    do_mkfs_xfs(), and permit the caller to specify "-m crc=0" for
    mkfs.xfs. Then use this option when the temporary filesystem is
    created in the XFS test that disables lazy counters.

(2) Extend the "guestfs_int_xfsinfo" structure in the libguestfs-common
    project, with an "xfs_crc" field. Extend parse_xfs_info()
    [daemon/xfs.c] to populate the field from "meta-data=...crc=[01]".
    Modify the test case to check the following post-condition:

      xfs_crc || xfs_lazycount == 0

    instead of the current

      xfs_lazycount == 0

    effectively ignoring "xfs_lazycount" when "xfs_crc" is set.

(3) Remove the test altogether that attempts to disable lazy counters
    after filesystem creation.

Given that new XFS filesystems are created with metadata CRCs enabled by
default, and several XFS features depend on metadata CRCs being enabled,
this patch implements option (3).

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20210920052335.3358-4-lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
2021-09-21 19:01:18 +02:00
Laszlo Ersek
24f98939ae test-md-and-lvm-devices: work around RAID0 regression in Linux v3.14/v5.4
The "test-md-and-lvm-devices" test case creates, among other things, a
RAID0 array (md127) that spans two *differently sized* block devices
(sda1: 20MB, lv0: 16MB).

In Linux v3.14, the layout of such arrays was changed incompatibly and
undetectably. If an array were created with a pre-v3.14 kernel and
assembled on a v3.14+ kernel, or vice versa, data could be corrupted.

In Linux v5.4, a mitigation was added, requiring the user to specify the
layout version of such RAID0 arrays explicitly, as a module parameter. If
the user fails to specify a layout version, the v5.4+ kernel refuses to
assemble such arrays. This is why "test-md-and-lvm-devices" currently
fails, with any v5.4+ appliance kernel.

Until we implement a more general solution (see the bugzilla link below),
work around the issue by sizing sda1 and lv0 identically. For this,
increase the size of sdb1 to 24MB: when one 4MB extent is spent on LVM
metadata, the resultant lv0 size (20MB) will precisely match the size of
sda1.

This workaround only affects sizes, and does not interfere with the
original purpose of this test case, which is to test various *stackings*
between disk partitions, software RAID (md), and LVM logical volumes.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=2005485
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20210920052335.3358-3-lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
[lersek@redhat.com: remove stray empty line]
2021-09-21 19:00:59 +02:00
Laszlo Ersek
8156c16520 test-9p: fix the base directory that's exported to the guest
In commit 6d32773e81 ("tests: Run the tests in parallel.", 2021-03-18),
the "abs_srcdir" macro value that the 9p test would see changed from
".../tests/9p" to just ".../tests" -- the last component got dropped.

(Said commit updated some "abs_srcdir"-based references accordingly, for
example under "tests/disks", but "tests/9p/test-9p.sh" was missed.)

Therefore, the guest-visible location of the "/test-9p.sh" file changed to
"/9p/test-9p.sh", and a non-recursive listing of the guest-visible root
directory would not return the file. Thus, the test fails now.

Restore the host-side base directory to ".../tests/9p".

Fixes: 6d32773e81
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20210920052335.3358-2-lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
2021-09-21 19:00:11 +02:00
Olaf Hering
f47e0bb672 appliance: reorder mounting of special filesystems in init
Make sure proc and dev are available early.
No change in behavior intended.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
2021-09-15 12:37:08 +01:00
Olaf Hering
9db0c98c99 appliance: enable bash's Process Substitution feature
bash can read input from a spawned process, and even provide input to
such process. This feature relies on /dev/fd/ being present. In the
past udev silently created this symlink, so this bash feature worked
more or less by accident. With recent systemd versions, such as 246
which is included in Leap 15.3, the symlink is not created anymore. As
a result scripts, such as /sbin/dhclient-script, fail to work
properly.

This symlink should have been created in version 1 of this variant of /init.

https://bugzilla.opensuse.org/show_bug.cgi?id=1190501

Signed-off-by: Olaf Hering <olaf@aepfle.de>
2021-09-15 12:37:08 +01:00
Olaf Hering
c0de4de902 appliance: add reboot and netconfig for SUSE
systemd-sysvinit contains the reboot command, which is used to
properly stop the VM. This was required by other packages, and as a
result always available. Since Leap 15.3 it will not be installed, and
as a result the VM will just panic because /init died.

If the appliance is started with --network, dhclient will run
/usr/sbin/dhclient-script, which in turn may call /sbin/netconfig to
update /etc/resolv.conf. Install sysconfig-netconfig to make sure DNS
resolving actually works.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
2021-09-14 20:49:02 +01:00
Richard W.M. Jones
46ab3dbbc0 docs: Prepare draft release notes for 1.46 2021-09-13 19:29:17 +01:00
Richard W.M. Jones
ae8ff236ab bugs-in-changelog.sh: Various fixes to cope with new changelog format 2021-09-13 19:29:17 +01:00
Richard W.M. Jones
e14ff93742 lib: direct: Remove use of sga
sga (or "sgabios" or "Serial Graphics Adapter") is an option ROM for
seabios which directs output to the serial adapter.  This is very
useful for debugging BIOS problems during boot.

RHEL wants to deprecate this feature (in fact, they just deprecated it
without telling us).  However there is an equivalent feature in
seabios (seabios >= 1.11 / qemu >= 2.11.0) which can be enabled using
either -nographic or -machine graphics=off

This commit removes sga and enables -machine graphics=off in the
direct backend.

References (for RHEL 9 qemu change):
https://bugzilla.redhat.com/show_bug.cgi?id=2002325
https://bugzilla.redhat.com/show_bug.cgi?id=2000845
https://lists.nongnu.org/archive/html/qemu-devel/2021-09/msg02417.html
https://listman.redhat.com/archives/libvir-list/2021-September/msg00205.html

For the libvirt backend we will continue to use <bios useserial=yes>.
This currently breaks when sga is not available, but I talked to Dan
and the plan there is to adapt libvirt so the same XML will enable
-machine graphics=off.  IOW libguestfs does not need to make any
change.

References (for libvirt change):
https://bugzilla.redhat.com/show_bug.cgi?id=2003092
https://listman.redhat.com/archives/libvir-list/2021-September/msg00193.html

Thanks: Gerd Hoffman, Daniel Berrangé
2021-09-13 10:40:50 +01:00
Laszlo Ersek
523b0180d8 daemon_utils_tests: generalize ocaml-hivex[-devel] lookup
Pass $(HIVEX_LIBS) with -cclib under the "daemon_utils_tests_LINK" target;
otherwise the OCaml compiler does not tell the linker where "-lhivex" can
be found, and the linking step fails if "-lhivex" is not on a system
library path.

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20210908133542.19002-3-lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
2021-09-09 14:52:03 +02:00
Laszlo Ersek
53e03eefae daemon: generalize ocaml-hivex[-devel] lookup
"ocamlc -where" is supposed to "print the location of the standard library
and exit". While this directory contains core OCaml C header files, it
does not contain hivex-related C header files. Trim "guestfsd_CPPFLAGS"
accordingly.

Furthermore, the hivex module for OCaml may exist elsewhere than under the
OCaml standard library directory. Invoke "ocamlfind query hivex" to find
this module. This is what AC_CHECK_OCAML_PKG(hivex) does too, in
"m4/guestfs-ocaml.m4" and "m4/ocaml.m4".

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20210908133542.19002-2-lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
2021-09-09 14:52:02 +02:00
Richard W.M. Jones
ceb034c92c python, java: Avoid bogus -fanalyzer warnings
This is essentially the same as the previous OCaml commit.  It does
not fix a real bug.
2021-09-07 16:50:38 +01:00
Richard W.M. Jones
ea04d6b878 ocaml/guestfs-c.c: Avoid bogus -fanalyzer warning
This warning is bogus, caused by the analyzer cannot track that len ==
0 if roots == NULL.  I just changed the code to make it easier to
analyze, this doesn't fix any real bug.

guestfs-c.c: In function 'guestfs_finalize':
guestfs-c.c:85:9: error: dereference of NULL '0B' [CWE-476] [-Werror=analyzer-null-dereference]
   85 |         caml_remove_generational_global_root (roots[i]);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2021-09-07 16:45:23 +01:00
Richard W.M. Jones
a7245fba7a daemon/utils.c: Fix potential unbounded stack usage
utils.c: In function 'prog_exists':
utils.c:650:1: error: stack usage might be unbounded [-Werror=stack-usage=]
  650 | prog_exists (const char *prog)
      | ^
2021-09-07 15:55:48 +01:00
Richard W.M. Jones
58599031f8 daemon/xattr.c: Increase size of temporary buffer for %zu
Found by GCC -fanalyzer:

xattr.c:478:32: error: '%zu' directive output may be truncated writing between 1 and 19 bytes into a region of size 16 [-Werror=format-truncation=]
  478 |     snprintf (num, sizeof num, "%zu", nr_attrs);
      |                                ^
xattr.c:478:32: note: directive argument in the range [0, 2305843009213693950]
/usr/include/bits/stdio2.h:71:10: note: '__builtin___snprintf_chk' output between 2 and 20 bytes into a destination of size 16
   71 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      |          ^
2021-09-07 15:55:43 +01:00
Richard W.M. Jones
d00c36410b daemon/luks.c: Ignore bogus GCC -fanalyzer double-free warning
As far as I can tell the analysis is completely bogus.  We don't
double-free the tempfile string in do_luks_add_key.  Therefore add a
GCC suppression around the remove_temp function.

luks.c: In function 'do_luks_add_key':
luks.c:84:3: error: double-'free' of 'tempfile_14' [CWE-415] [-Werror=analyzer-double-free]
   84 |   free (tempfile);
      |   ^~~~~~~~~~~~~~~
  'do_luks_add_key': events 1-2
    |
    |  143 | do_luks_add_key (const char *device, const char *key, const char *newkey,
    |      | ^~~~~~~~~~~~~~~
    |      | |
    |      | (1) entry to 'do_luks_add_key'
    |......
    |  146 |   char *keyfile = write_key_to_temp (key);
    |      |                   ~~~~~~~~~~~~~~~~~~~~~~~
    |      |                   |
    |      |                   (2) calling 'write_key_to_temp' from 'do_luks_add_key'
    |
    +--> 'write_key_to_temp': events 3-12
           |
           |   41 | write_key_to_temp (const char *key)
           |      | ^~~~~~~~~~~~~~~~~
           |      | |
           |      | (3) entry to 'write_key_to_temp'
           |......
           |   47 |   tempfile = strdup ("/tmp/luksXXXXXX");
           |      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~
           |      |              |
           |      |              (4) allocated here
           |   48 |   if (!tempfile) {
           |      |      ~
           |      |      |
           |      |      (5) assuming 'tempfile_14' is non-NULL
           |      |      (6) following 'false' branch (when 'tempfile_14' is non-NULL)...
           |......
           |   53 |   fd = mkstemp (tempfile);
           |      |   ~~
           |      |   |
           |      |   (7) ...to here
           |   54 |   if (fd == -1) {
           |      |      ~
           |      |      |
           |      |      (8) following 'false' branch...
           |......
           |   59 |   len = strlen (key);
           |      |   ~~~
           |      |   |
           |      |   (9) ...to here
           |   60 |   if (xwrite (fd, key, len) == -1) {
           |      |      ~
           |      |      |
           |      |      (10) following 'false' branch...
           |......
           |   66 |   if (close (fd) == -1) {
           |      |   ~~ ~
           |      |   |  |
           |      |   |  (12) following 'false' branch...
           |      |   (11) ...to here
           |
         'write_key_to_temp': event 13
           |
           |cc1:
           | (13): ...to here
           |
    <------+
    |
  'do_luks_add_key': events 14-17
    |
    |  146 |   char *keyfile = write_key_to_temp (key);
    |      |                   ^~~~~~~~~~~~~~~~~~~~~~~
    |      |                   |
    |      |                   (14) returning to 'do_luks_add_key' from 'write_key_to_temp'
    |  147 |   if (!keyfile)
    |      |      ~
    |      |      |
    |      |      (15) following 'false' branch...
    |......
    |  150 |   char *newkeyfile = write_key_to_temp (newkey);
    |      |   ~~~~               ~~~~~~~~~~~~~~~~~~~~~~~~~~
    |      |   |                  |
    |      |   |                  (17) calling 'write_key_to_temp' from 'do_luks_add_key'
    |      |   (16) ...to here
    |
    +--> 'write_key_to_temp': events 18-26
           |
           |   41 | write_key_to_temp (const char *key)
           |      | ^~~~~~~~~~~~~~~~~
           |      | |
           |      | (18) entry to 'write_key_to_temp'
           |......
           |   47 |   tempfile = strdup ("/tmp/luksXXXXXX");
           |      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~
           |      |              |
           |      |              (19) allocated here
           |   48 |   if (!tempfile) {
           |      |      ~
           |      |      |
           |      |      (20) following 'false' branch (when 'tempfile_14' is non-NULL)...
           |......
           |   53 |   fd = mkstemp (tempfile);
           |      |   ~~
           |      |   |
           |      |   (21) ...to here
           |   54 |   if (fd == -1) {
           |      |      ~
           |      |      |
           |      |      (22) following 'false' branch...
           |......
           |   59 |   len = strlen (key);
           |      |   ~~~
           |      |   |
           |      |   (23) ...to here
           |   60 |   if (xwrite (fd, key, len) == -1) {
           |      |      ~
           |      |      |
           |      |      (24) following 'false' branch...
           |......
           |   66 |   if (close (fd) == -1) {
           |      |   ~~ ~
           |      |   |  |
           |      |   |  (26) following 'false' branch...
           |      |   (25) ...to here
           |
         'write_key_to_temp': event 27
           |
           |cc1:
           | (27): ...to here
           |
    <------+
    |
  'do_luks_add_key': events 28-32
    |
    |   84 |   free (tempfile);
    |      |   ~~~~~~~~~~~~~~~
    |      |   |
    |      |   (31) first 'free' here
    |      |   (32) second 'free' here; first 'free' was at (31)
    |......
    |  150 |   char *newkeyfile = write_key_to_temp (newkey);
    |      |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~
    |      |                      |
    |      |                      (28) returning to 'do_luks_add_key' from 'write_key_to_temp'
    |  151 |   if (!newkeyfile) {
    |      |      ~
    |      |      |
    |      |      (29) following 'false' branch...
    |......
    |  156 |   const char *argv[MAX_ARGS];
    |      |   ~~~~~
    |      |   |
    |      |   (30) ...to here
    |
cc1: all warnings being treated as errors
2021-09-07 14:53:06 +01:00
Richard W.M. Jones
8dd09a16f5 daemon/inotify.c: Clean up error handling
In particular avoid calling fclose on a popen'd handle.

Error identified by GCC -fanalyzer.
2021-09-07 14:48:03 +01:00
Laszlo Ersek
81ad309d47 Update common submodule to commit 19302b64c5f1
Short log:

Laszlo Ersek (2):
      Makefile.am: supply missing $(LIBGUESTFS_CFLAGS)
      Makefile.am: use $(LIBGUESTFS_LIBS) for linking OCaml test programs

Richard W.M. Jones (4):
      tools: Refactor create_standard_options
      tools: Add optional --program-name flag.
      mltools/test-getopt.sh: Allow test to work for tools version 2
      mltools: Add JSON_parser.object_get_bool

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
2021-09-06 18:16:11 +02:00
Richard W.M. Jones
4e02c13941 m4/guestfs-appliance.m4: Add support for Alma and Cloud Linux
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2001636
Thanks: sasha121196@mail.ru
2021-09-06 17:02:19 +01:00
Richard W.M. Jones
ae7187af94 appliance: Add mount package for Debian
https://listman.redhat.com/archives/libguestfs/2021-September/msg00013.html

Reported-by: Joerg Schiermeier
2021-09-06 15:23:03 +01:00
Laszlo Ersek
0a2f7621a0 tests/mount-local: fix relative pathname of FUSE client executable
In commit 6d32773e81 ("tests: Run the tests in parallel.", 2021-03-18),
the working directory relative to which "test-parallel-mount-local" would
be launched (by the test machinery) changed from "tests/mount-local" to
just "tests".

While the relative pathname of the "guestunmount" executable was updated
inside "test-parallel-mount-local" accordingly, the relative pathname of
the FUSE client ("test-parallel-mount-local" itself, just invoked with
"--test") was not. This issue guarantees that the exec call fails in the
child, and so the test case always hangs.

Because we had removed "mount-local" from the end of the working
directory, prepend it now to the relative pathname of the FUSE client
executable.

Fixes: 6d32773e81
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20210902135124.15191-3-lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
2021-09-03 12:06:54 +02:00
Laszlo Ersek
79d7fc8674 tests/mount-local: exit child immediately when exec fails
Each worker thread of "test-parallel-mount-local" performs the following
steps (among others):

(1) it starts an appliance dedicated to that thread, using a private
    scratch disk image,

(2) exports a dedicated FUSE mount point on the host, exposing the file
    system on the appliance's disk,

(3) launches a child process for manipulating the particular FUSE mount
    point on the host,

(4) enters a FUSE request processing loop, translating requests between
    the host kernel (coming in via the FUSE mount point) and the
    appliance.

Items to note:

- The child process from step (3) consists of a single thread of execution
  (see fork() in POSIX): a duplicate of the parent process's respective
  worker thread.

- The child process from step (3) blocks on any FUSE mount point access on
  the host until the worker thread in the parent process starts processing
  FUSE requests, in step (4).

- The FUSE request processing in step (4), in the worker thread living in
  the parent process, terminates if and only if the child process unmounts
  the FUSE mount point originating from (2).

Should the exec call in step (3) fail for any reason, the child currently
jumps to the "error" label. This is wrong: under the error label, we call
guestfs_close() on the appliance -- but the appliance is owned by the
parent process's worker thread, not the child. What happens is that the
child kills off the appliance while the parent's worker thread is in the
FUSE request processing loop (4).

The "error" label was never meant to be reached by the child process -- if
exec fails for any reason, exit the child immediately. The parent will
remain in the FUSE request processing loop (4) forever, but no state will
be corrupted. For example, using another (interactive) session on the
host, the FUSE mount points can be interacted with, and if all of them are
manually unmounted, the FUSE request processing (4) completes in every
worker thread.

This patch does not fix the primary issue with
"test-parallel-mount-local", but removes "chaos" from the symptoms. The
next patch will fix the actual regression in this test case.

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20210902135124.15191-2-lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
2021-09-03 12:06:45 +02:00
Richard W.M. Jones
13a1ae6da6 Version 1.45.7. 2021-08-31 16:32:02 +01:00
Hilko Bengen
39f514b28d appliance: Fix searching for shared libraries on usr-merged Debian systems
If /lib is a symlink to usr/lib, paths to shared libraries as
determined by ld.so may differ from dpkg's file lists.

We turn the filename search pattern into a glob expression by
prefixing it with a '*', so the required packages are found again:

$ dpkg -S /lib/x86_64-linux-gnu/libpcre2-8.so.0
dpkg-query: no path found matching pattern /lib/x86_64-linux-gnu/libpcre2-8.so.0
$ dpkg -S */lib/x86_64-linux-gnu/libpcre2-8.so.0
libpcre2-8-0:amd64: /usr/lib/x86_64-linux-gnu/libpcre2-8.so.0
2021-08-31 15:49:55 +01:00
Richard W.M. Jones
45de287447 lib: Autodetect backing format for qemu-img create -b
qemu 6.1 has decided to change qemu-img create so that a backing
format (-F) is required if a backing file (-b) is specified.  Since we
don't want to change the libguestfs API to force callers to specify
this because that would be an API break, autodetect it.

This is similar to commit c8c181e8d9 ("launch: libvirt: Autodetect
backing format for readonly drive overlays").

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1998820
2021-08-31 08:35:52 +01:00
Alexandre Iooss
210959cc34 build: Define HAVE_RPM, HAVE_DPKG and HAVE_PACMAN
When using option `--with-distro`, `HAVE_RPM`, `HAVE_DPKG` and
`HAVE_PACMAN` are not defined and make the configure phase fail.
This makes sure that these conditionals are always defined.
2021-08-27 20:25:14 +01:00
Richard W.M. Jones
73cd0a0c8d lib: Add osinfo information for Windows Server 2022 Datacenter
Windows Server 2022 preview is identified as <osinfo>win2k16</osinfo>.
Although current osinfo-db does not have an entry "win2k22", return
this instead.

osinfo-db issue to add win2k22:
https://gitlab.com/libosinfo/osinfo-db/-/issues/82

Inspection information for the guest:

    type: windows
    distro: windows
    product_name: Windows Server 2022 Datacenter
    product_variant: Server
    version: 10.0
    arch: x86_64

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1997446
Reported-by: Yongkui Guo
2021-08-25 11:09:37 +01:00
Heinrich Schuchardt
efb3d01992 launch: board model for RISC-V
On RISC-V there is no default machine type. Invoking QEMU requires to
specify a board model with the -M option. So let's define MACHINE_TYPE
as virt.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2021-08-20 08:13:10 +01:00
Richard W.M. Jones
90a076fe19 appliance: Add IBM850 iconv converter for syslinux
$ guestfish -N fs:vfat:2G syslinux /dev/sda1
libguestfs: error: syslinux: Error converting to codepage 850 Invalid argument
...

This happens because of the default codepage requested by syslinux
(code page 850) combined with the appliance missing the iconv
converter for this codepage.

Reported-by: Yongkui Guo
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1990720
2021-08-06 08:26:51 +01:00
Richard W.M. Jones
e84c63a2ca python: Don't leak fields when creating Python structs
When creating and returning a Python struct we were adding fields from
the C struct, but did not reduce the ref count on the temporary value
after it had been moved to the struct, resulting in a memory leak.

Reported-by: 朱丹 <zhudan24@huawei.com>
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1985912
2021-07-27 08:58:28 +01:00
Martin Kletzander
e68a844eb4 build: Don't use non-POSIX tests
The `test` builtin/binary usually accepts `==` for string comparison, it is
mostly accepted for typos and people being used to double equals, but is not
documented and not always accepted either.  Since autoconf uses the default
shell, it might just fail in some cases with:

    ./configure: 29986: test: xrustc: unexpected operator
    ./configure: 29990: test: xcargo: unexpected operator

Just change it to single equals as it is done everywhere else.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2021-06-01 10:34:58 +01:00
Richard W.M. Jones
6410c99844 Version 1.45.6. 2021-05-27 17:32:10 +01:00
Richard W.M. Jones
0b223a2877 test-data: Replace deprecated luks_open with cryptsetup_open.
The two calls are identical, so this simply avoids a deprecation
warning.
2021-05-27 17:21:16 +01:00
Daniel P. Berrangé
5e98999b1f point users to Libera Chat rather than FreeNode
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-05-27 13:00:36 +01:00
Richard W.M. Jones
047cf7dcd2 daemon/link.c: Fix out of memory error when reading symlinks
Commit 0f54df53d2 ("build: Remove gnulib") introduced a bug when I
rewrote existing code that used gnulib areadlink().

A missing "continue" statement on the path where fstatat(2) failed
caused fall-through to the case where it tries to use malloc(3) on the
value from the uninitialized stat buf.  This caused a huge amount of
memory to be allocated, invoking the oom-killer inside the appliance.

Reported-by: Yongkui Guo
Fixes: commit 0f54df53d2
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1960217
2021-05-13 12:04:41 +01:00
Richard W.M. Jones
51d21f7684 daemon: Fix isoinfo on files
Commit 2f587bbaec ("daemon: Read ISO9660 Primary Volume Descriptor
directly.") changed daemon/isoinfo.ml to read the PVD directly.  This
was fine for guestfs_isoinfo_device which opens a device name, but did
not work for ISOs embedded within filesystems opened using
guestfs_isoinfo because we did not chroot into the filesystem first.

Example reproducer (run from the libguestfs source directory):

$ guestfish -N fs -m /dev/sda1 upload ./test-data/test.iso /test.iso
$ guestfish --ro -a test1.img -m /dev/sda1 isoinfo /test.iso
libguestfs: error: isoinfo: open: /test.iso: No such file or directory

After this fix:

$ guestfish --ro -a test1.img -m /dev/sda1 isoinfo /test.iso
iso_system_id:
iso_volume_id: ISOIMAGE
iso_volume_space_size: 2490
[etc.]

Reported-by: Yongkui Guo
Fixes: commit 2f587bbaec
Fixes: https://bugzilla.redhat.com/show_bug.cgi
2021-05-13 09:19:31 +01:00
Richard W.M. Jones
d01ce08218 rust: Fix deprecated use of panic!(format!(...))
warning: panic message is not a string literal
 --> src/bin/event_leak.rs:9:30
  |
9 |             Err(e) => panic!(format!(" could not create handle {:?}", e)),
  |                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(non_fmt_panic)]` on by default
  = note: this is no longer accepted in Rust 2021
  = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
2021-05-05 12:57:51 +01:00
Richard W.M. Jones
d3bbc02190 lib: qemu: Don't use -enable-fips option.
QEMU has deprecated this option:

    commit 166310299a1e7824bbff17e1f016659d18b4a559
    Author: Daniel P. Berrangé
    Date:   Tue Oct 20 17:08:27 2020 +0100

    os: deprecate the -enable-fips option and QEMU's FIPS enforcement

    The -enable-fips option was added a long time ago to prevent the use of
    single DES when VNC when FIPS mode is enabled. It should never have been
    added, because apps are supposed to unconditionally honour FIPS mode
    based on the '/proc/sys/crypto/fips_enabled' file contents.

    In addition there is more to achieving FIPS compliance than merely
    blocking use of certain algorithms. Those algorithms which are used
    need to perform self-tests at runtime.

    QEMU's built-in cryptography provider has no support for self-tests,
    and neither does the nettle library.

    If QEMU is required to be used in a FIPS enabled host, then it must be
    built with the libgcrypt library enabled, which will unconditionally
    enforce FIPS compliance in any algorithm usage.

    Thus there is no need to keep either the -enable-fips option in QEMU, or
    QEMU's internal FIPS checking methods.
2021-05-05 12:50:17 +01:00
Richard W.M. Jones
2883fc2acc python: Relicense setup.py to LGPLv2+ (originally GPLv2+)
Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1951560#c3
2021-04-23 10:49:55 +01:00
Richard W.M. Jones
e94d2345bc daemon/isoinfo.ml: Fix offset of Abstract File Identifier
https://listman.redhat.com/archives/libguestfs/2021-April/msg00058.html

Thanks: Thomas Schmitt
2021-04-17 19:00:26 +01:00
Richard W.M. Jones
26427b9ecc inspection: More reliable detection of Linux split /usr configurations
In RHEL 8+, /usr/etc no longer exists.  Since we were looking for this
directory in order to detect a separate /usr partition, those were no
longer detected, so the merging of /usr data into the root was not
being done.  The result was incomplete inspection data and failure of
virt-v2v.

All Linux systems since forever have had /usr/src but not /src, so
detect this instead.

Furthermore the merging code didn't work, because we expected that the
root filesystem had a distro assigned, but in this configuration we
may need to look for that information in /usr/lib/os-release (not on
the root filesystem).  This change makes the merging work even if we
have incomplete information about the root filesystem, so long as we
have an /etc/fstab entry pointing to the /usr mountpoint.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1949683
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1930133
Fixes: commit 394d11be49
2021-04-15 09:41:35 +01:00
Richard W.M. Jones
7ed0da779f Ignore return value from strerror_r.
It seems like newer glibc added warn_unused_result to this function.
Try harder to ignore the result.
2021-04-13 15:40:48 +01:00
Richard W.M. Jones
2ebacabd68 golang: Fix quoting in Makefile.
Fixes: commit c8cab6219f
Fixes: commit 95de3f6c50
2021-04-09 14:27:11 +01:00
Richard W.M. Jones
afe7e16c0f golang: Fix build when libguestfs is not already installed.
See similar fix in libnbd:
031aaefaa8

Fixes: commit 95de3f6c50
2021-04-09 14:27:01 +01:00
Richard W.M. Jones
536b5ed993 Version 1.45.5. 2021-04-09 11:39:10 +01:00
Richard W.M. Jones
4c6de453f1 golang: Add go.mod to EXTRA_DIST.
Fixes: commit 95de3f6c50
2021-04-09 11:38:37 +01:00
Richard W.M. Jones
026b52c848 build: Remove m4/.gitignore from EXTRA_DIST.
This file was removed when we got rid of gnulib, but left in
EXTRA_DIST by mistake.

Fixes: commit 0f54df53d2
2021-04-09 11:37:49 +01:00
Richard W.M. Jones
c8cab6219f golang: Try to deal with srcdir != builddir builds.
Updates: commit 95de3f6c50
Thanks: Gianfranco Costamagna
2021-04-09 11:05:17 +01:00
Richard W.M. Jones
93c2d09136 golang: Partially fix the tests.
./guestfs.go:4945:16: conversion from _Ctype_char (int8) to string yields a string of one rune, not a string of digits (did you mean fmt.Sprint(x)?)
./guestfs.go:7320:16: conversion from _Ctype_char (int8) to string yields a string of one rune, not a string of digits (did you mean fmt.Sprint(x)?)
./guestfs.go:7335:16: conversion from _Ctype_char (int8) to string yields a string of one rune, not a string of digits (did you mean fmt.Sprint(x)?)
2021-04-08 12:59:17 +01:00
Richard W.M. Jones
95de3f6c50 golang: Fix bindings for golang 1.16.
See https://blog.golang.org/go116-module-changes
2021-04-08 12:55:19 +01:00
Richard W.M. Jones
0f54df53d2 build: Remove gnulib.
As part of our efforts to clean up and simplify libguestfs, removing
gnulib deletes a large dependency that we mostly no longer use and
causes problems for new users trying to build the library from source.

A few modules from gnulib are still used (under a compatible license)
and these are copied into gnulib/lib/
2021-04-08 11:36:40 +01:00
Richard W.M. Jones
48e7520ec5 lib/guestfs-internal.h: Remove need to include gnulib "hash.h" here.
Centrally including "hash.h" means everything that needs this header
file (everything in lib/) has to depend on gnulib.
2021-04-08 11:12:17 +01:00
Richard W.M. Jones
9cfa1c410f Remove use of gnulib glthread.
This gnulib feature abstracts away threads, locks and TLS, and also
allowed libguestfs to be linked with or without pthread.  However
since pthread these days is part of glibc and so every program is
using pthread, and we want to get rid of gnulib as a dependency, just
use pthread directly.
2021-04-08 11:12:17 +01:00
Richard W.M. Jones
5244d11bd7 generator/bindtests.ml: Remove use of gnulib intprops.h 2021-04-06 13:27:02 +01:00
Richard W.M. Jones
b18ac489db Version 1.45.4. 2021-04-03 12:10:13 +01:00
Richard W.M. Jones
bf28bc01db tests: Fix isoinfo test.
Also remove GUESTFS_ISO_SYSTEM_ID.

Fixes: commit 2f587bbaec
2021-04-03 12:02:35 +01:00
Richard W.M. Jones
278d0d3226 lib/appliance-kcmdline.c: Read UUID directly from appliance.
Instead of using the external file utility, read the UUID directly
from the extfs filesystem.  file 5.40 broke parsing of UUIDs
(https://bugs.astron.com/view.php?id=253).

Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1945122
2021-03-31 13:45:17 +01:00
Richard W.M. Jones
2f587bbaec daemon: Read ISO9660 Primary Volume Descriptor directly.
It turns out we can read the information we need for the isoinfo API
directly from the ISO9660 PVD.  We don't need to use either isoinfo or
xorriso.  This also has the advantages of reducing by 1 the number of
dependencies in the appliance, and reducing potential vulnerability to
a crafted ISO file.

This also fixes timezone calculation for the datetime fields.

Thanks: Thomas Schmitt
Updates: commit efb8a766ca
2021-03-31 11:35:32 +01:00
Richard W.M. Jones
efb8a766ca daemon: Allow xorriso as an alternative to isoinfo.
Currently the guestfs_isoinfo and guestfs_isoinfo_device APIs run
isoinfo inside the appliance to extract the information.

isoinfo is part of genisoimage which is somewhat dead upstream.
xorriso is supposedly the new thing.  (For a summary of the situation
see: https://wiki.debian.org/genisoimage).

This commit rewrites the parsing from C to OCaml to make it easier to
deal with, and allows you to use either isoinfo or xorriso.

Mostly the same fields are available from either tool, but xorriso is
a bit more awkward to parse.
2021-03-30 15:21:54 +01:00
Richard W.M. Jones
2216ab2e32 tests: Prefer xorriso over genisoimage to generate test.iso
This Debian page explains the upstream situation:
https://wiki.debian.org/genisoimage

On Fedora, xorriso provides a compatibility program called "mkisofs".
However this is not present in Debian.  Hence the choice to look for
the program called "xorrisofs".
2021-03-30 13:57:30 +01:00
Richard W.M. Jones
49b8b69cb8 daemon/xfs.c: Fix error message.
Fixes: commit 87206e4e9e
2021-03-30 12:56:58 +01:00
Richard W.M. Jones
0b7207b8c3 Version 1.45.3. 2021-03-29 19:42:29 +01:00
Richard W.M. Jones
8317279c35 m4/guestfs-find-db-tool.m4: Remove unused file.
Fixes: commit 42e5e7cfdb
2021-03-29 18:38:39 +01:00
Richard W.M. Jones
cb8c4d90e1 podwrapper: Use the tarball release date to calculate the stable date.
Fixes: commit eb53d74ba2
2021-03-29 18:29:15 +01:00
Richard W.M. Jones
df983200d7 po/POTFILES: Fix list of files for translation.
Fixes: commit c9ee831aff
2021-03-29 18:25:57 +01:00
Richard W.M. Jones
42e5e7cfdb test-data/phony-guests: Fix phony RPM database, fix virt-inspector test.
libguestfs 1.45.3 now reads the RPM database using librpm, which means
our old phony database created by db_dump can no longer work.  Instead
provide a real (but very minimal) sqlite database.

This commit also fixes the virt-inspector test since the RPM database
contents are now different.
2021-03-29 17:26:43 +01:00
Richard W.M. Jones
fef73bce7e inspection: Return RPM epoch.
Fixes: commit c9ee831aff
2021-03-27 09:31:00 +00:00
Richard W.M. Jones
c9ee831aff inspection: Fix inspection of recent RPM guests using non-BDB.
Recent RPM-based guests have switched from using Berkeley DB (BDB) to
sqlite.  In order to inspect these guests (and earlier ones) we need
to stop using the hokey parsing of the BDB and use librpm APIs
instead.

This commit adds a new internal API so we can call librpm from the
daemon, and changes the library part to use the new API for RPM-based
guests.

This change removes the requirement for BDB tools like db_dump.

See also:
http://lists.rpm.org/pipermail/rpm-ecosystem/2021-March/000751.html
http://lists.rpm.org/pipermail/rpm-ecosystem/2021-March/000754.html
https://blog.fpmurphy.com/2011/08/programmatically-retrieve-rpm-package-details.html

This breaks the virt-inspector test (now in the separate guestfs-tools
repository).  However this is not a bug in libguestfs, but a bug in
the phoney Fedora guest that we use for testing - we created a
BDB-style RPM database which was supposed to be just enough to make
the old code work.  The new code using real librpm needs
/usr/lib/rpm/rpmrc (not present in the phoney image) and also cannot
parse the phoney database, so we will need to separately rework that
test.

Thanks: Panu Matilainen
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1766487
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1409024
2021-03-26 16:26:00 +00:00
Richard W.M. Jones
94e64b28be daemon: chroot: Fix long-standing possible deadlock.
The child (chrooted) process wrote its answer on the pipe and then
exited.  Meanwhile the parent waiting for the child to exit before
reading from the pipe.  Thus if the output was larger than a Linux
pipebuffer then the whole thing would deadlock.
2021-03-26 16:06:03 +00:00
Richard W.M. Jones
48a35c117e tests: btrfs: Use a valid sector size in the test.
Latest btrfs seems to reject 512 byte sector size.  It may be because
of the specific hardware that I'm running the test on.  Anyway using a
4K sector size works.

libguestfs: error: mkfs_btrfs: /dev/sda1: ERROR: invalid sectorsize 512, expected range is [4K, 64K]
2021-03-25 11:57:37 +00:00
Richard W.M. Jones
5b01bcda17 tests: Source test-command and test-pwd from the correct directory.
Fixes: commit 6d32773e81
2021-03-25 11:55:10 +00:00
Richard W.M. Jones
3b1ed4c9bc build: Use correct ounit2 OCaml module.
Also update common module to get the same fix.
2021-03-25 08:26:42 +00:00
Richard W.M. Jones
4991fe5259 bash-completion: Remove completion scripts for tools.
These have moved to guestfs-tools.

Fixes: commit 733d2182b6
2021-03-23 11:08:42 +00:00
Richard W.M. Jones
eb53d74ba2 Don't include huge ChangeLog in the tarball.
Adds a few megabytes which people can easily get from the git
repository.
2021-03-23 10:00:12 +00:00
Richard W.M. Jones
09639387aa Version 1.45.2. 2021-03-22 16:41:30 +00:00
Richard W.M. Jones
008cda2bd2 generator: Do not build mlcustomize if directory does not exist.
When shipping the libguestfs tarball we do not necessarily have
common/mlcustomize.  If we run the generator in this situation then
don't try to generate files in the non-existent directory.

See-also: commit 7ced2b9354
2021-03-22 16:37:55 +00:00
Richard W.M. Jones
b0b2979dce tests: Fix EXTRA_DIST.
Fixes: commit 6d32773e81
2021-03-22 16:27:07 +00:00
Richard W.M. Jones
9dddd8ec62 tests/mount-local/test-parallel-mount-local.c: Fix bogus -fanalyzer warning.
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99716 for the reduced
test case.
2021-03-22 15:52:22 +00:00
Richard W.M. Jones
e0a1106103 daemon: Don't return bogus failure from readdir.
This was returning "readdir: Invalid argument" which is actually
impossible (readdir(3) cannot fail with EINVAL).  It turns out that
the problem is just errno from some other place leaking out.
2021-03-22 14:56:10 +00:00
Richard W.M. Jones
e282558581 tests/charsets/test-charset-fidelity.c: Print all errors.
Not just the first error.
2021-03-22 14:49:41 +00:00
Richard W.M. Jones
b5b22893a1 tests/charsets/test-charset-fidelity.c: Fix code indentation regression.
A previous commit adding assert statements (to make -fanalyzer happy)
accidentally broke this test.

Fixes: commit 8a4275c568
2021-03-22 14:49:09 +00:00
Richard W.M. Jones
9108ad152d daemon/btrfs.c: Ignore mkfs.btrfs allocstart option.
This was deprecated in btrfs 4.14.1 and recently removed (see
btrfs-progs commit 4bd94dba8a "btrfs-progs: mkfs: remove alloc start
options and docs").  If the option is set simply ignore it.
2021-03-22 14:26:57 +00:00
Richard W.M. Jones
1eb055bd46 tests/nbd/test-nbd.pl: Multiple improvements.
Use qemu-nbd --pid-file option so we don't have to use an arbitrary
sleep.

Enable all parts of the test, since everything should work now with
various upstream bugs having been fixed in the 8 years since the test
was originally written.
2021-03-22 14:12:43 +00:00
Richard W.M. Jones
d4ab4ff683 tests: Fix test for new libcap output.
libcap commit 177cd41803 ("A more compact form for the text
representation of capabilities.") changed the format used by
cap_to_text(3), breaking our test.  Change the test to cope.  This
will break with older libcap now, but there's not a lot we can do
about it.
2021-03-22 13:52:41 +00:00
Richard W.M. Jones
245d1a3d7c python: Ignore code style error E128. 2021-03-22 13:19:19 +00:00
Richard W.M. Jones
6d32773e81 tests: Run the tests in parallel.
Before this change the tests ran in about 12m34 and afterwards in
about 6m20, although the real change is more dramatic if you only run
tests from the tests/ subdirectory (as language tests still run serially).

This breaks valgrinding for now, which I intend to fix properly later.
2021-03-18 16:28:55 +00:00
Richard W.M. Jones
ff3fdb0418 tests/regressions: Remove virt-resize test rhbz1285847.sh
This test was correctly copied into the new guestfs-tools repository
when virt-resize was moved there along with the other tools.  However
it was never removed from libguestfs.  We were effectively running the
test on the installed virt-resize.

Fixes: commit 733d2182b6
2021-03-18 13:55:20 +00:00
Richard W.M. Jones
22e9b682a4 tests: Remove obsolete automake2junit script.
Originally added in commit 38fbda9d37 as
a way to integrate the output from automake into CI systems, but not
actually used.
2021-03-18 13:54:44 +00:00
Richard W.M. Jones
13ceb6a87b appliance: Use <cpu mode="maximum"/> for -cpu max on libvirt.
Note this requires libvirt >= 7.1.0 which was only released in March 2021.

With an older libvirt you will see this error:

  Original error from libvirt: unsupported configuration: Invalid mode attribute 'maximum' [code=67 int1=-1]

In theory we could check if this is supported by looking at the
libvirt capabilities and fall back, but this commit does not do that,
in the expectation that most people will be using the default backend
(direct) and on Fedora/RHEL we will add an explicit minimum version
dependency to the package.

qemu support has been around quite a bit longer (at least since 2017).

Fixes: commit 30f74f38bd
2021-03-18 12:42:35 +00:00
Richard W.M. Jones
24e112c1b7 perl: Remove dependency on Win::Hivex::*
This is used in virt-win-reg, but that tool have moved out to
guestfs-tools so the dependency is no longer needed by libguestfs
itself.

Fixes: commit 733d2182b6
2021-03-18 12:19:55 +00:00
Richard W.M. Jones
061be6bb84 tests: Remove dependency on Sys::Virt.
This was only used for a single rule (check-valgrind-local-guests)
which ran "make check-valgrind" on local guests.  This was never
really used by me and was fairly inadvisable anyway, so we can easily
remove it and thus remove the dependency on perl Sys::Virt.
2021-03-18 12:16:28 +00:00
Sam Eiderman
5d686b92a6 launch: libvirt, direct: Add force_kvm backend setting.
By using:

  export LIBGUESTFS_BACKEND_SETTINGS=force_kvm

you can force the backend to use KVM and never fall back to
TCG (software emulation).
2021-03-16 16:11:23 +00:00
Richard W.M. Jones
f8f424325c Update common to get OCaml PCRE module fix. 2021-03-16 15:13:49 +00:00
Richard W.M. Jones
82493579f3 Port libguestfs to use pcre2 instead of pcre.
https://bugzilla.redhat.com/show_bug.cgi?id=1938982
2021-03-16 11:24:37 +00:00
Richard W.M. Jones
fbf573d2c9 daemon/daemon-c.c: Fix whitespace. 2021-03-16 11:24:37 +00:00
Richard W.M. Jones
733d2182b6 Remove the tools.
These have now moved to a new repository.  Provisionally it is here:

https://github.com/rwmjones/guestfs-tools/

but this is not the final location, as it will eventually be hosted on
gitlab.com.

The tarballs are here:

https://download.libguestfs.org/guestfs-tools/
2021-03-11 13:58:41 +00:00
Remi Collet
ff4080378d php: Fix the build. 2021-03-05 13:22:05 +00:00
Richard W.M. Jones
a009a4cf6f Version 1.45.1. 2021-03-03 12:35:48 +00:00
Richard W.M. Jones
e743fb94d6 Update common. 2021-03-02 10:43:55 +00:00
Richard W.M. Jones
5f499208cf builder: Don't redefine Val_none (OCaml 4.12).
CC       virt_builder-setlocale-c.o
setlocale-c.c:38: error: "Val_none" redefined [-Werror]
   38 | #define Val_none (Val_int (0))
      |
In file included from /usr/lib64/ocaml/caml/alloc.h:24,
                 from setlocale-c.c:23:
/usr/lib64/ocaml/caml/mlvalues.h:395: note: this is the location of the previous definition
  395 | #define Val_none Val_int(0)
      |
2021-03-02 10:42:49 +00:00
Richard W.M. Jones
21cd97732c daemon: lvm: Use lvcreate --yes to avoid interactive prompts.
See https://bugzilla.redhat.com/show_bug.cgi?id=1930996#c1

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1930996
2021-02-22 11:04:15 +00:00
Richard W.M. Jones
064c3b6a94 Update common submodule. 2021-02-22 10:38:19 +00:00
Richard W.M. Jones
20dbc24d68 lib/fuse.c: Use safe_malloc instead of malloc.
Avoids having to check the return value, and in this case avoids a GCC
analyzer error.
2021-02-22 10:38:19 +00:00
Richard W.M. Jones
c253398247 fuse/guestmount.c: Avoid leaking fp on error path.
Bug found by GCC analyzer.
2021-02-22 10:38:19 +00:00
Richard W.M. Jones
acefa23758 diff: Don't try to call unlink(NULL) on certain error paths.
Actual bug found by GCC analyzer.
2021-02-22 10:38:19 +00:00
Richard W.M. Jones
001c1dc09f daemon/tar.c: Avoid bogus GCC analyzer warning.
See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99196
2021-02-22 10:38:19 +00:00
Richard W.M. Jones
4af1c631a2 daemon/command.c daemon/debug.c df/main.c: Ignore bogus GCC analyzer warnings
See upstream bug report:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99193
2021-02-22 10:37:49 +00:00
Richard W.M. Jones
f19fd566f6 appliance: Add dhclient for Arch-like Manjaro distro.
Thanks: hatifnatt on IRC
2021-02-17 09:44:19 +00:00
Richard W.M. Jones
30f74f38bd appliance: Use -cpu max.
QEMU has a newish feature (from about 2017 / qemu 2.9) called -cpu max
which is supposed to select the best CPU, ideal for libguestfs.

After this change, on x86-64:

               KVM                          TCG

Direct         -cpu max                     -cpu max
(non-libvirt)

Libvirt   <cpu mode="host-passthrough">     <cpu mode="host-model">
            <model fallback="allow"/>         <model fallback="allow"/>
          </cpu>                            </cpu>

Thanks: Daniel Berrangé
2021-01-28 14:04:29 +00:00
Richard W.M. Jones
7ac82beb89 fish/tilde.c: Suppress more bogus -fanalyser warnings. 2021-01-28 12:27:41 +00:00
Richard W.M. Jones
fdda111e0e lib/qemu.c: Suppress another bogus -fanalyser warning. 2021-01-28 12:27:41 +00:00
Richard W.M. Jones
4e66dd5736 website/download/builder/index: Automatic update.
Updates: commit 97902a9cf6
2021-01-28 12:27:41 +00:00
Richard W.M. Jones
97902a9cf6 builder: templates: Add ubuntu-20.04.
The reason is wasn't working before is that virt-manager was missing
this fix:

b55b7e9462/virtinst/install/urldetect.py

Thanks: fepitre on IRC
2021-01-28 11:57:36 +00:00
Richard W.M. Jones
8670e4ee90 builder: templates: Added rhel-7.9. 2021-01-27 11:57:41 +00:00
Richard W.M. Jones
03347d49ee lib: Move CLEANUP_GL_RECURSIVE_LOCK_UNLOCK to libguestfs header.
Previously this was in common/utils.  However it is not used anywhere
else, and guestfs-tools wants to remove gnulib dependencies, so move
this to libguestfs.
2021-01-22 13:39:16 +00:00
Richard W.M. Jones
fb7b683a29 appliance: Avoid having ${exec_prefix} in guestfs appliance path.
Normally packagers should try to use ./configure --with-guestfs-path=...
However if they do not, then a regression in 1.44 caused the path to
constain the literal string "${exec_prefix}".  This was because of
autoconf stupidity.

Try to resolve this by expanding ${exec_prefix} to something sensible.

The expansion will often be wrong (but at least it will now be a valid
path), hence the recommendation to always set --libdir and/or
--with-guestfs-path when configuring.

Fixes: commit 94ff24b880
Fixes: https://bugzilla.redhat.com/1915646
2021-01-15 14:20:00 +00:00
Richard W.M. Jones
0c82987531 builder: Fix Fedora 33 boot problem.
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1911177
Thanks: Daniel P. Berrangé
2021-01-13 12:35:47 +00:00
Richard W.M. Jones
812f837c97 build: Avoid warnings about unknown pragmas.
In commit 4bbbf03b8b we started to
ignore bogus GCC 11 warnings.  Unfortunately earlier versions of GCC
don't know about those pragmas so give warnings [hence errors in
developer builds] like:

tsk.c:75:32: error: unknown option after '#pragma GCC diagnostic' kind [-Werror=pragmas]

Turn off these warnings.

Updates: commit 4bbbf03b8b
2021-01-12 10:27:35 +00:00
Richard W.M. Jones
de9a5e59f1 Version 1.44.0. 2021-01-06 10:18:34 +00:00
Richard W.M. Jones
8cf46e4886 docs: Add release notes for libguestfs 1.44.
This is quite a small release.
2021-01-05 19:41:31 +00:00
Richard W.M. Jones
675b336f63 gnulib: Update to latest. 2021-01-05 15:53:51 +00:00
Richard W.M. Jones
8ec4f256f2 Version 1.43.4. 2021-01-05 14:25:01 +00:00
Richard W.M. Jones
a9975a5a9b common: Update to latest. 2021-01-05 10:32:20 +00:00
Richard W.M. Jones
26f5cdaab3 rescue: Don't call exit(3) from a signal handler.
Found by GCC 11 analyzer.
2021-01-05 10:31:08 +00:00
Richard W.M. Jones
4bbbf03b8b Ignore completely bogus GCC 11 warnings.
Various varieties of this:

           |   45 |   tempfile = strdup ("/tmp/luksXXXXXX");
           |      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~
           |      |              |
           |      |              (19) this call could return NULL
           |   46 |   if (!tempfile) {
           |      |      ~
           |      |      |
           |      |      (20) following 'false' branch (when 'tempfile' is non-NULL)...
           |......
           |   51 |   fd = mkstemp (tempfile);
           |      |   ~~   ~~~~~~~~~~~~~~~~~~
           |      |   |    |
           |      |   |    (22) argument 1 ('tempfile') from (19) could be NULL where non-null expected
           |      |   (21) ...to here
2021-01-05 10:31:00 +00:00
Richard W.M. Jones
07585189cf lib: Ignore a bunch of bogus GCC 11 warnings.
-Werror=analyzer-file-leak doesn't follow CLEANUP_FCLOSE properly.

yara.c:64:24: error: leak of FILE '<unknown>' [CWE-775] [-Werror=analyzer-file-leak]
   64 |   CLEANUP_FCLOSE FILE *fp = NULL;
      |                        ^~
2021-01-05 10:09:21 +00:00
Richard W.M. Jones
6d0ab14b56 tar-in: Add workaround because tar doesn't restore capabilities (RHBZ#1384241).
Current GNU tar does not restore all extended attributes.  In
particular only user.* capabilities are restored (although all
are saved in the tarball).

To restore capabilities, SELinux security attributes, and other things
we need to use --xattrs-include=*

For further information on the tar bug, see:
https://bugzilla.redhat.com/show_bug.cgi?id=771927
2020-12-11 10:23:21 +00:00
Richard W.M. Jones
b2e457767d Version 1.43.3. 2020-12-01 16:47:32 +00:00
Richard W.M. Jones
8a4275c568 tests/charsets/test-charset-fidelity.c: Asserts to avoid bogus CWE-690.
The new GCC static analyzer has trouble understanding when some
strings are non-NULL.  Adding asserts helps avoid warnings.
2020-12-01 15:39:53 +00:00
Richard W.M. Jones
6573ae6ee4 Update gnulib to latest. 2020-12-01 15:35:45 +00:00
Richard W.M. Jones
3d2c38d5ab m4: Define INCLUDE_DIRECTORY for libguestfs only. 2020-12-01 14:31:12 +00:00
Richard W.M. Jones
a624016baa common: Update to latest submodule. 2020-12-01 12:39:47 +00:00
Thierry Vignaud
d2611b62e9 include rpm for Mageia
This fixes:
"-supermin: ext2fs_namei: parent directory not found:
/var/lib/rpm: File not found by ext2_lookup"

This because chkconfig contains /var/lib/rpm/alternatives on Mageia
2020-11-24 09:30:06 +00:00
Thierry Vignaud
32021c72fe Include exfatprogs
It's the new upstream name of exfat-utils.
As eg found on Mageia.
2020-11-24 09:28:05 +00:00
Thierry Vignaud
d63c8041d5 fix detecing db_* tool on Mageia 2020-11-24 09:28:05 +00:00
Thierry Vignaud
e62ccfca4a explain how to install on Mageia 2020-11-24 09:28:05 +00:00
Thierry Vignaud
999fca8731 appliance: Add ntfs-3g-system-compression for Mageia
This package in Mageia enables optional support for Windows 10
"CompactOS" (file-level compression), read-only, which is sufficient
for inspecting Windows guests and doing certain types of modifications
to them.  Virt-v2v appears to work, but it may be that anything that
involves modifying a compressed file might not work.

See commit e6764a5415
2020-11-12 10:36:03 +00:00
Richard W.M. Jones
3f5d080d02 builder: templates: Add Fedora 33 2020-11-02 10:13:22 +00:00
Dmitry Tantsur
fe52d9fd0c rust: fix a typo in the crates.io link 2020-10-28 10:34:04 +00:00
Richard W.M. Jones
0896dea338 gnulib: Replace hash_delete with hash_remove.
Renamed in gnulib with the old function deprecated.
2020-10-22 14:50:58 +01:00
Richard W.M. Jones
e49be55630 m4/.gitignore: Update.
Fixes: commit cfcd3385cc
2020-10-22 14:50:33 +01:00
Richard W.M. Jones
cfcd3385cc Update gnulib to master. 2020-10-22 14:05:35 +01:00
Hilko Bengen
133a491677 Use guestfsd binary to auto-generate library dependencies for appliance
The ELF NEEDED are used to determine guestfsd's library dependencies
with help from the dynamic linker and the package manager.

This was prompted by Debian bug #972241 which was caused by a
libtirpc package renaming in Debian/unstable because the SONAME had
been changed.
2020-10-19 12:14:34 +01:00
Richard W.M. Jones
3f4a529ab7 fuse: Don't override access(X_OK) if user is root.
Bug originally reported here by trysis:
https://stackoverflow.com/questions/64273334/test-x-in-mounted-filesystem

If the user is root then we override normally access controls in FUSE,
see https://bugzilla.redhat.com/show_bug.cgi?id=1106548.

However this causes test -x to mark all files as executable.  We
shouldn't let root execute any file, only ones which have the 'x' bit
set.  Therefore this narrows the fix in bug 1106548 so it only applies
to read and write bits.

To test this I created a disk with guestfish which had an executable
and a non-executable file:

  $ guestfish -N fs -m /dev/sda1
  ><fs> touch /file1
  ><fs> touch /file2
  ><fs> chmod 0755 /file1
  ><fs> ll /
  total 24
  drwxr-xr-x  3 root root  4096 Oct 12 14:04 .
  drwxr-xr-x 19 root root  4096 Oct 12 14:04 ..
  -rwxr-xr-x  1 root root     0 Oct 12 14:04 file1
  -rw-r--r--  1 root root     0 Oct 12 14:04 file2
  drwx------  2 root root 16384 Oct 12 14:04 lost+found

I then mounted and tested it as non-root:

  $ guestmount -a test1.img -m /dev/sda1 /tmp/mnt -v -x
  $ ls -l /tmp/mnt
  total 16
  -rwxr-xr-x. 1 root root     0 Oct 12 15:04 file1
  -rw-r--r--. 1 root root     0 Oct 12 15:04 file2
  drwx------. 2 root root 16384 Oct 12 15:04 lost+found
  $ test -x /tmp/mnt/file1; echo $?
  0
  $ test -x /tmp/mnt/file2; echo $?
  1

and as root:

  $ sudo guestmount -a test1.img -m /dev/sda1 /tmp/mnt -v -x
  $ test -x /tmp/mnt/file1; echo $?
  0
  $ test -x /tmp/mnt/file2; echo $?
  0

In the debug output for non-root we can see the difference:

  libguestfs: /file1: testing access mask X_OK: caller UID:GID = 1000:1000, file UID:GID = 0:0, file mode = 100755, result = OK
  libguestfs: /file2: testing access mask X_OK: caller UID:GID = 1000:1000, file UID:GID = 0:0, file mode = 100644, result = EACCESS

and for root:

  libguestfs: /file1: testing access mask X_OK: caller UID:GID = 0:0, file UID:GID = 0:0, file mode = 100755, result = OK
  libguestfs: /file2: testing access mask X_OK: caller UID:GID = 0:0, file UID:GID = 0:0, file mode = 100644, result = OK

After this commit the root output changes to this (ie. same decision
as non-root):

  libguestfs: /file1: testing access mask X_OK: caller UID:GID = 0:0, file UID:GID = 0:0, file mode = 100755, result = OK
  libguestfs: /file2: testing access mask X_OK: caller UID:GID = 0:0, file UID:GID = 0:0, file mode = 100644, result = EACCESS
2020-10-12 15:17:41 +01:00
Richard W.M. Jones
4663112d89 lib/canonical-name.c: Hide errors from underlying API call.
When guestfs_lvm_canonical_lv_name was called with a /dev/dm* or
/dev/mapper* name which was not an LV then a noisy error would be
printed.  This would typically have happened with encrypted disks, and
now happens very noticably when inspecting Windows BitLocker-
encrypted guests.

This commit hides this error in all cases, although it is still logged
to debug.  See comment and the thread below for detailed rationale.

https://www.redhat.com/archives/libguestfs/2020-October/thread.html#00055
2020-10-12 10:46:10 +01:00
Richard W.M. Jones
5631106a73 daemon: lvm_canonical_lv_name: Return EINVAL if called with non-LV.
Previously callers were unable to distinguish a regular error (like an
I/O error) from the case where you call this API on something which is
valid but not a logical volume.  Set errno to a known value in this
case.
2020-10-12 10:44:29 +01:00
Richard W.M. Jones
86577ee388 daemon: Search device-mapper devices for list-filesystems API.
In case any bare filesystems were decrypted using cryptsetup-open,
they would appear as /dev/mapper/name devices.  Since list-filesystems
did not consider those when searching for filesystems, the unencrypted
filesystems would not be returned.

Note that previously this worked for LUKS because the common case
(eg. for Fedora) was that whole devices were encrypted and thoes
devices contained LVs, so luks-open + vgactivate would activate the
LVs which would then be found by list-filesystems.  For Windows
BitLocker, the common case seems to be that each separate NTFS
filesystem is contained in a separate BitLocker wrapper.
2020-10-12 10:44:29 +01:00
Richard W.M. Jones
79f3d451a8 daemon: Reimplement list_dm_devices API in OCaml.
Simple refactoring.  The only annoying point is requiring an extra
module because of OCaml module dependency restrictions.
2020-10-12 10:44:29 +01:00
Richard W.M. Jones
41cbc89330 daemon: Ignore BitLocker disks in list-filesystems API. 2020-10-12 10:44:29 +01:00
Richard W.M. Jones
6e870a8e43 daemon: Rewrite list-filesystems implementation imperatively.
Simple refactoring to make the code clearer, should have no other
effect.
2020-10-12 10:44:29 +01:00
Richard W.M. Jones
c8e0b45389 fish: Update documentation to refer to cryptsetup-open/close and BitLocker. 2020-10-12 10:44:29 +01:00
Richard W.M. Jones
c456ea0332 New APIs: cryptsetup-open and cryptsetup-close.
This commit deprecates luks-open/luks-open-ro/luks-close for the more
generic sounding names cryptsetup-open/cryptsetup-close, which also
correspond directly to the cryptsetup commands.

The optional cryptsetup-open readonly flag is used to replace the
functionality of luks-open-ro.

The optional cryptsetup-open crypttype parameter can be used to select
the type (corresponding to cryptsetup open --type), which allows us to
open BitLocker-encrypted disks with no extra effort.  As a convenience
the crypttype parameter may be omitted, and libguestfs will use a
heuristic (based on vfs-type output) to try to determine the correct
type to use.

The deprecated functions and the new functions are all (re-)written in
OCaml.

There is no new test here, unfortunately.  It would be nice to test
Windows BitLocker support in this new API, however the Linux tools do
not support creating BitLocker disks, and while it is possible to
create one under Windows, the smallest compressed disk I could create
is 37M because of a mixture of the minimum support size for BitLocker
disks and the fact that encrypted parts of NTFS cannot be compressed.

Also synchronise with common module.
2020-10-12 10:44:08 +01:00
Richard W.M. Jones
bfd0886765 golang: Fix path to include/guestfs.h.
Thanks: Martin Kletzander
Fixes: commit 75abec1f70
2020-10-06 15:26:14 +01:00
Pino Toscano
dbfab7d3b2 build: fix includedir in uninstalled libguestfs.pc
Update includedir with the new directory that contains guestfs.h.

Updates commit 75abec1f70.
2020-09-22 18:12:05 +02:00
Richard W.M. Jones
b89f377540 Version 1.43.2. 2020-09-21 18:56:18 +01:00
Richard W.M. Jones
75abec1f70 include: Move lib/guestfs.h to include/guestfs.h
This brings libguestfs into line with other projects which have a
separate include/ directory for the public header.

It's also the case that <guestfs.h> has never particularly belonged in
the lib/ subdirectory.  Some tools add -Ilib/ but they only need
<guestfs.h> and not any other headers from that directory, and
separating out the public header allows us to clean those up.  This is
certainly the case for examples, and some language bindings and some
tests.

In future I'm hopeful we can use this as the basis to tease out other
dependencies, as a prelude to separating them out from the repo.
2020-09-21 18:38:28 +01:00
Richard W.M. Jones
3743cc89f6 golang: Capitalize fields in structs so they are publicly accessible.
See: https://github.com/libguestfs/libguestfs/issues/53
2020-09-21 10:56:29 +01:00
Yuri Chornoivan
fce82fe55a Fix minor typos 2020-08-24 16:24:38 +01:00
Pino Toscano
14ff95c511 po-docs: turn language list into LINGUAS file
Use a LINGUAS file with the list of available translations instead of
defining them in a make variable. This way Weblate will be able to
update the list using an available addon, and we do not need to list
those not built.

Accordingly, rename the variable with built languages to
'linguas_translated'.
2020-08-17 07:08:11 +02:00
Richard W.M. Jones
bd3fb65351 fish: Fix parsing of exportnames in NBD URIs.
https://github.com/NetworkBlockDevice/nbd/blob/master/doc/uri.md#nbd-uri-export-name
2020-08-16 11:02:42 +01:00
Weblate
b96c8f5146 Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-docs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-docs-master/
2020-08-13 11:59:02 +02:00
Weblate
48b0799297 Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/
2020-08-13 11:56:56 +02:00
Pino Toscano
9a986ed60a Remove references to Zanata
We migrated to Weblate, and Zanata is being decommissioned.
2020-08-13 11:27:44 +02:00
Pino Toscano
049d83f6e4 po/po-docs: update catalog templates
Regenerate the catalog templates according to the updated extraction
rules (mostly fixed paths).
2020-08-13 11:27:44 +02:00
Pino Toscano
d3b43bb47a po-docs: fix references to sources
Start the message extraction from the toplevel source directory, so the
file references are relative to that, instead of relative to this
po-docs subdirectory.

Also update/regenerate podfiles accordingly.
2020-08-13 11:27:44 +02:00
Pino Toscano
a16f67e404 po: fix references to OCaml sources
Start the message extraction from the toplevel source directory, so the
file references are relative to that, instead of relative to this po
subdirectory.
2020-08-13 11:27:44 +02:00
Pino Toscano
bd896d68c0 po-docs: split pot and po handling
With the Weblate adoption, we let it update the po files from the
catalog template. The po4a behaviour of extracting the template,
merging the existing translations, and creating the translated PODs at
once is problematic. Hence, split the extraction and the translated POD
generation in two.

Use po4a-gettextize to extract the catalog template only, not doing it
anymore automatically at each build. There is no more need for a
po4a.conf file.

Use po4a-translate to create translated PODs from the po files, keeping
the fixup of the generated files (to avoid spurious =encoding, etc).
Add a silent rule to hide the po4a-translate command lines by default.

These changes also allow us to get rid of the POD existance checks with
associated error message pointing to the update-po rule. Now each
translated POD file is generated because of make dependency, and it
depends only on its po file.

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
2020-08-13 11:27:44 +02:00
Pino Toscano
3095825350 podfiles: add missing documentation 2020-08-13 11:27:44 +02:00
Pino Toscano
5be4970b1f po-docs: add missing dependencies for guestfish.1
The guestfish man page uses also additional POD snippets, so list them
as dependencies to make sure they are up-to-date.

This does not change the behaviour at the moment, however it will matter
when each traslated POD file will be generated on its own.
2020-08-13 11:27:44 +02:00
Pino Toscano
0dc0f87f20 po: remove rules for pot/po update
Weblate will handle the update of the po files from the translation
catalog, so avoid stomping on its feet by doing the same.

The translation catalog will be regenerated manually periodically.
2020-08-13 11:27:44 +02:00
Pino Toscano
eb7ba4b1d2 po: turn language list into LINGUAS file
Use a LINGUAS file with the list of available translations instead of
defining them in a make variable. This way Weblate will be able to
update the list using an available addon.

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
2020-08-13 11:27:44 +02:00
Andrey Shinkevich
3cad943a85 appliance: extract UUID from QCOW2 disk image
For the appliance of the QCOW2 format, the function get_root_uuid()
fails to get the UUID of the disk image.
In this case, let us read the first 256k bytes of the disk image  with
the 'qemu-img dd' command. Then pass the read block to the 'file'
command.

Suggested-by: Denis V. Lunev <den@openvz.org>
Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
2020-08-13 10:11:09 +01:00
Richard W.M. Jones
2469b4b790 rescue: Initialize roots.
Even though it seems clear from the code that roots cannot be used
uninitialized, GCC 10.1 cannot seem to work it out (possibly an LTO
bug).  Easiest way out here is to just initialize it.

rescue.c:396:37: error: 'roots' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  396 |     CLEANUP_FREE_STRING_LIST char **roots;
      |                                     ^
2020-08-01 07:33:45 +01:00
Richard W.M. Jones
0b8ef5a98d daemon/debug.c: Use __builtin_trap to cause segfault.
I couldn't get GCC 10.1 to ignore this warning any longer, possibly
because I am using LTO.  In any case dereferencing a pointer is
undefined behaviour, so let's use GCC's __builtin_trap() function
instead (also supported by clang).

debug.c: In function 'debug_segv':
debug.c:1002:8: error: null pointer dereference [-Werror=null-dereference]
 1002 |   *ptr = 1;
      |        ^
2020-08-01 07:27:17 +01:00
Richard W.M. Jones
599f2f7bd9 m4: Increase warning limit for frame-larger-than.
Generated code in virt-builder causes the error below.  Since we
cannot control what is generated by bison, increase the limit.

  CCLD     virt-index-validate
index-parse.c: In function 'yyparse':
index-parse.c:1857:1: error: the frame size of 5152 bytes is larger than 5000 bytes [-Werror=frame-larger-than=]
 1857 | }
      | ^
lto1: all warnings being treated as errors
lto-wrapper: fatal error: gcc returned 1 exit status
2020-08-01 07:09:52 +01:00
Richard W.M. Jones
5b29fba5b2 docs: Move shared POD for --keys-from-stdin to common code.
No functional change.
2020-07-30 14:06:45 +01:00
Richard W.M. Jones
eb78e990ac daemon, lib: Replace deprecated security_context_t with char *.
This gives deprecation warnings.  It always was simply a char *, and
the recommendation upstream is to replace uses with char *:

9eb9c93275
2020-07-30 13:58:35 +01:00
Richard W.M. Jones
224f373043 lib: Increase default memsize to 1280 (RHBZ#1837765).
Argon2 is the default LUKS Password-Based Key Derivation Function
(PBKDF) for some new guests such as RHEL 8.2 and Fedora.  It is
designed to be "memory hard", meaning that by design it requires large
amounts of memory, making it expensive to brute-force.  Unfortunately
the default for guests which had more than a few GB of RAM at install
time is to require about 1 GB of RAM to decrypt the block device,
which is considerably larger than the default available in the
libguestfs appliance.

To make it possible to open these encrypted disks we need to make the
appliance larger.  This could be done as a one-off, and the current
workaround is simply to set LIBGUESTFS_MEMSIZE=2048 or a similar
amount.  However since we don't know in advance whether we could be
dealing with an encrypted disk, partition, etc. or what PBKDF it uses,
the only way to deal with this in all circumstances is to increase the
default memsize.  This commit increases it quite a lot (768 -> 1280)
which is unfortunate.

Note as there is some confusion on this point: Since libguestfs does
not attempt to decrypt disks in parallel, you only need ~ 1GB in
total, not per encrypted disk.

For a reproducer, see:
https://bugzilla.redhat.com/show_bug.cgi?id=1837765#c14
2020-07-17 10:47:18 +01:00
Richard W.M. Jones
c5eec6c17b docs: Increase minimum version of Python to 3.6.
3.5 is needed to support type hints.

Debian oldstable has 3.5 (oldoldstable needed 3.4).
2020-07-06 20:37:51 +01:00
Sam Eiderman
66a5913462 python: Add type hints
Since support for python2 is dropped we can use the new python3 syntax
for type hints.

Signed-off-by: Sam Eiderman <sameid@google.com>
2020-07-06 20:35:58 +01:00
Richard W.M. Jones
dfe9fe8de8 Version 1.43.1. 2020-07-06 16:25:36 +01:00
Richard W.M. Jones
75def0ef18 python: Remove deprecated use of PyEval_ThreadsInitialized.
The correct/modern way to do this is:

https://docs.python.org/3/c-api/init.html#releasing-the-gil-from-extension-code

PyEval_ThreadsInitialized was deprecated in 3.9 and will be removed
completely in 3.11, so we shouldn't use that function.
2020-07-06 12:40:33 +01:00
Richard W.M. Jones
403d17a876 python: Drop support for Python 2.
Python 2 reached end of life on 2020-01-01:
https://python3statement.org/
https://pythonclock.org/

The minimum version required is now Python 3.4 (since that is the
version in Debian oldoldstable), but 3.6 is the minimum version that
I actually test.
2020-07-06 12:40:33 +01:00
Richard W.M. Jones
38e2ad1fbc builder: Update index file.
Fixes: commit 4837698d83.
2020-07-06 12:40:33 +01:00
Richard W.M. Jones
4837698d83 builder: templates: Add CentOS 8.2 and RHEL 8.2. 2020-06-16 12:51:09 +01:00
Richard W.M. Jones
6670dc0fbf builder: templates: Add centos-7.8, fedora-32, rhel-7.8.
Ubuntu 20.04 could not be built because their installer has changed in
a way which is not compatible with the current build script.  This
needs some work to fix.
2020-06-04 15:22:38 +01:00
Sergei Golovan
987734fcca erlang: Port to libei for Erlang 23
Replace the use of liberl_interface, which is removed in Erlang 23,
by libei. The implementation uses the ei_decode_iodata() function
which has been introduces only for Erlang 23, so it doesnt work with
earlier Erlang versions.
2020-06-04 13:49:35 +01:00
Pino Toscano
faa5d8507f sysprep: add Kerberos keytab file removal
This new operation removes the Kerberos /etc/krb5.keytab file from the
guest.

Thanks to Christian Heimes and François Cami for the hints.

Related to RHBZ#1789592.
2020-05-26 11:02:46 +02:00
Pino Toscano
0a53e2c7fc sysprep: add IPA offline unenrollment (RHBZ#1789592)
This new operation unenrolls the guest from a IPA server offline, by
removing the configuration files and certificates.

Thanks to Christian Heimes and François Cami for the hints.
2020-05-26 11:02:37 +02:00
Pino Toscano
b9065fa7ad sysprep: ca-certificates: request system CA store update
In case any certificate is removed from the guest, regenerate the system
CA store.
2020-05-07 14:05:09 +02:00
Pino Toscano
bb7fc6d0a1 sysprep: add a update_system_ca_store side effect
Add a simple side effect to make operation flag that a regeneration of
the system CA store is needed. In case it is flagged, regenerate the
system CA store directly, or using a firstboot script in case of
incompatible architectures.

This change is almost a no-op, since no operation requires the
regeneration of the system CA store yet.
2020-05-07 14:05:09 +02:00
Pino Toscano
b25e3495f5 customize: port do_run to run_in_guest_command
Make use of the new helper function in Tools_utils to run commands in
the guest.
2020-05-07 14:04:56 +02:00
Richard W.M. Jones
94ff24b880 appliance: Set default guestfs appliance path to $libdir/guestfs.
For unclear reasons this broke recently, although the breakage is only
reproducible in Fedora Koji.  It appears to be caused by the
calculation of the internal autoconf variable $acl_libdirstem
changing.  In the reproducer system:

checking for the common suffixes of directories in the library search path... lib,lib,lib64

On my local system:

checking for the common suffixes of directories in the library search path... lib64,lib64

My local system would be the correct one.  The actual code that
calculates this does some crazy stuff with ‘gcc -print-search-dirs’
which would hint that this output has changed in some way that subtly
breaks the generated configure script.  However even with match GCC
versions on my local system I could still not reproduce the issue.

None of this matters, as the easiest fix here is simply to stop using
internal autoconf variables at all.  I also added some AC_MSG_*
statements so we can more easily see what's going on in the configure
output.

Fixes commit 0f79400c7f.
2020-05-06 12:39:41 +01:00
Richard W.M. Jones
26324d5445 builder: templates: Add Ubuntu 20.04 code name (focal). 2020-05-05 22:23:49 +01:00
Richard W.M. Jones
a6ed62b0a6 builder: Fix all download.devel links.
All broken in early 2020 for no discernible reason.
2020-04-30 12:33:11 +01:00
Geoff Toole
ef2761eaa0 build: Fix linking of OCaml components when srcdir != builddir
ocaml-link.sh is a generated file, so run it from the build directory.
Remove it from EXTRA_DIST and also adjust docs/guestfs-hacking.pod
accordingly.
2020-04-20 09:31:35 +01:00
Richard W.M. Jones
c2c11382bb daemon: xattr: Filter out user.WofCompressedData from xattrs (RHBZ#1811539).
See comment in code for justification.

Thanks: Yongkui Guo for finding the bug.
2020-03-30 10:40:13 +01:00
Richard W.M. Jones
af8ed266a2 daemon: Add filter_list utility function.
For filtering lists of strings based on a predicate.
2020-03-30 10:40:13 +01:00
Richard W.M. Jones
5c175fe732 daemon: xattr: Refactor code which splits attr names from the kernel.
The kernel returns xattr names in a slightly peculiar format.  We
parsed this format several times in the code.  Refactor this parsing
so we only do it in one place.
2020-03-30 10:40:13 +01:00
Pino Toscano
088b6d1c80 get-kernel: fallback to uncompressed vmlinux kernels
In case the Linux guest has no compressed linux kernel (vmlinuz),
fallback to uncompressed ones (vmlinux).

Reported by: Laurent Vivier.
2020-03-12 13:52:17 +01:00
Pino Toscano
7265f08ce9 lib: remove extra @LIBS@ from pkg-config file
At the moment it is empty, so probably it does not exist. Remove it to
avoid adding spurious content to the pkg-config file in case that
variable will get a value in the future.
2020-03-12 11:45:30 +01:00
Richard W.M. Jones
bf61bf7355 build: Allow OCaml programs using libguestfs to be compiled against build dir.
You have to use:
  ../libguestfs/run ./configure
  ../libguestfs/run make

Use of the second ../libguestfs/run against make is unfortunate but I
believe it's unavoidable due to the way that ocamlfind works.
2020-03-12 10:08:23 +00:00
Richard W.M. Jones
e33b3c83a0 build: Allow C programs using libguestfs to be compiled against build dir.
We use a similar trick to libvirt to allow external C programs that
use libguestfs to be compiled against the built (but not installed)
libguestfs with:

  ../libguestfs/run ./configure
  make

What actually happens is we have a second pkg-config file
(lib/local/libguestfs.pc) which points to the locally built
libguestfs.  The ./run script sets up PKG_CONFIG_PATH to point to this
directory.  Assuming that ./configure is using pkg-config/pkgconf and
not some other half-baked solution it will pick up the libguestfs.pc
file from here which will set CFLAGS and LIBS appropriately.
2020-03-12 10:05:39 +00:00
Pino Toscano
b45b7cc08f builder: templates: add the AppStream repo
It is generally used together with BaseOS (which contains a restricted
set of packages), so add it to the preconfigured repositories by
default.
2020-03-12 10:13:03 +01:00
Richard W.M. Jones
31e6b18710 po: Remove virt-v2v related dependency from POTFILES-ml.
Causes this error if you compile libguestfs 1.42.0 from the tarball
without invoking the generator:

make[4]: *** No rule to make target '../common/mlv2v/uefi.ml', needed by 'libguestfs.pot'.  Stop.
2020-03-09 17:31:55 +00:00
Richard W.M. Jones
da6324ea31 Version 1.42.0. 2020-03-09 14:32:38 +00:00
Richard W.M. Jones
bfe98ffe13 Update release notes for 1.42.
Also update generator/authors.ml so that ‘make maintainer-check-authors’
passes.
2020-03-09 13:35:40 +00:00
Richard W.M. Jones
5a2b191de8 po-docs: Fix translation error in Ukrainian docs.
./uk.po:87712: 'msgid' and 'msgstr' entries do not both begin with '\n'
msgfmt: found 1 fatal error

Fixes commit 7a534669ae.
2020-03-09 13:35:40 +00:00
Richard W.M. Jones
786dba91d1 Revert "lib: Autodetect backing format and specify it explicitly."
This reverts commit 92fd5d5d40.

See discussion here:
https://www.redhat.com/archives/libguestfs/2020-March/thread.html#00041
2020-03-09 12:54:05 +00:00
Richard W.M. Jones
7a534669ae Update translations from Zanata (RHBZ#1787301).
This is before we move to Weblate.  See:
https://bugzilla.redhat.com/show_bug.cgi?id=1787301
2020-03-06 20:08:32 +00:00
Richard W.M. Jones
d107f12ac9 common: Update submodule to latest. 2020-03-06 19:41:02 +00:00
Richard W.M. Jones
0e17236d7d Update copyright dates to 2020. 2020-03-06 19:32:32 +00:00
Richard W.M. Jones
77f8018f6a Update gnulib to latest. 2020-03-06 19:03:03 +00:00
Richard W.M. Jones
18c3f40c60 appliance: Pass root=UUID=<uuid> instead of appliance device name (RHBZ#1804207).
Appliance device names are not reliable since the kernel no longer
enumerates virtio-scsi devices serially.  Instead get the UUID of the
appliance and pass this as the parameter.

Note this requires supermin >= 5.1.18 (from around July 2017).
2020-03-06 19:03:03 +00:00
Richard W.M. Jones
a06262e199 daemon: Print device names when they are translated.
This helps to debug problems with the new device name translation
code.  We can think about removing this later when the code is known
to work well.
2020-03-06 19:03:03 +00:00
Richard W.M. Jones
bca9b94fc5 daemon: Translate device names if Linux device ordering is unstable (RHBZ#1804207).
Linux from around 5.6 now enumerates individual disks in any order
(whereas previously it enumerated only drivers in parallel).  This
means that /dev/sdX ordering is no longer stable - in particular we
cannot be sure that /dev/sda inside the guest is the first disk that
was attached to the appliance, /dev/sdb the second disk and so on.

However we can still use SCSI PCI device numbering as found in
/dev/disk/by-path.  Use this to translate device names in and out of
the appliance.

Thanks: Vitaly Kuznetsov, Paolo Bonzini, Dan Berrangé.
2020-03-06 19:03:03 +00:00
Richard W.M. Jones
92fd5d5d40 lib: Autodetect backing format and specify it explicitly.
In the guestfs_disk_create API we have traditionally allowed you to
set backingfile without setting backingformat.  The meaning of this is
to let qemu autodetect the backing format when opening the overlay
disk.

However libvirt >= 6.0 refuses to even pass such disks to qemu (see
https://bugzilla.redhat.com/show_bug.cgi?id=1798148).

For this reason, move the autodetection earlier and make it explicit.
We now autodetect the format of the backing disk at the time of
creation of the overlay, and set that as the backing format in the
overlay disk itself, allowing libvirt to open the disk later.
2020-03-06 19:03:03 +00:00
Richard W.M. Jones
4e90febbaa RHEL 7: python: Check for _Py_IsFinalizing.
This symbol is not present in Python 2.7 or 3.6.  It's not really
necessary to call this, it just avoids a crash in certain corner cases
when the interpreter is shutting down.  So make the call conditional
on the function existing.

Fixes commit e6f9e0b0f6.
2020-03-06 18:59:52 +00:00
Richard W.M. Jones
6ff1055f40 daemon: 9p: modprobe 9pnet_virtio before 9pfs operations.
Recent Linux kernels seem to require this, for unclear reasons.
2020-03-06 14:50:37 +00:00
Richard W.M. Jones
0eb8d428a2 lib: Fix leak of XPath objects.
These are two unrelated leaks of XPath objects, both found by valgrind.

Fixes commit 9484136fd0
and commit 94843f155a.
2020-03-06 13:10:10 +00:00
Richard W.M. Jones
55401b3f89 valgrind: Add further suppressions for OCaml 4.10.
See also:
c260c25cf0
2020-03-06 12:24:48 +00:00
Richard W.M. Jones
3cea2cfe04 lib: Move guestfs_device_index impl from daemon to library.
This function doesn't work reliably with the proposed change to device
name translation.  The reason is that strings returned by
Devsparts.list_devices contained translated names, so their indexes
did not correspond to the untranslated names used outside the
appliance..

We can avoid this and make the function much simpler and faster by
implementing it on the library side instead.
2020-03-05 13:18:27 +00:00
Richard W.M. Jones
eb17229c3e tests/disks: Don't segfault if guestfs_list_devices returns an error.
Although it's highly unlikely in normal use, while testing device name
translation patches it did happen and caused the test to segfault
instead of exiting with an error.
2020-03-05 12:08:35 +00:00
Richard W.M. Jones
2639de38c1 todo: Remove virt-rescue suggestion which has been done. 2020-03-05 12:02:14 +00:00
Martin Kletzander
8339f766d7 Update the 5 year logo to 10 year logo
Already outdated, but rounded ;)

I literally just opened the 5yrs logo, changed the text and then done:

  inkscape -z -o logo/fish-10yrs.{png,svg}
  cp {logo,website}/fish-10yrs.svg

and then updated the rest of the files.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2020-03-05 10:38:41 +01:00
Pino Toscano
b6bead0097 filesystems: fix size reporting for filesystems
The current way to get the size of a filesystem is to query the size in
bytes of the device. However, this gives the whole size of the device
where a filesystem is stored, and it does not consider the actual size
for which the filesystem is configured (e.g. in case it was shrunk).
A simple reproducer for this is:
$ guestfish -N test.img=fs:ext4:2G resize2fs-size /dev/sda1 1073741824

As result, try to mount the filesystem, and get its actual statistics to
determine its full size. In case mounting fails, fall back to the
previous method, which is still a good value in the majority of the
cases.

Thanks to: Erik Skultety.
2020-02-27 10:25:54 +01:00
Richard W.M. Jones
1e180cb9fd Update common submodule to latest. 2020-02-26 09:48:45 +00:00
Nikolay Ivanets
d9b4e3086e virt-make-fs: add '--blocksize' option support
This patch adds '--blocksize' command line option for virt-make-fs
tool.  This option allows specifying disk sector size as described in
'guestfs_add_drive_opts' libguestfs API.
2020-02-24 20:48:33 +00:00
Daniel P. Berrangé
7db041a660 docs: fix instructions for building from git
On current Fedora releases the ocaml modules will fail to
link unless CFLAGS contains -fPIC.

The autogen.sh script only updates the 'gnulib' submodule,
and so the build will fail due to the missing 'common'
submodule. This needs to be manually initialized at checkout.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-02-24 13:25:59 +00:00
Martin Kletzander
c7d7b25524 mlcustomize: Trim whitespaces from commands read from file (RHBZ#1351000)
The first split does not care about the whole string, it is just trying to get
the command name in front, so triml is just right.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2020-02-24 13:14:46 +01:00
Richard W.M. Jones
ab4e4af090 Update common submodule. 2020-02-24 11:12:10 +00:00
Csaba Henk
83474887ed ruby: change value of 'readonly' drive toption to Boolean in doc/example/test
Seeing `g.add_drive_opt :readonly => 1` allows one to imply
that ensuring writable access to drive should happen via
`g.add_drive_opt :readonly => 0`. However, the passed option
value gets passed down to C according to Ruby Boolean semantics,
that is, any value apart from `false` and `nil` will be true
(see RTEST in Ruby C API).

So its more idiomatic and provides a better hint if we use
`g.add_drive_opt :readonly => true` in Ruby samples.
2020-02-19 18:27:02 +00:00
Richard W.M. Jones
b68a67e1a9 Revert "golang: Don't run launch test if appliance has not been built."
This causes a strange error with modern golang:

  go: parsing $GOFLAGS: non-flag "appliance"

This reverts commit d57d8f22de.
2020-02-19 18:24:51 +00:00
Csaba Henk
95244fd2ca golang: make API idiomatic so that functions return (<val>, error)
Go API functions returned (<val>, *GuestfsError) that made
code like this fail to build:

    n, err := os.Stdin.Read(buf)
    if err != nil {
        log.Fatal(err)
    }
    n, err = g.Pwrite_device(dev, buf[:n], off)
    ...

As err should be of error (interface) type as of the stdlib call,
and should be of *GuestfsError type as of the libguestfs call.

The concrete error value that libguestfs functions return can be
a *GuestfsError, but the function signature should have (<val>, error)
as return value.
2020-02-19 18:12:15 +00:00
Nikolay Ivanets
c509420be7 virt-get-kernel: add '--blocksize' option support
This patch adds '--blocksize' command line option for virt-get-kernel
tool.  This option allows specifying disk sector size as described in
'guestfs_add_drive_opts' libguestfs API.
2020-02-17 18:04:11 +00:00
Richard W.M. Jones
e6764a5415 appliance: Add ntfs-3g-system-compression (RHBZ#1703463).
This package in Fedora enables optional support for Windows 10
"CompactOS" (file-level compression), read-only, which is sufficient
for inspecting Windows guests and doing certain types of modifications
to them.  Virt-v2v appears to work, but it may be that anything that
involves modifying a compressed file might not work.

I couldn't find the equivalent package in Debian or SUSE.  It's
available in Arch AUR although I didn't verify that part of the change
actually works there (but should be safe because supermin ignores
packages that are not known about on the target system).
2020-02-17 12:38:27 +00:00
Nikolay Ivanets
6b6bb44ebc tools: add '--blocksize' option for C-based tools
This patch adds '--blocksize' command line option for guestfish and
other C-based tools.  This option allows specifying disk sector size.
2020-02-17 12:32:03 +00:00
Nikolay Ivanets
94843f155a lib: add support for disks with 4096 bytes sector size
Nowadays there are hard drives and operating systems which support
"4K native" sector size.  In this mode physical and logical block size
exposed to the operating system is equal to 4096 bytes.

GPT partition table (as a known example) being created in this mode will
place GPT header at LBA1 which is 4096 bytes.  libguetfs is unable to
recognize partition table on such physical block devices or disk images.
The reason is that libguestfs appliance will look for a GPT header at
LBA1 which is seen at 512 byte offset.

In order to fix the issue we need a way to provide correct logical block
size for attached disks.  Fortunately QEMU and libvirt already provides
a way to specify physical/logical block size per disk basis.

After discussion in a mailing list we agreed that physical block size is
rarely used and is not so important.  Thus both physical and logical
block size will be set to the same value.

In this patch one more optional parameter 'blocksize' is added
to add_drive_opts API method.  Valid values are 512 and 4096.

add_drive_scratch has the same optional parameter for a consistency and
testing purpose.

add-domain and add_libvirt_dom will pass logical_block_size value from
libvirt XML to add_drive_opts method.
2020-02-11 15:20:09 +00:00
Richard W.M. Jones
815eab8a66 tests: Use explicit backing format for all backing disks.
Libvirt 6.0 now requires that every disk in the backing chain has an
explicit backing format.  For example this will be rejected by
libvirt:

  qemu-img create -f qcow2 -b backing-disk disk.qcow2

with the error:

  Original error from libvirt: Requested operation is not valid:
  format of backing image 'backing-disk' of image 'disk.qcow2' was not
  specified in the image metadata (See
  https://libvirt.org/kbase/backing_chains.html for troubleshooting)
  [code=55 int1=-1]

Instead you have to use the -F option to specify the format, eg:

  qemu-img create -f qcow2 -b backing-disk -F raw disk.qcow2
2020-02-06 16:06:19 +00:00
Daria Phoebe Brashear
56834875b2 properly initialize error_data_lock_list before use
when a handle is allocated, the error_data_list_lock must be initialized
2020-02-06 13:23:31 +00:00
Richard W.M. Jones
d6fcf519f2 builder: Fix const correctness for OCaml 4.10.
String_val now returns a const char *.
2020-02-06 10:33:39 +00:00
Richard W.M. Jones
9f3148c791 ocaml: Use caml_alloc_initialized_string instead of memcpy.
See this commit in libguestfs-common:
398dc56a6c
2020-02-06 10:32:08 +00:00
Richard W.M. Jones
378b49152d m4: ocaml: Move definition of HIVEX_OPEN_UNSAFE_FLAG closer to test.
Minor code cleanup, no change in semantics.
2020-02-06 10:28:34 +00:00
Richard W.M. Jones
4e199494c4 cat: Fix GCC 10 warning.
I believe this warning is bogus, but simply initializing the local
variable is enough to avoid it.

log.c: In function 'do_log':
log.c:390:7: error: 'comm_len' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  390 |       printf (" %.*s", (int) comm_len, comm);
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2020-02-06 10:28:34 +00:00
Pino Toscano
b3ef101a0f daemon: fix/enhance error reporting of Augeas exceptions
The current code was broken, as the field 1 of the exception value is
the error code (int), not an error string, and thus it would have
crashed.  This did not happen in practice, as all the usage of
ocaml-augeas were only in the inspection code with ad-hoc exception
catching blocks.

Other than fixing the aforementioned issue, enhance the error reporting
to be as close as possible to what the current AUGEAS_ERROR() macro
does: error message, error minor message (if available), error details
(if available).
2020-01-27 14:53:35 +01:00
Richard W.M. Jones
a883a2f0c9 Update BUGS and PO files. 2020-01-22 13:07:08 +00:00
Richard W.M. Jones
d4a1c3a778 build: Add build-aux/config.rpath from gettext.
This is somehow required after updating gnulib.  I lack the energy to
find out exactly why, but this fixes it.
2020-01-22 13:07:01 +00:00
Richard W.M. Jones
538f728d5f Update gnulib. 2020-01-22 13:03:03 +00:00
Richard W.M. Jones
f7bb3eef19 Update common submodule. 2020-01-22 13:03:03 +00:00
Richard W.M. Jones
bd4d9264e5 docs: Update release notes in preparation for 1.42 release. 2020-01-22 13:03:03 +00:00
Richard W.M. Jones
54ccd4fee9 docs: Document that Python 2.7 or above is now required.
Updates commit 444750bfd1.
2020-01-22 10:45:37 +00:00
Pino Toscano
a754cd4307 launch: libvirt: use machine type when querying for domcaps
On some architectures a certain machine type is used, so use it when
querying the libvirt domain capabilities.
2020-01-20 13:00:12 +01:00
Pino Toscano
e636e64d34 lib: uefi: use the efi libvirt firmware if available
In case libvirt supports the firmware autoselection and there is an EFI
firmware available, use it directly instead of handling the firmware
manually.
2020-01-20 13:00:12 +01:00
Pino Toscano
029901113c lib: allow to use libvirt firmware autoselection
Enhance the UEFI firmware lookup function with the information on the
libvirt firmware autoselection, allowing it to return a value to use for
the appliance.

At the moment no firmware is selected this way, so there is no behaviour
change.
2020-01-20 13:00:06 +01:00
Pino Toscano
777a21b16b lib: uefi: reset out parameters earlier
Make sure they are always reset, no matter the code branches later on.

This is mostly code motion.
2020-01-20 13:00:06 +01:00
Pino Toscano
9484136fd0 launch: libvirt: parse firmware autoselection
Parse from the domain capabilities whether libvirt supports the
autoselection of firmware, and which values are supported.
2020-01-20 13:00:06 +01:00
Pino Toscano
5d8cca738e build: define HAVE_PYCODESTYLE in all the cases
Fixes commit cad3ea9e74 in case Python is
disabled, or not available.
2020-01-16 11:02:25 +01:00
Richard W.M. Jones
711fab172c ocaml: Fix test for -runtime-variant _pic.
This fails with Fedora 32, and possibly earlier versions:

  checking if OCaml ‘-runtime-variant _pic’ works... no

The reason is:

  $ ocamlc -runtime-variant _pic test.ml -o test
  File "test.ml", line 1:
  Error: Cannot find file camlheader_pic

which may even be a packaging error in the Fedora package.  However it
makes no sense to test the bytecode compiler since we don't use it on
any architecture we care about and bytecode doesn't even contain a
linked runtime.  Changing the test to use ocamlopt instead of ocamlc
fixes the problem.
2020-01-15 12:52:29 +00:00
Pino Toscano
cad3ea9e74 python: add a pycodestyle test
Look for pycodestyle, and use it to check all the Python sources (tests
and auxiliary scripts included) of the Python bindings.
2020-01-14 16:21:22 +01:00
Pino Toscano
da4c7f9112 python: skip line length check in license line
Properly mark the long line with the license classifier in setup.py:
the classifier is long on its own, and changing the code to stay within
79 characters would result in worse code.
2020-01-14 16:21:22 +01:00
Pino Toscano
92759efbf5 python: improve errors in inspect_vm example
When validating user input, print an error message and exit, instead of
either asserting or raising a non-existing exception.
2020-01-14 16:21:22 +01:00
Pino Toscano
7d0f8e1b22 python: tests: remove unused imports
No functional changes.
2020-01-14 16:21:22 +01:00
Pino Toscano
4719cca7f5 python: tests: improve variable naming
Use a slightly more descriptive name, as also pointed out by
pycodestyle.

No functional changes.
2020-01-14 16:21:22 +01:00
Pino Toscano
6d0e9531c8 python: tests: catch specific exception
When trying to import libvirt, catch the specific exception that is
raised when an importing fails.
2020-01-14 16:21:22 +01:00
Pino Toscano
0703ec9c8c python: PEP 8: adapt whitespaces in lines
Fix continuation indentation, and whitespaces around operators.

This is just code reformatting, with no behaviour changes; no content
changed beside whitespaces, so "git diff -w" gives an empty diff.
2020-01-14 16:21:22 +01:00
Pino Toscano
df3e693b1b python: PEP 8: adapt empty lines
Add or remove empty lines to match the needed ones around
blocks/functions/etc.

Adapt the generation of guestfs.py to emit the separating empty line
before adding a new function/alias, rather than after it.

This is just formatting, no behaviour changes.
2020-01-14 16:21:22 +01:00
Pino Toscano
40251e4b3c python: replace guestfs_int_py_fromstringsize in Py2 branches
In Python 2 code branches use PyString_FromStringAndSize directly
instead of the guestfs_int_py_fromstringsize wrapper (which calls
PyString_FromStringAndSize anyway on Python < 3).
2020-01-09 17:49:16 +01:00
Pino Toscano
a68a0298b5 python: remove compile time check for PyString_AsString
The PyString API is specific to Python < 3, replaced by PyBytes and
PyUnicode in Python 3+; hence, drop the compile time check, and use the
right API depending on the Python version.
2020-01-09 17:45:26 +01:00
Pino Toscano
c3728416fb python: assume support for Capsules
They were introduced in Python 2.7 and 3.1, so we can assume they exist
(as Python 2.7 is the minimum version required, and 3.0 is long gone).
2020-01-09 17:29:15 +01:00
Pino Toscano
444750bfd1 python: drop code for Python < 2.5
Python >= 2.7 is required.
2020-01-09 17:22:16 +01:00
Pino Toscano
d8cb64dbe7 build: enforce a minimum Python version
In case the Python bindings are enabled, enforce a minimum version.
Set this minimum version to 2.7, as it has been de-facto for a while
now.
2020-01-09 17:15:20 +01:00
Pino Toscano
2c4aec6dcf build: update miscellaneous files
C_SOURCE_FILES
POTFILES

Followup of commit cb0edd4354.
2020-01-09 15:47:56 +01:00
Pino Toscano
eb43478f83 inspect: avoid returning "unknownX.Y" for unknown Linux distros
If it is not possible to detect the distribution of a Linux OS, do not
propose "unknownX.Y" (where X is the major version number, and Y the
minor) as short osinfo ID. Just return "unknown" instead.
2020-01-09 14:57:59 +01:00
Pino Toscano
cb0edd4354 build: use split stringlist functions from common/utils
The OCaml and Python bindings directly use the utils.c source in
common/utils, mostly for guestfs_int_free_string_list.  That source
contained also functions using gnulib functions, however without
linking to gnulib.  When building with default build flags (e.g. without
as-needed mode), the gnulib symbols cannot be resolved, leading to
unusable OCaml and Python libraries.

As solution, update the common submodule to get the split of the split
of the stringlist functions in common/utils, and adapt the OCaml and
Python bindings:
- both now use stringlists-utils.c instead of utils.c
- fix the Python distutils setup to include only the sources really
  needed
2020-01-09 14:57:38 +01:00
Pino Toscano
e789a070de python: remove also __pycache__ directories on clean 2019-12-19 15:34:37 +01:00
Pino Toscano
a420e535d5 daemon: reorder internal static libs to fix linking
Move the interal static libraries as the last items in the list of
libraries of guestfsd, to make sure their symbols are used for all the
other libraries.  This is because GCC resolves the symbols looking at
the arguments from the beginning to the end of the command line.
This currently does not cause failures, however it "just works" because
of the tricky situation set up.

The situation is the following:

1) common/utils contains few utility sources: one of them is utils.c,
which contains various functions -- for example
guestfs_int_free_string_list and guestfs_int_drive_name --, it is built
as utils.o, and bundled in the static library libutils.a

2) common/mlutils builds a OCaml library with bindings for some utility
functions in libutils.a, in particular guestfs_int_drive_name (but not
guestfs_int_free_string_list); there are two versions of this library,
one OCaml library (dllmlcutils.so) that links with libutils.a, and one
static library (libmlcutils.a), which cannot specify the libraries it
links to (as it is static)

3) when the daemon is linked, the command line was the following
(simplified):
  $ gcc [...] -o guestfsd guestfsd-9p.o other_daemon_object.o [...] \
      ../common/utils/.libs/libutils.a [...] -lmlcutils [...]
Some of the objects of the daemon itself use
guestfs_int_free_string_list, and thus the compiler opens libutils.a
(it is after the objects in the command line) and picks utils.o, which
contains also guestfs_int_drive_name (not used directly in the daemon);
when linking later on with libmlcutils.a, the symbols for this static
library (like guestfs_int_drive_name) are already resolved, and thus
all the symbols are resolved, and the linking succeeds

This fragile situation can be easily broken by moving e.g.
guestfs_int_drive_name out of common/utils/utils.c to a new source (say
utils2.c) still built as part of libutils.a: since nothing before
-lmlcutils actually needs to pick utils2.o from libutils.a for symbols,
then GCC will not be able to resolve all the symbols in libmlcutils.a.

As solution, move libutils.a (and other internal static libraries) as
last libraries to link guestfsd to: this way, GCC knows where to find
all the symbols needed by all the objects and libraries specified in
the command line.
2019-12-19 13:10:41 +01:00
Pino Toscano
d8540adffb inspect: document OpenMandriva Lx as detected distro
Also extend the virt-inspector RNG schema to allow it.

Followup of commit a4ef6716b4.
2019-12-18 13:14:59 +01:00
Pino Toscano
1cc8293935 po: reduce the list of extracted sources
Prune from the list of sources where to extract messages various sources
with no messages:
- .pl and .pm files, as they do not contain messages: almost all the
  .pl files are tests, and the only .pm file is the Perl Sys::Guestfs
  module, which wraps the XS extension
- dummy.c sources; they are empty sources used to build OCaml-only
  targets using automake
- gperf generated sources
- C/OCaml tests
2019-12-18 11:06:40 +01:00
Pino Toscano
98700b6d8c docs: exclude dummy.c sources
They are empty sources used to build OCaml-only targets using automake,
so there is no documentation to extract.
2019-12-18 11:01:58 +01:00
Pino Toscano
af3b8624b7 build: exclude common/mlv2v from distcheck
It is part of the common submodule but not used in libguestfs, so it is
not included in distribution tarballs.
2019-12-17 16:31:09 +01:00
Pino Toscano
4cd801dcff build: fix make implicit dependencies on ml/mli files
As proposed in the Debian bug #946594 [1], the implicit .cmi/.cmo/.cmx
dependencies are tied to files in the source directory only, and thus
they break when either the .ml or the .mli files are in the build
directory. Since there is already VPATH set up by automake, rely on it
to locate the right source.

[1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=946594#36

Solution proposed by Vincent Danjean, thanks!

This reverts commit 802c5d2055 in this
file.
2019-12-17 15:38:00 +01:00
Pino Toscano
78a18b20e1 tests: fix srcdir references
Make sure to properly reference to files in the source directory.
2019-12-17 15:33:21 +01:00
Pino Toscano
dd99b6f68d inspector: ship the actual test script
It is no more generated by configure now; fixes
commit 68f5c27ada.
2019-12-17 12:28:02 +01:00
Pino Toscano
957549cd2d Remove mlaugeas and mllibvirt leftovers
Update according to the removal of the embedded copies of augeas-ocaml,
and libvirt-ocaml from the common submodule.
2019-12-16 18:55:01 +01:00
Pino Toscano
3c8e7e41db Update common to latest 2019-12-16 18:46:44 +01:00
Pino Toscano
fb7e21be96 build: switch embedded copy of ocaml-augeas
Use the newer copy shipped locally as bundled, instead of the one in
the common submodule, as the latter copy will go away soon.
2019-12-16 18:33:49 +01:00
Pino Toscano
c93cc14b9f Bundle the ocaml-augeas library for use by libguestfs
Add a copy of the libvirt-ocaml library, currently available at:
  http://git.annexia.org/?p=ocaml-augeas.git;a=summary
This is a snapshot at commit 1cf5aef99b26a46529ca797547c0b49627fffe78,
which has all the features we need (and that builds fine).
It is expected to stay synchronized with upstream, until there is a new
upstream release, and it will be widespread enough.
2019-12-16 18:30:08 +01:00
Pino Toscano
68f5c27ada tests: switch to config.sh for xmllint
Instead of generating test scripts from configure with the path of
xmllint, export that path in config.sh, so the tests can be static
scripts again.
2019-12-16 11:19:00 +01:00
Pino Toscano
54a9d04f72 build: add an empty config.sh
This helper script will contain variables with results of configure
checks, so other scripts can source it.

Source it automatically in test-functions.sh, so every test can already
make use of it.
2019-12-16 10:48:14 +01:00
Pino Toscano
c9bd101383 Update common to latest 2019-12-13 16:07:51 +01:00
Pino Toscano
062e1bd26e rust: fix list of generator-built files
src/lib.rs is not created by the generator, while src/guestfs.rs is.
2019-12-12 18:01:32 +01:00
Pino Toscano
d44ef6aa50 rust: fix path to lib.rs
It is a source file, so explicitly look for it in the source directory.
2019-12-12 18:01:32 +01:00
Pino Toscano
21ef7adb37 perl: fix path to Build.PL
It is a generated file, so it is in the build directory.
2019-12-12 18:01:32 +01:00
Pino Toscano
7ced2b9354 generator: do not generate mlv2v files when not needed
mlv2v is not shipped with libguestfs, so do not try to generate the
files for it in case generator is invoked on a release tarball.
2019-12-12 18:01:32 +01:00
Pino Toscano
e17f9f43fd docs: fix out-of-source documentation build
Invoke make-internal-documentation.pl by its path in the source
directory.

Also, depend on it to regenerate the documentation in case
make-internal-documentation.pl changes.
2019-12-12 18:01:32 +01:00
Pino Toscano
323909d92e build: stop shipping files generated by configure
They will be generated by configure.
2019-12-12 18:01:32 +01:00
Richard W.M. Jones
5469db383a builder: templates: Build RHEL 8.1 image internally. 2019-12-12 15:22:50 +00:00
Pino Toscano
ebcd915997 docs: remove utils files
They were moved to a different repository.

Follwup of commit 58ab39ba34.
2019-12-12 13:54:36 +01:00
Pino Toscano
c37673eaea tests: fix podcheck tests
Pass to the various podcheck invocations the paths with POD files that
are included.

Followup of commit 46e59e9535.
2019-12-11 14:24:01 +01:00
Pino Toscano
b8f9bb3092 podcheck: __INCLUDE:file.pod__ and __VERBATIM:file.txt__ in POD files.
Make sure the pod checker script can deal with the newer additions of
podwrapper.pl.

Followup of commit 46e59e9535.
2019-12-11 14:20:37 +01:00
Pino Toscano
8bd80847fe inspect: correct osinfo ID for CentOS >= 8
CentOS 8 is represented with a simpler "centos8" osinfo ID.
2019-12-11 13:35:30 +01:00
Richard W.M. Jones
b6e5abd7e4 Update common to latest.
Resynch with upstream ocaml-augeas so libguestfs can be built with
OCaml 4.09.0.
2019-12-11 11:43:39 +00:00
Pino Toscano
4aa4edf972 ocaml: add handling for errno ENOSPC 2019-11-29 13:16:32 +01:00
Pino Toscano
355bed63f4 tests: test --key for a real guest (with inspection)
Test both the decryption by device name, and UUID.
2019-11-29 13:03:20 +01:00
Pino Toscano
206ce8bbf1 New API: luks_uuid
Return the UUID of a LUKS device.
2019-11-29 12:04:55 +01:00
Richard W.M. Jones
58ab39ba34 Remove boot and qemu analysis tools into a separate project.
These have now moved here:
https://github.com/libguestfs/libguestfs-analysis-tools

This commit removes them and updates guestfs-performance(1) to point
to the new location.
2019-11-28 15:37:31 +00:00
Richard W.M. Jones
8ba0457e9e options: Update documentation for --key SELECTOR.
Use the common/options/key-option.pod fragment to document the --key
option and selector instead of duplicating the same documentation
everywhere.
2019-11-28 13:28:49 +00:00
Richard W.M. Jones
152ff05ae0 fish: Update documentation to use new __INSERT:...___ directive. 2019-11-28 13:28:49 +00:00
Richard W.M. Jones
46e59e9535 podwrapper: __INCLUDE:file.pod__ and __VERBATIM:file.txt__ in POD files.
The current method of adding multiple --insert or --verbatim
parameters to the podwrapper command is not very easy to use because
it involves modifying the Makefile.am in every place where this is
used, plus under po-docs/$language/Makefile.am.  It's better if the
POD file itself can do the inclusion.

This enhances support so that the special sequences

  __INCLUDE:file.pod__

or

  __VERBATIM:file.txt__

are treated as file inclusion.

The filename must be a plain file and is searched along a path
(supplied by the optional podwrapper --path parameter).  The purpose
of the path is to allow translations to happen more easily.  For
example we can include a particular POD fragment from common/options/
for the English version, but copy the translated file to
po-docs/$language/ for every translated version.
2019-11-28 13:28:49 +00:00
Pino Toscano
08481e05d0 build: ignore unused submodules
Do not build the mlv2v, and mllibvirt submodules, as they are not used.
2019-11-28 13:09:21 +01:00
Pino Toscano
72d83cc6eb build: remove unused gnulib modules
Remove gnulib modules that provide stuff clearly not used within
libguestfs (library, daemon, and C tools).  Among directly and
indirectly modules used previous (and now no more), they are:

  cycle-check
  d-ino
  dev-ino
  dup3
  dup3-tests
  fcntl-safer
  fcntl-safer-tests
  fdopendir
  fdopendir-tests
  filevercmp
  filevercmp-tests
  ftell
  ftell-tests
  ftello
  ftello-tests
  fts
  getaddrinfo
  getaddrinfo-tests
  getcwd
  getcwd-tests
  gnu-make
  hostent
  i-ring
  i-ring-tests
  iconv
  iconv-tests
  inet_ntop
  inet_ntop-tests
  isatty
  isatty-tests
  openat-safer
  openat-safer-tests
  opendirat
  ptsname_r
  ptsname_r-tests
  read-file
  read-file-tests
  rewinddir
  servent
  ttyname_r
  ttyname_r-tests
  xgetcwd

Some of the removed modules are still used pulled indirectly as
dependency of other modules.  There should be no behaviour change on
recent Linux distros, although older distros were not tested (adding
a module back is easy, anyway).

Remove accordingly unused automake variables, and ignored files.
2019-11-28 13:09:21 +01:00
Pino Toscano
86d5ddc296 daemon: remove unused include 2019-11-28 13:09:21 +01:00
Pino Toscano
b87e20ccf1 daemon: switch from read_file to read_whole_file
Since we have already an helper to read a file, use it instead of the
gnulib function.
2019-11-28 13:09:21 +01:00
Pino Toscano
73a58394a9 daemon: move read_whole_file to common utils
Move the read_whole_file function to the common utilities of the daemon,
so other parts can use it.  For this purpose, add an out parameter to
get the amount of bytes read.

Except from the parameter addition, this should be just refactoring.
2019-11-28 13:09:21 +01:00
Pino Toscano
a2b37a495c tests: switch away from xgetcwd
xgetcwd is used only in a test, so there is no need to pull a gnulib
module just for it.

Switch to use getcwd directly with a fixed buffer: the tests would have
failed with paths longer than 992 characters, as the libvirt_uri would
have been truncated.  Since there were no reports of issues, we can
assume that the current working directory will fit in 1024 characters;
adapt the size of libvirt_uri accordingly.
2019-11-28 13:09:21 +01:00
Richard W.M. Jones
38ff3354ea tests: luks: Test the --key options.
Previously untested, and as always happens they were quite buggy.
2019-11-28 10:13:57 +00:00
Richard W.M. Jones
a7ed7752cf Version 1.41.8. 2019-11-19 16:18:03 +00:00
Richard W.M. Jones
31272305fa po-docs: Remove virt-v2v man pages.
Fixes commit 85c99edec1.
2019-11-19 15:56:03 +00:00
Richard W.M. Jones
43e44477ec po-docs: Split language release notes by release too.
Fixes commit e9eaf4d889.
2019-11-19 15:49:53 +00:00
Sam Eiderman
e6f9e0b0f6 python: Don't call Python functions if Python interpreter has already gone.
If you've registered a callback in Python and the handle is implicitly
closed when the Python interpreter exits, then it can be that the
following happens:

 - Python interpreter is finalized.
 - guestfs_close is called
 - callback is invoked (eg. close event or to display a debug message)
 - Python code runs from the callback wrapper

This cause a segfault on shutdown.  Catch this case and stop the
callback from running (we lose the event but given the above sequence
of events there's not much we can do about it).

See:
https://bugzilla.redhat.com/show_bug.cgi?id=1773520#c7
2019-11-18 15:35:17 +00:00
Sam Eiderman
7757eb8d0c Python: Fix GIL usage in guestfs_int_py_event_callback_wrapper (RHBZ#1773520)
All Py_* functions should be protected by the GIL.
Otherwise internal python data structures can get corrupted.

Move PyGILState_Ensure to the beginning of the block and
PyGILState_Release to the bottom.

Signed-off-by: Sam Eiderman <sameid@google.com>
2019-11-18 15:30:01 +00:00
Richard W.M. Jones
62c36fa297 Update common to latest. 2019-11-16 08:38:51 +00:00
Richard W.M. Jones
bd42180006 Version 1.41.7. 2019-11-13 12:49:55 +00:00
Richard W.M. Jones
85c99edec1 v2v: Remove virt-v2v.
It has moved to a new repository:
https://github.com/libguestfs/virt-v2v
2019-11-13 12:49:55 +00:00
Richard W.M. Jones
ededdce3c1 autogen: Fix detection of gnulib submodule status.
Don't require a rebuild every time the common module changes status.
2019-11-13 12:49:54 +00:00
Richard W.M. Jones
e9eaf4d889 docs: Split release notes by release.
See analogous change in nbdkit for the rationale:

98395d6f7a
2019-11-13 12:49:54 +00:00
Richard W.M. Jones
7c05fc91dc website: Update builder index with fedora-31.
Updates commit 9c693ca0e8.
2019-11-12 12:28:36 +00:00
Richard W.M. Jones
9c693ca0e8 builder: templates: Add Fedora 31. 2019-11-12 09:58:46 +00:00
Richard W.M. Jones
696b1b059a common: Update to latest. 2019-10-16 14:39:31 +01:00
Richard W.M. Jones
8097dc16e7 Version 1.41.6. 2019-10-15 13:34:40 +01:00
Richard W.M. Jones
435b70f564 customize, v2v: Remove existing file before copying.
The generator creates these files with 0444 mode, so they cannot be
overwritten by a simple ‘cp’ command.  We could use ‘cp -f’ or ‘rm -f’.

Fixes commit 15394cb4dd.
2019-10-15 13:34:39 +01:00
Richard W.M. Jones
8f3210c875 Replace common/ with git submodule.
This directory contains code which is shared between libguestfs and
the tools.  It now points to a new repository:

https://github.com/libguestfs/libguestfs-common
2019-10-15 13:34:39 +01:00
Richard W.M. Jones
15394cb4dd common/{mlcustomize,mlv2v}: Add generated files to git.
With the proposed split we will only run the generator from the
libguestfs repo.  When compiling virt-v2v or the guestfs-tools we will
need certain generated files to be present already in the
libguestfs-common repo, and therefore these files must be added to
git.  Hopefully they won't change very often.
2019-10-14 19:38:36 +01:00
Richard W.M. Jones
20c2dfbe00 generator, customize, v2v: Only place generated files in libguestfs or common.
After the proposed split of the libguestfs repo, we will end up with
the following layout:

  libguestfs.git
      common -> git submodule libguestfs-common.git
      generator

  virt-v2v.git
      common -> git submodule libguestfs-common.git

  guestfs-tools.git
      common -> git submodule libguestfs-common.git

The generator will only be able to write to libguestfs directories and
the common directory/submodule.  This is mostly the case already with
only 6 exceptions:

  customize/customize-options.pod
  customize/customize-synopsis.pod
  customize/customize_cmdline.ml
  customize/customize_cmdline.mli
  v2v/uefi.ml
  v2v/uefi.mli

This commit moves these files around so they appear under common/ml*

It is somewhat unsatisfactory because it involves copying files
around, but there are some mitigating factors:

(1) Any changes now give us more freedom to develop faster and thus
clean things up in future.

(2) The v2v/uefi files ought to go away in future anyway.

This is simple code motion and should have no effect on the built
programs or tests.
2019-10-14 18:37:29 +01:00
Richard W.M. Jones
a07b9a2cda v2v: virt-v2v doesn't need to link directly with -lutils.
It is linked indirectly via mlcutils.cmxa.
2019-10-14 15:28:28 +01:00
Richard W.M. Jones
ddfec6a97d customize: Move Firstboot and SELinux_relabel modules to common/mlcustomize.
These two modules are a dependency of virt-v2v.  Since we intend to
split virt-v2v from the other OCaml virt-* programs, we cannot have a
dependency between virt-v2v and virt-customize.  Instead we must move
the modules to a common directory (common/mlcustomize) and have both
tools depending on the modules from there.

This is simple refactoring and should not affect how the programs work
or are tested.
2019-10-14 12:36:47 +01:00
Richard W.M. Jones
a1c036b4a6 .gitignore: Ignore website/download/builder/*.xz.
This makes it easier to run the slow tests by copying the virt-builder
templates into this directory.
2019-10-14 12:36:47 +01:00
Richard W.M. Jones
b85dd3dee1 v2v: Split out source and source_disks.
Remove the source.s_disks field and keep it as a separate list.

This is just refactoring.  For more about the purpose of this change:
https://www.redhat.com/archives/libguestfs/2019-October/msg00072.html
2019-10-11 16:29:57 +01:00
Richard W.M. Jones
e3a3c2fd6c v2v: Remove 4 unused parameters to output#prepare_targets.
Not used by any existing output mode, remove the parameters.
2019-10-11 16:12:41 +01:00
Richard W.M. Jones
50a4a41ef3 v2v: Don't pass full metadata to output#prepare_targets.
The existing output objects only used the s_name field so pass that
instead.  (There was one minor exception: -o libvirt adjusted an error
message based on the hypervisor field but that was simply to fix.)
2019-10-11 16:03:33 +01:00
Richard W.M. Jones
624fff6461 v2v: Pass source.s_disks to conversion fn instead of whole metadata.
Existing conversions do not use anything except the source disks, so
only pass this.

This also renames src_disks -> source_disks in a few places for
consistency.

Pure refactoring with no change in function, designed to reduce
coupling between stages.
2019-10-11 15:57:47 +01:00
Richard W.M. Jones
ee400894f9 virt-tools: Remove -Ifish from various tools.
Appears to be a copy and paste error.  At least, I cannot understand
why any of these tools would borrow source code from guestfish.
2019-10-11 15:33:51 +01:00
Tomáš Golembiovský
00b4ed312b v2v: windows: install QEMU Guest Agent MSI
Use firstboot script to install MSI with QEMU-GA from virtio-win ISO or
oVirt/RHV guest tools ISO.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2019-10-10 17:14:51 +01:00
Richard W.M. Jones
2299154dc8 Version 1.41.5. 2019-10-09 19:15:07 +01:00
Richard W.M. Jones
dfd9fac743 v2v: Copy static IP address information over for Windows guests (RHBZ#1626503).
For Linux the guest itself remembers the IP address associated with
each MAC address.  Thus it doesn't matter if the interface type
changes (ie. to virtio-net), because as long as we preserve the MAC
address the guest will use the same IP address or the same DHCP
configuration.

However on Windows this association is not maintained by MAC address.
In fact the MAC address isn't saved anywhere in the guest registry.
(It seems instead this is likely done through PCI device type and
address which we don't record at the moment and is almost impossible
to preserve.)  When a guest which doesn't use DHCP is migrated, the
guest sees the brand new virtio-net devices and doesn't know what to
do with them, and meanwhile the right static IPs are still associated
with the old and now-defunct interfaces in the registry.

We cannot collect the required information from within the guest.
However we can collect it outside the tool by some other means
(eg. using VMware Tools APIs) and present this information to virt-v2v
which then writes it into the Windows guest at firstboot time.

This commit adds the --mac ..:ip:.. sub-option which creates a
Powershell script to set network adapters at firstboot.  An option
such as:

  --mac 00:0c:29:e6:3d:9d:ip:192.168.0.89,192.168.0.1,24,192.168.0.254

approximately turns into this script:

  # Wait for the netkvm (virtio-net) driver to become active.
  $adapters = @()
  While (-Not $adapters) {
      Start-Sleep -Seconds 5
      $adapters = Get-NetAdapter -Physical |
                     Where DriverFileName -eq "netkvm.sys"
  }
  $mac_address = '00-0c-29-e6-3d-9d'
  $ifindex = (Get-NetAdapter -Physical |
                 Where MacAddress -eq $mac_address).ifIndex
  if ($ifindex) {
      New-NetIPAddress -InterfaceIndex $ifindex
                       -IPAddress '192.168.0.89'
                       -DefaultGateway '192.168.0.1'
                       -PrefixLength 24
      Set-DnsClientServerAddress -InterfaceIndex $ifindex
                       -ServerAddresses ('192.168.0.254')
  }

Thanks: Brett Thurber for diagnosing the problem and suggesting paths
towards a fix.
2019-10-08 13:32:34 +01:00
Richard W.M. Jones
e1e9b3845e v2v: windows: Add a helper function for installing Powershell firstboot scripts. 2019-10-08 13:30:05 +01:00
Richard W.M. Jones
d4840bd29f Update website/download/builder/index.
Fixes commit a3320aaa50.
2019-10-08 13:29:23 +01:00
Richard W.M. Jones
12f5e2eb90 v2v: nbdkit: Add the retry filter unconditionally if it exists.
This experimental filter can be used to work around brief
interruptions in service, such as the network going down, firewalls
timing out connections etc., without requiring virt-v2v to be rerun.
2019-10-08 13:15:10 +01:00
Richard W.M. Jones
4ad6e184a9 v2v: Implement SSH password authentication for Xen and VMX over SSH.
For example:
$ virt-v2v -i vmx -it ssh -ip /tmp/passwd \
    'ssh://root@esxi/vmfs/volumes/datastore1/Windows/Windows.vmx' -o null
2019-10-08 13:15:10 +01:00
Richard W.M. Jones
735529b393 v2v: Implement the --bandwidth* options to control network bandwidth.
For input methods which use nbdkit, we can cheaply add
nbdkit-rate-filter to control input-side network bandwidth.  These
options control that filter.  We can choose to set the bandwidth
statically and optionally change it dynamically:

  --bandwidth 10M
    # static bandwidth of 10 Mbps, no dynamic adjustment possible

  --bandwidth 5M --bandwidth-file /tmp/bw
    # initial static bandwidth of 5 Mbps, adjustable by writing to /tmp/bw

  --bandwidth-file /tmp/bw
    # no initial bandwidth cap, can be added later by writing to /tmp/bw

It only makes sense to control the input side since virt-v2v writes a
lot less data than it reads.
2019-10-08 13:15:10 +01:00
Richard W.M. Jones
0aa3545e4d v2v: vCenter: Replace qemu block curl driver with nbdkit-curl-plugin.
Because of the self-configuring readahead plugin we can entirely get
rid of input#adjust_overlay_parameters, which is definitely a good
thing.
2019-10-08 13:15:10 +01:00
Richard W.M. Jones
bded1ee837 v2v: -i libvirtxml: Replace qemu block curl driver with nbdkit-curl-plugin.
‘virt-v2v -i libvirtxml’ has a little-known feature where it can read
network disks over HTTP or HTTPS.  This can be used to test VMware
conversions without needing VMware, although as far as I can tell the
current test suite does not use the feature.  This commit changes this
functionality to use nbdkit-curl-plugin instead of the qemu curl
driver.

This change shouldn't affect functionality.  The readahead size is
changed from a fixed 1M buffer to using the readahead filter which is
self-configuring.

See also commit 38bf2a0f97 which
originally introduced this functionality in 2017.
2019-10-08 13:15:10 +01:00
Richard W.M. Jones
d481598067 v2v: nbdkit: Add the readahead filter unconditionally if it is available.
The readahead filter is a self-configuring filter that makes
sequential reads faster when the plugin is slow (and all of the
plugins we use here are always slow).

I observed the behaviour of the readahead filter with our qcow2
overlay when converting a guest from a vCenter source.  Even when
doing random reads, qemu issues 64K reads which happen to also be the
minimum request size of the readahead filter, so there is no extra
overhead.  When doing the sequential copy the readahead filter
performed better than qemu curl’s readahead because it scaled the
prefetched data appropriately on long contiguous stretches and then
shrunk it back to 64K around fragmented parts of the base image.
2019-10-08 13:15:10 +01:00
Richard W.M. Jones
0796092e05 v2v: nbdkit: Add a generic function to probe if filters are available.
This uses the technique described in the nbdkit-probing(1) man page.
It should work with a wide range of versions of nbdkit, and is the one
which the nbdkit developers currently recommend.
2019-10-08 13:15:10 +01:00
Richard W.M. Jones
56727f8431 v2v: nbdkit: Add support for nbdkit-curl-plugin. 2019-10-08 13:15:10 +01:00
Richard W.M. Jones
57f6c72a9d v2v: -i vmx -it ssh: Replace qemu block ssh driver with nbdkit-ssh-plugin.
One immediately advantage is we can use libvirt again.
2019-10-08 13:15:10 +01:00
Richard W.M. Jones
0977f4b909 v2v: xen: Replace qemu block ssh driver with nbdkit-ssh-plugin.
Initially this is a like-for-like replacement, but in future commits
this will allow us to implement:

 - password authentication (instead of SSH agent)

 - bandwidth throttling

 - readahead

Note this requires nbdkit >= 1.12.
2019-10-08 13:15:10 +01:00
Richard W.M. Jones
8e5930b9a8 v2v: nbdkit: Add support for nbdkit-ssh-plugin. 2019-10-08 13:15:10 +01:00
Richard W.M. Jones
ca9f904b22 v2v: Generic code for querying nbdkit version and plugin.
In forthcoming commits we will be adding support for ssh, curl and
other features that require nbdkit >= 1.12.

As a prelude to that work, add generic code for querying ‘nbdkit
--dump-config’ and ‘nbdkit plugin --dump-plugin’ and checking the
minimum version number.

This changes the minimum version from 1.1.16 to 1.2, although that was
released about a year ago and is widely available, and in any case
we're going to require 1.12 in the next commit.
2019-10-08 13:15:10 +01:00
Richard W.M. Jones
0899f876a1 v2v: Factor out the nbdkit VDDK code into a new module.
This refactoring takes the nbdkit-specific code from the ‘-it vddk’
mode and puts it into a separate module.  The idea is to reuse this
module (in future commits) to support ssh, curl and rate limiting.

This refactoring is not quite neutral because it moves some of the
prechecking into the Nbdkit.create function.  This means it will
happen a little bit later in the cycle (in input#source instead of
input#precheck - refer to the diagram in v2v/types.mli).  However it's
still almost in the same place and importantly still happens before we
start copying.
2019-10-08 13:15:10 +01:00
Tomáš Golembiovský
644a6e4637 build: define CGO_CFLAGS_ALLOW with -U option we need
cgo does not allow arbitrary CFLAGS to be used. Instead it contains a
list of flags (safelist) that are allowed to be passed to the compiler.
Sadly -U option (introduced in commit d8d8c856a1) is not among them.

See: https://github.com/golang/go/issues/23672

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2019-10-07 22:08:49 +01:00
Richard W.M. Jones
a3320aaa50 builder: templates: Add CentOS 8.0 2019-10-04 09:01:32 +01:00
Richard W.M. Jones
f7733f44c3 builder: templates: Work around for CentOS 8.0 kickstart brokenness. 2019-10-04 09:01:05 +01:00
Richard W.M. Jones
0177552375 daemon: btrfs: Fix parsing for new output from btrfs scrub.
The format changed at some point breaking our existing parsing code.
Typical example of the new format is below.

UUID:             b8604449-c7b5-4d3b-9fad-56114e8594f5
Scrub started:    Wed Oct  2 12:54:06 2019
Status:           finished
Duration:         0:00:00
\tdata_extents_scrubbed: 0
\ttree_extents_scrubbed: 16
\tdata_bytes_scrubbed: 0
\ttree_bytes_scrubbed: 262144
\tread_errors: 0
\tcsum_errors: 0
\tverify_errors: 0
\tno_csum: 0
\tcsum_discards: 0
\tsuper_errors: 0
\tmalloc_errors: 0
\tuncorrectable_errors: 0
\tunverified_errors: 0
\tcorrected_errors: 0
\tlast_physical: 253493248
2019-10-02 14:29:35 +01:00
Richard W.M. Jones
9f516b4fcc builder: templates: Increase RAM for installation to 4G on all architectures.
We thought this could solve the CentOS problem, but it did not.
However it's probably a useful change anyway.
2019-10-02 10:23:31 +01:00
Richard W.M. Jones
b8372310cc builder: templates: Add support for centos-8.0.
Unfortunately I could not get the install to work yet:
https://lists.centos.org/pipermail/centos-devel/2019-September/017813.html
2019-10-02 10:23:31 +01:00
Pino Toscano
0a5eaad7db v2v: -o rhv-upload: make -oo rhv-cafile optional
It makes little sense to require the oVirt certificate, especially when
the verification of the connection (-oo rhv-verifypeer) is disabled by
default.  The only work done with the certificate in that case is
checking that it is a valid certificate file.

Hence, make -oo rhv-cafile optional, requiring it only when
-oo rhv-verifypeer is enabled.
2019-09-27 13:56:42 +02:00
Pino Toscano
02890096d5 builder: templates: set "unassigned" hostname
By default the installer will set the hostname to what the DHCP returns,
exposing details of the machine where make-template.ml runs.

Instead, force "unassigned-hostname.unassigned-domain" as hostname, so
plays nicely with the hostname setting code in virt-customize.
2019-09-26 13:32:50 +02:00
Richard W.M. Jones
aee0f3b011 website: Update index file. 2019-09-20 10:34:45 +01:00
Richard W.M. Jones
7050f4a6a6 erlang: Avoid deprecation warnings.
According to the Erlang website:

  The old legacy erl_interface library (functions with prefix erl_) is
  deprecated as of OTP 22, and will be removed in OTP 23. This does
  not apply to the ei library. Reasonably new gcc compilers will issue
  deprecation warnings. In order to disable these warnings, define the
  macro EI_NO_DEPR_WARN.

That's a shame and probably means we will have to drop the Erlang
bindings soon unless someone ports them to this new API (stable APIs
FTW people!).  In the meantime add the flag to prevent warn-errors
about deprecation.
2019-09-20 10:34:45 +01:00
Pino Toscano
29dc045bc6 v2v: -o rhv-upload: use same tmpdir for Python scripts
Make use of the temporary directory of the rhv-upload mode also for the
Python scripts that the mode creates, instead of creating new
directories.
2019-09-20 11:14:07 +02:00
Pino Toscano
b659d044f7 v2v: add optional tmpdir parameter for Python_script
Add an optional parameter for Python_script.create, to specific the
temporary directory to use instead of creating a new one.
2019-09-20 11:11:38 +02:00
Pino Toscano
977fac2012 v2v: linux: do not install qemu-guest-agent if already installed
In case qemu-guest-agent is already installed in the guest, then do not
attempt to install it again.

Reported by Martin Kletzander.
2019-09-20 11:11:38 +02:00
Pino Toscano
1311842a64 v2v: linux: install linux tools after unconfigurations
Install the new tools after removing the old hypervisor tools.

It should not change the result of the conversion.
2019-09-20 11:11:38 +02:00
Pino Toscano
537ba8357e v2v: -o rhv-upload: add -oo rhv-disk-uuid option
This way it is possible to override the UUIDs of the uploaded disks,
instead of letting RHV generate them.

This can be useful to force certain UUIDs, and to specify the disks in
--no-copy mode (which now can be used).
2019-09-20 11:11:38 +02:00
Pino Toscano
0a9d7efb40 v2v: -o rhv-upload: check for a valid image transfer right away
Check for the INITIALIZING state of the image transfer right away,
without waiting 5 seconds even before the first time: this way, if the
transfer is already in the right state then there is no need to wait.
2019-09-20 11:11:38 +02:00
Pino Toscano
0f3686e9ed v2v: -o rhv-upload: cancel disk transfer on open failure
Make sure to cancel the trasfer in RHV in case of failure during the
open/creation of the disk in RHV, so it is automatically removed.
2019-09-20 11:11:38 +02:00
Martin Kletzander
da71714a9a build: Move po subdir after everything else except po-docs
Otherwise it complains about missing files that it has no rules for, for example
`builder/index-parser.c`.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2019-09-20 10:01:16 +01:00
Pino Toscano
27690f55ff v2v: -o rhv-upload: adapt phony ovirtsdk4 module to recent changes
Add the missing objects, methods, variables, and relations among the
various objects.

Followup/fixes commit c49aa4fe01, and
commit 8118f28b6f.
2019-09-19 12:27:23 +02:00
Richard W.M. Jones
bbf4aeaf2b builder: templates: Add centos-7.7. 2019-09-18 10:52:12 +01:00
Richard W.M. Jones
cece35e114 builder: templates: Add rhel-7.7 kickstart and virt-install command. 2019-09-18 10:52:12 +01:00
Pino Toscano
8118f28b6f v2v: -o rhv-upload: cancel disk transfer on failure
Make sure to cancel the trasfer in RHV in case of failure during the
copying of a disk: this way, the disk can be actually removed by RHV
itself.
2019-09-17 15:04:36 +02:00
Pino Toscano
145ae3db04 v2v: -o rhv-upload: remove uploaded disks on failure
In case the whole conversion fails, run a new Python script to cleanup
all the uploaded (and finalized) disks.
2019-09-17 15:04:36 +02:00
Pino Toscano
7b93ad6a32 v2v: -o rhv-upload: collect disks UUIDs right after copy
Instead of waiting for the completion of the nbdkit transfers to get the
UUIDs of the disks, use the new #disk_copied hook to do that after each
disk is copied.

This has almost no behaviour on rhv-upload, except for the --no-copy
mode:
- previously it used to hit the 5 minute timeout while waiting for the
  finalization of the first disk
- now it asserts on the different number of collected UUIDs vs the
  actual targets; at the moment there is nothing else that can be done,
  as this assumption is needed e.g. when creating the OVF file
2019-09-17 15:04:36 +02:00
Pino Toscano
74ee936505 v2v: add output#disk_copied hook
Add a simple method in the Output class to do work right after a disk
was successfully copied.
2019-09-17 15:04:36 +02:00
Pino Toscano
2b39c27b7f v2v: -o rhv-upload: tell whether a SD actually exists
If there is no DC with the specified storage domain attached to it, it
can mean that the SD does not exist.
2019-09-17 15:04:36 +02:00
Pino Toscano
c49aa4fe01 v2v: -o rhv-upload: improve lookup of specified resources (RHBZ#1612653)
Improve the way the precheck script checks for the specified resources:
- look directly for a data center with the specified storage domain
- get the storage domain object from the storage domains attached to the
  data center found
- similarly, look for the specified cluster among the ones attached to
  the data center found
When everything is found, return the UUID of the storage domain, and of
the cluster back to virt-v2v, which will store them.

Similarly, rework the createvm script to directly get the requested
cluster, instead of looking for it once again.  Also, since the UUID of
the storage domain is available in virt-v2v already, use it directly
instead of using a placeholder.

This should fix a number of issues:
- unexisting/unattached storage domains are rejected outright
- the cluster is rejected if not part of the same data center of the
  selected storage domain
- renaming the specified storage domain during the data copying will not
  cause the conversion to fail (which will still use the specified
  storage domain, no matter the new name)

Based on the hints by Daniel Erez in RHBZ#1612653.
2019-09-17 15:04:21 +02:00
Pino Toscano
cc6e2a7f9e v2v: -o rhv-upload: change precheck script to return a JSON
This way it is possible to communicate data from the precheck script
back to virt-v2v.

For now there are no results, so the resulting JSON is discarded.
2019-09-17 14:04:47 +02:00
Pino Toscano
6499fdc199 v2v: -o rhv-upload: split vmcheck out of precheck
Split the VM existance check out of the precheck script to a new vmcheck
script, and invoke that in #prepare_targets.  Invoke the precheck script
in #precheck, as now it can be run with only values of command line
options.

This does not change which checks are performed; however, an invalid
cluster name will make virt-v2v fail way earlier (even before connecting
to the source).
2019-09-17 14:03:13 +02:00
Pino Toscano
dea9636c59 Remove remaining virt-p2v bits
Remove (almost) all the remaining bits related to virt-p2v.
2019-09-10 17:52:16 +02:00
Pino Toscano
2c02adb8ba Remove virt-p2v
This removes only the tool itself, and all the bits strictly needed to
not break the build.

This is now available as separate tool in its own repository:
https://github.com/libguestfs/virt-p2v
2019-09-10 17:52:16 +02:00
Eric Blake
730642676b drives: Typo fix
Favor 'atomically' over 'atomicly'.

Signed-off-by: Eric Blake <eblake@redhat.com>
2019-09-10 16:40:17 +01:00
Daniel Erez
eeabb3fdc7 v2v: rhv-upload-plugin - improve wait logic after finalize (RHBZ#1680361)
After invoking transfer_service.finalize, check operation status by
examining DiskStatus.  This is done instead of failing after a
predefined timeout regardless the status.

Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1680361
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
Tested-by: Ilanit Stein <istein@redhat.com>
2019-09-09 17:04:18 +01:00
Chris Lamb
d58c4e79d8 Make the build reproducible
Whilst working on the Reproducible Builds effort [0] we noticed
that libnbd could not be built reproducibly.

This is due to it shipping a pod generation wrapper that
does not use/respect SOURCE_DATE_EPOCH [1] and additionally
varies the output depending on the build user's current
timezone.

(This was originally filed in Debian as #939546 [2].)

 [0] https://reproducible-builds.org/
 [1] https://reproducible-builds.org/docs/source-date-epoch/
 [2] https://bugs.debian.org/939546

Signed-off-by: Chris Lamb <lamby@debian.org>
2019-09-06 09:42:35 +01:00
Richard W.M. Jones
a0f9553d21 html: Link within all libguestfs projects. 2019-09-05 15:11:40 +01:00
Richard W.M. Jones
74ce7332db ocaml: Change calls to caml_named_value() to cope with const value* return.
In OCaml >= 4.09 the return value pointer of caml_named_value is
declared const.

Based on Pino Toscano's original patch to ocaml-augeas.
2019-09-05 09:00:14 +01:00
Nir Soffer
fcfdbc9420 v2v: Set DISKTYPE=2 in RHV and VDSM meta files (RHBZ#1746699).
Added in virt-p2v commit:

  commit e83b6f50af34ce650063ecc520bfabab400e8e73
  Author: Matthew Booth <mbooth@redhat.com>
  Date:   Fri Mar 26 09:40:20 2010 +0000

    Add export to RHEV

    Allow guests to be written to a RHEV NFS export storage domain.

    Add 'rhev' output method and -osd command-line option.
    Example command line:

     virt-v2v -f virt-v2v.conf -ic 'esx://yellow.rhev.marston/' \
              -o rhev -osd blue:/export/export RHEL3-32

    This will connect to an ESX server and write the guest 'RHEL3-32' to
    blue:/export/export, which is a pre-initialised RHEV export storage domain.
2019-09-02 21:20:27 +01:00
Richard W.M. Jones
bf5ee2fb21 Version 1.41.4. 2019-09-02 19:45:12 +01:00
Richard W.M. Jones
bbe4490795 rust: Don't add Cargo.lock to EXTRA_DIST.
It's a file generated by cargo.  If cargo is not installed then this
breaks ‘make dist’.
2019-09-02 19:28:30 +01:00
Richard W.M. Jones
ad58324c70 Version 1.41.3. 2019-09-02 12:56:12 +01:00
Richard W.M. Jones
cce016dfe3 docs: Remove p2v/ directory from generated docs files.
make[2]: *** No rule to make target '../p2v/about-authors.c', needed by 'internal-documentation.pod'.  Stop.

Since we're going to remove the whole p2v subdirectory shortly anyway,
it was simplest to ignore the whole directory.
2019-09-02 12:34:07 +01:00
Richard W.M. Jones
e8ab5b451a Version 1.41.2. 2019-09-02 12:23:28 +01:00
Richard W.M. Jones
0d0c3eb1dd docs: Remove generated file common/mllibvirt/libvirt_c.c.
Avoids this error when building from git:

make[2]: *** No rule to make target '../common/mllibvirt/libvirt_c.c', needed by 'internal-documentation.pod'.  Stop.

This file doesn't have any generated docs or gettext annotations in it
so adding it to these files is useless anyway.
2019-09-02 12:22:25 +01:00
Richard W.M. Jones
2a5ea2892e Version 1.41.1. 2019-09-02 10:12:38 +01:00
Richard W.M. Jones
3f8609434f rust: Add more source files to EXTRA_DIST.
Fixes commit 3f7ff1b068.
2019-09-02 10:01:05 +01:00
Richard W.M. Jones
ffd0b5484d Revert "rust: Add missing file to EXTRA_DIST."
This reverts commit 9a6d162852.

(This file was later removed in
commit 3f7ff1b0689408695d21b4c50384fa24b47e5e8f.)
2019-09-02 10:01:05 +01:00
Richard W.M. Jones
15d1611889 python: Ignore -Wcast-align warnings in Python 3.8 header files.
Disable this warning/error in the Python 3.8 header files:

In file included from /usr/include/python3.8/abstract.h:837,
                 from /usr/include/python3.8/Python.h:147,
                 from actions.h:31,
                 from actions-6.c:34:
/usr/include/python3.8/cpython/abstract.h: In function '_PyVectorcall_Function':
/usr/include/python3.8/cpython/abstract.h:91:11: error: cast increases required alignment of target type [-Werror=cast-align]
   91 |     ptr = (vectorcallfunc*)(((char *)callable) + offset);
      |           ^
2019-09-02 09:00:18 +01:00
Richard W.M. Jones
451e6a7b97 python: Include <Python.h> in one place.
Previously to work around some problems in Python 2 header files we
had to include <Python.h> before any other config file.

For Python 3 which is all we really care about now this is no longer
needed.  We can move the include from three files into the local
"actions.h" file, bringing all the Python definitions and workarounds
into a single place.
2019-09-02 09:00:18 +01:00
Pino Toscano
2581d3c25e build: disable deprecated GTK stuff
We are not using deprecated GTK APIs/stuff, so make sure to not
accidentally use them, and easily catch more deprecations in the future.
2019-09-02 09:00:18 +01:00
Pino Toscano
ff7d94faf8 Copy GtkAttachOptions from GTK >= 3.4
GtkAttachOptions is part of GtkTable, which is used only with GTK < 3.4;
however, these enum values are used also in the GtkGrid version of the
code, so they are needed also when disabling deprecated stuff.

As easy solution to make the current code working without deprecated
stuff of GTK, copy the GtkAttachOptions enum when using GtkGrid (i.e.
with GTK >= 3.4).
2019-09-02 09:00:18 +01:00
Richard W.M. Jones
0731767a20 ocaml: Compile compat bytes.mli file. 2019-08-20 18:10:41 +01:00
Richard W.M. Jones
031016444a m4: ocaml: Remove unused definitions of OCAML_BYTES_COMPAT_*
These were last used in commit 024efc0f2f
and commit 8d09d716aa (both in Jul 2017).
2019-08-20 18:08:43 +01:00
Richard W.M. Jones
4b9efadce2 v2v: Fix missing backslash character in list of tests.
Fixes commit c0d95dcde8.
2019-08-20 17:43:10 +01:00
Richard W.M. Jones
2fbf9a3f94 Update gnulib.
Contains fix for a bug where it would always compile the
replacement accept4 function.

https://lists.gnu.org/archive/html/bug-gnulib/2019-08/msg00029.html

Thanks: Eric Blake
2019-08-20 17:32:19 +01:00
Richard W.M. Jones
11923627cd builder: templates: Add Debian 10 (buster). 2019-08-20 16:59:56 +01:00
Richard W.M. Jones
2cd905f093 Update gnulib. 2019-08-20 16:11:49 +01:00
Richard W.M. Jones
c873e04b26 Update docs/C_SOURCE_FILES. 2019-08-20 16:11:49 +01:00
Pino Toscano
5d94be2583 generator: improve pod2text invocation
- feed the content directly to stdin, avoid the need of read (and write)
  a temporary file
- read all the output at once, without a tail-recursive function
- apply trimming and first line discarding after closing the process
2019-08-13 16:01:25 +02:00
Pino Toscano
81a01f20c3 generator: adjust variable names
Rename some pod2text-related variables to better-fitting names.

This is just a small refactoring.
2019-08-13 13:45:13 +02:00
Pino Toscano
da0137e828 generator: isolate memoized cache in own module
Isolate the logic for the memoized disk cache in a small module, so it
can be reused for other tools.

Other than refactoring, there should be no behaviour changes.
2019-08-13 13:19:17 +02:00
Pino Toscano
8402a73465 v2v: -o rhv-upload: fix the phony ovirtsdk4 module
- add a no-op Connection.close(), as it called explicitly in the
  close() callback of the nbdkit plugin (rhv-upload-plugin.py)
- fix the types of the 'id' variables, which are strings
2019-08-13 07:43:42 +02:00
Pino Toscano
0c261637f9 Fix small issues in documentations of APIs
- fix names of arguments & optional arguments in C<..> markers
- use https for URLs where possible
- fix links to other guestfs APIs
- use more C<..> markers for special tests, shell commands, values of
  arguments, and names of fields
- link to command man pages where an explicit command is mentioned
- fix few incorrect documentation bits
2019-08-13 07:43:42 +02:00
Richard W.M. Jones
52c7e787d2 rust: Add README.md to EXTRA_DIST.
Fixes previous commit.
2019-08-12 20:36:28 +01:00
Hiroyuki Katsura
212f1a5f71 Rust bindings: Make it able to publish this crate
I added
- data required to publish this crate to `crates.io`.
- README.md which contains the details of how to publish this crate.
2019-08-12 20:34:47 +01:00
Richard W.M. Jones
dcfa382b27 v2v: Remove double space.
Tiny whitespace-only fix.
2019-08-09 12:51:10 +01:00
Richard W.M. Jones
4f30db5ae4 Update gnulib to latest version.
This fixes some test breakage I was experiencing with recent
kernel/glibc.
2019-08-08 13:17:37 +01:00
Richard W.M. Jones
7692c31494 v2v: -i vmx: Use scp -T option if available to unbreak scp (RHBZ#1733168).
Tested using:

cd v2v
LIBGUESTFS_BACKEND=direct ../run virt-v2v -i vmx -it ssh "ssh://localhost/$PWD/test-v2v-i-vmx-1.vmx" -o null -v -x

and manually examining the debug output.

Thanks: Ming Xie, Jakub Jelen.
2019-08-08 12:08:17 +01:00
Hiroyuki Katsura
3f7ff1b068 Rust bindings: Implement callback handlers
This patch includes:

- Event callback handlers
- Tests related to events(410-430)

src/bin/event.rs and src/bin/event_leak.rs
are the PoCs that Boxes related to callbacks are
not leaked.
2019-08-06 14:54:04 +01:00
Hiroyuki Katsura
bb0cb3e730 Rust bindings: Add Event structs, Clarify Handle lifetime
Without clarifying handle's lifetime, it is unable
to see how long the callbacks which the handle
owns will live. Then, Rust compiler will infer
that the callbacks have 'static lifetime. It is
not convenient for users.
2019-08-06 14:54:04 +01:00
Richard W.M. Jones
ab09bc25c7 build: Update miscellaneous files.
BUGS
docs/C_SOURCE_FILES
po/POTFILES
po/POTFILES-ml

These files are normally updated by ‘make dist’ but as we've not had a
release in a while they had not been updated for some time.
2019-07-29 12:57:24 +01:00
Richard W.M. Jones
b81c252e44 p2v: Add .gitignore to EXTRA_DIST.
Fixes commit 9fe175cd76.
2019-07-29 12:55:22 +01:00
Richard W.M. Jones
34a0a724c0 v2v: Fix EXTRA_DIST.
Fixes commit a27748d700.
2019-07-29 12:54:11 +01:00
Richard W.M. Jones
97e2be01b5 common/mltools: Fix EXTRA_DIST.
Fixes commit f79129b8dc.
2019-07-29 12:53:14 +01:00
Richard W.M. Jones
9a6d162852 rust: Add missing file to EXTRA_DIST. 2019-07-29 12:22:20 +01:00
Richard W.M. Jones
94f20e2511 rust: Remove rust/.gitignore from EXTRA_DIST.
Fixes commit b484ca4da1.
2019-07-29 12:18:17 +01:00
Richard W.M. Jones
45e66a567d generator: Use ~copyrights shorthand for ~copyrights:copyrights 2019-07-29 12:15:32 +01:00
Richard W.M. Jones
e6f5ec35cc generator: copywrites -> copyrights 2019-07-29 12:14:23 +01:00
Richard W.M. Jones
b484ca4da1 rust: Move .gitignore to top level file and add extra files. 2019-07-29 12:12:14 +01:00
Hiroyuki_Katsura
3bbd00c83e Rust bindings: Add Rust bindings
This patch includes Actions and their tests. Missing:

- Events
- Examples

Rust bindings: Add create / close functions

Rust bindings: Add 4 bindings tests

Rust bindings: Add generator of structs

Rust bindings: Add generator of structs for optional arguments

Rust bindings: Add generator of function signatures

Rust bindings: Complete actions

Rust bindings: Fix memory management

Rust bindings: Add bindtests

Rust bindings: Add additional 4 bindings tests

Rust bindings: Format test files

Rust bindings: Incorporate bindings to build system
2019-07-29 10:28:31 +01:00
Pino Toscano
6d251e3828 v2v: remove extra nbdkit bit from documentation (RHBZ#1723305)
Since there is no more need to build nbdkit from sources, then there is
no need to set $PATH with a custom build of nbdkit.

Followup of commit 0704d8eb0b.
2019-07-18 15:38:53 +02:00
Pino Toscano
730d2122c4 p2v: split appliance tests in own variable
This way they can be properly shipped also when creating a distribution
tarball ('make dist') from a build configured with --disable-appliance.
2019-07-08 18:58:19 +02:00
Pino Toscano
99cec3c1e7 p2v: fix tests with srcdir!=builddir
Point to files in the source directory using the right variables, so
they are found also when the build directory is different than the
source directory.
2019-07-08 18:56:06 +02:00
Pino Toscano
c5db961cf1 p2v: consider p2v-config.h as generated source
While it is generated at configure time for dependency reasons, consider
it a generated source nevertheless: after the first run, there will be
dependency rules available, so automake will trigger the proper rule to
generate it again using generate-p2v-config.pl.
2019-07-08 17:58:23 +02:00
Pino Toscano
31e8ae38d9 p2v: clean also the test images
Followup of commit ea4d9bd157, and
commit f02c0cb552.
2019-07-08 17:57:41 +02:00
Richard W.M. Jones
c22a8b68fe v2v: Allow Windows virtio ISO to be a block device as well as a regular file.
Thanks: Steven Rosenberg
2019-07-04 22:23:52 +01:00
Pino Toscano
f30840e01b p2v: stop including guestfs.h
It is no more needed, guestfs-utils.h is enough these days.
2019-07-03 12:41:02 +02:00
Pino Toscano
498f940419 contrib: move p2v files within p2v 2019-07-03 12:41:02 +02:00
Pino Toscano
fe96e24001 p2v: generate C about data authors from AUTHORS file
Create a small Perl script to generate about-authors.c from the p2v
AUTHORS file at build time, instead of generating in the generator
at dist time.
2019-07-03 12:41:02 +02:00
Pino Toscano
e7a550c2d8 p2v: ship generate-p2v-config.pl
Fixes commit 796ce74f31.
2019-07-03 12:41:02 +02:00
Pino Toscano
1fe60aabdf p2v: remove non-author credits
Soon only the virt-p2v authors will be available, so remove all the
other roles.  This leaves only in the virt-p2v about dialog, which is a
mild regression compared to the current situation, although it is just
for user information.
2019-07-03 12:40:52 +02:00
Pino Toscano
7ad6afc222 p2v: generate an AUTHORS file
Create a simple AUTHORS file for virt-p2v, so it is easier to
extract or use it later on.
2019-07-02 15:40:39 +02:00
Pino Toscano
f02c0cb552 p2v: tests: use a local blank-part disk image
Instead of using the "global" blank-part test image, use a local version
of it created with guestfish.
2019-07-01 18:47:18 +02:00
Pino Toscano
ea4d9bd157 p2v: tests: switch windows image with local fedora one
Instead of using the "global" Windows test image, use a local Fedora
image created with virt-builder.
2019-07-01 18:44:30 +02:00
Pino Toscano
9fe175cd76 p2v: split gitignore
Move (or copy the general ones) all the p2v entries in the top-level
.gitignore file to a new file specific for p2v.  This will make it
easier to keep them when splitting p2v.
2019-07-01 18:38:09 +02:00
Pino Toscano
35916b6030 generator: remove p2v_config
No more used now, as this configuration is generated within p2v itself
at build time.
2019-07-01 14:26:44 +02:00
Pino Toscano
180290ff74 p2v: move kernel config POD docs to perl script
Copy from generator/p2v_config.ml also the bits for POD documentation,
adding them to generate-p2v-config.pl; this way,
virt-p2v-kernel-config.pod can be generated at build time directly,
instead of statically shipped as generator output.
2019-07-01 14:14:56 +02:00
Pino Toscano
796ce74f31 p2v: move kernel config to perl script
Instead of generating the p2v kernel config using the OCaml generator,
create a Perl script to do this job, mostly at build time.  This is done
to rely less on the generator for p2v, and because the generation of
these sources is quick enough that it can be done at build time (instead
of shipping the generated sources in dist tarballs).

The generate-p2v-config.pl mimics what generator/p2v_config.ml --
namings, and general structure are kept close to that for comparison.

The two C sources are created at build time by the script; however, the
p2v-config.h header is generated at configure time: this is done because
p2v-config.h is included by p2v.h (another header), which in turn is
included by all the p2v C sources -- automake is not able to properly
resolve the dependency, and thus it would not be generated properly.
2019-07-01 13:58:13 +02:00
Richard W.M. Jones
c4638739d6 python: PYTHON_LIBS is not set in Python 3.8 (RHBZ#1705482).
Python 3.8 no longer links C extensions to -lpython, instead relying
on the fact that the python binary itself already contains those
symbols.  This means $PYTHON_LIBS is empty and so the Python bindings
are not built.

Use a different test to see if the python module is available.
2019-05-31 13:07:25 +01:00
Pino Toscano
ca8f8afcc5 Revert "daemon: implement OptString for OCaml APIs"
This causes the build to fail, as Val_optstring is still not used by any
generated C glue function.

This reverts commit 8e51e9078f.
2019-05-30 09:45:40 +02:00
Pino Toscano
8e51e9078f daemon: implement OptString for OCaml APIs
It is already considered as string option, so create an option string
value in the C glue for OptString parameters.
2019-05-30 09:12:32 +02:00
Pino Toscano
8eb696f827 appliance: remove custom Shadow augeas lens
Now that augeas 1.2.0 is required, assume the Shadow lens is available
there, and thus drop the local copy.
2019-05-30 09:12:32 +02:00
Pino Toscano
31d72dc463 build: raise augeas requirement to 1.2.0
It is widely available also on older distributions.
2019-05-30 09:12:32 +02:00
Richard W.M. Jones
2bb6be333e appliance: Remove /etc/dhcp/dhclient-enter-hooks.d/resolved.
Workaround for Ubuntu which uses this script to try to start a systemd
service.  That won't work because systemd is not used inside the
appliance.  See:

https://bugs.launchpad.net/ubuntu/+source/supermin/+bug/1824236

Thanks: Ioanna Alifieraki
2019-05-29 17:54:52 +01:00
Pino Toscano
0cafcc0e88 build: build C sources using OCaml API with CAML_NAME_SPACE
This way no non-namespaced OCaml C symbols are used, reducing the risk
of clashes with other code.

The only exception is ocaml-augeas, which does not build with
CAML_NAME_SPACE; it will be fixed upstream, and it affects only
ocaml-augeas itself.
2019-05-28 11:39:20 +02:00
Martin Kletzander
c2918b8b74 Use proper label for nbdkit sockets
While svirt_t can be used for sockets it does not always guarantee that it will
be accessible from a virtual machine.  The VM might be running under svirt_tcg_t
context which will need a svirt_tcg_t label on the socket in order to access it.

There is, however, another label, svirt_socket_t, which is accessible from
virt_domain:

  # sesearch -A -s svirt_t -c unix_stream_socket -p connectto
  ...
  allow virt_domain svirt_socket_t:unix_stream_socket { ... connectto ... };
  ...

And virt_domain is a type attribute of both svirt_t and svirt_tcg_t:

  # seinfo -x -a virt_domain
  Type Attributes: 1
     attribute virt_domain;
          svirt_t
          svirt_tcg_t

Resolves: https://bugzilla.redhat.com/1698437

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2019-05-28 10:14:37 +01:00
Pino Toscano
2ad84a080d tests: import importlib.util directly
It seems that on older Python 3 versions importlib.util is not imported
automatically when importlib is imported; as solution, import
importlib.util directly (as it is what is used, anyway).

Fixes commit f79129b8dc.
2019-05-24 14:49:05 +02:00
Pino Toscano
c9543de73d launch: libvirt: fix custom hypervisor check
Previously, is_custom_hv() used to compare the QEMU executable found
during configure to the hypervisor set to check whether it is a custom
one; however, the QEMU found at configure time can be different than
what libvirt was configured with.

This fixes the libvirt backend when libguestfs is configured with a
different QEMU, that now will be specified as emulator overriding the
libvirt one.
2019-05-24 14:49:05 +02:00
Pino Toscano
797925cc3c launch: libvirt: get default QEMU from domcapabilities
Parse the libvirt domain capabilities for the default emulator
capabilities, and get the path to the default QEMU executable.
2019-05-24 14:49:05 +02:00
Pino Toscano
8d453fe9cc build: stop looking for ocaml-libvirt
We ship our own copy of it, so we do not need the external version.
(Also, the latest upstream version of ocaml-libvirt was already not
usable to build the test harness of v2v.)
2019-05-20 13:40:19 +02:00
Pino Toscano
5c4bd181b6 v2v: test-harness: stop using the external ocaml-libvirt
Use the embedded copy.
2019-05-20 13:40:19 +02:00
Pino Toscano
3e89a1d44f v2v: -o libvirt: switch away from virsh
Now that we have a proper libvirt connection object, use it directly to
refresh the storage pool, and define the final guest.  This avoids
spawning a new virsh process twice, with no possibility to even share a
possible authentication required.
2019-05-20 13:40:19 +02:00
Pino Toscano
e8f9ea2f67 v2v: -o libvirt: use a Lazy for the connection
Store the Libvirt.Connect.t object as instance variable, so it can be
used also outside of prepare_targets.  Use a private method to access
it, so there is no need to directly use the Lazy object.
2019-05-20 13:40:19 +02:00
Pino Toscano
a871f6c251 v2v: switch to ocaml-libvirt
Currently virt-v2v has few custom C-based functions for libvirt
operations, which are limited in what they do, and there is a lot of
duplicated code.

Instead, switch to ocaml-libvirt for all the libvirt interaction
currently done by the Libvirt_utils module.  This has few advantages:
- each input & output module now opens a libvirt connection only once,
  only when needed
- no need to pass URIs and passwords around, if not needed
- a wider range of libvirt APIs can now be used, with no need to create
  bindings manually

The hierarchy of input_libvirt* classes is changed to take a Lazy object
with the libvirt connection, accessing it through a "proctected" method:
this way, the connection is opened only at the first access.
Also, the Libvirt_utils module now is just helpers around the Libvirt
module, to centralize error handling, and few common operations.
2019-05-20 13:40:19 +02:00
Pino Toscano
99493eeddd common: Bundle the libvirt-ocaml library for use by virt-v2v
Add a copy of the libvirt-ocaml library, currently available at:
  https://libvirt.org/git/?p=libvirt-ocaml.git;a=summary
This is a snapshot at commit d3ed8dcf1b0a6a8a855ceecbe0bb97f21e6665e3,
which has all the features we need (and that builds fine).
It is expected to stay synchronized with upstream, until there is a new
upstream release, and it will be widespread enough.
2019-05-20 13:32:59 +02:00
Pino Toscano
c0d95dcde8 v2v: require libvirt
While there are input modes that do not use libvirt, making libvirt
mandatory for virt-v2v slightly simplifies the code now, and allow for
further improvements/integration with libvirt later on.
2019-05-20 13:30:23 +02:00
Pino Toscano
71b021c99d v2v: -o json: add a simple test for it
Followup of commit f190e08d85.
2019-05-20 10:22:29 +02:00
Richard W.M. Jones
052d2be483 builder: templates: Add RHEL 8.0 (x86-64 only for now). 2019-05-10 16:24:53 +01:00
Richard W.M. Jones
652e8de397 builder: templates: Remove RHEL 8 Alpha temporary hacks. 2019-05-10 16:24:53 +01:00
Richard W.M. Jones
05decc6976 builder: Fedora 30 templates. 2019-05-04 21:07:05 +01:00
Pino Toscano
8bbf8e8900 test-data: switch away from deprecated APIs
Adapt make-fedora-img.pl to not use deprecated APIs anymore:
- set_e2uuid -> set_uuid
- txz_in -> tar_in + compress:xz

This causes no changes in the generated test images.
2019-05-02 18:34:18 +02:00
Pino Toscano
9f39e9be24 python: silence usage of add_cdrom in test
One test explicitly tests add_cdrom, so silence the deprecation warning
only for that function.
2019-04-24 12:49:48 +02:00
Pino Toscano
19ce506ccb perl: silence usage of add_cdrom in test
One test explicitly tests add_cdrom, so silence the deprecation warning
only for that function.
2019-04-24 12:49:28 +02:00
Pino Toscano
b6a7157751 python: modernize inspect_vm example
Since we already assume Python >= 2.7, modernize this example to make it
work also on Python 3:
- use print() as function
- sort the mount points using a key for sorted(), instead of a
  comparison function
- remove extra newline escape
- reident two lines according to the PEP 8 style
2019-04-24 11:59:36 +02:00
Pino Toscano
96aed2fc9e perl: show warnings for deprecated functions
Emit a deprecation warning when a deprecated function is used, so users
have a way to know that they are using one.
2019-04-23 18:08:19 +02:00
Pino Toscano
a7666c1f1c ruby: show warnings for deprecated functions
Emit a warning when a deprecated function is used, so users have a way
to know that they are using one.
2019-04-23 18:08:19 +02:00
Pino Toscano
cf865444a8 python: show warnings for deprecated functions
Emit a DeprecationWarning warning when a deprecated function is used, so
users have a way to know that they are using one.
2019-04-23 18:08:19 +02:00
Pino Toscano
d8d8c856a1 lib: introduce GUESTFS_NO_DEPRECATED
Add a simple way to do not even provide prototypes of deprecated
functions in the C library: this way, users (like our tools) can build
against the library making sure to not use any deprecated function, not
even when compiler deprecation warnings are disabled.

Add it to the majority of our tools/internal libraries, and make sure
that it is not defined when building the API bridges of our bindings.
2019-04-23 18:08:19 +02:00
Pino Toscano
9d1fc91cca build: stop using GUESTFS_WARN_DEPRECATED
This is no more used now, as compiler deprecation warnings are triggered
by default.
2019-04-23 18:08:19 +02:00
Pino Toscano
84d0f5aa9f lib: enable deprecation warnings by default
Right now, deprecated functions of the library do not trigger any
compiler deprecation warning by default; they do that only if
GUESTFS_WARN_DEPRECATED=1 is defined.  However, this is not something
that seems to be done often -- at least none of the projects using the
libguestfs C API does that.

Hence, do a small behaviour change to change this on the other way
round: now deprecated functions trigger compiler deprecation warnings by
default, using GUESTFS_NO_WARN_DEPRECATED to disable this (and revert
to the previous behaviour).  Even though deprecated functions will not
be removed, we really want users to migrate away from them, as they were
deprecated for good reasons.

Define GUESTFS_NO_WARN_DEPRECATED where needed:
- in all the bindings, as they bind all the functions including the
  deprecated ones
- in the guestfish actions, as it exposes almost all the APIs
- in the C API test, as it runs the automated tests of all the APIs that
  have them
- for two tests that explicitly test deprecated functions
2019-04-23 18:08:19 +02:00
Pino Toscano
7a54596aaf tests: switch last-errno away from deprecated APIs
This test only calls stat to check the failure on missing file, so
switch to statns to get the same behaviour with a non-deprecated API.
2019-04-23 18:06:31 +02:00
Pino Toscano
05e559549d v2v: -o rhv-upload: check whether the cluster exists
In the precheck script, check that the target cluster actually exists.
This will avoid errors when creating the VM after the data copying.
2019-04-16 12:17:18 +02:00
Denis Plotnikov
4cfc071a84 daemon: drop error message check in do_part_expand_gpt
part-expand-gpt takes extreme cautions and doesn't proceed to writing
to the disk if the preliminary dry run of sgdisk has generated any
warnings on stdout.

This blocks the use of part-expand-gpt on disk shrink (with disk
resize being the main usecase for part-expand-gpt), because sgdisk dry
run produces a warning in that case.

So remove the excessive safety check, and leave it up to the caller.

Signed-off-by: Denis Plotnikov <dplotnikov@virtuozzo.com>
Reviewed-by: Roman Kagan <rkagan@virtuozzo.com>
2019-04-16 09:32:02 +01:00
Richard W.M. Jones
3b2d83d470 v2v: Move have_selinux to utils.
This is not quite a neutral refactoring, because it means we now run
the getenforce command every time virt-v2v starts up.  However it's a
trivial command that reads a single /sys file and it can't fail even
if the command is missing or on platforms that know nothing about
SELinux.
2019-04-15 11:41:29 +01:00
Richard W.M. Jones
5067968297 common/mlstdutils: Add String.unix2dos function.
Simple string line ending replacement convenience function.
2019-04-15 11:41:29 +01:00
Pino Toscano
1629ec6a56 v2v: warn when the guest has direct network interfaces (RHBZ#1518539)
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 direct network interfaces, so at least this can be noticed
when converting a guest.
2019-04-12 17:28:12 +02:00
Pino Toscano
0704d8eb0b v2v: update documentation on nbdkit (RHBZ#1605242)
nbdkit >= 1.6 ships a VDDK plugin always built, so recommend that
version instead of recommending to build nbdkit from sources.
2019-04-12 16:19:43 +02:00
Pino Toscano
fb7983f999 v2v: start reading the new libvirt firmware autoselect
Starting with 5.2.0, libvirt has a way to select automatically the
firmware for a guest using an attribute of the <os> tag.  Hence, use
this information (when available, of course) to flag the firmware used
by the guest.
2019-04-08 18:23:27 +02:00
Pino Toscano
3720900438 inspect: get icon of OpenMandriva guests
Followup of commit a4ef6716b4.
2019-04-08 13:34:11 +02:00
Pino Toscano
c4205809bc inspect: correct osinfo ID for ALT Linux >= 8
ALT Linux 8.x has different IDs in osinfo-db, so return the proper IDs
for the newest stable series.
2019-04-04 10:25:03 +02:00
Pino Toscano
764ee8c74e inspect: return osinfo short IDs for rolling distros
Return the right osinfo short IDs for some rolling Linux distributions,
such as Arch Linux, Gentoo, and Void Linux.  Their IDs were recently
added to osinfo-db.
2019-04-04 10:25:03 +02:00
Pino Toscano
aee4a96ce2 inspect: fully detect Arch Linux from os-release
Consider Arch Linux as rolling distribution, so it is recognized using
/etc/os-release.

The end result does not change, although this makes Arch Linux inspected
using os-release only, instead of getting inspection details mixed from
both os-release and lsb-release.
2019-04-04 10:25:03 +02:00
Pino Toscano
c0155f5823 inspect: detect Gentoo from os-release
Add "gentoo" as recognized ID in /etc/os-release, and consider it as
rolling distribution (so without VERSION_ID in os-release).

This avoids using a not-useful version read from /etc/gentoo-release,
e.g. "Gentoo Base System release 2.6".
2019-04-04 10:25:03 +02:00
Pino Toscano
a6db759a72 inspect: factorize list of rolling distros
Use a static list of rolling distros, so it is easier to handle them
differently; use this list for handling the lack of VERSION_ID in
os-release files.

This is just refactoring, no behaviour changes.
2019-04-04 10:25:03 +02:00
Hiroyuki Katsura
7772cfc771 Add missing python bindings tests
Signed-off-by: Hiroyuki Katsura <hiroyuki.katsura.0513@gmail.com>
2019-04-03 17:28:58 +01:00
Bernhard Rosenkränzer
a4ef6716b4 Add OpenMandriva support as guest and host (RHBZ#1694268). 2019-04-03 13:08:08 +01:00
Pino Toscano
f190e08d85 v2v: add -o json output mode
Add a new output mode to virt-v2v: similar to -o local, the written
metadata is a JSON file with the majority of the data that virt-v2v
knowns about (or collects) during the conversion.

This is meant to be used only when no existing output mode is usable,
and a guest needs to be converted to run on KVM anyway.  The user of
this mode is supposed to use all the data in the JSON, as they contain
important details on how even run the guest (e.g. w.r.t. firmware,
drivers of disks/NICs, etc).
2019-04-01 18:44:00 +02:00
Pino Toscano
a27748d700 v2v: add Var_expander
This helper module provides a facility to replace %{FOO}-like variables
in text strings with user-provided content.
2019-04-01 18:44:00 +02:00
Pino Toscano
0ed2e5c14a common/mlpcre: add offset flag for PCRE.matches
This way it is possible to change where the matching start, instead of
always assuming it is the beginning.
2019-04-01 18:44:00 +02:00
Pino Toscano
1086599ad8 OCaml tools: fix 3999 -> 3339 typo
RFC 3339 is the actual RFC for date/time strings.
Typo found by Martin 'eagle eyes' Kletzander.

Fixes commit f79129b8dc.
2019-04-01 18:44:00 +02:00
Richard W.M. Jones
e047cc4da8 lib: qemu: rbd: Properly escape IPv6 addresses.
Each ':' character in the address must be escaped from qemu.

Thanks: Jonathan Wright
2019-04-01 17:31:25 +01:00
Pino Toscano
f79129b8dc OCaml tools: output messages into JSON for machine readable
When the machine readable mode is enabled, print all the messages
(progress, info, warning, and errors) also as JSON in the machine
readable stream: this way, users can easily parse the status of the
OCaml tool, and report that back.

The formatting of the current date time into the RFC 3999 format is done
in C, because of the lack of OCaml APIs for this.
2019-03-29 13:57:47 +01:00
Pino Toscano
70514dfaf1 common/mltools: allow fd for machine readable output
Allow to specify a file descriptor for the machine readable output.

Use the same assumption as done in v2v, i.e. that Unix.file_descr is
simply the int file descriptor.
2019-03-29 13:57:47 +01:00
Pino Toscano
abf1607f46 common/mltools: make sure machine readable output is flushed
Enhance the helper printf function for machine readable output to always
flush after each string: this way, readers of the machine readable
stream can get the output as soon as it is outputted.
2019-03-29 13:57:46 +01:00
Pino Toscano
8b06ea0ebc common/mltools: move the code for machine readable up
Move the code for handling machine readable up in the file, so it can be
used by other functions.

Only code motion, no behaviour changes.
2019-03-29 13:57:46 +01:00
Tomáš Golembiovský
200bec7cfd v2v: windows: save log file from rhev-apt installer
Store log from MSI installer. Log file will be located in firstboot
scripts-done directory with name rhev-apt.log. The path has to be
double-quoted to handle spaces in path name properly.

Hopefully this can help resolve RHBZ#1584678 someday.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2019-03-27 16:34:44 +01:00
Tomáš Golembiovský
f4bda5571a v2v: fix path to source when copying files from guest tools directory
The debug message was slightly changed too to better match the similar
message for ISO case. It refers to the root directory instead of the
specific subdirectory inside guest tools.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2019-03-27 16:34:44 +01:00
Pino Toscano
cbf887ed90 v2v: change the reporting of RHV Tools messages/warnings/error
The RHV Tools ISO is provided as Red Hat only product, and thus not
available for all the virt-v2v users.  Hence, change the way we report
the status of the installation of the qemu guest agent from the RHV
Tools ISO:
- do not warn if virt-v2v does not know how to install the package for
  the current guest
- do not warn if the ISO does not contain packages for the current guest
- on successful installations, show an info message

Related: RHBZ#1691659
2019-03-27 14:46:34 +01:00
Pino Toscano
78f08a15fa v2v: try to pick the right arch for qemu-ga pkgs
Right now the code copies, and then tries to install, all the files
found for the directory of a distro.  This does not take into account
differences in the architectures of the packages available, so a x86_64
package must be installed only on x86_64 guests.

As solution, filter the packages using the typical suffix used by
packages (so architecture + file extension), to pick only packages
compatible with the current guest.
2019-03-27 14:46:34 +01:00
Pino Toscano
13ef175a7b v2v: linux: add helper functions for pkg arch and extension
Add helper functions to get the typical extension of binary packages
for a package manager, and the string for an architecture.
2019-03-27 14:46:34 +01:00
Richard W.M. Jones
ba7fa03923 lib: direct: Set QEMU_AUDIO_DRV=none when testing schema.
Schema parsing was failing with errors such as:

libguestfs: QMP parse error: '[' or '{' expected near end of file (ignored)

This happened because the QMP command was actually completely failing
and never printing a result at all.  This happens because the qemu
audio driver can't be set up without a console.  We can suppress this
by setting the environment variable QEMU_AUDIO_DRV=none, which is the
same thing that libvirt does, and also the same thing that we are
already doing when launching the real appliance subprocess.

See also: https://bugzilla.redhat.com/show_bug.cgi?id=1692047
2019-03-27 11:53:31 +00:00
Pino Toscano
c0a78ea844 v2v: test-v2v-conversion-of.sh: basic check for libvirt XML
Use virt-xml-validate to check that the libvirt XML is actually valid,
at least regarding its schema.
2019-03-26 15:40:05 +01:00
Pino Toscano
831f3c06b9 v2v: test-v2v-conversion-of.sh: update the guest
Make sure the create guest is always up-to-date: this way it is possible
to test the conversion even taking into account the latest upgrades
available.
2019-03-26 15:40:05 +01:00
Pino Toscano
4e108ae225 v2v: tests: add debian-9 and fedora-29 for test-v2v-conversion-of
Test the newer versions of these distros.
2019-03-26 15:40:05 +01:00
Richard W.M. Jones
464de98ff6 inspector: Fix tests to match new Windows 7 osinfo information.
Fixes commit 3ed32996dd.
2019-03-26 10:18:58 +00:00
Pino Toscano
1a4fd822ef v2v: linux: do not uninstall open-vm-tools w/ ubuntu-server
ubuntu-server depends on open-vm-tools on Ubuntu, so if v2v tries to
uninstall open-vm-tools then dpkg will (rightfully) fail with a
dependency issue.

Since open-vm-tools is harmless after the conversion anyway (it will
not even run), then do not attempt to uninstall it if ubuntu-server is
installed too.

Followup of commit 2bebacf8bf.

Thanks to: Ming Xie.
2019-03-25 16:10:21 +01:00
Pino Toscano
3ed32996dd inspect: return osinfo short IDs for recent Windows versions
Return the right osinfo short IDs for the majority of Windows versions
since Windows XP.
2019-03-25 16:10:20 +01:00
Pino Toscano
bb11507fff v2v: -o libvirt: write win2k19 osinfo ID
When writing the libosinfo metadata in the libvirt XML, use the newly
added (in osinfo-db) ID for Windows Server 2019; sadly, this version of
Windows has the same version as Windows Server 2016, so distinguish it
by looking at its product name.
2019-03-25 16:10:20 +01:00
Pino Toscano
c648052690 inspect: fix icon of RHEL
Use a better icon for RHEL guests, still provided by redhat-logos (or
equivalent in downstream distributions), and which fits a better
definition of logo for the distribution.

Thanks to Ray Strode for the hints.
2019-03-25 16:10:20 +01:00
Mike Latimer
612f170e60 v2v: Fix default graphics driver for SUSE guests.
See discussion in this upstream thread:
https://www.redhat.com/archives/libguestfs/2019-February/thread.html#00047

Thanks: Mike Latimer, Pino Toscano.
2019-03-25 14:41:00 +00:00
Pino Toscano
363b5e0b4e v2v: linux: improve arch detection from modules (RHBZ#1690574)
Try to look for a well known kernel module (so far only virtio, or kvm)
to use for detecting the architecture of a kernel.  This way, we can
avoid picking 3rd party modules that cause troubles.
2019-03-20 17:41:07 +01:00
Pino Toscano
0a093035d4 v2v: linux: canonicalize module path for arch detection (RHBZ#1690574)
Kernel modules can be also symlinks to files available outside the
"canonical" module directory; the "file" API, used by the
"file-architecture" API, return the actual type of a file (so symlinks,
block devices, etc), and thus "file-architecture" fails on symlinks.

To prevent this situation, canonicalize the path of the module picked
for architecture detection: this way, "file-architecture" will act on a
real file.
2019-03-20 17:41:07 +01:00
Pino Toscano
89b5dabf8d tests: skip test-relabel.pl when selinuxrelabel is not available
test-relabel.pl performs a full SELinux relabelling of the phony guest,
and the selinux_relabel API does not work if the "selinuxrelabel"
feature is not available.
2019-02-11 16:43:53 +01:00
Pino Toscano
c8a26adf1d inspect: get icon of Gentoo guests
The icon is installed by x11-themes/gentoo-artwork, which is not
installed by default (and most probably only on "desktop"
installations), although it's the best hit so far...
2019-02-07 19:00:13 +01:00
Pino Toscano
f41a75cea6 inspect: revamp icon extraction for *SUSE guests
Newer versions do not have the 24px distributor.png icon; OTOH they have
the 48px version, so look for that one before the 24px one.

Also, bump the size limit to 10K, as newer versions of the icon are
bigger than 3K.
2019-02-06 15:19:53 +01:00
Pino Toscano
6ff95acc72 inspect: factor out find_png helper function
Isolate the code for looking for a PNG file among a specified list from
the icon_ubuntu implementation, and switch that function to it.

This is just code refactoring, with no behaviour changes.
2019-02-06 15:15:08 +01:00
Pino Toscano
032b8d4c72 inspect: bump size limit for Mageia guests
Newer versions of the logo in Cauldron are almost 3K, so bump the limit
to 10K for now.
2019-02-06 15:05:51 +01:00
Pino Toscano
5eafd12731 v2v: linux: use NEVR for querying RPM packages (RHBZ#1669395)
Use NEVR when querying RPM for the list of files of a package, instead
of ENVR.  Also, use the epoch only when non-zero, and version of RPM
supports it.

The approach is basically copied from what supermin does in its RPM
package handler.
2019-01-30 16:59:32 +01:00
Richard W.M. Jones
b26bd778b5 build: Reduce -Wformat-overflow=2 to =1.
GCC 9 gives this error:

qemuopts.c: In function 'qemuopts_to_config_channel':
qemuopts.c:987:29: error: '%.*s' directive output between 0 and 2147483647 bytes may exceed minimum required size of 4095 [-Werror=format-overflow=]
  987 |             fprintf (fp, "  %.*s = ", (int) k, values[j]);
      |                             ^~~~
qemuopts.c:987:26: note: assuming directive output of 1 byte
  987 |             fprintf (fp, "  %.*s = ", (int) k, values[j]);
      |                          ^~~~~~~~~~~

See discussion at the following GCC bug:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88993
2019-01-24 09:54:23 +00:00
Pino Toscano
fbaa5f003a build: correctly report whether vala is enabled
Use the right autoconf variable.

Followup of commit 4f96e823d3.
2019-01-23 14:56:27 +01:00
Corentin Noël
4f96e823d3 gobject: Add Vala binding support
RWMJ: Add optional dependency on vala to the docs.
2019-01-23 13:05:59 +00:00
Pino Toscano
0ee02e0117 python: change types for RBufferOut/FBuffer with Python 3 (RHBZ#1661871)
So far RBufferOut return values, and FBuffer struct fields are 'str' on
all the versions of Python.  Python 3 distinguishes between 'str'
(unicode strings), and 'bytes', with 'str' no more able to hold
arbitrary data.

For this reason, switch the return value of RBufferOut functions, and
FBuffer struct fields to bytes on Python 3: while this is a potentially
incompatibile change, this is the only way to handle safely sequences
of arbitrary bytes.
2019-01-22 14:29:13 +01:00
Pino Toscano
85235aec83 python: fix call of Python handlers of events
Make sure to reference the arguments, to make sure they are kept alive
during the function call; this is visible when setting an event handler
for the CLOSE event, and testing it with Python 3.

This does not seem to create a memory leak e.g. with Python 2.

Also, switch away from the quasi-internal PyEval_CallObject to the
public PyObject_CallObject, which takes care of doing safety checks.
2019-01-22 12:43:11 +01:00
Pino Toscano
a8006afaf5 build: integrate ocaml-link.sh with automake silent rules
In case either the silent rules are disabled, or V=1 is set, print the
full command line that is executed.
2019-01-22 12:31:03 +01:00
Richard W.M. Jones
ea7c13fed7 valgrind: Add workaround for slow loading of debuginfo by valgrind.
See nbdkit commit
bd32d899ed
and https://bugzilla.redhat.com/show_bug.cgi?id=1662656
2019-01-17 12:03:07 +00:00
Richard W.M. Jones
1de72f8f00 Version 1.40.0. 2019-01-16 12:04:25 +00:00
Richard W.M. Jones
6151d8694d po: Drop ca and pt_BR from linguas.
Commit 4252a490bb dropped the PO files
for ca (Catalan) and pt_BR (Brazilian Portuguese).  However it did not
drop these languages from the linguas line in the Makefile resulting
in a build failure.
2019-01-16 11:57:57 +00:00
Richard W.M. Jones
d1ff62f3e0 configure: Move remaining detection of p2v features to m4/guestfs-v2v.m4.
./configure output now contains a distinct section for v2v and p2v:

  --- Checking the virt-v2v and virt-p2v dependencies ---
  checking for the nbdkit python plugin name... python3
  checking for --with-gtk option... 2
  checking for GTK... yes
  checking for DBUS... yes
  checking if we can build virt-p2v... yes, with Gtk 2

Thanks: Pino Toscano.
2019-01-16 11:57:57 +00:00
Richard W.M. Jones
61b86bac2e v2v: -o rhv-upload: Allow configure to set the nbdkit Python version.
No functional change, but it does allow downstream distributions to
adjust the nbdkit Python plugin used by virt-v2v -o rhv-upload mode:

./configure --with-virt-v2v-nbdkit-python-plugin=...
2019-01-16 11:57:57 +00:00
Richard W.M. Jones
090f5589e7 po-docs: uk: Fix inconsistent use of \n in translation.
Invalid po file ./uk.po:
./uk.po:90428: 'msgid' and 'msgstr' entries do not both begin with '\n'
msgfmt: found 1 fatal error
2019-01-15 14:44:16 +00:00
Richard W.M. Jones
1db0140428 docs: Finalize release notes for 1.40.
Updates commit 0ce8ecdf66.
2019-01-15 14:44:16 +00:00
Richard W.M. Jones
b8882fed97 website: Update website for 1.40. 2019-01-15 14:44:16 +00:00
Pino Toscano
cf6b527824 inspect: fix inspection of partition-less devices (RHBZ#1661038)
When parsing "xdev"-kind devices, do not assume that the partition
number can be converted to integer: re_xdev accepts an empty part of the
partition number, so just handle as it is, as string.

This fixes a regression due to the conversion of the inspection code to
OCaml, as the old C version did not have this issue.
2019-01-14 17:29:13 +01:00
Pino Toscano
d3ff88c894 OCaml: use the new behaviour of Std_utils.which
Since Std_utils.which can handle relative/absolute paths, remove the
manual checks, and use Std_utils.which directly.
2019-01-14 15:19:32 +01:00
Pino Toscano
ebe2c7b458 mlstdutils: allow relative/absolute paths for Std_utils.which
Make Std_utils.which behave a bit more like which(1), checking the
existance of relative/absolute paths specified.
2019-01-14 15:19:32 +01:00
Pino Toscano
88a754bd07 mlstdutils: add a very simple test for Std_utils.which 2019-01-14 15:19:32 +01:00
Pino Toscano
27cd2888c3 automake2junit.ml: string -> bytes
Make it usable OOTB with OCaml >= 4.02.0.
2019-01-14 15:19:32 +01:00
Yuri Chornoivan
7f97433a3c Fix miscellaneous typos in comments. 2019-01-11 17:14:45 +00:00
Richard W.M. Jones
4040c7de93 Update gnulib to latest version. 2019-01-11 17:14:45 +00:00
Richard W.M. Jones
4252a490bb Update PO files from Zanata. 2019-01-08 18:28:27 +00:00
Richard W.M. Jones
fc028bf57a v2v: -o openstack: Don't echo full commands (RHBZ#1664310).
They can contain passwords or tokens if for example the
‘-oo os-password’ option is used.

Thanks: Tomáš Golembiovský, Brett Thurber.
2019-01-08 14:17:44 +00:00
Richard W.M. Jones
05d4fcb64d Update copyright dates for 2019.
This command run over the source:

perl -pi.bak -e 's/(20[01][0-9])-2018/$1-2019/g' `git ls-files`
2019-01-08 11:58:30 +00:00
Richard W.M. Jones
0ce8ecdf66 Update release notes for 1.40 release. 2019-01-07 20:03:40 +00:00
Richard W.M. Jones
492a945791 Revert "launch: libvirt: Use qemu-bridge-helper to implement a full network (RHBZ#1148012)."
We've been carrying this exact patch in RHEL 7 for several years.  It
reverts the change made in 2014 where we switched to using the virbr0
bridge for libguestfs networking instead of SLIRP.  We thought SLIRP
was going to become unsupported in qemu, but recently there have been
more encouraging signs since it looks like SLIRP will be spun off as a
separate project, running as a modular process and properly secured
and supported.

This reverts commit 224de20b9a.
2019-01-07 15:03:07 +00:00
Pino Toscano
5e5896752e v2v: further doc update for VMware roles
Remove "Allow virtual machine download", added with
commit 37955f14aa, because it does not
seem to be actually needed.

Related: RHBZ#1530967
2019-01-07 12:23:25 +01:00
Pino Toscano
6b80c5fb51 v2v: -o rhv-upload: decouple name of nbdkit python plugin
Do not assume that the Python plugin of nbdkit has the same name of the
Python interpreter.

Use the default upstream name of nbdkit to identify it; downstream
distributions must adjust this variable, in case they rename the Python
plugin of nbdkit.
2018-12-16 16:13:44 +01:00
Richard W.M. Jones
216fe13fcc v2v: windows: Add comment about possibility of removing GPO restrictions.
Although it may not be a good idea because usually they are installed
for a reason.
2018-12-14 13:07:41 +00:00
Pino Toscano
37955f14aa v2v: update docs for VMware roles (RHBZ#1530967)
Update the list of permissions needed for VMware vCenter 6.5.
2018-12-13 14:58:39 +01:00
Richard W.M. Jones
6aa46f4303 Version 1.39.14. 2018-12-12 12:35:30 +00:00
Richard W.M. Jones
52ec462fea lib: direct: Move serial option from -drive to -device.
qemu deprecated and removed this option from the -drive parameter,
resulting in:

  Block format 'raw' does not support the option 'serial'

See also:
https://www.mail-archive.com/qemu-devel@nongnu.org/msg574583.html
2018-12-12 12:29:33 +00:00
Richard W.M. Jones
08a14d9fa7 Version 1.39.13. 2018-12-11 19:40:02 +00:00
Richard W.M. Jones
b38e4eff2b gnulib: Use https URL instead of git.
This is apparently more secure (against MITM attacks), and furthermore
Savannah git: access is broken at the moment.
2018-12-11 19:38:09 +00:00
Richard W.M. Jones
b7cf2dfff8 Version 1.39.12. 2018-12-11 19:15:22 +00:00
Richard W.M. Jones
e62a443165 tests: Provide a way for skipping tests/bigdirs/test-big-dirs.pl.
This test is currently broken because of a kernel bug
(https://bugzilla.redhat.com/show_bug.cgi?id=1657200).
2018-12-11 17:53:29 +00:00
Richard W.M. Jones
d9f5e47f82 tests: Fix console for slow tests on Ubuntu 18.04.
Use the same fix as for Debian and Ubuntu 16.04.
2018-12-11 16:38:55 +00:00
Nir Soffer
854aad230f v2v: -o rhv-upload: Fix emulated zero
Replace python 2 only "buffer" with "memoryview".

Falling back to emulated zero would fail with:

    NameError: name 'buffer' is not defined

I did not test the changed code but it was not tested before so it is
unlikely to be worse.

Detected by pylint.
2018-12-07 18:49:54 +00:00
Nir Soffer
6c9eb03117 v2v: -o rhv-upload: Fix request headers in pread
headers was initialized with a set literal {"key", "value"} instead of
dict literal {"key": "value"}.

Calling pread() will fail with:

    AttributeError: 'set' object has no attribute 'items'

I did not test the changed code, but it was not tested before, so it is
unlikely to be worse.

Detected by pylint.
2018-12-07 18:49:54 +00:00
Richard W.M. Jones
0d2ce92e55 builder: Add a second archive repo to the virt-builder repos.
builder.libguestfs.org has almost run out of space.  I would like to
move templates for older guests to the archive site (which is slower
but has unlimited space).  The easiest way to do this is to add a
second repo.

This only affects obsolete/unsupported Fedora releases.
2018-12-07 11:23:23 +00:00
Richard W.M. Jones
217002b2e2 builder: Fix redirect in virt-builder configuration.
For a while libguestfs.org/builder has redirected to
builder.libguestfs.org.  This change just makes virt-builder go direct
to the subsite instead of via the redirect.
2018-12-07 11:23:23 +00:00
Nir Soffer
7be28a2585 v2v: -o rhv-upload: Fix upload when using https
Fix rhv-cafile option access, broken by commit 6694028f98 (v2v: -o
rhv-upload: Only set SSL context for https connections).
2018-12-07 08:36:05 +00:00
Richard W.M. Jones
b8a7672936 builder: templates: Build CentOS 7.6. 2018-12-06 15:48:27 +00:00
Richard W.M. Jones
02086837d0 v2v: -o glance: Mention glance(1) in the SEE ALSO section of the manual.
It is already mentioned in the main body text.
2018-12-05 20:20:31 +00:00
Richard W.M. Jones
88c237261f v2v: -o openstack: Check openstack binary exists before running it.
Improves the error message when openstack is not installed.

This also mentions the openstack command in the manual page.
2018-12-05 20:20:29 +00:00
Tomáš Golembiovský
1c85b64c1c v2v: don't fail when virtio-win does not have qemu-ga packages
It should not be error to use virtio-win ISO that does not have Linux
packages of QEMU Guest Agent. Only oVirt/RHV guest tools ISO has such
packages now. Regular virtio-win ISO does not have them and maybe never
will.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2018-12-05 20:11:01 +00:00
Pino Toscano
50b08fd84b v2v: linux: improve regex for resume= entries (RHBZ#1651987)
Add few more characters for the devices of resume= entries in the
command line of grub: this way it is possible to match also /dev/mapper
devices.

This should require no further processing, since the names of the
/dev/mapper devices do not change after the conversion.
2018-12-04 19:01:06 +01:00
Richard W.M. Jones
b0c11adee7 tests: md: Increase size of MD partitions in test.
Commit c11a92751e chose some strangely
sized partitions for testing Linux MD devices.  The disks were 100M
however the four partitions only covered the first 10M of disk space
(with the rest being unallocated and unused in the test).

This worked until Linux 4.20 where the ~2M-sized partitions become too
small for a Linux MD device.

This commit changes the test to use four 20M-sized partitions which is
sufficient space to create the MD device with recent kernels.  I also
modified the partition allocation code to use explicit calculations
and variables, making it considerably clearer.
2018-11-30 14:59:32 +00:00
Pino Toscano
78a29dbd1e lib: inspect: tweak limits of package manager files
Tweak the limits of the files of package managers downloaded to list the
installed applications:
- bump RPM 'Packages' up to 500M: Fedora installations upgraded to each
  new Fedora release have an ever-growing file, reported to be even
  slightly bigger than 400M
- reduce the other files down to 50M: they are usually small, not bigger
  than 1M-5M, so 50M is a good enough high threshold
2018-11-30 13:44:28 +01:00
Pino Toscano
b12e168efc lib: inspect: split limits of package manager files
Use different defines for the limits of the package manager files
downloaded during the inspection of applications.  This way it will be
possible to tweak each of them without affecting the others.

This is a minor refactoring, with no behaviour change.
2018-11-30 13:44:28 +01:00
Pino Toscano
8197336a9b lib: move MAX_PKG_DB_SIZE to inspect-apps
It is used only there, so avoid exposing it to all the users of
guestfs-internal.h.

This is just code motion.
2018-11-30 13:44:28 +01:00
Pino Toscano
28bd06227b inspect: handle os-release "opensuse-tumbleweed" as opensuse
Followup of commit 70407cd622 for openSUSE
Thumbleweed.
2018-11-30 13:44:19 +01:00
Richard W.M. Jones
0e6bbcee7e v2v: docs: Remove sentence about supporting qemu-kvm-rhev in RHEL (RHBZ#1651977).
The previous support documentation said that for UEFI guests, when
using RHEL ≥ 7.3 host, you must use qemu-kvm-rhev.  For RHEL 8 this is
inaccurate since qemu-kvm-rhev no longer exists.

To fix this I've dropped the whole sentence.  It only applies to the
downstream product (RHEL) and so RHEL can add the right documentation
if it needs to.

Thanks: Ming Xie, Pino Toscano.
2018-11-30 12:20:23 +00:00
Richard W.M. Jones
9c8d133455 Replace -nodefconfig with -no-user-config.
This option was removed from qemu for no apparent reason except to
break existing consumers.  It does the same as -no-user-config, added
in May 2012, so use that instead.
2018-11-30 12:18:01 +00:00
Martin Kletzander
cbe4150fbc v2v: Add support for libosinfo metadata
There's a standardized libosinfo namespace for libvirt domain metadata.  For now
it supports the id of the OS only.  However that is still a very helpful feature
that is already supported in gnome-boxes and virt-manager (at least).

The discussion happened here:

  https://www.redhat.com/archives/libosinfo/2018-September/msg00003.html

So let's add the support to local and libvirt outputs.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2018-11-23 20:16:08 +00:00
Martin Kletzander
d3478036a8 Fix include for xattr.h
The proper file that should be included is `sys/xattr.h` as that comes from
`glibc` and not `attr/xattr.h` which ships with the `attr` utility.

New enough `attr` utility (at least 2.4.48 in my case) even includes a #warning
in `attr/xattr.h` for projects that still have this mistake in the code.
2018-11-23 08:34:16 +00:00
Richard W.M. Jones
724d7877f8 v2v: -o rhv-upload: Fix test so it doesn't fail if Content-Length header missing.
If the Content-Length header was missing from the headers returned by
the server then the test would fail with:

KeyError: 'content-length'

This happens on RHEL 7.6 in particular.  We can fix this by using an
alternate method to fetch the header, which will return None instead
of throwing an exception if the header doesn't exist.  See:
https://stackoverflow.com/a/19255675
2018-11-21 15:58:38 +00:00
Richard W.M. Jones
a4f83ee6a4 v2v: -o openstack: -oo verify-server-certificate=(true|false) (RHBZ#1651432).
If ‘virt-v2v -oo verify-server-certificate=false’ is used then
‘openstack --insecure’ flag is added whenever we invoke the openstack
command.  This turns off SSL certificate validation.  The default is
to verify the server certificate (which is the default of the
openstack command).
2018-11-20 16:14:09 +00:00
Richard W.M. Jones
07d1d946be v2v: -o openstack: Restrict passthrough auth params to ‘os-*’.
This was already documented, but the implementation allowed you to
pass through anything to the openstack command.
2018-11-20 16:14:09 +00:00
Richard W.M. Jones
ed3ff51df9 test-data: Allow tests to be run when Btrfs is not available.
Create the fedora-btrfs.img as an empty file.

The only place this is used explicitly is tests/mountable/
test-mountable-inspect.sh, but that test already skips if !btrfs.

Also this is used via guests-all-good.xml, but the script that creates
this XML skips the file if it has zero size.
2018-11-20 15:40:10 +00:00
Richard W.M. Jones
fe9988eff8 common/mltools: Add a debug statement when we try to run a non-existent program.
Previously:

  $ virt-v2v -v -x -i disk fedora-28.img -o openstack -oo server-id=foo
  virt-v2v: libguestfs 1.39.11fedora=29,release=1.fc29,libvirt (x86_64)
  libvirt version: 4.5.0
  virt-v2v: error: openstack: precheck failed, there may be a problem with
  authentication, see earlier error messages
  rm -rf '/var/tmp/null.dTxRFN'

Notice there is no "earlier error message".

After this commit the error changes to:

  openstack: executable not found
  virt-v2v: error: openstack: precheck failed, there may be a problem with
  authentication, see earlier error messages
2018-11-20 15:40:10 +00:00
Pino Toscano
545147f9be v2v: create an empty windows.vmdk in case of disabled appliance
In case the appliance is disabled at configure, then all the phony
guests will not be built during the 'make check' time.  Since the tests
already handle an empty windows.vmdk fine (in case ntfs-3g is not
available), then just create it empty in this case.

Reported by: Martin Kletzander.
2018-11-20 09:43:56 +01:00
Martin Kletzander
d1c5c5a7c1 m4: Add java search path for Gentoo
In Gentoo the java alternatives are managed using jva-config (or eselect java),
but because the selection is treated as a configuration the symlink to the
current jvm selected is stored in /etc, particularly in the symlink
/etc/java-config-2/current-system-vm which works such as /usr/lib/jvm/default.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2018-11-20 08:41:02 +00:00
Pino Toscano
7cbd7bf209 v2v: windows: uninstall VMware Tools
It looks like VMware Tools support their unattended uninstallation even
after the guest is not running anymore on VMware.
2018-11-15 18:11:46 +01:00
Pino Toscano
d6c4b90b00 v2v: windows: factor uninstall commands search
Turn the code for 'prltools_uninsts' into an helper function
'unistallation_commands', so that can be used also for other
applications installed.
2018-11-15 18:11:46 +01:00
Richard W.M. Jones
4aa712d551 v2v: tests: Fix module ordering of v2v_unit_tests.
New dependency from Windows_virtio -> Linux requires the
objects to be linked in a slightly different order.

Fixes commit 6b2e0b5468.
2018-11-14 19:02:17 +00:00
Richard W.M. Jones
6d3b9a2812 v2v: Split up huge manual page into smaller pages.
The primary virt-v2v(1) page now contains a more concise overview of
virt-v2v, along with things like detailed options documentation which
we would expect in a tool manual.

The documentation for VMware, Xen, local output, oVirt and OpenStack
has been moved to new pages where it is introduced in a more narrative
/ tutorial style.  The idea is that people who are interested in
converting from or to these sources will be able to start at
virt-v2v(1) for an overview before moving to one of these new pages
for a friendlier introduction to the topic.

The support matrix has also been moved to a new page called
virt-v2v-support(1).  The idea is that downstream packagers will be
more easily able to modify or completely replace this page according
to their support requirements.

When rewriting the VMware documentation, I dropped the section
"INPUT FROM VMWARE ESXi HYPERVISOR" which discussed using
virt-v2v-copy-to-local.  This should no longer be necessary since you
can use SSH or VDDK.  (See also previous commit).
2018-11-14 18:20:24 +00:00
Richard W.M. Jones
3dfce4b5bb v2v: copy-to-local: Remove references to using this tool for ESXi.
virt-v2v is capable of accessing ESXi hypervisors now.  There is only
one remaining use of this tool - when converting from Xen hypervisors
over ssh which are using host block devices for storage.
2018-11-14 18:20:24 +00:00
Richard W.M. Jones
df54c75d4c test-data: Fix indentation in make-fedora-img.pl.
Only a whitespace change.
2018-11-14 18:20:24 +00:00
Richard W.M. Jones
325fffd361 v2v: Reduce the amount of appliance memory back to around 2GB.
Commit ba82fb023d changed the default
libguestfs appliance memory from 500 -> 768MB.

Virt-v2v used a formula to calculate how much memory to use which is
based on this which was designed to result in around 2GB of memory:

  500 * 20 / 5 = 2000

However after the commit the same formula now produces:

  768 * 20 / 5 = 3072

This commit reduces the numerator in the formula to yield (about) 2GB
again:

  768 * 14 / 5 = 2150
2018-11-14 18:15:32 +00:00
Tomáš Golembiovský
6b2e0b5468 v2v: linux: install QEMU-GA (RHBZ#1619665)
Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2018-11-14 09:55:42 +00:00
Tomáš Golembiovský
db9b45f020 v2v: fix path construction in Windows_virtio.copy_files()
Some paths in the function are evaluated in libguestfs environment.
Previous commit copied the invalid construction. This is now fixed.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2018-11-14 09:55:42 +00:00
Tomáš Golembiovský
6b74a051dc v2v: refactor copy_drivers() in Windows_virtio
Changed the function to be more generic and renamed.
The only change in behavior is in produced debug messages.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2018-11-14 09:55:42 +00:00
Tomáš Golembiovský
4b7fd09bf6 v2v: linux: install packages
Install packages from local files without touching network.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2018-11-13 17:35:20 +00:00
Richard W.M. Jones
8a01e13fee Update gnulib to latest.
Various tests fail with the new Linux kernel, update gnulib to see if
this helps.
2018-11-08 21:32:10 +00:00
Pino Toscano
dd665e4bbb p2v: use newer GTK+ APIs if possible
Make use of APIs available in early GTK+ 3 versions, adding
compatibility functions/macros for older GTK+ versions.

There is no behaviour change, and it helps in porting to even newer GTK+
versions.
2018-11-07 11:52:46 +01:00
Richard W.M. Jones
3430c2dd65 builder: templates: Set 0644 permissions on final disk image.
I think libvirt or virt-install has changed recently so that it
creates disk images which are not public readable.  This has lead to
me uploading two sets of non-readable templates for virt-builder.  Set
the mode explicitly to 0644.

Thanks: Laine Stump, Jacob Shivers.
2018-11-06 21:46:20 +00:00
Pino Toscano
c7343a29dd p2v: make-disk: rely on os-release for host distro detection
Instead of assuming the latest Fedora version if /etc/redhat-release is
available, or the latest Debian with /etc/debian_version, use only
/etc/os-release.  The possible name of the virt-builder template is
created by concatenating $ID and $VERSION_ID, which is generally a
better guess than what previously done, and better matches the host OS.

This affects only the case when os-version is not specified as command
line argument.
2018-11-06 16:31:41 +01:00
Pino Toscano
f2a1ef01ab p2v: add a Shutdown action (RHBZ#1642044)
Add a "Shutdown" action to the Shutdown button in the conversion dialog,
before the Reboot action: this way it is possible to shutdown the
physical server directly from the GUI after the conversion.
2018-11-06 16:31:41 +01:00
Pino Toscano
b6925d03cb p2v: turn Reboot button into a Shutdown popup menu button
To ease adding a proper Shutdown action in the conversion dialog, turn
the current Reboot button into a button that pops a menu up, with Reboot
as the only available action.

The menu is implemented using a popover when using "recent" versions of
GLib, and GTK+ 3, because of all the APIs needed.  In older versions, a
simple toggle button with menu is used, which though needs a manual menu
firing when pressing the button itself (and not its side arrow).
2018-11-06 16:31:41 +01:00
Richard W.M. Jones
eb4d14cb41 v2v: windows: Document use of pnputil to install drivers.
This seems to be necessary for Windows Server Core 2012 + R2, although
it has not been necessary with virt-v2v previously.  By adding this
simple comment-only change we will know this for future reference.
2018-11-06 12:24:21 +00:00
Richard W.M. Jones
03807c9412 v2v: -o qemu: Comma before -device ...,mac=<MAC>
The comma before the mac option was lost accidentally during
refactoring in commit f6ece2c01a.
2018-11-05 18:01:26 +00:00
Richard W.M. Jones
b0daa89ef0 lib/launch-libvirt.c: Fix tabs/spaces issue in this file.
Convert randomly used tabs into spaces.
2018-11-02 19:42:23 +00:00
Richard W.M. Jones
296d6a9fda lib, p2v: Use single_element() macro where possible.
After the previous commit, wherever we had:

  start_element ("foo") {
    string ("bar");
  } end_element ();

this can now be replaced by:

  single_element ("foo", "bar");
2018-11-02 19:38:11 +00:00
Richard W.M. Jones
4bc30d2f9a inspector: Use libxml writer macros.
Change virt-inspector so it uses the common set of macros.  I also
added:

* single_element() and single_element_format():
  creates <foo>bar</foo> which is used extensively by virt-inspector

* base64():
  used by virt-inspector for the icon
2018-11-02 19:38:08 +00:00
Richard W.M. Jones
6d5959a045 common/utils: Move libxml2 writer macros to a common header file.
In some places when generating XML output in C code we use some clever
macros:

  start_element ("memory") {
    attribute ("unit", "MiB");
    string_format ("%d", g->memsize);
  } end_element ();

This commit which is mostly refactoring moves the repeated definitions
of these macros into a common header file.

I also took this opportunity to change / clean up the macros:

 - The macros are now documented properly.

 - comment() and empty_element() macros are now available everywhere.

 - Error handling has been made generic.

 - Added do..while(0) around some of the macros to make them safe to
   use in all contexts.
2018-11-02 15:15:04 +00:00
Richard W.M. Jones
970dccf147 docs: Allow enhanced comments for macros (ie. #define). 2018-11-02 13:44:26 +00:00
Richard W.M. Jones
ba82fb023d lib: Increase default memory assigned to the appliance.
With recent Linux kernels, adding and partitioning 255 disks causes
the appliance to run out of memory.  This causes a test failure in
tests/disks/test-255-disks.sh.  This change gives the appliance enough
memory to complete the test.
2018-11-02 13:44:26 +00:00
Richard W.M. Jones
f00f920ad3 lib: Use qemu-img info -U option to avoid locking error.
https://bugs.launchpad.net/qemu/+bug/1740364
2018-11-02 13:19:51 +00:00
Richard W.M. Jones
97a8833a1b builder: Add RHEL 7.6 templates. 2018-11-01 12:12:21 +00:00
Richard W.M. Jones
9bc1eda0a9 builder: Add Fedora 29 templates. 2018-11-01 12:12:21 +00:00
Tomáš Golembiovský
d76acb13ae v2v: enable UEFI for oVirt/RHV outputs
Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>

RWMJ: Update documentation with versions of oVirt/RHV and virt-v2v
required for UEFI support.
2018-10-16 14:10:47 +01:00
Tomáš Golembiovský
a878b3011b v2v: ovf: add firmware and machine type element
Add oVirt specific elemnt to OVF. It represents the combination of
machine type (i440fx/q35) and firmware (BIOS/UEFI).

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2018-10-16 14:10:47 +01:00
Richard W.M. Jones
bfd9bee9fc v2v: -o rhv-upload: Test using HTTP/1.1 protocol.
Fixes commit b54b58c44e.

Thanks: Nir Soffer.
2018-10-16 09:59:51 +01:00
Richard W.M. Jones
d23b89f217 builder: templates: Add RHEL 6.9, 6.10. 2018-10-15 22:15:37 +01:00
Richard W.M. Jones
0e575234fd v2v: -it vddk: Add a warning about using vddk* options (RHBZ#1527334).
Stress these options shouldn't be used unless you know what you're
doing.
2018-10-04 15:33:09 +01:00
Richard W.M. Jones
42d10f0b0e v2v: -it vddk: Remove ‘-io vimapiver’ option (RHBZ#1527334).
This option was added in error.  It never had any effect and now the
nbdkit VDDK plugin ignores it.  Virt-v2v users shouldn't have been
using it.

This removes the option completely (so if anyone was using it they
will now get an error).
2018-10-04 15:33:09 +01:00
Pino Toscano
04a157d0f8 v2v: linux: try to trick vmware-uninstall-tools.pl
When installing the VMware tools from tarball, the installation script
rebuilds the initramdisk of all the available kernels to inject the
missing kernel drivers; in the end, the information on which kernels
were changed is recorded in the internal "database" of the installation
answers.  When uninstalling the VMware tools, the uninstallation script
reads the saved answers, and in the case of ramdisks will do the reverse
job done during the installation (which is done again when new kernels
are installed).

OTOH, virt-v2v already rebuilds the initramdisk of the default kernel,
not touching the other available kernels (no matter whether they have
the right modules or not).  Hence, trick the answers "database" of the
VMware tools to discard all the information about ramdisks to restore on
uninstallation: this way they are not rebuilt, and the whole
uninstallation time will be reasonable enough (a couple of minutes or
so).
2018-10-04 10:57:25 +02:00
Pino Toscano
2bebacf8bf v2v: linux: remove open-vm-tools packages
Linux distributions usually ship the open source VMware tools as
open-vm-tools (and open-vm-tools-desktop for the integration with X).
While they will not run already anymore after the conversion, uninstall
them during the conversion, to save some space in the converted guest.
2018-10-04 10:48:17 +02:00
Pino Toscano
caff0ba3ad build: remove extra quote in result message
Followup of commit 3acf6768f0.
2018-10-03 12:45:32 +02:00
Pino Toscano
55bb0003f5 rpm: generalize openSUSE support
It seems that all the newer versions of openSUSE have an 'opensuse-'
prefix in their distro ID; hence, check for that prefix at once, keeping
compatibility for the old "opensuse" ID.

Followup of commit a4e53bcbc5.
2018-10-02 12:54:26 +02:00
Pino Toscano
69ee0fb873 v2v: -o rhv-upload: test-v2v-o-rhv-upload.sh: add more skip checks
-o rhv-upload requires python3, and nbdkit with the python3 plugin, so
skip this test if they are not installed.
2018-10-01 16:32:25 +02:00
Pino Toscano
a4e53bcbc5 build: support openSUSE Leap 15.0
Support the ID found in openSUSE Leap 15.0 in addition to  the other
SUSE-related IDs.  While there is already --with-distro=ID to force the
ID without using os-release, this makes it possible to build OOTB.
2018-10-01 16:17:51 +02:00
Richard W.M. Jones
70407cd622 inspection: Parse os-release "opensuse-leap" as opensuse (RHBZ#1634248). 2018-10-01 11:17:13 +01:00
Pino Toscano
4ff573c352 ocaml: make sure to pass LDFLAGS to ocamlmklibs linker (RHBZ#1624130)
Pass the LDFLAGS properly as arguments for the C linker when using
ocamlmklibs via the -ldopt option.

Followup of commit 34c23403c5.
2018-09-27 15:51:01 +02:00
Richard W.M. Jones
b54b58c44e v2v: -o rhv-upload: Add a test.
Previously this output method was almost completely untested.

This commit adds a fake ovirtsdk4 module so we can test the
-o rhv-upload method fairly completely without needing an actual
oVirt instance around.

Thanks: Pino Toscano.
2018-09-26 19:00:40 +01:00
Richard W.M. Jones
6694028f98 v2v: -o rhv-upload: Only set SSL context for https connections.
For real imageio servers the destination will always be https.  This
change has no effect there.

However when testing we want to use an http server for simplicity.  As
there is no certificate or cafile in this case the call to create the
context will fail.

This also simplifies creation of the context object and recognizes the
"insecure" flag for connecting to imageio.

Thanks: Nir Soffer.
2018-09-26 19:00:40 +01:00
Richard W.M. Jones
edd4980cef v2v: -o rhv-upload: Print commands before running them in verbose mode. 2018-09-26 19:00:40 +01:00
Richard W.M. Jones
e2bafffce2 Version 1.39.11. 2018-09-21 16:15:37 +01:00
Richard W.M. Jones
da48f4e5ff sparsify: Fix test-virt-sparsify-in-place-fstrim-unsupported.sh
Since Linux commit f663b5b38fff trimming vfat is now supported by
Linux.  This broke the test which assumed it was not supported.  Use
another filesystem (minix) which does not support trimming instead.

Thanks: Daniel P. Berrangé and Pino Toscano.
2018-09-21 13:32:58 +01:00
Richard W.M. Jones
165add060e Version 1.39.10. 2018-09-21 11:57:08 +01:00
Richard W.M. Jones
6f605a0804 lib: direct: Query qemu binary for availability of KVM (RHBZ#1605071).
When using the direct backend, you should see the result of testing
the qemu binary for the availability of KVM:

  libguestfs: qemu KVM: enabled

Thanks: Andrea Bolognani.
2018-09-21 10:56:25 +01:00
Richard W.M. Jones
34c23403c5 tools: Ensure CFLAGS and LDFLAGS are passed to all OCaml binaries (RHBZ#1624130).
After this commit, all annocheck errors are fixed except for:

  Hardened: virt-get-kernel: MAYB: Gaps were detected in the annobin coverage.  Run with -v to list.

After discussion with the annocheck maintainers this gap in coverage
(which corresponds to the OCaml runtime) seems to be caused either by
the runtime not being linked with the right flags, or might be a bug
in annocheck itself.  In any case it's not something that can be
resolved within the scope of libguestfs.
2018-09-21 10:16:34 +01:00
Richard W.M. Jones
09abb9c990 tools: Link OCaml programs with -runtime-variant _pic if available.
OCaml has a small runtime which is statically linked into the virt
tools (providing things like GC and primitives).  Since OCaml 4.03 it
has been possible to select variants of this runtime, one of which is
compiled with -fPIC, using ‘ocamlopt -runtime-variant _pic’.

This has performance implications on i686, but is relatively free on
other architectures.  Since it (in theory) adds to the security of the
final binary this commit enables it whenever it is available.
2018-09-21 10:16:34 +01:00
Pino Toscano
4b1e5b0c3f Introduce a --key option in tools that accept keys
The majority of the tools have already options (--echo-keys &
--keys-from-stdin) to deal with LUKS credentials, although there is no
way to automatically provide credentials.  --keys-from-stdin is
suboptimal, because it is a usable solution only when there is just one
device to open, and no other input passed via stdin to the tool (like
the commands for guestfish).

To overcome this limitation, introduce a new --key option in tools:
* --key /dev/device:file:/filename/with/key
* --key /dev/device:string:the-actual-key
this way it is possible to pass all the credentials needed for the
specific devices to open, with no risk of conflict with stdin, and also
in a secure way (when using the "file" way).

On the technical side: this adds a new "key_store" API for the C tools,
making sure it is used only when needed.  Partially mirror it also for
the OCaml tools, although there will be a conversion to the C API
because the decryption helpers used are in the common C parts.
2018-09-21 10:30:05 +02:00
Pino Toscano
ec438b7b85 mltools: create a cmdline_options struct
Instead of returning directly a Getopt.t handle, now
Tools_utils.create_standard_options returns a struct, which at the
moment contains only the Getopt.t handle.  This way, it will be easy to
add more data needed for handling standard command line options.

This is mostly refactoring, with no functional changes.
2018-09-20 17:52:53 +02:00
Richard W.M. Jones
51a9c874d3 v2v: Add a slow test of Windows conversions.
As with the previous commit this requires that Windows guests have
been created first using the procedure from:

https://rwmj.wordpress.com/2018/09/13/creating-windows-templates-for-virt-builder/

For me:

PASS: test-v2v-conversion-of-windows-6.3-server.sh
PASS: test-v2v-conversion-of-windows-6.2-server.sh
PASS: test-v2v-conversion-of-windows-10.0-server.sh

If you don't have these templates in virt-builder then the tests will
skip.
2018-09-14 14:59:35 +01:00
Richard W.M. Jones
4b6341072c customize: tests: Add slow test of Windows firstboot.
This requires that Windows guests have been created using the
procedure outlined here:

https://rwmj.wordpress.com/2018/09/13/creating-windows-templates-for-virt-builder/

For me:

PASS: test-firstboot-windows-6.2-server.sh
PASS: test-firstboot-windows-6.3-server.sh
PASS: test-firstboot-windows-10.0-server.sh

An incidental change is that we dump the firstboot log from the guest
(even on success).  If the firstboot fails this is very useful for
determining the real cause.
2018-09-14 14:39:46 +01:00
Richard W.M. Jones
d54be028a2 customize: Use set -x for test-firstboot.sh slow test.
Aids in debugging failed tests.
2018-09-14 13:49:54 +01:00
Richard W.M. Jones
bbefbc8a48 v2v: -it vddk: Fix check for incorrect LD_LIBRARY_PATH.
In nbdkit >= 1.7.2, nbdkit vddk --dump-plugin will print the shared
library name in normal output, which breaks this test.

The actual error when LD_LIBRARY_PATH is not set includes this line:

  nbdkit: error: libvixDiskLib.so.6: cannot open shared object file: No such file or directory

so search instead for the error message "cannot open shared object file".
2018-09-14 12:01:53 +01:00
Richard W.M. Jones
089f0345f4 builder: templates: Add Windows template support.
Provides support for building:

 - Windows 7
 - Windows Server 2008 R2
 - Windows Server 2012
 - Windows Server 2012 R2
 - Windows Server 2016

Note that these images cannot be released to the public because of
obvious licensing issues.  But this documents how we build them for
internal consumption so that others can also build them.

Thanks: Christophe Fergeau, Tomáš Golembiovský.
2018-09-13 09:51:58 +01:00
Richard W.M. Jones
755834c797 builder: templates: Use virt-sparsify --in-place (instead of copying).
virt-sparsify in copying mode takes a huge amount of temporary space
and takes a very long time.  In any case it's not really necessary for
modern guests since in-place sparsification is fully supported now.
2018-09-13 09:17:21 +01:00
Nikolay Ivanets
eaa9c8cbc6 daemon: consider /etc/mdadm/mdadm.conf while inspecting mountpoints.
Inspection code checks /etc/mdadm.conf to map MD device paths listed in
mdadm.conf to MD device paths in the guestfs appliance. However on some
operating systems (e.g. Ubuntu) mdadm.conf has alternative location:
/etc/mdadm/mdadm.conf.

This patch consider an alternative location of mdadm.conf as well.
2018-09-13 09:17:21 +01:00
Richard W.M. Jones
e6895bd9d2 builder: templates: Specify --arch explicitly, even on x86_64. 2018-09-11 16:52:10 +01:00
Richard W.M. Jones
cc01166a24 builder: templates: Make UEFI code arch-independent.
Previously it only worked for aarch64.
2018-09-11 16:52:10 +01:00
Richard W.M. Jones
613c1782ea builder: templates: Refactor code for using UEFI.
Simple refactoring.
2018-09-11 16:52:10 +01:00
Richard W.M. Jones
00fff03485 builder: templates: Refactor code for adding --initrd-inject.
Initrd is a Linux thing, so this code should only be used for
Linux-based OSes.  Refactor to make it a bit cleaner.
2018-09-11 16:52:10 +01:00
Richard W.M. Jones
d0ff42dfa2 builder: templates: Add a can_sysprep_os function.
Does virt-sysprep know how to sysprep this disk image?  Add a function
to find out.

Just refactoring.
2018-09-11 16:52:10 +01:00
Richard W.M. Jones
112880e61b builder: templates: Rename make_kickstart function.
This function will soon be used to generate Windows unattended.xml
files (as well as Debian preseed) so just rename it back to
‘make_kickstart’ rather than attempting to explain in the name every
way it could be used.
2018-09-11 16:52:10 +01:00
Richard W.M. Jones
e9bd010f6a builder: templates: Add generic method for deleting files on exit.
Simple refactoring.
2018-09-11 16:52:10 +01:00
Richard W.M. Jones
2c349a00d2 Revert "build: Maintain a central list of skipped tests."
This reverts commit 79a3ac5d0e.
2018-09-04 11:25:56 +01:00
Richard W.M. Jones
46bb1428ec Revert "tests: Disable 255 disk test until we can find a way to make it reliable."
This reverts commit 9b911a2a85.
2018-09-04 11:25:56 +01:00
Richard W.M. Jones
969cacead9 v2v: Add -o openstack target, writes to OpenStack & Cinder using APIs. 2018-09-03 18:29:33 +01:00
Richard W.M. Jones
e4f4ed6188 mltools: Add with_timeout utility function.
Higher-order function which performs an operation repeatedly until it
succeeds or fails, or a timeout is reached.
2018-09-03 18:29:33 +01:00
Richard W.M. Jones
16c9dad598 v2v: -o glance: Refactor OpenStack image properties into a new module.
Straightforward refactoring.  Apart from small modifications to clean
up the code and reorder the properties more logically there should be
no functional change.
2018-09-03 18:29:33 +01:00
Richard W.M. Jones
e12c56176a v2v: windows: Fix rhev-apt command line (RHBZ#1624902).
See:
https://bugzilla.redhat.com/show_bug.cgi?id=1584678#c15

Fixes commit bcdbe6405c.  However this
bug was copied directly from old virt-v2v which did the same thing
(from lib/Sys/VirtConvert/Converter/Windows.pm):

  echo installing rhev-apt >>log.txt
  "rhev-apt.exe" /S /v /qn >>log.txt

Thanks: Lev Veyde
2018-09-03 18:29:33 +01:00
Richard W.M. Jones
741ef228cd v2v: docs: Describe support for SHA-2 certs for Windows 7 / 2008 R2 (RHBZ#1624878).
Thanks: Yan Vugenfirer.
2018-09-03 18:29:33 +01:00
Richard W.M. Jones
56f1e6cecd java: Link with gnulib to resolve missing hash_free symbol. 2018-08-28 22:24:46 +01:00
Richard W.M. Jones
9b911a2a85 tests: Disable 255 disk test until we can find a way to make it reliable. 2018-08-28 22:24:46 +01:00
Richard W.M. Jones
79a3ac5d0e build: Maintain a central list of skipped tests.
I was maintaining this list unofficially.  Let's maintain it in the
sources so it is versioned and branched along with the libguestfs
code.
2018-08-28 22:24:46 +01:00
Richard W.M. Jones
5b87b9f132 ppc64le: Remove bogus __powerpc64le__.
Not a thing - tested on P9.
2018-08-28 22:24:46 +01:00
Richard W.M. Jones
56318f0b5f ppc64le: Don't use -cpu parameter under any circumstances (RHBZ#1605071). 2018-08-28 22:24:46 +01:00
Richard W.M. Jones
598e879ad1 Version 1.39.9. 2018-08-28 22:17:02 +01:00
Richard W.M. Jones
af5b117ade mltools: Add test-machine-readable-script.sh to EXTRA_DIST.
Fixes commit afa8111b75.
2018-08-28 22:15:30 +01:00
Nir Soffer
8f250c00c8 v2v: rhv-upload-plugin: Use BrokenPipeError
With python 3, we have a nicer way to handle socket.error with errno set
to EPIPE (or ESHUTDOWN).

This is also more correct since in some cases (that I could not
reproduce yet with v2v), using e[0] with BrokenPipeError will fail with:

>>> OSError(errno.EPIPE, "Broken pipe")[0]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'BrokenPipeError' object is not subscriptable

For python 2 e[0] seems to work, but is leftover from historic python
version that used to raise a tuple instead of socket.error instance.
In python 2.7 library code e.args[0] is used. If we ever port this to
python 2 this is the best form.
2018-08-28 21:56:11 +01:00
Richard W.M. Jones
0d0b551130 v2v: Document how to adjust ESXi NFC memory limit (RHBZ#1614276). 2018-08-24 14:25:27 +01:00
Richard W.M. Jones
9f678c3bde v2v: Add --print-estimate option to print copy size estimate.
This option prints the estimated size of the data that will be copied
from the source disk.

Currently this overestimates by the size of the qcow2 header, but for
real disk images that doesn't matter much.

For example:

$ virt-builder fedora-27
$ virt-v2v -i disk fedora-27.img -o null --print-estimate
[...]
virt-v2v: This guest has virtio drivers installed.
[  44.0] Mapping filesystem data to avoid copying unused and blank areas
[  44.5] Closing the overlay
disk 1: 1047920640
total: 1047920640
2018-08-24 14:13:01 +01:00
Pino Toscano
10f9779c08 v2v: test-harness: use Xml.parse_file
Use Xml.parse_file instead of read_whole_file + Xml.parse_memory.
2018-08-24 13:11:09 +02:00
Pino Toscano
d7772fb78b builder: index_parser_tests: really use parameter
Really use the parameter of the "read_file" function, instead of
hardcoding "out".  This does not change the behaviour, since all the
callers already use "out" as the file name to read.

Fixes commit 7e3689bfe0.
2018-08-24 13:06:36 +02:00
Pino Toscano
ec345aca02 builder: use the new json_parser_tree_parse_file
No need to read the whole file manually.
2018-08-23 19:12:46 +02:00
Pino Toscano
bb00c482e8 mltools: JSON: add json_parser_tree_parse_file
Easy way to parse JSON from a file, without reading it all to string
first.
2018-08-23 19:06:22 +02:00
Sebastian Meyer
fd43730e2b Fix error with --uninstall option on SUSE
The `-l` option for some `zypper` subcommands is short for
`--auto-agree-with-licenses` and not available on the `zypper rm` command.
2018-08-23 18:05:04 +02:00
Pino Toscano
afa8111b75 OCaml tools: add output selection for --machine-readable
Add an optional argument for --machine-readable to select the output,
adding a new function to specifically write data to that output stream.
The possible choices are:
* --machine-readable: to stdout, like before
* --machine-readable=file:name-of-file: to the specified file
* --machine-readable=stream:stdout: explicitly to stdout
* --machine-readable=stream:stderr: explicitly to stderr

Adapt all the OCaml-based tools to use the new function, so the
--machine-readable choice is respected.
2018-08-23 18:03:39 +02:00
Pino Toscano
8863ccbd64 common/mltools: getopt: add Getopt.OptString
Introduce a new type of option with an optional string argument.
2018-08-23 16:04:27 +02:00
Pino Toscano
962e8b6255 lib: create: avoid one extra string allocation
When creating the qemu-img command, use the guestfs_int_cmd_add_arg &
guestfs_int_cmd_add_arg_format APIs to add the proper filename directly,
without creating a string for it.

This should cause no functional change.
2018-08-23 13:22:00 +02:00
Richard W.M. Jones
df11067329 mltools: JSON: unify JSON_parser type with JSON.json_t. 2018-08-23 09:56:51 +01:00
Richard W.M. Jones
f9994c7ffb mltools: JSON: Implement JSON.Null.
Implements the ‘null’ value.
2018-08-23 09:56:51 +01:00
Richard W.M. Jones
38f688b8b5 build: Rebuild docs/C_SOURCE_FILES and po/POTFILES.
Remove:

common/utils/libxml2-utils.c
common/utils/libxml2-utils.h

These were accidentally added by
commit a63d02f8f1 because of a bad
interactive rebase.
2018-08-22 15:28:50 +01:00
Richard W.M. Jones
279472f304 mltools: JSON: combine JSON.Int and JSON.Int64 into a single variant.
It was convenient to have these as separate variants when we were only
using this type to generate JSON.  However if we also use it to parse
JSON documents then integers in the document should only map to a
single variant.
2018-08-22 15:18:57 +01:00
Richard W.M. Jones
bd5c0b7c12 mltools: JSON: Implement JSON.Float.
This is not actually used anywhere, but it completes the JSON
implementation and it will be useful for unifying JSON with
JSON_parser.
2018-08-22 15:18:57 +01:00
Richard W.M. Jones
a63d02f8f1 mltools: JSON: Rename Yajl module as JSON_parser and move to common/mltools.
Commit bd1c5c9f4d changed all the code
to use Jansson instead of yajl.  However it didn't change the OCaml
module name (still Yajl).

This commit changes the module to a neutral name ("JSON_parser") and
moves it into common/mltools so it can be used by other tools.

This leaves us in a slightly awkward situation of having two JSON-ish
OCaml modules (JSON for creating trees and JSON_parser for parsing
them) with incompatible types.  That is left for future work to
resolve.  (It should be easier to do now that both modules live in the
same directory.)

This is just renaming and general refactoring.  There should be no
change in functionality.
2018-08-22 15:18:57 +01:00
Richard W.M. Jones
1b25fc393b build: Use LT_INIT in configure.ac.
Avoids the warning:
libtoolize: Remember to add 'LT_INIT' to configure.ac.

This is the new name for AC_PROG_LIBTOOL, so I removed that.

However to use this macro we must enable AC_USE_SYSTEM_EXTENSIONS.
(AC_GNU_SOURCE was removed back in 2011).
2018-08-22 11:36:36 +01:00
Bernhard M. Wiedemann
4d39faaa30 generator: Do not claim copyright for future years
This change helps to make libguestfs package build reproducible.
See https://reproducible-builds.org/ for why this is good.

Without this patch, building today's libguestfs in 2033, claims
 Copyright (C) 2009-2033 Red Hat Inc.
which cannot be correct.

This affected files like
/usr/include/guestfs-gobject.h
/usr/lib/perl5/vendor_perl/5.26.2/x86_64-linux-thread-multi/Sys/Guestfs.pm
/usr/lib64/python2.7/site-packages/guestfs.py
/usr/lib64/ocaml/guestfs/guestfs.mli

Commits like 212762c593
will take care of updating the year.
2018-08-22 11:29:29 +01:00
Nir Soffer
1368b1bb7d v2v: rhv-upload-plugin: Fix error formatting
Fix the error format so we actually format the arguments instead of
raising the format string and the arguments.

Here is an upload error formatted correctly with this change:

nbdkit: python[1]: error: /home/nsoffer/src/libguestfs/tmp/v2v.eC5yCl/rhv-upload-plugin.py:
pwrite: error: could not write sector offset 218911744 size 3584: 403 Forbidden:
b'{"explanation": "Access was denied to this resource.", "code": 403, "detail":
"Ticket u\'61ac0483-48e3-4984-84d6-438884ba8bb2\' expired", "title": "Forbidden"}'
2018-08-21 12:05:24 +01:00
Nir Soffer
a651169085 v2v: rhv-upload-plugin: Handle send failures
The oVirt server may fail a PUT request before reading all request body.
However before closing the connection, it writes a detailed error
response, that will make debugging issues like expired tickets much
easier to handle. If we don't get the response and log the error, the
error may be lost when the daemon log is rotated.

Change pwrite() and emulate_zero() to get the response after EPIPE,
failing with the error response from the oVirt server.

Here is an example error log when a ticket expires during import:

nbdkit: python[1]: error: /home/nsoffer/src/libguestfs/tmp/v2v.pRoyXm/rhv-upload-plugin.py:
pwrite: error: ('%s: %d %s: %r', 'could not write sector offset 1841154048 size 1024', 403,
'Forbidden', b'{"explanation": "Access was denied to this resource.", "code": 403, "detail":
"Ticket u\'6071e16f-ec60-4ff9-a594-10b0faae3617\' expired", "title": "Forbidden"}')
2018-08-21 12:05:24 +01:00
Pino Toscano
2fa78e6dce OCaml tools: simplify machine-readable handling
Make use of the helper provided by Tools_utils.create_standard_options,
so there is no need to implement the logic in each tool.

This affects all the OCaml tools with --machine-readable, namely:
virt-builder, virt-builder-repository, virt-dib, virt-get-kernel,
virt-resize, virt-sparsify, and virt-v2v.
2018-08-20 22:25:55 +01:00
Pino Toscano
b8f0740b51 mlstdutils/mltools: factorize the machine-readable option
Store the machine-readable flag globally, just like done for
verbose/debug/etc, and enhance create_standard_options to provide
--machine-readable automatically.
2018-08-20 22:20:31 +01:00
Richard W.M. Jones
13d85d722f mltools: Rename run_command std*_chan -> std*_fd.
These are file descriptors, not the high level OCaml in_channel/
out_channel type, so we would normally not refer to them as *_chan.

Just renaming, no functional change.
2018-08-20 16:50:24 +01:00
Richard W.M. Jones
f835c314cd mltools: Document that run_command closes stdout_chan/stderr_chan.
This behaviour is documented for run_commands, but not documented for
run_command, so document it.
2018-08-20 16:50:24 +01:00
Richard W.M. Jones
9afcf13af4 v2v: -o rhv-upload: Simplify build of Python scripts using wildcards.
No functional change.
2018-08-17 12:03:31 +01:00
Pino Toscano
840dbb1dfc v2v: parse_libvirt_xml: number disks from 0
When parsing the libvirt XML, make sure to assign the IDs for disks
(s_disk_id) from 0 instead of 1.  This does not change the actual
behaviour, just makes the IDs like in all the other input modes not
based on libvirt XML.
2018-08-15 12:08:59 +02:00
Richard W.M. Jones
90c9c12258 v2v: -o rhv-upload: Fix error message disk numbering (RHBZ#1615885).
The output method used the s_disk_id field assuming it was a unique,
monotonically increasing number counting from 0.  However this is not
the case, the input method simply has to set s_disk_id to be unique
for each disk.

Fixes commit cc04573927.

Thanks: Xiaodai Wang
2018-08-15 10:58:17 +01:00
Richard W.M. Jones
f9745c8229 v2v: Verify that ’source.s_disks.s_disk_id‘s are all unique. 2018-08-15 10:58:17 +01:00
Pino Toscano
c486f0cf4a Change wording from "twice" to "more than once" in error messages
When erroring out about duplicated parameters, say "more than once"
instead of "twice", since there can be more than two repeated
parameters.

Thanks to: Xiaodai Wang
2018-08-10 15:01:02 +02:00
Pino Toscano
c9abaa3e96 v2v: parse_libvirt_xml: handle srN CDROM devices (RHBZ#1612785)
This device naming is mostly written by virt-p2v, so get the slot from
it directly without using the drive_index "decoding" function.
2018-08-10 15:01:02 +02:00
Pino Toscano
a3e8871705 daemon: utils: add a couple of checks for split_device_partition
Mostly to check the behaviour of the function with cases like in
RHBZ#1611690.
2018-08-09 12:14:04 +02:00
Tomáš Golembiovský
71b588bab0 v2v: Add --mac option to machine-readable
Patch fe1a8866 added --mac option that allows mapping bridges/networks
based on the MAC address. It would be nice to have that listed in
machine-readable output

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2018-08-07 14:14:23 +02:00
Richard W.M. Jones
389e165519 v2v: -o rhv-upload: Properly replace SD_UUID in OVF (RHBZ#1612653).
The @SD_UUID@ pattern was not being replaced correctly.

Thanks: Daniel Erez.
2018-08-07 11:56:38 +01:00
Pino Toscano
31ee088812 btrfs_balance_status: delay allocation of 'ret'
Allocate 'ret' as late as possible, so there is no risk that early
returns will leak it.
2018-08-06 15:36:46 +02:00
Nir Soffer
c4a0d64f63 v2v: rhv-plugin: Use string literal concatenation
When splitting long strings over multiple lines, we can use string
literal concatenation instead of +.

See https://docs.python.org/3/reference/lexical_analysis.html#string-literal-concatenation
2018-08-06 09:02:17 +01:00
Richard W.M. Jones
8f4a8ae71c v2v: python_script: Use correct syntax for array slices in documentation.
Fixes commit 3d4df39732.
2018-08-03 17:24:18 +01:00
Pino Toscano
cf9995bae4 v2v: -o rhv-upload: PEP8 fixes for rhv-upload-plugin.py
- wrap a too long line
- join strings in multiple lines using + (plus) instead of \ (backslash)
2018-07-31 18:55:07 +02:00
Richard W.M. Jones
eb66dafe2e v2v: Add more detailed documentation for input methods.
Just comment changes.
2018-07-29 10:34:54 +01:00
Richard W.M. Jones
f9898e12ab v2v: Add more detailed documentation for output methods.
Just comment changes.
2018-07-27 18:28:04 +01:00
Pino Toscano
67c36779c3 daemon: inspect: ignore fstab devs that cannot be resolved (RHBZ#1608131)
If the /etc/fstab of a guest contains devices specified with UUID or
LABEL, then the new OCaml inspection code will report the findfs failure
as general failure of the inspection.  OTOH, the old C inspection code
simply ignored all the devices that cannot be resolved.

Hence, restore the old behaviour by ignoring unresolvable devices.
2018-07-27 15:07:00 +02:00
Richard W.M. Jones
040cb93717 Version 1.39.8. 2018-07-27 12:06:04 +01:00
Richard W.M. Jones
3d4df39732 v2v: Factor out code to call python scripts into a separate module.
Just refactoring, no change in functionality.
2018-07-27 10:35:17 +01:00
Richard W.M. Jones
5f1bc725fe v2v: Pass all metadata to #prepare_targets.
In commit 2894b8f392, #prepare_metadata
was added then later removed.

This commit provides the same data to #prepare_targets so that output
methods can create metadata early if necessary.  (Note that creating
metadata here is optional, it should normally be created
by #create_metadata method after the copying step).
2018-07-27 10:23:15 +01:00
Richard W.M. Jones
91132416c4 v2v: Move target bus assignment earlier.
By not storing the target pointer in the target bus assignment data
struct we can move target bus assignment earlier.
2018-07-27 10:23:15 +01:00
Richard W.M. Jones
45a525d834 Revert "v2v: Add output#prepare_metadata method to prepare metadata before copying."
This reverts commit 2894b8f392.
2018-07-27 10:23:15 +01:00
Richard W.M. Jones
b768121593 Revert "v2v: Add --print-target to display overlay and target information."
Remove this function (not available in any released stable version of
virt-v2v).  It complicates the code and is not used anywhere.

This reverts commit 9ac4f99fdc.
2018-07-27 10:23:15 +01:00
Richard W.M. Jones
82c6f6e31f v2v: Remove init_targets function completely.
The init_targets function is pretty odd, responsible for at least two
rather different functions: calculating the final format of each
target, and calling output#prepare_targets to get the output mode to
create each target.

Factor out the calculation of format into a separate function.  This
allows us to enhance this feature, so that -o null can now properly
override the output format (whereas previously it relied on some
internals).

After this, init_targets becomes mostly a small wrapper around calling
output#prepare_targets and we can remove init_targets completely.
2018-07-27 10:23:15 +01:00
Richard W.M. Jones
72caa8ff2f v2v: Move output#prepare_targets call to just before the copy.
Previously we initialized the targets and called #prepare_targets very
early on.  However this causes various problems:

 - the targets struct is only half-initialized
   (target_file is set to a dummy value)
 - the targets struct is passed around unnecessarily

The ostensible reason for this was so that #prepare_targets is called
very early on so that errors can be displayed quickly.  This is
important, but in practice it doesn't really matter if the user has to
wait for a few seconds for the conversion to happen first.

We also have the #precheck method which can do some pre-checking
functions, and that does run very early.

This is just refactoring, but it will allow some more significant
changes in how targets get initialized.  There are some large
whitespace changes in this patch so it is better to look at it using
‘git show -w’.
2018-07-27 10:23:15 +01:00
Richard W.M. Jones
4294b34b19 v2v: Move target_stats structure into overlay.
As there is a 1-1 relationship between overlays and targets, it
doesn't matter where this structure actually lives.  Move it from the
target struct to the overlay struct.
2018-07-27 10:23:15 +01:00
Richard W.M. Jones
3abacc3021 v2v: Remove output#check_target_free_space method.
Commit 5a620137bf (in 2014) introduced
an output#check_target_free_space method but noted that it was not
used:

    Provide an extra output method (#check_target_free_space) which output
    modules may use to check that there is sufficient free space to
    proceed, before conversion starts.  None of the output modules
    actually implement this at the moment.

As this method has never been used in nearly 4 years, remove it.
2018-07-27 10:23:15 +01:00
Richard W.M. Jones
4b9c64ef34 p2v: Generate the code and docs for parsing the kernel command line.
As a side effect, a lot more fields are now settable on the
kernel command line.

Existing kernel command lines & corresponding documentation should
still remain backwards compatible.
2018-07-27 10:23:15 +01:00
Richard W.M. Jones
98e2f8d7e9 p2v: Group configuration settings in sections.
Since the previous commit introduced configuration sections, we can
now group more configuration settings together in these sections.

The largest part of this commit is a simple renaming of fields in the
struct.
2018-07-27 10:22:51 +01:00
Richard W.M. Jones
818fd1e197 p2v: Generate config struct and p2v/config.c.
Mostly refactoring to make it easier to add fields to this struct in
future.

I'd like to call the header p2v/config.h but that's not possible since
it conflicts with the autoconf-generated file.
2018-07-26 17:10:19 +01:00
Richard W.M. Jones
ec2228ea05 inspector: Add a regression test for LUKS images (RHBZ#1602353). 2018-07-26 12:02:59 +01:00
Richard W.M. Jones
55dfcb2211 New API: lvm_scan, deprecate vgscan (RHBZ#1602353).
The old vgscan API literally ran vgscan.  When we switched to using
lvmetad (in commit dd162d2cd5) this
stopped working because lvmetad now ignores plain *scan commands
without the --cache option.

We documented that vgscan would rescan PVs, VGs and LVs, but without
activating them.

I have introduced a new API (lvm_scan) which scans or rescans PVs, VGs
and LVs.  It has an optional activate parameter allowing activation of
any new LVs that are found.

With lvmetad this nicely maps to the single command:

 pvscan --cache [--activate ay]
2018-07-26 12:02:59 +01:00
Richard W.M. Jones
16e64b8988 test-data/phony-guests: Add Fedora LUKS phony image for testing.
This is not added to guests-all-good since it cannot be used in
automated tests -- a password must be supplied.
2018-07-26 12:02:59 +01:00
Richard W.M. Jones
83fb657bec Revert "lvm: do not pass --cache to vgscan"
This reverts commit 19b0ae6c65.
2018-07-26 12:02:59 +01:00
Richard W.M. Jones
55879b2f2c v2v: Model machine type explicitly.
QEMU for x86 supports two machine types, "pc" (emulating the ancient
Intel i440FX chipset originally used by the Pentium Pro), and "q35"
(https://wiki.qemu.org/Features/Q35).

Currently virt-v2v does not set any machine type, so libvirt or the
target hypervisor will choose some default, probably i440fx.  The
latest advice from the QEMU and libvirt communities is not to rely on
the default machine type but to specify what we need explicitly, but
it may also be that the libvirt configuration file has been changed to
set the default machine type to Q35 (either by the distro or the end
user).

None of this matters for reasonably new guests since they can boot
with either chipset.  However there are some very old guests (notably
Windows XP) which cannot handle Q35.

This commit changes virt-v2v so it always tries to specify the machine
type explicitly (assuming the target supports that, and not all of
them do).  For x86_64 guests this patch always selects i440fx (pc).
In future we hope to get the correct machine type for the guest from
libosinfo but this is not available yet.

For non-x86 architectures we select the "virt" model which will
probably only work for AArch64.  More work is needed for POWER.

For secure boot we still have to force the machine type to Q35.  In a
future version this forcing can be removed since any guest which is
using secure boot will be new enough that it'll be using Q35 anyway
(on x86).
2018-07-26 12:02:59 +01:00
Daniel Erez
23b62f391b v2v: rhv plugin - case-sensitive search queries
Changed both search queries to case-sensitive (to ensure an exact match).
2018-07-25 09:38:18 +01:00
Daniel Erez
2547df8a0d v2v: rhv plugin - fix DC search string
Search for DC by 'storage.name=' to make it explicit.
I.e. "storage=" uses regex, so similar names can be
found in the search query. For example, searching for
a domain named FCSD, will find FCSD1 as well.
2018-07-24 17:26:11 +01:00
Richard W.M. Jones
3a87c4bb44 test-data/phony-guests: Add comment to Makefile above Fedora btrfs image.
Fixes commit 754e819438.
2018-07-18 13:15:47 +01:00
Richard W.M. Jones
fe1a886612 v2v: Implement MAC address to network/bridge mapping.
This allows specific NICs (identified by their source MAC address) to
be mapped to networks or bridges on the target.  You can use the --mac
parameter to select this mapping, eg:

 $ virt-v2v ... \
    --mac 52:54:00:d0:cf:0e:network:mgmt \
    --mac 52:54:00:d0:cf:0f:network:clientdata

The old --network and --bridge mappings can also be used but --mac
takes precedence.

Note this does not adjust MAC addresses inside the guest which is a
hard problem to solve.  For this to work you must still carry over the
MAC addresses from the source to target hypervisor as that is how most
guests identify and associate functions with specific network
interfaces.
2018-07-17 16:32:44 +01:00
Pino Toscano
682d3f8b01 v2v: -o rhv-upload: check for ovirtsdk4 (RHBZ#1601943)
Check earlier whether the ovirtsdk4 Python can be imported correctly,
to avoid errors later on during the migration.
2018-07-17 17:12:38 +02:00
Pino Toscano
4167ee2173 uefi: add non-deprecated Fedora paths for OVMF w/ secboot
Add new paths for the Secure Boot variant of OVMF as found in Fedora.
2018-07-17 15:21:41 +02:00
Richard W.M. Jones
0521a2f9b7 Version 1.39.7. 2018-07-14 10:23:45 +01:00
Richard W.M. Jones
2280c501ff build: Disable warnings about attribute malloc functions. 2018-07-13 20:39:04 +01:00
Richard W.M. Jones
fa2107e49e maintainer: Update to latest gnulib. 2018-07-13 20:38:36 +01:00
Pino Toscano
aa9e18f6d1 v2v: change QXL ResourceType in OVirt flavour (RHBZ#1598715)
Due to a conflict with the IDs of the OVF standard, and the existing
implementation in ovirt-engine, the ID of QXL devices changed to a
different value.

As a consequence, change the ResourceType of QXL devices, but only in
OVirt flavour to avoid breaking vdsm mode.

See: https://bugzilla.redhat.com/show_bug.cgi?id=1598715#c5
2018-07-13 18:04:46 +02:00
Richard W.M. Jones
58f7043234 Revert "v2v: oVirt changed the ResourceType for QXL video devices (RHBZ#1598715)."
This fix is incorrect, for details see:
https://bugzilla.redhat.com/show_bug.cgi?id=1598715#c11

This reverts commit 296b2f66c7.
2018-07-13 13:32:38 +01:00
Richard W.M. Jones
296b2f66c7 v2v: oVirt changed the ResourceType for QXL video devices (RHBZ#1598715).
See:
https://bugzilla.redhat.com/show_bug.cgi?id=1598715#c5
2018-07-12 10:02:04 +01:00
Richard W.M. Jones
1bc9facfdd builder: templates: More RHEL templates. 2018-07-12 09:44:03 +01:00
Richard W.M. Jones
32202e3917 v2v: Remove old TODO file. 2018-07-12 08:32:08 +01:00
Richard W.M. Jones
aeabe622ac build: Disable -Wabi warning as it is broken with GCC 8.1. 2018-07-11 16:28:43 +01:00
Richard W.M. Jones
1f79f2531e builder: templates: Update RHEL virt-install osinfo version for Fedora 28. 2018-07-11 10:17:19 +01:00
Richard W.M. Jones
b11b870166 v2v: Preserve VM Generation ID (RHBZ#1598350).
virt-v2v moves guests, it doesn't clone them.  Therefore we should try
to preserve the VM Generation ID (genid) as much as possible.

This has the ability to read the genid from VMware VMX files and
libvirt XML (but note RHBZ#1598348).  It can also write the genid to
libvirt (‘-o libvirt’, ‘-o local’) and QEMU (‘-o qemu’).

We are missing support currently for all OVF-based formats (hence
‘-i ova’, and all oVirt/RHV output modes).  It's unclear where we
would store the genid in this format.  oVirt does not yet support
genid (see RHBZ#1118825).
2018-07-09 08:56:45 +01:00
Richard W.M. Jones
9a25ac6b4e v2v: Add s_mapping_explanation field to source NIC.
Instead of storing the original network name (s_vnet_orig) in the
source NIC struct and then trying to guess what happened much later
when we're writing target metadata, get our newly created Networks
abstract data type to store the precise mapping explanation.
2018-07-09 08:56:45 +01:00
Richard W.M. Jones
c3bec46355 v2v: Make Cmdline.NetworkMap into an abstract data type.
No change, just code refactoring.
2018-07-09 08:56:45 +01:00
Daniel Erez
4ed1bc5a79 v2v: rhv plugin - find suitable host (RHBZ#1596810) (RHBZ#1596851)
For direct upload, a suitable host must be in status 'Up'
and belong to the same datacenter as the created disk.
Added these criteria to the host search query.
2018-07-05 21:35:23 +01:00
Richard W.M. Jones
2894b8f392 v2v: Add output#prepare_metadata method to prepare metadata before copying.
Currently unused, this method will allow output methods to prepare the
target hypervisor to receive a guest before the actual copy/upload
begins.

For rhv-upload this is useful since RHV would prefer to have the
metadata for the guest before receiving disk data.  The only metadata
unavailable here is target_stats.target_actual_size, but in the RHV API
case this is never available as we stream the data directly into RHV
rather than writing it to a local file.
2018-07-03 19:45:05 +01:00
Richard W.M. Jones
7850e0bfb8 v2v: Add comment about where the actual copy is performed in the code. 2018-07-03 19:45:05 +01:00
Richard W.M. Jones
6ca5986e45 v2v: Move per-target size stats into a separate mutable sub-struct.
This change avoids us threading the targets structure awkwardly
through several functions, and also makes it clear from the code that
the targets struct does not change after its creation in init_targets
(but the stats change).

Just code refactoring.
2018-07-03 19:45:05 +01:00
Richard W.M. Jones
8fdc1d4852 v2v: types: Fix comment for #create_metadata method. 2018-07-03 19:45:05 +01:00
Richard W.M. Jones
186ac2bfb2 v2v: Single character whitespace change. 2018-07-03 19:20:27 +01:00
Nir Soffer
891b5a0ec0 v2v: rhv-upload-plugin: Optimize only direct upload
The optimization to start the transfer on the local host makes sense
only when using the rhv-direct=true option. When using a proxy, let the
engine choose a host.
2018-06-30 07:41:08 +01:00
Nir Soffer
f5442d2f04 v2v: rhv-upload-plugin: Improve error handling
When optimizing the connection using unix socket, we handle these cases:

- The local host is not an oVirt host (no /etc/vdsm/vdsm.id).
- The local host is an oVirt host, but is not registered with engine.
- Creating UnixHTTPConnection() fails. Unlikely and probably a bug in
  the plugin, but we can recover by using the https connection.

The current code handle these cases silently, making it harder to
understand why the unix socket optimization did no happen. Add debug
message to make this clear.

Also comment in the error handler why we take this path instead of
failing the operation.
2018-06-30 07:41:08 +01:00
Nir Soffer
d5f36bacf9 v2v: rhv-upload-plugin: Remove unneeded auth
Old imageio proxy was using Authorization header for GET and PUT
requests. Remove unneeded authorization when sending OPTIONS request.

Remove unneeded duplicated comments about authorization for old
imageio, and replace them with a comment when we set needs_auth.
2018-06-29 16:09:11 +01:00
Pino Toscano
8d33ff8ba4 v2v: improve -os documentation for rhv-upload
Thanks to: Ming Xie
2018-06-29 12:59:26 +02:00
Richard W.M. Jones
1d7b63447a Version 1.39.6. 2018-06-29 10:23:54 +01:00
Richard W.M. Jones
d3dded2208 Update AUTHORS. 2018-06-29 10:22:36 +01:00
Pino Toscano
5a990d77b5 bash: add a completion script for libguestfs-test-tool
Use the simple virt-v2v-copy-to-local script for it.
2018-06-28 10:10:10 +02:00
Pino Toscano
53de4aeec5 test-tool: add a documentation test
Add the podcheck.pl test, to make sure the documentation is in sync with
the available options.

Also fix the formats of options in the current POD, so it matches what
used already in other documentations, and what podcheck.pl expects.
2018-06-28 10:10:10 +02:00
Pino Toscano
5565cf767a test-tool: implement --short-options & --long-options
While not useful per-se, it will help checking the available options.
2018-06-28 10:10:10 +02:00
Pino Toscano
b61c98b9e1 v2v: -o local: print libvirt XML
In verbose mode, print the generated libvirt XML to stderr for
debugging, just like -o libvirt does.
2018-06-28 10:10:10 +02:00
Richard W.M. Jones
b7a2e6270d v2v: -o rhv-upload: Use Unix domain socket to access imageio (RHBZ#1588088).
In the case where virt-v2v runs on the same server as the imageio
daemon that we are talking to, it may be possible to optimize access
using a Unix domain socket.

This is only an optimization.  If it fails or if we're not running on
the same server it will fall back to the usual HTTPS over TCP
connection.

Thanks: Nir Soffer, Daniel Erez.
2018-06-28 08:37:11 +01:00
Richard W.M. Jones
a1e1f6ec88 v2v: -o rhv-upload: Always fetch server options when opening the connection.
Previously we lazily requested the server options in the can_*
callbacks.  The can_* callbacks are always called by nbdkit straight
after open, so this just adds complexity for no benefit.  This change
simply makes the code always fetch the server options during the open
callback.

This is — functionally at least — mostly just refactoring.  However I
also added a useful debug message so we can see what features the
imageio server is offering.
2018-06-26 08:49:37 +01:00
Nir Soffer
32ab53cecd v2v: rhv-upload-plugin: Remove unused variables
Remove some instances of "transfer" and "transfer_service" that are not
used in current code.
2018-06-26 08:42:06 +01:00
Nir Soffer
0ae61ce99c v2v: rhv-upload-plugin: Fix name error
"http" and "transfer" variables were missing in emulate_zero, so the
code would fail with NameError.  This can happen only when communicating
with old imageio versions not supporting the "zero" feature.

Testing with qemu-img 2.12 show that we never send emulated zero request
because of the highestwrite mechanism, but it can break with older
qemu-img-rhev used on RHEL.
2018-06-25 19:09:34 +01:00
Nir Soffer
f4e0a8342d v2v: rvh-upload-plugin: Always read the response
Python manual warns[1]:

    Note that you must have read the whole response before you can send
    a new request to the server.

The reason for this warning is exposed only when the server is using
keep alive connections. When the response is not read, sending a new
request will fail with:

    httplib.ResponseNotReady

Even if Content-Length was 0 or the request has no content. The failure
looks like this when using --verbose:

nbdkit: python[1]: debug: zero count=33554432 offset=0 may_trim=1 fua=0
nbdkit: python[1]: debug: zero count=33554432 offset=33554432 may_trim=1 fua=0
nbdkit: python[1]: error: /home/nsoffer/src/libguestfs/tmp/rhvupload.Au2B5I/rhv-upload-plugin.py: zero: error: Request-sent
nbdkit: python[1]: debug: sending error reply: Input/output error
qemu-img: error writing zeroes at offset 0: Input/output error

Change all requests to read the whole response.

Tested with imageio patch supporting keep alive connections:
https://gerrit.ovirt.org/#/c/92296/

[1] https://docs.python.org/3.8/library/http.client.html#http.client.HTTPConnection.getresponse
2018-06-25 19:09:22 +01:00
Richard W.M. Jones
264f7ae9dd docs: building: autotools and gettext must be installed separately.
Thanks: Nir Soffer
2018-06-25 08:48:21 +01:00
Yuri Chornoivan
adbf1bc320 Fix minor typos 2018-06-25 08:35:43 +01:00
Richard W.M. Jones
3886a113f2 p2v: Allow virt-v2v input and output drivers containing '-' (RHBZ#1590220).
The new ‘-o rhv-upload’ output mode contains a '-' character in the
name, but the regular expression which matched the output of the
virt-v2v command did not recognize '-' as a valid character.  It ended
up mapping this to just "rhv" meaning two "rhv" entries would appear
in the list of output drivers.

Thanks: Ming Xie.
2018-06-22 12:51:10 +01:00
Richard W.M. Jones
75e8b13867 v2v: <File ovf:size> changed to the actual size (if known).
Note that this attribute is optional.

Thanks: Arik Hadas
2018-06-21 15:16:53 +01:00
Richard W.M. Jones
7c2afc88fd v2v: Add <Disk ovf:capacity> attribute containing disk virtual size (RHBZ#1592468).
Virt-v2v transfers to newer versions of ovirt-engine can fail with:

  ovirtsdk4.Error: Fault reason is "Operation Failed". Fault detail is "failed to parse a given ovf configuration ovf error: [empty name]: cannot read '//*/disksection' with value: null". HTTP response code is 400.

This was caused by a change made to oVirt:

  https://gerrit.ovirt.org/#/c/91902/

so that it now requires the <Disk ovf:capacity> attribute.

Thanks: Arik Hadas
2018-06-21 15:16:53 +01:00
Richard W.M. Jones
8c3375d47c v2v: docs: Removed vsyscall support in Debian kernels requiring workaround (RHBZ#1592061).
Thanks: Haigang Li
2018-06-21 15:14:20 +01:00
Richard W.M. Jones
e2910eeaf8 v2v: -o libvirt: Don't write only <vendor> without <model> (RHBZ#1591789).
Avoids the libvirt error:

  error: XML error: CPU vendor specified without CPU model
2018-06-21 15:09:05 +01:00
Richard W.M. Jones
70bc83f893 lib: libvirt: Convert all socket parameters to an absolute path (RHBZ#1588451). 2018-06-21 13:19:04 +01:00
Nir Soffer
77a412c0a1 v2v: -o rhv-upload: Optimize http request sending
When sending request with small or no payload, it is simpler and
possibly more efficient to use the high level HTTPSConnection.request(),
instead of the lower level APIs.

The only reason to use the lower level APIs is to avoid copying the
payload, or on python 2, to use a bigger buffer size when streaming a
file-like object.
2018-06-18 11:56:00 +01:00
Pino Toscano
4f927e58a9 fuse: fix build when not available
The 'localmountpoint' variable in the handle is available only when
building with FUSE support, so guard it in a proper #ifdef block.

Fixes commit 296370fb86.

Thanks to: Corentin Labbe (both reporting, and testing)
2018-06-15 18:36:39 +02:00
Richard W.M. Jones
afd1c70601 gitignore: Don't ignore patch files. 2018-06-14 11:10:48 +01:00
Richard W.M. Jones
a804a6f205 v2v: tests: Stable-sort CPU features in --print-source option.
The test failed with:

  -   CPU features: pae,apic,acpi
  +   CPU features: acpi,apic,pae

Fixes commit 67145499ec.
2018-06-12 17:36:28 +01:00
Richard W.M. Jones
67145499ec v2v: parse_libvirt_xml: Simplify code by using xpath_get_nodes utility fn.
No functional change.
2018-06-12 10:29:17 +01:00
Richard W.M. Jones
24404a5dec v2v: Refactor order of parameters to input objects.
Simple refactoring of the order of parameters to input objects
so they are always in the order:

  input_foo          ; class name
    input_conn       ; command line -iX parameters, alphabetically
    input_password   ;
    ...              ;
    vddk_options     ; extra class parameters
    ...              ;
    guestname        ; remaining command line parameters
2018-06-12 10:29:17 +01:00
Richard W.M. Jones
f49c5d14dd v2v: Use -ip to pass input password (instead of --password-file).
Consistent with the option -op added in
commit a4e181137a, use -ip to pass
passwords for the input side.

This replaces --password-file, and like that option you have to pass a
filename.

This also changes the code so we pass around the filename instead of
the password between functions.  For ‘-it vddk’ this simplifies
things: we can pass the filename through to nbdkit and we never need
to read it in virt-v2v.  For other input methods we eventually need to
read the password from the file at some lower level place in the code.
2018-06-12 10:29:16 +01:00
Richard W.M. Jones
0b3c95cc7a v2v: copy-to-local: Use Getopt ‘M’ for -ic parameter. 2018-06-12 10:29:16 +01:00
Richard W.M. Jones
f25404c65f v2v: -o rhv-upload: Set inactivity timeout (RHBZ#1586198).
This increases the inactivity timeout for transfers from the default
(60 seconds in oVirt < 4.2.3, 600 seconds in >= 4.2.3), up to 1 hour,
so that we should never hit it for ordinary transfers.

Note this requires oVirt >= 4.2.3.  The corresponding oVirt fix was
https://bugzilla.redhat.com/1563278

I also replaced the deprecated ‘image’ parameter with ‘disk’.

Thanks: Nir Soffer, Daniel Erez.
2018-06-07 19:17:18 +01:00
Richard W.M. Jones
831a75cd11 v2v: -o rhv-upload: Log full imageio response on failure.
Thanks: Nir Soffer
2018-06-07 19:17:18 +01:00
Richard W.M. Jones
a4d5548a45 docs: security: Document CVE-2018-11806.
Qemu: slirp: heap buffer overflow while reassembling fragmented
datagrams.
2018-06-06 11:02:19 +01:00
Richard W.M. Jones
553e201119 fish: rc: Minor whitespace fixes. 2018-06-04 05:41:58 -04:00
Richard W.M. Jones
2add3c6995 utils: Factor out hexdump code used by --enable-packet-dump.
Factor out the common code used to hexdump the protocol when
./configure --enable-packet-dump is used.

It's not quite a straight refactor because I had to fix some
signedness bugs in the code which were not revealed before because
this code is usually disabled.
2018-06-04 05:36:56 -04:00
Mykola Ivanets
b699111e04 daemon: list-filesystems: Filter out MBR extended partitions.
Extended MBR partitions cannot hold filesystems - filter them out.

RWMJ:

* Simplify is_mbr_extended function.

* Fix regression test rhbz1285847:

  The test assumed that list-filesystems would return an extended MBR
  partition (as "unknown").  However such partitions only contain
  logical partitions inside them, not filesystems.

* Some minor whitespace changes.
2018-06-01 15:09:34 +01:00
Mykola Ivanets
0a2f276be0 daemon: list-filesystems: Filter out Microsoft Reserved and Windows Snapshot partitions.
Filter out Microsoft Reserved Partition and Windows Snapshot Partition.
2018-06-01 15:09:34 +01:00
Mykola Ivanets
16192ad953 daemon: list-filesystems: Change the way we filter out LDM partitions.
1. Now we use GPT partition type to filter out LDM partitions.
2. We also check for filesystems on LDM volumes because LDM partitions
doesn't contain filesystems (list_ldm_partitions is not called anymore).
3. Obvious repetitive comments are moved to a function description.
2018-06-01 15:09:34 +01:00
Mykola Ivanets
af63e6e491 tests: list-filesystems command ignores partitioned MD devices.
Test guestfish list-filesystems command finds file system on partitioned md device and doesn't take into account md device itself (similar to as physical devices are filtered out if they are partitioned).
2018-06-01 15:09:34 +01:00
Mykola Ivanets
b316a33264 daemon: list-filesystems: Ignore partitioned MD devices.
Ignore partitioned MD devices the same way we ignore regular partitioned
devices because they cannot contain filesystems as well.
2018-06-01 15:09:34 +01:00
Mykola Ivanets
55abc820cd daemon: Changing the way that we detect if a device contains partitions.
Instead of using part_to_dev to find such devices we open the device's
directory under /sys/block/<dev_name> and look for entries starting with
<dev_name>, eg. /sys/block/sda/sda1.
2018-06-01 15:09:34 +01:00
Mykola Ivanets
7b4d13626f daemon: inspect: better handling windows drive mapping.
I saw several Windows disk images which contains strange registry entry
for mapped drives:

"\\DosDevices\\Y:"=hex(3):00,00,00,00,00,00,00,00,00,00,00,00

Which is decoded something like diskID = 0x0, partition starts at 0
bytes offset from the start of the disk.  In addition to a Windows disk
image, I have attached dummy disk and made xfs file system on a whole
device without partitioning it.  I mount xfs file system to a "/" and
then mkdir and mount other found file systems inside (/fs1, /fs2 etc.).

When we decode drive mappings we are looking for a disk with ID 0x0 (it
is 4 bytes somewhere LBA0).  It is appeared that dummy non-partitioned
disk with xfs file system has zeros by offset where diskID is expected
to be).  So the disk is considered as a candidate to search for
partition at offset 0. part-list command (and "parted" which is used
under the hood) reports there is 1 partition on "dummy" disk which
starts exactly at offset 0.  And thus dummy device name and partition
number are simply concatenated together and corresponding drive mapping
is returned: Y => /dev/sdX1.  But /dev/sdX1 is not existing block
device.

No matter either it is a bug in "parted" (or it works this way
by-design), let's protect ourself from this situation: in addition we
look for msdos partition table on a disk before making any further
assumptions.
2018-06-01 15:09:34 +01:00
Richard W.M. Jones
dd162d2cd5 daemon: Move lvmetad to early in the appliance boot process.
When the daemon starts up it creates a fresh (empty) LVM configuration
and starts up lvmetad (which depends on the LVM configuration).

However this appears to cause problems: Some types of PV seem to
require lvmetad and don't work without it
(https://bugzilla.redhat.com/show_bug.cgi?id=1581810).  If we don't
start lvmetad earlier, the device nodes are not created.

Therefore move the whole initialization step into appliance/init.

Two further changes had to be made:

Now we are using lvmetad all the time, using vgchange is incorrect.
With lvmetad activated early we must use ‘pvscan --cache --activate ay’
to scan all disks for PVs and activate any VGs on them (although the
documentation is complex, confusing and contradictory so I'm not
completely sure about this).

The ‘lvm_system_dir’ local variable in ‘daemon/lvm-filter.c’
previously contained the path of the directory above $LVM_SYSTEM_DIR
(eg. $LVM_SYSTEM_DIR = "/etc/lvm", lvm_system_dir = "/etc").  As this
was highly confusing, I have changed it so the local variable and the
environment variable have identical contents.  This involved removing
the ‘lvm/’ component from a couple of paths since it is now included
in the local variable.
2018-05-29 20:38:40 +01:00
Pino Toscano
c0da02f90d v2v: add and use Create_ovf.ovf_flavour_to_string
Add an helper to convert an OVF flavour to string, and use it in
-o vdsm to print the actual value of the vdsm-ovf-flavour option.

Thanks to Ming Xie.
2018-05-29 07:04:50 +02:00
Pino Toscano
c021ac5e64 v2v: fix "rhevexp" typo in documentation
Spotted by Ming Xie.
2018-05-29 06:49:23 +02:00
Pino Toscano
a4e3b7c059 v2v: fix build rules for output_rhv_upload_*_source.ml files
Use the $(srcdir) variable where needed, to make sure it builds also
with srcdir != builddir.

Furthermore, make sure that the OCaml dependencies calculation depend on
the generated output_rhv_upload_*_source.ml files, otherwise there will
be incomplete OCaml rules for them in the generated .depend.

Fixes commit cc04573927.
2018-05-22 21:20:13 +02:00
Pino Toscano
500acb15f8 v2v: linux: fix kernel detection when split in different packages
The current detection code for Linux kernels assumes that a kernel
package contains everything in it, i.e. the kernel itself, its modules,
and its configuration.  However, since recent Ubuntu versions (e.g.
starting from 18.04) modules & config (with few more files) are split in
an own package, thus not detecting the modpath from installed vmlinuz
files.

To overcome this situation, rework this detection a bit:
1) find the vmlinuz file as before, but then immediately make sure it
   exists by stat'ing it
2) find the modules path from the package as before:
2a) if found, extract the version in the same step
2b) if not found, get the kernel version from the vmlinuz filename,
    and use it to detect the modules path
3) check that the modules path exists

The detection done in (2b) is based on the current packaging scheme
found in the most important Linux distributions (Fedora, RHEL, CentOS,
Debian, Ubuntu, openSUSE, AltLinux, and possibly more).  The notable
exception is Arch Linux.

As additional change, do not assume the config file is in the same
package as vmlinuz, but directly look into the filesystem using the
version we already have.
2018-05-22 10:46:21 +02:00
Pino Toscano
1b6a2b221d v2v: -o null: support older qemu-img (RHBZ#1580309)
Commit 4699c7b6e1 converted the null
output to use the null-co qemu driver with a JSON URL syntax --
especially the latter is only available in newer versions of qemu.

Even if this output mode is mostly for testing, check at runtime whether
the null-co + JSON way is possible, falling back to the creation of
thrown-away temporary files as before.
2018-05-22 10:25:30 +02:00
Richard W.M. Jones
0c934144eb v2v: Use Std_utils.qemu_input_filename instead of prefixing "file:" to filename (RHBZ#1580292).
This also allows us to use virt-v2v with the old version of qemu in
RHEL 7.

Fixes commit e29296cfa2.

Thanks: Pino Toscano for suggesting the fix.
2018-05-22 09:07:33 +01:00
Richard W.M. Jones
f366da30e6 Version 1.39.5. 2018-05-21 13:09:53 +01:00
Richard W.M. Jones
4683f4c99f builder: templates: Rebuild index.
Fixes commit 1f983a050f.
2018-05-21 10:01:35 +01:00
Richard W.M. Jones
1f983a050f builder: templates: Rebuild Ubuntu 18.04 image without proxy (RHBZ#1579047). 2018-05-21 09:58:23 +01:00
Richard W.M. Jones
3632c77bfd builder: templates: Remove bogus proxy from Ubuntu apt configuration (RHBZ#1579047).
Thanks: Lars Seipel.

See also commit 4b2e9c9264 which did the
same for Debian back in 2013.
2018-05-21 09:58:23 +01:00
Richard W.M. Jones
140a25b511 authors: Add Nikolay Ivanets (alternate form). 2018-05-15 14:05:03 +01:00
Richard W.M. Jones
5982f7aec8 authors: Add Adam Robinson. 2018-05-15 14:05:03 +01:00
Richard W.M. Jones
eb4d283a09 macOS: unix-utils: Include <sys/mount.h>.
If <sys/mount.h> is available on the platform, always include
it in this file.
2018-05-15 11:15:54 +01:00
Adam Robinson
431d8c8c1e macOS: Include <rpc/types.h> before <rpc/xdr.h>.
The ordering of includes is required on this platform.
2018-05-15 11:15:54 +01:00
Yuri Chornoivan
22cae846ce Fixes for typos in manual pages. 2018-05-12 20:26:59 +01:00
Pino Toscano
1286779ded v2v: update results of test-v2v-i-ova-snapshots for non-json
When using non-JSON disk notation, the disk will be the snapshot #2.

Fixes commit e5946165c8.
2018-05-11 13:12:36 +02:00
Richard W.M. Jones
1c974855dc builder: templates: Add centos-7.5. 2018-05-10 22:19:13 +01:00
Pino Toscano
3151d5e927 daemon: tweak regexp for file type detection (RHBZ#1575640)
Newer versions of file slightly changed the output, removing the comma
between the type, and the architecture string.

Tweak the regular expression so:
- the comma is optional, but if missing then only the architecture
  string will follow
- the architecture string has no commas
2018-05-07 17:06:11 +02:00
Pino Toscano
662dc5d0bf java: support OpenJDK 10+
Starting OpenJDK 10, the 'javah' utility is no more provided [1], and
its functionality is provided by 'javac' itself.  Hence, do not error
out on missing 'javah', and store whether it was found; in case it is
not, then:
1) assume 'javac' has the -h parameter to generate the C header, and
   make use of it
2) tell the buildsystem that com_redhat_et_libguestfs_GuestFS.h depends
   on the JAR, since the the header is generated at the step (1)

[1] https://bugs.java.com/view_bug.do?bug_id=JDK-8182758
2018-05-06 23:35:50 +02:00
Pino Toscano
784f18156e common/qemuopts: ensure arg lists are never empty
Since it does not make much sense, then forbid this situation outright:
- change qemuopts_end_arg_list() to return an error if the current arg
  list has no elements
- when creating the argv array, assert that each arg list is not empty
2018-05-04 15:52:52 +02:00
Pino Toscano
2dd9fd8530 appliance: initialize the appliance_files struct
Some compilers do not manage to figure out that the members of it are
set only when search_appliance() in the end returns 1, which is already
checked.  Help them a bit by resetting the appliance_files struct on our
own, so they will not report that 'appliance.kernel', and the others are
used as uninitialized.
2018-05-04 15:49:20 +02:00
Pino Toscano
c36f284b15 daemon: fix memory allocation and leaks in OCaml stubs
Use the cleanup handlers to free the structs (and list of structs) in
case their OCaml->C transformation fails for any reason; use calloc()
to not try to use uninitialized memory.

In case of lists, avoid allocating the memory for the array if there
are no elements, since the returned pointer in that case is either NULL,
or a free()-only pointer; also, set the list size only after the array
is allocated, to not confuse the XDR routines.
2018-05-03 18:27:02 +02:00
Mykola Ivanets
296370fb86 fuse: mount_local: Fix crash when called from Java binding.
"localmountpoint" parameter is allocated in JNI before calling
mount_local and freed afterward.  But guestfs handle keeps reference
to passed "localmountpoint" parameter and will try to access it in
umount_local and free after mount_local_run caller thread ends
which leads to a crash (an attempt to access to already freed memory).

RWMJ: Remove ‘const’ from definition of localmountpoint, and
wrap a comment at 80 columns.
2018-05-02 12:07:16 +01:00
Nikolay Ivanets
994ca1f8eb daemon: Reimplement 'part_get_mbr_part_type' API in OCaml.
Instead of parsing 'parted' output OCaml implementation relies on the following facts:

1. MBR partition table can hold up to 4 "primary" partitions.
2. Partition with number greater then 4 is "logical" partition.
3. Partition with number less then or equal to 4 with MBR ID 0x05 or 0x0f is "extended" partition (http://thestarman.pcministry.com/asm/mbr/PartTypes.htm; https://en.wikipedia.org/wiki/Partition_type) or "primary" otherwise.
2018-05-02 12:07:16 +01:00
Richard W.M. Jones
81d951239f Version 1.39.4. 2018-05-01 17:48:06 +01:00
Pino Toscano
9667587366 daemon: simplify string allocation
When creating an helper string for do_aug_match(), use a simpler
asprintf() with manual free(), since the code block is small enough.

This slightly helps static code analyzers.
2018-05-01 17:26:16 +01:00
Pino Toscano
d48d0fc2d1 common/qemuopts: use the old pointer as realloc pointer
Call realloc() directly with the pointer to the old data, instead of
assigning it to the destination variable, and using that one.  The rest
of the code is the same, already properly checking for the results of
realloc(), so this mostly help static code analyzers.
2018-05-01 17:26:16 +01:00
Pino Toscano
526f6b4012 launch: libvirt: free format string
When the result guestfs_disk_format() is not known, free the string
before returning an error.
2018-05-01 17:26:16 +01:00
Pino Toscano
fced132718 daemon: upload: fix fd leak on lseek failure
Make sure to not leak the file descriptor in the upload() function, in
case lseek() fails.
2018-05-01 17:26:16 +01:00
Richard W.M. Jones
5ddef548b0 builder: templates: Add Fedora 28 x86_64 and i686 templates. 2018-05-01 17:17:54 +01:00
Richard W.M. Jones
7631be21d7 builder: templates: Update osinfo for Fedora. 2018-05-01 17:17:54 +01:00
Richard W.M. Jones
7a2cc8ba29 builder: templates: aarch64 is now a primary architecture, fix location. 2018-05-01 17:17:53 +01:00
Richard W.M. Jones
c6e8929929 v2v: Map Windows Server 2012 R2 x86-64 to ovirt ID 25.
Thanks: Michal Skrivanek

Fixes commit 593a19cc86.
2018-05-01 12:09:35 +01:00
Pino Toscano
bd4e99cc13 common/mlpcre: fix access to freed memory
free_last_match() frees the memory of the match passed as argument, so
accessing it is not possible after free_last_match().  Since all we
need is the return code, save it locally for later usage.
2018-04-30 09:15:44 +02:00
Richard W.M. Jones
7be88554af slow tests: Add slow tests of Ubuntu 18.04.
- firstboot
 - settings
 - password setting
 - console
 - v2v conversion
2018-04-27 14:58:28 +01:00
Richard W.M. Jones
a75c13d301 builder: templates: Add Ubuntu 18.04. 2018-04-27 14:57:17 +01:00
Richard W.M. Jones
e5946165c8 v2v: -i ova: Handle OVAs containing snapshots (RHBZ#1570407).
Also adds a regression test.
2018-04-27 10:13:04 +01:00
Richard W.M. Jones
80d6d93962 v2v: -i ova: Sanity check hrefs to ensure they stay inside the tarball.
Check for hrefs like "../../../../dev/sda", or dubious symlinks in the
tarball, which could escape from the tarball into the host system.

We use realpath(3) to do this.  Since this function does not work on
non-existent files, we must change the signature of get_file_ref so it
can return whether the file exists or not.
2018-04-27 10:13:04 +01:00
Richard W.M. Jones
e247714680 v2v: -i ova: Replace subdirectory function with clearer inline code. 2018-04-27 10:13:04 +01:00
Richard W.M. Jones
075333ede2 common: mlstdutils: Inline unsafe ‘subdirectory’ function.
This function is ill-defined and unsafe.  As a preparation for
removing it completely, inline it in the places where it is used.
2018-04-27 10:13:04 +01:00
Richard W.M. Jones
184dba5981 v2v: -i ova: Factor out code for dealing with OVA files.
Factor out the complex code that handles dealing with multiple
different OVA file formats into a separate Parse_ova module.

This is largely straightforward code refactoring -- there should be no
significant functional change.

However:

 - Parse_ova now checks up front if the OVA contains any compressed
   disks and avoids the tar optimization in that case.  This is a
   regression for the case of an OVA containing a mix of both
   compressed and uncompressed disks (we expect this to be rare).
   The change is nevertheless good because it reduces the coupling
   between two parts of the code.

 - I had to simplify an error message.
2018-04-27 10:13:04 +01:00
Richard W.M. Jones
ece2c60c50 v2v: parse OVF: Export useful parse_disks function.
So you can parse out just the list of disks.
2018-04-27 10:13:04 +01:00
Richard W.M. Jones
d1e95a30f3 v2v: Ignore miscellaneous tar messages when parsing tar for file locations.
We use ‘tar tRvf’ to parse the locations of files within the tarball.
However examination of tar.git:src/list.c shows various other messages
which can appear in the output:

  block <offset>: ** Block of NULs **
  block <offset>: ** End of File **

Indeed it was easy to produce the first message just by using modern
tar to create a tarball:

  $ tar tRvf '/var/tmp/bz1570407-reproducer.ova'
  block 0: -rw-r--r-- rjones/rjones   100 2018-04-22 17:06 RHEL7_3_042218_extra-disk1.vmdk.000000000
  block 2: -rw-r--r-- rjones/rjones   243 2018-04-22 17:07 RHEL7_3_042218_extra.mf
  block 4: -rw-r--r-- rjones/rjones 13066 2018-04-22 15:08 RHEL7_3_042218_extra.ovf
  block 31: ** Block of NULs **

Ignore these messages.
2018-04-27 10:13:04 +01:00
Richard W.M. Jones
112e3bc311 v2v: -i ova: Ignore non-existent files mentioned in *.mf.
Some OVA files generated by VMware have a *.mf file which contains
checksums for files which don't exist in the OVA.  Ignore these
checksums.

Thanks: Nisim Simsolo.
2018-04-27 10:13:04 +01:00
Richard W.M. Jones
190333b8b0 mltools: Checksums.verify_checksum{,s} returns an error type instead of throwing exception.
Simple code refactoring, making it both more difficult to ignore the
error case and easier to add other error cases in future.
2018-04-27 10:13:04 +01:00
Tomáš Golembiovský
f3f00d3f9c v2v: -o rhv-upload: install RHV tools (RHBZ#1561828).
Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2018-04-23 09:40:46 +01:00
Pino Toscano
ac76732a9a uefi: remove last references to kraxel's old edk2 builds
Commit 889386f8c6 removed most of them
already, so remove the last ones, and the supporting code.
2018-04-23 08:56:01 +02:00
Richard W.M. Jones
e515352f84 utils: Add utility to find maximum number of virtio-scsi disks.
This is an evolution of a Perl script that I originally wrote for this
bug:

https://bugzilla.redhat.com/show_bug.cgi?id=1478201
2018-04-20 15:25:20 +01:00
Richard W.M. Jones
2fdaf27b08 Version 1.39.3. 2018-04-20 13:17:10 +01:00
Richard W.M. Jones
70741b9121 Update AUTHORS 2018-04-20 13:17:05 +01:00
Richard W.M. Jones
2274ee593e v2v: tests: Set VIRTIO_WIN to point to phony virtio drivers directory.
As well as being consistent with other tests in this directory this
also fixes a problem when we ran the tests and the real virtio-win
package happened to be installed on the same machine.

The test used to pick up the virtio drivers from the virtio-win
package, resulting in different test output (because virtio drivers
had been installed).

Now we use the phony virtio drivers in all cases and also update the
test output (because virtio drivers are now always installed).
2018-04-20 13:01:48 +01:00
Richard W.M. Jones
a8b4d2749b v2v: windows: Print calculated virtio_win in debugging output.
So we know where drivers are being installed from, and whether
that is a directory or a CD/ISO.
2018-04-20 13:01:48 +01:00
Richard W.M. Jones
b3769afaec v2v: -o rhv-upload: Don't require ‘-of raw’ parameter.
Because we checked the limitation of raw+sparse during command line
processing, it had the effect of forcing you to use ‘-of raw’ even if
the input was already in raw format.  Move the checking to the output
mode to avoid this.

Fixes commit cc04573927.
2018-04-20 13:01:48 +01:00
Pino Toscano
aa078b362e Update documentation/translation file indexes
Followup of commits cc04573927, and
commit d00e860ef0.
2018-04-20 13:04:29 +02:00
Pino Toscano
cf49fe1003 v2v: refer to the right embed script in EXTRA_DIST
Fixes commit cc04573927.
2018-04-20 13:00:56 +02:00
Pino Toscano
ac398265c4 v2v: rework handling of CPU topology
Instead of storing the number of sockets, cores, and threads separately
with the possibility to have each of them optional, store them together,
so either we have a CPU topology or none.  This slightly simplifies the
handling of CPU topology.

Most of the output modes/producers already considered a missing
information of a topology as "1" when any of the other was specified, so
the behaviour is unchanged.  The only behaviour changes are when
parsing, and creating libvirt XMLs:
- libvirt requires all the three attributes to be specified, so when
  reading use them only if <topology> has all of them
- for the same reason, write <topology> only when all of them are
  specified

Adapt the vmx, and ova input modes to consider 1 threads when they have
the other information of a CPU topology, since none of them can provide
that information yet.
2018-04-20 10:57:31 +02:00
Pino Toscano
de71f17d80 resize: expand f2fs partitions
Use resize.f2fs (via f2fs_expand) to expand f2fs filesystems, if
available.
2018-04-19 11:30:29 +02:00
Pino Toscano
d00e860ef0 New API: f2fs_expand
Expose the resize.f2fs utility from f2fs-tools, to expand a f2fs
filesystem.
2018-04-19 11:30:29 +02:00
Pino Toscano
f2bd817bbc v2v: linux: correctly update resume=/dev/device entries (RHBZ#1532224)
When updating the device names to the new names, handle GRUB_CMDLINE
entries (typically in grub2 configuration files) correctly: loop over
the whole configuration value, and replace each occurrency of
resume=/dev/device found.

The actual code is moved away from replace_if_device, since this
function now does only the actual replacement of the device string.
2018-04-19 11:30:29 +02:00
Richard W.M. Jones
201e6d1595 v2v: Give better diagnostics if filesystem falls back to read-only (RHBZ#1567763).
Some filesystems fall back silently to read-only if there are problems
such a dirty filesystem and an unrecoverable journal.  Almost all
conversions involve writing to the root filesystem, so these will
inevitably fail later on with a strange error message.

Test the root filesystem is writable by creating and deleting a
temporary file, and if the creation fails then give better
diagnostics.

Reported-by: Piotr Kliczewski
2018-04-17 11:56:13 +01:00
Richard W.M. Jones
cc04573927 v2v: Add -o rhv-upload output mode (RHBZ#1557273).
This adds a new output mode to virt-v2v.  virt-v2v -o rhv-upload
streams images directly to an oVirt or RHV >= 4 Data Domain using the
oVirt SDK v4.  It is more efficient than -o rhv because it does not
need to go via the Export Storage Domain, and is possible for humans
to use unlike -o vdsm.

The implementation uses the Python SDK (‘ovirtsdk4’ module).  An
nbdkit Python 3 plugin translates NBD calls from qemu into HTTPS
requests to oVirt via the SDK.
2018-04-17 11:56:09 +01:00
Richard W.M. Jones
adc23829e4 fish: Increase default size of prepared disks (-N) to 1G.
The guestfish prepared disks (-N option) all defaulted to 100M.  This
has always been too small for btrfs (so for example ‘-N fs:btrfs’ has
failed for a long time), and can be too small for LVs with new LVM2 /
kernel >= 4.16.

This changes the default from 100M to 1G.  The beginning of the 1.39
branch seems like a good time to make this change.
2018-04-16 11:09:38 +01:00
Richard W.M. Jones
64b517608c builder: templates: rhel-7.5 kickstarts and virt-install commands. 2018-04-13 12:44:49 +01:00
Richard W.M. Jones
74edd79354 builder: templates: Fix path for RHEL 7 aarch64.
Now using ALT-ernate kernel.
2018-04-13 10:14:35 +01:00
Richard W.M. Jones
32d7b77946 builder: templates: Also update download.devel location for RHEL on s390x.
Updates commit f9395e6760.
2018-04-13 10:12:48 +01:00
Richard W.M. Jones
f9395e6760 builder: templates: Add location for RHEL on s390x.
It's not likely we can actually build templates for this architecture
since I don't think qemu fully supports the architecture yet.
2018-04-13 08:55:18 +01:00
Richard W.M. Jones
2f62020f08 builder: templates: Use --cpu=power7|power8 because of libvirt regression.
Works around libvirt regression:
https://bugzilla.redhat.com/show_bug.cgi?id=1539022
2018-04-13 08:52:08 +01:00
Hilko Bengen
802c5d2055 Fix out-of-tree builds of OCaml components
- Add $(srcdir), $(builddir) to Makefiles where required
- Post-process ocamldep output
- generate ocaml/.depends
2018-04-12 11:43:56 +02:00
Kashyap Chamarthy
bb9636acac virt-builder.pod: Update Fedora versions
This is just a mechanincal change, so that the public documentation[*]
refers to the latest release Fedora versions, instead of the EOLed
versions.

While at it, also update the `virt-cutomize` Makefile.am

[*] http://libguestfs.org/virt-builder.1.html

Signed-off-by: Kashyap Chamarthy <kchamart@redhat.com>
2018-04-10 16:57:23 +01:00
Pino Toscano
e655676157 daemon: autogenerate OCaml interfaces
Add a way to generate OCaml interfaces for all the modules in the
daemon that implement APIs: this makes sure that for them the
interface of each function matches the actual API specified in the
generator.
2018-04-10 12:55:37 +02:00
Pino Toscano
6c13d2356e daemon: move Mount.umount_all to new Mount_utils module
This way the Mount module contains only the OCaml implementations of
mount-related daemon APIs.

This is simple refactoring, with no functional changes.
2018-04-10 12:12:10 +02:00
Pino Toscano
2bdc7b83ce daemon: move Lvm.lv_canonical to new Lvm_utils module
This way the Lvm module contains only the OCaml implementations of LVM
daemon APIs.

This is simple refactoring, with no functional changes.
2018-04-10 12:12:09 +02:00
Pino Toscano
188e995d32 daemon: use the structs from the Structs module
No need to redeclare them again in few modules, just use them from the
Structs module.
2018-04-10 12:12:09 +02:00
Pino Toscano
a43bdb9379 daemon: directly use Optgroups
Avoid extra module variables, and just use Optgroups directly.
2018-04-10 12:12:09 +02:00
Lin Ma
e4056aa57a configure: support using local gnulib src directory as $GNULIB_SRCDIR
Don't clone online gnulib repo if the environment variable $GNULIB_SRCDIR
is available, and add an option '--gnulib-srcdir' for bootstrap to specify
a local source directory.

(borrowed some code which wrote by Jim Meyering and Eric Blake in libvirt)

Signed-off-by: Lin Ma <lma@suse.com>
2018-04-10 09:21:09 +01:00
Lin Ma
a682c6776d configure: output clearer message when missing libmagic
Some of users probably don't know which packages they exactly need to
install while they experienced the error message:

libmagic (part of the "file" command) is required.

So add corresponding package information into error message.

Signed-off-by: Lin Ma <lma@suse.com>
2018-04-10 09:21:09 +01:00
Lin Ma
ec0bf981bd configure: try pcre-config if pcre pkg-config file not found
Signed-off-by: Lin Ma <lma@suse.com>
2018-04-10 09:21:09 +01:00
Lin Ma
104d47453e configure: output the default backend in summary
Signed-off-by: Lin Ma <lma@suse.com>
2018-04-10 09:21:09 +01:00
Lin Ma
5f25f4273f configure: error out if using libvirt backend and no header files
It should error out instead of warning if users provide the option
'--with-default-backend=libvirt' and no libvirt devel package installed.

Signed-off-by: Lin Ma <lma@suse.com>
2018-04-10 09:21:09 +01:00
Richard W.M. Jones
07ead43cbb daemon: Fix type signature of mount_vfs (RHBZ#1564983).
Reported-by: Yongkui Guo.

Fixes commit 82bbd9c8a5.
2018-04-09 13:31:40 +01:00
Pino Toscano
b8401108c7 v2v: OVF: adjust tests to updated XML format for OVirt flavour
Updates commit 593a19cc86 and
commit 9dce43931a.
2018-04-09 14:06:35 +02:00
Pino Toscano
9dce43931a v2v: OVF: fix ovf:id for VirtualSystem in OVirt flavour
When writing the OVF in OVirt flavour, write the actual UUID of the
VM as ovf:id attribute for <VirtualSystem>, instead of a dummy value.

Suggested by Arik Hadas in
https://www.redhat.com/archives/libguestfs/2018-April/msg00005.html
2018-04-09 09:15:51 +02:00
Pino Toscano
593a19cc86 v2v: OVF: write ovirt:id attribute for the OS in OVirt flavour
When writing the OVF in OVirt flavour, add a ovirt:id attribute to the
OperatingSystemSection tag: this attribute represents the numeric value
of the ostype ID, which is ignored by oVirt when parsing OVFs in API
mode.
2018-04-09 09:15:51 +02:00
Pino Toscano
8307dcb3a9 v2v: OVF: improve get_ostype mappings
- consider CentOS as RHEL, since oVirt has no CentOS OS mappings, and
  CentOS is derived from RHEL
- use rhel_6_9_plus_ppc64 for RHEL 6 >= 6.9 on ppc64/ppc64le, while
  rhel_6_ppc64 for RHEL 6 < 6.9
- use rhel_7_s390x for RHEL 7 on s390x
- use sles_11, and sles_11_ppc64 for any SLES greater than 11, not only
  11
- use sles_12_s390x for SLES 11+ on s390x
- use ubuntu_16_04_s390x for Ubuntu 16.04+ on s390x
- use other_linux_ppc64 for any unmapped Linux distro on ppc64/ppc64le
- use other_linux_s390x for any unmapped Linux distro on s390x
2018-04-05 14:21:55 +02:00
Richard W.M. Jones
cd65dcf576 todo: Remove section about using qmp-schema, since we are now using it. 2018-04-05 10:30:34 +01:00
Richard W.M. Jones
e79286f717 qemu: Fix transcription error in conversion of yajl to jansson.
This broke qemu mandatory locking detection.

Fixes commit bd1c5c9f4d.
2018-03-29 20:19:53 +01:00
Richard W.M. Jones
3a572b5fea Version 1.39.2. 2018-03-29 13:52:32 +01:00
Richard W.M. Jones
6327e716cd v2v: Add general mechanism for input and output options (-io/-oo).
Currently we have a bunch of ad hoc options like --vddk* and --vdsm*
(and proposed to add --rhv*) to handle extra parameters for input and
output modes/transports.  This complicates the command line parsing
and also the clarity of the command line (becauseit's not very obvious
which options apply to which side of the conversion).

Replace these with a general mechanism for handling input and output
options.

Thus (for example):

  --vddk-thumbprint=...   becomes   -io vddk-thumbprint=...
  --vdsm-compat=0.10                -oo vdsm-compat=0.10

The responsibility for parsing input and output options moves into the
input and output drivers.

This improves error checking so it's harder now for wrong flags to be
included on the command line when they don't apply to the current mode.

The old option names are preserved for compatibility.
2018-03-29 13:40:38 +01:00
Richard W.M. Jones
c2c17434e1 v2v: Fix test by adding new i_osinfo field.
Fixes commit ea49d75d0d.
2018-03-29 13:40:38 +01:00
Richard W.M. Jones
ea49d75d0d v2v: Add osinfo to internal inspection struct.
This makes it available to output modes when creating metadata.
2018-03-27 10:59:24 +01:00
Pino Toscano
551a64f9b6 v2v: ova: convert models of network interfaces
So far v2v did not read the model of network interfaces, resulting in
"virtio" as the model for such interfaces.

Start reading the model, if available, directly mapping E1000, while
other models are considered as Source_other_nic.
2018-03-23 16:24:09 +01:00
Richard W.M. Jones
3167ce1f91 v2v: cmdline: Move definition to before its only use. 2018-03-23 14:36:07 +00:00
Richard W.M. Jones
e03759f67a v2v: Move and rename vddk_options and vdsm_options structure.
Simple refactoring, giving the structures uniform names and handling.
2018-03-23 14:32:12 +00:00
Richard W.M. Jones
1c24761251 v2v: docs: Move the input and output modes "spider" after examples.
I've had several reports that it just puts people off.  Possibly we
should delete or rewrite it but this moves it below the examples
section which is more important.
2018-03-23 14:32:12 +00:00
Richard W.M. Jones
992f835258 v2v: Fix parsing of OVA files and documentation for --network and --bridge (RHBZ#1559027).
When parsing OVA files we have to work backwards to whether the
original VMware object was a network or a bridge.  It seems as if the
presence of <rasd:Connection> is sufficient.  I dropped the use of
<rasd:ElementName> since it is literally just an internal name for the
network element, and is not significant in how the network is used.

Also update documentation because you must use ‘--bridge’ when
converting VMware guests to RHV.

For a full explanation see:

  https://bugzilla.redhat.com/show_bug.cgi?id=1559027#c2
2018-03-23 10:02:31 +00:00
Pino Toscano
2bf88b102c tests: regressions: make test-big-heap use a temporary empty file
Newer versions of qemu use file locking for the images by default, and
apparently that does not work with /dev/null.  Since this test just
calls qemu-img to get the format of an empty image, create a temporary
one instead.
2018-03-21 13:40:59 +01:00
Richard W.M. Jones
971519fd57 v2v: cmdline: Replace { foo = foo } with { foo } in record expression.
See:
https://forge.ocamlcore.org/docman/view.php/77/112/leroy-cug2010.pdf

Followup of commit c7651744da.
2018-03-20 11:37:22 +00:00
Richard W.M. Jones
9ac4f99fdc v2v: Add --print-target to display overlay and target information.
This is analogous to --print-source, except that it prints the overlay
and target disk information.

The output looks like below.  Note there is one overlay and one target
section per disk.

Overlay and Target information (--print-target option):

             overlay file: /home/rjones/d/libguestfs/tmp/v2vovlc687fe.qcow2
      overlay device name: sda
overlay virtual disk size: 6442450944
  overlay source qemu URI: /var/tmp/fedora-27.img

          target file: [qemu] json:{ "file.driver": "nbd", "file.path": "/home/rjones/d/libguestfs/tmp/rhvupload.IWrzO6/nbdkit0.sock", "file.export": "/" }
        target format: raw
target estimated size: 2274060540
2018-03-20 11:37:22 +00:00
Richard W.M. Jones
777701a738 v2v: Update target.target_estimated_size in targets list in main function.
The rebasing in commit 5dae9ca23d caused
this field to never get updated.
2018-03-20 11:37:22 +00:00
Richard W.M. Jones
55b347d71c Version 1.39.1. 2018-03-13 12:17:28 +00:00
Richard W.M. Jones
58d70eedee v2v: Factor out wait_for_file utility function.
Simple code motion.
2018-03-09 10:47:21 +00:00
Richard W.M. Jones
a4e181137a v2v: Add -op (output password file) option.
Currently unused, in a future commit this will allow you to pass in a
password to be used when connecting to the target hypervisor.
2018-03-09 10:47:21 +00:00
Richard W.M. Jones
d7b31559c2 v2v: rhv: Fix virtio-rng and memballoon OVF fragment for RHV.
Without this extra element, oVirt will crash with a Java
NullPointerException (see https://bugzilla.redhat.com/1550123).

Fixes commit dac5fc53ac.
2018-03-09 10:47:21 +00:00
Pino Toscano
ba53251ab9 automake2junit.ml: use LargeFile to stat'ing files
While scanning the sources, some of the files (i.e. the cached
appliance) may be larger than 4G, and thus raise EOVERFLOW on 32bit
architectures.

Fixes commit b4e119d8b7.
2018-03-01 10:14:32 +01:00
Pino Toscano
8d5b3094d5 v2v: update once more the URL with glance metadata
Another year, another URL for them.
2018-02-27 17:07:33 +01:00
Richard W.M. Jones
95445949f5 v2v: -oc option specifies a generic target hypervisor URI.
No change in the code or the command line, this is just documenting
that -oc is not specifically a libvirt URI.
2018-02-26 09:54:07 +00:00
Richard W.M. Jones
802c8635cc v2v: DOM: Add doc_to_string function.
Convert a document to an in-memory string.
2018-02-26 09:54:07 +00:00
Pino Toscano
b4e119d8b7 automake2junit.ml: ignore symlinks when searching for .trs files
One gnulib test creates a symlink to the same directory, causing our
iteration to read the same test directory over and over, every time
considering it as new level of subdirectory.

As solution (or workaround), when iterating through a directory consider
only regular files, and directories, ignoring any other file type
(symlinks included).
2018-02-23 14:38:26 +01:00
Yuri Chornoivan
5f8bba5d52 docs: Fix typo in man page. 2018-02-23 09:54:08 +00:00
Pino Toscano
5e8052dc8f make-repository: use inspect_get_osinfo
Use the newly added API instead of the local implementation.
2018-02-22 17:30:41 +01:00
Pino Toscano
2f8ec91fc1 inspector: show the per-OS osinfo guess (RHBZ#1544842)
Output also the osinfo guess for each OS in the generated XML output;
adapt the RNG schema, and the test data to it.
2018-02-22 17:30:41 +01:00
Pino Toscano
286b88891c New API: inspect_get_osinfo
Try to guess the possible osinfo-db short ID for the specified OS.

Related to: https://bugzilla.redhat.com/show_bug.cgi?id=1544842
2018-02-22 17:30:41 +01:00
Richard W.M. Jones
9e83f3a2cc v2v: OVF: Code formatting.
Updates commit a52ed4b445
("v2v: ovf: Create OVF more aligned with the standard") with some
small code refactoring and formatting.
2018-02-22 15:06:43 +00:00
Tomáš Golembiovský
4344d9115b tmp: ignore virt-v2v overlay files
Failed virt-v2v tests can leave the overlay files on disk. Make sure
they are ignored.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2018-02-22 15:06:13 +00:00
Tomáš Golembiovský
285014b290 v2v: vdsm: add --vdsm-fixed-ovf option
Add option for -o vdsm that enables output of the modified OVF. oVirt
engine should already be able to consume the OVF, but let's not take any
chances and enable it only by command line argument. It can be made
default later when it receives proper testing.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2018-02-22 15:06:13 +00:00
Tomáš Golembiovský
a52ed4b445 v2v: ovf: Create OVF more aligned with the standard
For historical reasons the OVF used in RHV export domain contains some
deviations from the OVF standard. The format used in -o rhv has to
remain fixed but for -o vdsm and we could produce much nicer OVF. This
patch serves as a preparatory step to this.

The main reason for creating different OVF is that it can be used to
create VM by oVirt REST API. The RHV export domain flavor cannot be used
that way.

For now the virt-v2v behavior is unchanged. The modified output will be
enabled in some later patch.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2018-02-22 15:06:13 +00:00
Tomáš Golembiovský
8fb60072cc v2v: tests: check generated OVF
Check the generated OVF for -o rhv and -o vdsm outputs. Variable UUIDs
and date/times are filtered out. Make sure the the important UUIDs
(disk, volume, VM) are where we think they should be.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2018-02-22 15:06:13 +00:00
Pino Toscano
1c996bf314 daemon: tsk: handle new enum values in sleuthkit 4.5
Resort to a version check for them, as they do not exist in older
versions.
2018-02-19 17:14:18 +01:00
Pino Toscano
491970b82f lib: qemu: help GCC 8 by break'ing a case in a switch
GCC 8 thinks that the case drive_protocol_gluster may fall through, most
probably because the only code is a switch case that handles the
elements of an enum, and thus letting other fall through. In reality
this ought to not happen at all, so help GCC by break'ing the case,
which will then lead to the abort() at the end of
guestfs_int_drive_source_qemu_param.
2018-02-19 17:14:18 +01:00
Pino Toscano
83d2fa510f appliance: add lib64jansson4 on Mageia
Apparently the jansson library on 64bit installation does not provide
the non-64bit name, so jansson is not pulled in the appliance, and thus
the daemon does not start.

Updates commit eb4fbe96c9.
2018-02-19 17:14:18 +01:00
Pino Toscano
0cca7f9061 appliance: include dash for Debian distros
Make sure that /bin/sh is available in the appliance, and that path is
provided by dash on Debian distributions.
2018-02-19 15:47:08 +01:00
Pino Toscano
535a4471f3 inspect: use check_tests also for detecting Hurd
Even though the list of checks is very short, at least this migrates
from imperative checks to a "declarative" one.

There should be no behaviour change, other than using os-release if it
contains all the needed information.
2018-02-14 17:19:52 +01:00
Pino Toscano
eb4fbe96c9 build: mandate Jansson >= 2.7
Since we use APIs added in Jansson 2.7 (e.g. json_string_length), then
raise the minimum version required to that version.

Fixes commit bd1c5c9f4d.
2018-02-13 13:07:22 +01:00
Pino Toscano
62b09ba0b0 inspector: fix help text (RHBZ#1544674) 2018-02-13 10:54:05 +01:00
Pino Toscano
5c5f69ef37 customize, sysprep, v2v: handle Kali Linux as Debian
Kali Linux is a Debian derivative, so add basic support for it by using
most of the Debian code paths.  The only exception is the crypto
algorithm for passwords in passwd, which is always assumed as SHA512
(as Kali Linux is relatively new).
2018-02-12 14:32:19 +01:00
Pino Toscano
1dd11d2276 inspect: recognize the Kali Linux distribution (RHBZ#1544227)
Read the information from os-release, and make it behave like a
Debian distribution (i.e. using dpkg, and apt).
2018-02-12 14:32:19 +01:00
Pino Toscano
bd1c5c9f4d Switch from YAJL to Jansson
While YAJL mostly works fine, it did not see any active development in
the last 3 years.  OTOH, Jansson is another JSON C implementation, with
a very liberal license, and a much nicer API.

Hence, switch all of libguestfs from YAJL to Jansson:
- configure checks, and buildsystem in general
- packages pulled in the appliance
- actual implementations
- contrib scripts
- documentation

This also makes use of the better APIs available (e.g. json_object_get,
json_array_foreach, and json_object_foreach).  This does not change the
API of our OCaml Yajl module.
2018-02-12 11:24:06 +01:00
Richard W.M. Jones
d0e5a819e8 python: Fix missing & additional backslashes which broke python sdist.
Fixes commit e6c89f9631.
2018-02-09 16:00:00 +00:00
Richard W.M. Jones
1e99b96179 Version 1.38.0. 2018-02-09 09:39:02 +00:00
Richard W.M. Jones
ed1c8fcfd7 docs: Finalize release notes for 1.38. 2018-02-09 09:39:00 +00:00
Richard W.M. Jones
dc44de5e23 authors: Add a list of aliases.
This handles the case where a single author has multiple different
names in the git commit history.
2018-02-09 09:39:00 +00:00
Richard W.M. Jones
c00998b90e ocaml: When creating compat Bytes module, create bytes.mli file.
On distros with OCaml < 4.02 we need to create a compatibility Bytes
module.  However we didn't create the interface file (bytes.mli) which
would mean that dependencies wouldn't be created correctly for
parallel builds.  This commit uses ‘ocaml -i’ to create an interface
file which exports everything.
2018-02-08 17:16:41 +00:00
Yuri Chornoivan
7e4f03d2c2 Fix minor typos 2018-02-08 13:20:34 +01:00
Pino Toscano
6acf236d24 python: add missing newline
When checking the return value of guestfs_int_py_fromstring for string
fields of structs, add a newline to generated C code, so it is properly
indented.

Fixes commit 401c445636.
2018-02-08 13:11:51 +01:00
Richard W.M. Jones
d56a3aa0f0 diff: Fix typo in manual page.
Reported by: Yuri Chornoivan
2018-02-07 18:38:13 +00:00
Daniel P. Berrangé
3c7bbf97e2 daemon: add inspector support for MS-DOS distro
An installation of MS-DOS has various files in a /DOS directory,
which COMMAND.COM looking like a reasonable signal that its MS-DOS
or a very close relative there-of.

This is validated with an MS-DOS 6.22 install.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-02-07 18:18:27 +00:00
Richard W.M. Jones
6893c40627 tmpdirs: Make the ‘su broken’ error message actionable.
Revert "tmpdirs: Blame systemd because su is broken."

This reverts commit 9464304d7a.

Replace with an actionable error message.
2018-02-07 17:26:58 +00:00
Pino Toscano
693a8175ee fish: add a small doc note about -- for args (RHBZ#1536603)
This will hint what to do when any argument of a command starts with a
dash.
2018-02-07 17:33:14 +01:00
Pino Toscano
3d4c84185a v2v: fix -it ssh syntax in example (RHBZ#1540535)
Updates commit 1d38216d20.
2018-02-07 17:26:37 +01:00
Pino Toscano
8ce1373847 customize: avoid Array.mem for now
Since it is available only in OCaml >= 4.03, which is higher than our
requirement, add a simple reimplementation of it.

Fixes commit 719d68fa24.
2018-02-07 16:54:09 +01:00
Richard W.M. Jones
b10aa60d54 docs: Remove or correct links to virt-tools.org.
Unfortunately I wasn't able to find a good reference for checking if
your hardware virt is enabled.

Thanks: Yuri Chornoivan
2018-02-07 14:49:25 +00:00
Richard W.M. Jones
9464304d7a tmpdirs: Blame systemd because su is broken. 2018-02-07 14:36:15 +00:00
Richard W.M. Jones
4a771d30d9 website: Update links to new development branch and stable branches. 2018-02-07 14:35:59 +00:00
Richard W.M. Jones
6bb9884018 maintainer: Update translations from Zanata.
There were some problems with the Ukrainian translations which I have
fixed.  The 3 magic strings __CUSTOMIZE_OPERATIONS__,
__CUSTOMIZE_SYNOPSIS__ and __OPERATIONS__ were translated, breaking
substitutions in virt-builder, virt-customize and virt-sysprep manual
pages.
2018-02-07 14:28:25 +00:00
Richard W.M. Jones
248d91bfa4 maintainer: Update to latest gnulib. 2018-02-07 13:26:23 +00:00
Richard W.M. Jones
900cdc9d8e docs: release notes: Hivex 1.3.14 is _not_ required. 2018-02-07 13:26:23 +00:00
Pino Toscano
82fbf294fd daemon: build also without Hivex.OPEN_UNSAFE (RHBZ#1493048)
Do a configure check for the OPEN_UNSAFE flag in the OCaml binding of
Hivex, using it only when available.  This makes it possible to use
hivex < 1.3.14 to build libguestfs (the daemon, actually).

Amend the building documentation accordingly, bringing the minimum
version of hivex back as it was before
commit 64f49df747.
2018-02-06 17:27:23 +01:00
Richard W.M. Jones
382b544731 Version 1.37.37. 2018-02-06 14:24:18 +00:00
Richard W.M. Jones
ee36f582d4 docs: Update release notes for 1.38 release. 2018-02-06 13:27:45 +00:00
Pino Toscano
719d68fa24 customize: allow missing SELINUXTYPE in SELinux config
libselinux defaults to "targeted" when no SELINUXTYPE is specified in
/etc/config/selinux.  Hence do the same here, instead of failing because
of the missing key.

Add a slow test for checking SELinux relabeling on a Fedora 27 guest,
both with no changes, and with a modified configuration.
2018-01-31 17:50:50 +01:00
Richard W.M. Jones
0c3d2d9430 customize: Correctly handle crypt(3) returning NULL (RHBZ#1539395).
In particular glibc's crypt will return NULL / errno == ENOSYS and
other implementations might do that in future too.

Reported by: David Hill
2018-01-30 14:18:35 +00:00
Richard W.M. Jones
7021a234aa p2v: tests: Fix slow test ‘test-virt-p2v-pxe.sh’.
Since virt-builder Fedora 27 templates now use GPT, the root
filesystem has moved from /dev/sda3 to /dev/sda4.  /dev/sda3 is now a
swap device which could not be mounted as the root device, although
systemd unhelpfully hides the error unless you run qemu interactively.

I think this fixes commit a06e50e263.
2018-01-26 10:52:56 +00:00
Richard W.M. Jones
ff80f294d3 Version 1.37.36. 2018-01-25 14:30:43 +00:00
Richard W.M. Jones
b0df5f26fe customize: Use libxcrypt if available to provide crypt(3).
glibc 2.27 removes crypt(3) and suggests using libxcrypt.
libxcrypt requires <crypt.h> to be included.
2018-01-23 20:57:16 +00:00
Richard W.M. Jones
e4c3968880 lib/info: Remove /dev/fd hacking and pass a true filename to qemu-img info.
It obscures what's really going on and is no longer necessary
for the original purpose.

This reverts commit d50cb7bbb4.

See also:

  https://www.redhat.com/archives/libguestfs/2017-November/thread.html#00226
  https://www.redhat.com/archives/libguestfs/2017-December/thread.html#00044
2018-01-23 20:57:16 +00:00
Mykola Ivanets
24d1d46c98 lib: docs: guestfs_list_filesystems no longer needs to be used soon after launch when nothing is mounted.
guestfs_list_filesystems uses mount/umount to discover btrfs
sub-volumes and since 1.37 it generates random mountpoint so it will
longer affect already mounted filesystems if either.
2018-01-23 10:22:55 +00:00
Richard W.M. Jones
c3dd3f51a6 lua, perl: Use thread-safe strerror_r instead of strerror (RHBZ#1536763). 2018-01-22 17:52:46 +00:00
Richard W.M. Jones
e04aa823d1 perl: Free array on error path to avoid leak (RHBZ#1536765). 2018-01-22 17:52:46 +00:00
Richard W.M. Jones
a30b51747f launch: direct: Use old-style file= and format= parameters when not disabling locking (RHBZ#1503497).
Ancient qemu 1.5 (in RHEL 7) does not understand the
file.file.filename= and file.driver= parameters.  Go back to using the
old-style file= and format= parameters when we're not trying to set
the file.backing.file.locking=off parameter.

Fixes commit 9fe592808c.

Thanks: Yongkui Guo, Václav Kadlčík.
2018-01-19 16:01:01 +00:00
Richard W.M. Jones
7e43ef4171 common/mlxml: Remove -cclib from ocamlmklib.
ocamlmklib will get confused if the -cclib parameter expands to
anything except a single -lxml2 argument.  In any case it's not
necessary to specify the linker command here since every use of this
library links in a program to libxml2.
2018-01-16 13:03:39 +00:00
Richard W.M. Jones
49263be47a configure: Don't define _FORTIFY_SOURCE.
We routinely test the upstream code by running everything under
valgrind, and in any case _FORTIFY_SOURCE is usually defined by
downstream Linux distros and we can leave the optimization vs safety
decision to them.

See this bug: https://bugs.gentoo.org/640494
2018-01-16 13:03:39 +00:00
Cédric Bosdonnat
7c986228d5 resize: copy GPT partition flags
In some cases, the first stage bootloader needs the 'Legacy BIOS
bootable' flag to be set on the partition. This change copies all
flags (including this one) for each partition of the old disk to the
new one to avoid ending up with non-bootable disks.
2018-01-16 13:03:39 +00:00
Cédric Bosdonnat
c5fdc4f764 New APIs: part_set_gpt_attributes and part_get_gpt_attributes
Allow reading and setting the GPT partition attribute flags.
2018-01-16 13:03:39 +00:00
Cédric Bosdonnat
5f26f70262 daemon: make sgdisk_info_extract_uuid_field more generic
Rename the sgdisk_info_extract_uuid_field to
sgdisk_info_extract_field in order to reuse it for other field types.
Just like its C ancestor, it now needs an extractor function to be
passed as parameter.
2018-01-16 12:51:46 +00:00
Mykola Ivanets
079681058e tests: md: test guestfish finds md and LV devices in different combinations
Test guestfish finds:
1. md device created from physical block device and LV,
2. md device created from LVs
3. LV created on md device

raid0 is used for md device because it is inoperable if one of its components is inaccessible so it is easy observable that md device is missing (raid1 in this case will be operable but in degraded state).
2018-01-16 09:49:21 +00:00
Mykola Ivanets
c71e9e9acd tests: md: test guestfish finds logical volume on md device
Test guestfish finds logical volume (LV) created on md device
2018-01-16 09:49:21 +00:00
Mykola Ivanets
b00379fbd6 appliance: init: Avoid running degraded md devices
The issue:
- raid1 will be in degraded state if one of its components is logical volume (LV)
- raid0 will be inoperable at all (inacessible from within appliance) if one of its component is LV
- raidN: you can expect the same issue for any raid level depends on how many components are inaccessible at the time mdadm is running and raid redundency.

It happens because mdadm is launched prior to lvm AND it is instructed to run found arrays immediately (--run flag) regardless of completeness of their components.
Later (when lvm activates found LVs) md signature on LV might be recognized BUT newly found raid components could't be inserted into already running (in degraded state)
or marked as inoperable raid arrays.

The patch fixes the issue in the following way:

1. Found arrays won't be run immediately unless ALL expected drives (components) are present. Here '--no-degraded' flag comes into a play. See mdadm(8).
2. Second mdadm call (after LVM is scanned) will scan UNUSED yet devices and make an attempt to run all found arrays (even they will be in degraded state).

There is no performance penalty because second pass scans UNUSED yet devices. Here is 'boot-benchmark' before and after patch:

             : libvirt backend : direct backend
------------------------------------------------
master       : 835.2ms ±1.1ms  : 670.4ms ±0.3ms
master+patch : 837.7ms ±2.4ms  : 671.8ms ±0.2ms
2018-01-16 09:49:21 +00:00
Mykola Ivanets
9bdd2cacfd cat: virt-tail: Fix spontaneously failing test
According to 'guestfs_sync' API method documentation: "You should always call this if you have modified a disk image, before closing the handle."
So, 'guestfish --remote sync' is required because changes made on the disk (guestfish --remote rm /tail) should be visible to 'virt-tail' which works in different process and also accessing the same disk.
A you can see, other changes done via 'guestfish --remote' in this test are flushed via a 'sync' command.

The test is failing spontaneously beasue without 'sync' it very depends on outside factors like qemu caching policy, underlying host filesystem etc.
2018-01-16 08:37:16 +00:00
Richard W.M. Jones
4ac3be3d04 daemon: tests: Compile tests with compiler warnings.
And fix the problems.
2018-01-09 12:17:53 +00:00
Richard W.M. Jones
04031269f6 tests: Further instances of $(RPC_CFLAGS). 2018-01-09 12:17:53 +00:00
Richard W.M. Jones
df7f6b9c9a common/protocol: Fix indentation of $(RPC_CFLAGS).
Fixes commit 946d5bf8d4.
2018-01-09 12:17:53 +00:00
Richard W.M. Jones
0a9a3d62d9 diff: Set different identifiers on the two handles.
This allows us to easily see from trace output (‘virt-diff -x’) which
handle is being used for each call.  Otherwise you get meaningless
output such as:

libguestfs: trace: download "/Windows/WindowsUpdate.log" "/tmp/virtdiffy9m5YW/a"
libguestfs: trace: download = 0
libguestfs: trace: download "/Windows/WindowsUpdate.log" "/tmp/virtdiffy9m5YW/b"
libguestfs: trace: download = 0

Thanks: Xiang Hua Chen
2018-01-09 11:12:19 +00:00
Richard W.M. Jones
ab0a3e0276 resize: Clarify example in manual page.
Someone following this example started by literally copying "olddisk"
to "newdisk", which doesn't work (the target must always be blank).
Clarify the wording.
2018-01-05 15:01:20 +00:00
Richard W.M. Jones
212762c593 Update copyright dates for 2018.
Run the following command over the source:

  perl -pi.bak -e 's/(20[01][0-9])-2017/$1-2018/g' `git ls-files`
2018-01-04 15:30:10 +00:00
Richard W.M. Jones
dab065a8ee v2v: docs: Match the two instances of /path/to/nbdkit in the documentation.
Fixes commit d81a2ee185.
See also:
https://bugzilla.redhat.com/show_bug.cgi?id=1513884#c5
2017-12-18 10:30:25 +00:00
Richard W.M. Jones
d3afdb6e3e df: Handle block sizes smaller than 1024 bytes (RHBZ#1525241).
Thanks: Nikolay Ivanets
2017-12-14 22:42:06 +00:00
Richard W.M. Jones
2c359583b3 Version 1.37.35. 2017-12-10 09:34:50 +00:00
Richard W.M. Jones
1190b8ce56 generator: Update AUTHORS. 2017-12-10 09:34:29 +00:00
Richard W.M. Jones
66f5aceda8 builder: Fix name of repository_main.mli file.
Fixes commit 67b0de7399.
2017-12-10 09:23:19 +00:00
Richard W.M. Jones
442653d9cd php: Ignore php/extension/configure.ac
Latest php finally renames this (from configure.in).
2017-12-10 09:17:40 +00:00
Richard W.M. Jones
62da9d819f configure: If multiple entries in RELEASES file, pick first.
Multiple entries matching the grep would corrupt the output Makefile.
2017-12-10 09:16:45 +00:00
Richard W.M. Jones
1d38216d20 v2v: -i vmx: Enhance VMX support with ability to use ‘-it ssh’ transport.
This enhances the existing VMX input support allowing it to be
used over SSH to the ESXi server.

The original command (for local .vmx files) was:

 $ virt-v2v -i vmx guest.vmx -o local -os /var/tmp

Adding ‘-it ssh’ and using an SSH remote path gives the new syntax:

 $ virt-v2v \
     -i vmx -it ssh \
     "ssh://root@esxi.example.com/vmfs/volumes/datastore1/guest/guest.vmx" \
     -o local -os /var/tmp

I anticipate that this input method will be widely used enough that it
deserves its own example at the top of the man page.
2017-12-09 21:18:17 +00:00
Richard W.M. Jones
6f347b4f80 v2v: vddk: Switch to using ‘-it vddk’ to specify VDDK as input transport.
Previously the presence of the ‘--vddk <libdir>’ option magically
enabled VDDK mode.  However we want to introduce other transports for
VMware conversions so this wasn't a very clean choice.

With this commit you must use ‘-it vddk’ to specify that you want VDDK
as a disk transport.  The previous ‘--vddk <libdir>’ option has been
renamed to ‘--vddk-libdir <libdir>’ to be consistent with the other
passthrough options, and it is no longer required.

A new command line looks like:

  $ export PATH=/path/to/nbdkit:$PATH
  $ virt-v2v \
      -ic 'vpx://root@vcenter.example.com/Datacenter/esxi?no_verify=1' \
|     -it vddk \
|     --vddk-libdir /path/to/vmware-vix-disklib-distrib \
      --vddk-thumbprint xx:xx:xx:... \
      "Windows 2003" \
      -o local -os /var/tmp

where only the two lines marked with ‘|’ have changed.
2017-12-09 21:11:52 +00:00
Richard W.M. Jones
0bbedd47c0 mltools: Move urandom module to common/mltools.
So that we can use it in virt-v2v code.
2017-12-09 21:11:52 +00:00
Richard W.M. Jones
c2898c50fd urandom: Fail if /dev/urandom returns EOF.
This is an unexpected error, so fail hard instead of leaking
End_of_file exception.

Nothing that calls into the Urandom module expects or handles
End_of_file.
2017-12-09 21:11:52 +00:00
Richard W.M. Jones
fd0bfba7b2 urandom: Use with_openfile. 2017-12-09 21:11:52 +00:00
Richard W.M. Jones
7960eb9bc6 urandom: Use O_CLOEXEC. 2017-12-09 21:11:52 +00:00
Richard W.M. Jones
1f66344961 builder: planner: Don't add some impossible transitions.
Certain transitions where the input and output filename are the same
are impossible, eg copying a file to itself.  Don't add these.

Reported-by: David Kaylor.
2017-12-09 21:11:52 +00:00
Richard W.M. Jones
a93a06dc59 daemon: Rewrite inspection code using ‘return’ statements.
When rewriting this, I revisited the original C code and changed the
OCaml code so it's now reasonably similar to the original.
2017-12-08 16:22:14 +00:00
Richard W.M. Jones
506e90cf35 common/mlstdutils: Add ‘return’ statement for OCaml.
This adds a ‘return’ statement as found in other programming
languages.  You can use it like this:

  with_return (fun {return} ->
    some code ...
  )

where ‘some code’ may either return implicitly (as usual), or may call
‘return x’ to immediately return ‘x’.  All returned values must have
the same type.

The OCaml >= 4.04 implementation is by Petter A. Urkedal and octachron.
See this thread:
https://sympa.inria.fr/sympa/arc/caml-list/2017-11/msg00017.html

The version that works for any OCaml is by me.  (Note that my version
cannot be nested).
2017-12-08 16:22:14 +00:00
Richard W.M. Jones
0eb23230fa common/mlstdutils: Move list functions into extended List module.
However some existing functions had names which shadowed existing
functions in the List module, so I had to rename them:

  assoc -> List.assoc_lbl
  append -> List.push_back_list
  prepend -> List.push_front_list

This is an extension of the previous commit.
2017-12-08 16:22:11 +00:00
Richard W.M. Jones
b585fea976 common/mlstdutils: Extend the List module.
We defined a number of functions on lists which are not provided by
the standard library.  As with Char and String, let's extend List to
add these new functions to a List pseudo-module (really
Std_utils.List, but called List when you ‘open Std_utils’).

The initial exported functions are all List functions from OCaml 3.11
+ iteri + mapi.  We can add other functions as needed.
2017-12-08 16:21:10 +00:00
Richard W.M. Jones
4699c7b6e1 v2v: -o null: Use the qemu null device driver.
Instead of writing to a temporary file and deleting it, use the null
block driver (the "null-co://" URI) in qemu to throw it away.
2017-12-08 16:21:06 +00:00
Richard W.M. Jones
e29296cfa2 v2v: Abstract the target file so it could be a QEMU URI.
This complicated bit of refactoring abstracts the target file so it is
allowed to be either a filename or a QEMU URI.
2017-12-08 16:20:59 +00:00
Richard W.M. Jones
c6b2c0a008 v2v: vddk: Fix printing of nbdkit command.
Fixes commit 99a29125f6.
2017-12-08 11:48:43 +00:00
Pino Toscano
b34f457cf2 builder: use the template arch when caching all templates
When caching all the templates, use the architecture of each template,
instead of the architecture passed as --arch (or the host architecture,
as default).  This way, the right destination filename will be used.

Fixes commit b1cf6246f3.

Thanks to: Erik Skultety.
2017-12-07 18:16:17 +01:00
Richard W.M. Jones
99a29125f6 v2v: vddk: Print nbdkit command before running it.
Very useful for debugging.
2017-12-07 16:22:09 +00:00
Richard W.M. Jones
2b185d1e90 v2v: cmdline: Reformat array of arguments.
No change, just code formatting.
2017-12-07 16:22:09 +00:00
Richard W.M. Jones
eecf41956d v2v: Remove unused ‘scheme’ parameter.
It wasn't actually used for anything significant.  Even worse
virt-v2v-copy-to-local made up a scheme out of thin air.

Just code refactoring, no functional change.
2017-12-07 10:53:31 +00:00
Richard W.M. Jones
4b43697f9b v2v: docs: State that --vddk-thumbprint is only required if --vddk present (RHBZ#1513884).
Thanks: Ming Xie, Pino Toscano.

See also:
https://bugzilla.redhat.com/show_bug.cgi?id=1513884#c2
2017-12-06 15:56:47 +00:00
Richard W.M. Jones
5ac24b490e v2v: docs: Remove min version of VDDK, recommend nbdkit >= 1.1.25 (RHBZ#1513884).
Requires -> recommends because older versions of nbdkit will likely
work also.

See also:
https://bugzilla.redhat.com/show_bug.cgi?id=1513884#c3
2017-12-06 15:55:57 +00:00
Pino Toscano
614f680dc6 lib: libvirt: stop using <shareable/> for appliance disk (RHBZ#1518517)
Commit aa9e0057b1 made the libvirt backend
use <shareable/> for the disk of the appliance, since at that time all
the instances were using the disk directly.
OTOH, commit 3ad44c8660 switched to
overlays for read-only disks, including the appliance, so effectively
protecting the appliance.

Because of this, the libvirt backend does not need <shareable/> anymore.

Thanks to: Daniel Berrange, Richard W.M. Jones,  Peter Krempa.
2017-12-05 18:14:21 +01:00
Pino Toscano
1b2020ba04 v2v: bootloaders: handle no default grubby kernel (RHBZ#1519204)
When using grubby to get the default kernel of a guest, do not fail
with a bogus error like:

virt-v2v: error: libguestfs error: statns: statns_stub: path must start
with a / character

in case there is no default kernel that can be determined (e.g. because
of a bogus configuration).
2017-12-04 10:15:29 +01:00
Richard W.M. Jones
af4e3b3d3b bugs-in-changelog.sh: Python bugzilla client -t option changed to -s. 2017-11-25 21:07:29 +00:00
Richard W.M. Jones
5eabcdb9fd v2v: Add generator_built and BUILT_SOURCES listing generated files.
Fixes commit 0c396650b0.
2017-11-23 18:48:44 +00:00
Pino Toscano
06df910491 docs: add virt-builder-repository.pod to podfiles
Updates commit a442d2c321.
2017-11-23 14:49:44 +01:00
Lars Seipel
35320dd0ed launch: direct: Omit locking option for non-file disks (RHBZ#1516094)
QEMU does not accept options unrecognized by the block driver
in use. Disable locking only for read-only disks that are
file-backed, as that's the only block driver it is supported
with.

Signed-off-by: Lars Seipel <ls@slrz.net>
2017-11-23 08:42:46 +00:00
Yuri Chornoivan
1563ba5827 Fix minor typos 2017-11-22 20:33:23 +00:00
Richard W.M. Jones
67b0de7399 builder: Add missing builder/repository_main.mli file.
Fixes commit a442d2c321.
2017-11-21 23:11:34 +00:00
Cédric Bosdonnat
a442d2c321 New tool: virt-builder-repository
virt-builder-repository allows users to easily create or update
a virt-builder source repository out of disk images. The tool can
be run in either interactive or automated mode.
2017-11-21 16:36:32 +00:00
Cédric Bosdonnat
efaf570aaa builder: add a template parameter to get_index
get_index now gets a new template parameter. Setting it to true will
make the index parsing less picky about missing important data. This
can be used to parse a partial index file.
2017-11-21 16:16:19 +00:00
Cédric Bosdonnat
448a61fbd5 builder: change arch type to distinguish guesses
Change Index.arch to the type (Arch of string | GuessedArch of string).

In a future commit, the index parser will allow arch not to be set
for some cases. Thus arch value will be guessed by inspecting the
image. However we need to distinguish between a set value and a guessed
one. Using this new type will help it:

    match arch with
    | Arch s        -> (* This is a set value *)
    | GuessedArch s -> (* This is a guessed value *)
2017-11-21 16:16:19 +00:00
Martin Kletzander
946d5bf8d4 build: Reference RPC_CFLAGS where needed
Since glibc-2.26 removed the /usr/include/rpc/rpc.h, it caused problem even
though probing for libtirpc has taken place and worked properly.  The problem is
that RPC_CFLAGS (usually `-I/usr/include/tirpc` on Linux) was not used in places
where it was needed.  So the build failed with messages like the following:

In file included from guestfs_protocol.c:6:0:
guestfs_protocol.h:9:10: fatal error: rpc/rpc.h: No such file or directory
 #include <rpc/rpc.h>
          ^~~~~~~~~~~

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-11-19 19:59:01 +00:00
Richard W.M. Jones
31acbfef2f common/mlpcre: Compile bindings even with --disable-ocaml (RHBZ#1514756).
Thanks: Jean-Christophe Manciot
2017-11-18 12:33:05 +00:00
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
2024 changed files with 2581510 additions and 1018361 deletions

161
.github/workflows/main.yml vendored Normal file
View File

@@ -0,0 +1,161 @@
# Run the jobs below on every push to master branch and pull request.
on:
push:
branches:
- master
pull_request:
branches:
- master
# Runs basic configure, make and make check.
jobs:
ubuntu:
name: Ubuntu
runs-on: ubuntu-${{ matrix.release }}
continue-on-error: true
strategy:
fail-fast: false
matrix:
release:
- 24.04
steps:
- name: Identify the system
run: |
cat /etc/os-release
- name: Enable source repositories
run: |
sudo sed -i 's/Types: deb$/Types: deb deb-src/g' \
/etc/apt/sources.list.d/ubuntu.sources
- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get -y build-dep libguestfs
- name: Install extra dependencies
run: |
# Git is needed to run git submodule command.
# json-c is missing from the Ubuntu package deps.
sudo apt-get -y install git libjson-c-dev
- name: Fix broken Ubuntu kernel permissions
run: |
# https://bugs.launchpad.net/ubuntu/+source/linux/+bug/759725
sudo chmod 0644 /boot/vmlinuz*
- name: Enable KVM
run: |
sudo chmod 0666 /dev/kvm
- name: Checkout sources
uses: actions/checkout@v5
- name: Checkout submodule
run: |
git submodule update --init
- name: Compile the code
run: |
autoreconf -fiv
./configure --disable-gobject --enable-werror
make -j
- name: Run the quick test
run: |
make quickcheck
- name: Run the full tests
run: |
# grub-install: error: /usr/lib/grub/i386-pc/modinfo.sh
# doesn't exist. Please specify --target or --directory
export SKIP_TEST_GRUB_INSTALL_0=1
# Errors from hexdump, maybe not installed?
export SKIP_TEST_HEXDUMP_0=1
export SKIP_TEST_HEXDUMP_1=1
export SKIP_TEST_HEXDUMP_2=1
# error: luks_close: cryptsetup exited with status 5:
# Device lukstest is still in use
export SKIP_TEST_LUKS_SH=1
# error: passt exited with status 1
export SKIP_TEST_NETWORK_SH=1
# error: passt exited with status 1
export SKIP_TEST_RSYNC_SH=1
if ! make check; then
find -name test-suite.log -exec cat {} \;
exit 1
fi
fedora:
name: Fedora
runs-on: ubuntu-latest # VM where the container runs
strategy:
fail-fast: false
matrix:
release:
- 42
- 43
container:
image: quay.io/fedora/fedora:${{ matrix.release }}
options: --security-opt seccomp=unconfined
steps:
- name: Identify the system
run: |
cat /etc/os-release
- name: Install build dependencies
run: |
dnf builddep -y libguestfs
- name: Install extra dependencies
run: |
# Git is needed to run git submodule command.
# The others are needed to run the tests.
dnf install -y git kernel sqlite perl-hivex rubygem-minitest
- name: Checkout sources
uses: actions/checkout@v5
- name: Create user
run: |
useradd -m -s /bin/bash -G wheel guestfs
tail /etc/passwd
- name: Make checkout directory editable by the sscg user
run: |
chown -R guestfs:wheel ${GITHUB_WORKSPACE}
- name: Checkout submodule
run: |
su -c 'git submodule update --init' guestfs
- name: Compile the code
run: |
su -c '
autoreconf -fiv &&
./configure CFLAGS="-fPIC -g -O2" --disable-gobject --enable-werror &&
make -j
' guestfs
- name: Run the quick test
run: |
su -c 'make quickcheck' guestfs
- name: Run the full tests
run: |
# error: passt exited with status 1
export SKIP_TEST_NETWORK_SH=1
# error: passt exited with status 1
export SKIP_TEST_RSYNC_SH=1
# error: internal_autosync: umount: /sysroot: umount: /sysroot:
# target is busy
export SKIP_RHBZ1011907_1165785_SH=1
# We have to set $HOME since su -p won't set it below.
export HOME=/home/guestfs
if ! su -p -c 'make check' guestfs; then
find -name test-suite.log -exec cat {} \;
exit 1
fi

340
.gitignore vendored
View File

@@ -17,7 +17,6 @@
*.log
*.o
*.orig
*.patch
*.pyc
*.rej
*.swp
@@ -27,17 +26,16 @@ bindtests.tmp
cscope.out
.deps
.dirstamp
dll*.so
.gdb_history
.libs
Makefile
Makefile.in
/.sc-*
/ABOUT-NLS
/aclocal.m4
/align/stamp-virt-alignment-scan.pod
/align/virt-alignment-scan
/align/virt-alignment-scan.1
/appliance/guestfsd.deps
/appliance/libguestfs-make-fixed-appliance
/appliance/libguestfs-make-fixed-appliance.1
/appliance/make.sh
@@ -45,18 +43,12 @@ Makefile.in
/appliance/stamp-libguestfs-make-fixed-appliance.pod
/appliance/stamp-supermin
/appliance/supermin.d
/AUTHORS
/autom4te.cache
/bash/virt-builder
/bash/virt-cat
/bash/virt-df
/bash/virt-edit
/bash/virt-filesystems
/bash/virt-format
/bash/virt-inspector
/bash/virt-log
/bash/virt-ls
/bash/virt-sysprep
/bash/virt-sparsify
/bash/virt-copy-in
/bash/virt-copy-out
/bash/virt-tar-in
/bash/virt-tar-out
/build-aux/.gitignore
/build-aux/ar-lib
/build-aux/compile
@@ -69,87 +61,73 @@ Makefile.in
/build-aux/snippet/
/build-aux/test-driver
/build-aux/ylwrap
/builder/.depend
/builder/index-parse.c
/builder/index-parse.h
/builder/index-scan.c
/builder/libguestfs.conf
/builder/opensuse.conf
/builder/oUnit-*
/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-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
/cat/virt-filesystems
/cat/virt-filesystems.1
/cat/virt-log
/cat/virt-log.1
/cat/virt-ls
/cat/virt-ls.1
/ChangeLog
/compile
/config.cache
/config.guess
/config.h
/config.h.in
/config.log
/config.sh
/config.status
/config.sub
/configure
/csharp/Libguestfs.cs
/customize/.depend
/customize/customize_cmdline.ml
/customize/customize_cmdline.mli
/customize/customize-options.pod
/customize/customize-synopsis.pod
/customize/stamp-virt-customize.pod
/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/blkid.mli
/daemon/btrfs.mli
/daemon/callbacks.ml
/daemon/caml-stubs.c
/daemon/cryptsetup.mli
/daemon/daemon_config.ml
/daemon/daemon_utils_tests
/daemon/devsparts.mli
/daemon/dispatch.c
/daemon/file.mli
/daemon/filearch.mli
/daemon/findfs.mli
/daemon/guestfsd
/daemon/guestfsd.8
/daemon/guestfsd.exe
/daemon/guestfs_protocol.c
/daemon/guestfs_protocol.h
/daemon/install-sh
/daemon/missing
/daemon/inspect.mli
/daemon/is.mli
/daemon/isoinfo.mli
/daemon/ldm.mli
/daemon/link.mli
/daemon/listfs.mli
/daemon/lvm.mli
/daemon/lvm_dm.mli
/daemon/lvm_full.mli
/daemon/md.mli
/daemon/mount.mli
/daemon/names.c
/daemon/optgroups.c
/daemon/optgroups.h
/daemon/optgroups.ml
/daemon/optgroups.mli
/daemon/parted.mli
/daemon/realpath.mli
/daemon/rpm.mli
/daemon/selinux.mli
/daemon/sfdisk.mli
/daemon/stamp-guestfsd.pod
/daemon/stubs.c
/daemon/statvfs.mli
/daemon/structs-cleanups.c
/daemon/structs-cleanups.h
/daemon/structs.ml
/daemon/structs.mli
/daemon/stubs-?.c
/daemon/stubs.h
/daemon/types.ml
/daemon/xfs.mli
/depcomp
/df/stamp-virt-df.pod
/df/virt-df
/df/virt-df.1
/dib/.depend
/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.*.1
/docs/guestfs-release-notes.1
/docs/guestfs-security.1
/docs/guestfs-testing.1
@@ -160,20 +138,21 @@ Makefile.in
/docs/stamp-guestfs-internals.pod
/docs/stamp-guestfs-performance.pod
/docs/stamp-guestfs-recipes.pod
/docs/stamp-guestfs-release-notes-1.*.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
@@ -188,6 +167,7 @@ Makefile.in
/fish/cmds-gperf.c
/fish/cmds-gperf.gperf
/fish/completion.c
/fish/entries-?.c
/fish/event-names.c
/fish/fish-cmds.h
/fish/guestfish
@@ -200,19 +180,19 @@ 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
/fish/virt-tar-out.1
/format/stamp-virt-format.pod
/format/virt-format
/format/virt-format.1
/fuse/guestmount
/fuse/guestmount.1
/fuse/guestunmount
@@ -227,43 +207,55 @@ 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
/GNUmakefile
/gobject/bindtests.js
/gobject/Guestfs-1.0.gir
/gobject/Guestfs-1.0.typelib
/golang/bindtests.go
/gobject/guestfs-gobject.3
/gobject/libguestfs-gobject-1.0.vapi
/gobject/stamp-guestfs-gobject.pod
/golang/bindtests/bindtests.go
/golang/examples/guestfs-golang.3
/golang/examples/stamp-guestfs-golang.pod
/golang/pkg
/guestfsd-in-wine.log
/haskell/Bindtests
/haskell/Bindtests.hs
/haskell/Guestfs010Load
/haskell/Guestfs030Config
/haskell/Guestfs050LVCreate
/haskell/Guestfs.hs
/inspector/actual-*.xml
/inspector/stamp-virt-inspector.pod
/inspector/test-xmllint.sh
/inspector/virt-inspector
/inspector/virt-inspector.1
/include/guestfs.h
/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-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/local/libguestfs.pc
/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
@@ -275,7 +267,6 @@ Makefile.in
/lua/guestfs.so
/lua/lua-guestfs.c
/m4/ChangeLog
/m4/gnulib-cache.m4
/m4/intmax.m4
/m4/libtool.m4
/m4/lt~obsolete.m4
@@ -283,18 +274,9 @@ Makefile.in
/m4/ltsugar.m4
/m4/ltversion.m4
/maint.mk
/make-fs/stamp-virt-make-fs.pod
/make-fs/virt-make-fs
/make-fs/virt-make-fs.1
/missing
/mllib/.depend
/mllib/common_gettext.ml
/mllib/common_utils_tests
/mllib/dummy
/mllib/guestfs_config.ml
/mllib/JSON_tests
/mllib/libdir.ml
/mllib/oUnit-*
/ocaml-dep.sh
/ocaml-link.sh
/ocaml/bindtests.bc
/ocaml/bindtests.opt
/ocaml/bindtests.ml
@@ -305,6 +287,7 @@ Makefile.in
/ocaml/examples/guestfs-ocaml.3
/ocaml/examples/inspect_vm
/ocaml/examples/stamp-guestfs-ocaml.pod
/ocaml/guestfs
/ocaml/guestfs-c-actions.c
/ocaml/guestfs-c-errnos.c
/ocaml/guestfs.ml
@@ -314,32 +297,6 @@ Makefile.in
/ocaml/stamp-mlguestfs
/ocaml/t/*.bc
/ocaml/t/*.opt
/p2v/dependencies.archlinux
/p2v/dependencies.debian
/p2v/dependencies.redhat
/p2v/dependencies.suse
/p2v/launch-virt-p2v
/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/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-make-disk
/p2v/virt-p2v-make-disk.1
/p2v/virt-p2v-make-kickstart
/p2v/virt-p2v-make-kickstart.1
/perl/_build
/perl/bindtests.pl
/perl/blib
@@ -366,9 +323,11 @@ Makefile.in
/php/extension/config.status
/php/extension/config.sub
/php/extension/configure
/php/extension/configure.ac
/php/extension/configure.in
/php/extension/env
/php/extension/guestfs_php.c
/php/extension/guestfs_php.dep
/php/extension/install-sh
/php/extension/libtool
/php/extension/ltmain.sh
@@ -389,16 +348,16 @@ Makefile.in
/php/extension/tests/guestfs_*.sh
/php/extension/tests/guestfs_090_bindtests.phpt
/php/extension/tmp-php.ini
/pick-guests.pl
/po-docs/*/*.1
/po-docs/*/*.3
/po-docs/*/*.5
/po-docs/*/*.8
/po-docs/po4a.conf
/po-docs/*/*.pod
/podwrapper.1
/podwrapper.pl
/po/*.gmo
/python/actions-?.c
/python/actions.h
/python/bindtests.py
/python/build
/python/config.h
@@ -406,82 +365,42 @@ Makefile.in
/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-stringlists-utils.h
/python/MANIFEST
/python/module.c
/python/stringlists-utils.c
/python/structs.c
/python/__pycache__
/python/setup.py
/python/stamp-extra-files
/python/utils.c
/qemu-wrapper.sh
/python/t/tests_helper.py
/rescue/stamp-virt-rescue.pod
/rescue/virt-rescue
/rescue/virt-rescue.1
/resize/.depend
/resize/stamp-virt-resize.pod
/resize/virt-resize
/resize/virt-resize.1
/ruby/bindtests.rb
/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
/rust/Cargo.lock
/rust/Cargo.toml
/rust/**/*.rs.bk
/rust/src/bin/bindtests.rs
/rust/src/guestfs.rs
/rust/target
/run
/sparsify/.depend
/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/structs-print.c
/src/structs-print.h
/src/test-utils
/stamp-h1
/sysprep/.depend
/sysprep/stamp-script1.sh
/sysprep/stamp-script2.sh
/sysprep/stamp-script4.sh
/sysprep/stamp-virt-sysprep.pod
/sysprep/sysprep-extra-options.pod
/sysprep/sysprep-operations.pod
/sysprep/virt-sysprep
/sysprep/virt-sysprep.1
/tests/c-api/test-add-drive-opts
/tests/c-api/test-add-libvirt-dom
/tests/c-api/test-backend-settings
@@ -492,38 +411,32 @@ Makefile.in
/tests/c-api/test-dlopen
/tests/c-api/test-environment
/tests/c-api/test-event-string
/tests/c-api/test*.img
/tests/c-api/test-just-header
/tests/c-api/test-just-header-cxx
/tests/c-api/test-last-errno
/tests/c-api/test.log
/tests/c-api/test-private-data
/tests/c-api/test-pwd
/tests/c-api/tests
/tests/c-api/tests.c
/tests/c-api/test*.tmp
/tests/c-api/test-threads
/tests/c-api/test-user-cancel
/tests/charsets/test-charset-fidelity
/tests/daemon/captive-daemon.pm
/tests/disks/test-add-disks
/tests/disks/test-qemu-drive-libvirt.xml
/tests/events/test-libvirt-auth-callbacks
/tests/functions.sh
/tests/large-command/test-large-command
/tests/mount-local/test-parallel-mount-local
/tests/mountable/test-internal-parse-mountable
/tests/parallel/test-parallel
/tests/protocol/test-error-messages
/tests/qemu/boot-analysis
/tests/qemu/boot-benchmark
/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
/tests/testdownload.tmp
/test-data/test.iso
/test-data/blank-disks/blank-disk-*
/test-data/fake-virtio-win/fake-virtio-win.iso
@@ -539,6 +452,7 @@ Makefile.in
/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/lib-i586.so.zst
/test-data/files/test-grep.txt.gz
/test-data/phony-guests/archlinux.img
/test-data/phony-guests/blank-*.img
@@ -546,10 +460,11 @@ Makefile.in
/test-data/phony-guests/debian.img
/test-data/phony-guests/fedora.img
/test-data/phony-guests/fedora-btrfs.img
/test-data/phony-guests/fedora-luks-on-lvm.img
/test-data/phony-guests/fedora-lvm-on-luks.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/fedora.db
/test-data/phony-guests/guests.xml
/test-data/phony-guests/guests-all-good.xml
/test-data/phony-guests/stamp-fedora-md.img
@@ -561,29 +476,6 @@ Makefile.in
/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
/v2v/.depend
/v2v/centos-6.img
/v2v/centos-7.0.img
/v2v/fedora-20.img
/v2v/fake-virtio-win.iso
/v2v/oUnit-*
/v2v/rhel-5.10.img
/v2v/rhel-6.5.img
/v2v/rhel-7.0.img
/v2v/stamp-virt-v2v.pod
/v2v/stamp-virt-v2v-copy-to-local.pod
/v2v/test-harness/.depend
/v2v/test-harness/META
/v2v/test-harness/dllv2v_test_harness.so
/v2v/test-harness/stamp-virt-v2v-test-harness.pod
/v2v/test-harness/virt-v2v-test-harness.1
/v2v/v2v_unit_tests
/v2v/virt-v2v
/v2v/virt-v2v.1
/v2v/virt-v2v-copy-to-local
/v2v/virt-v2v-copy-to-local.1
/website/*.html
/website/README.txt
/website/TODO.txt

6
.gitmodules vendored
View File

@@ -1,3 +1,3 @@
[submodule "gnulib"]
path = .gnulib
url = git://git.sv.gnu.org/gnulib.git
[submodule "common"]
path = common
url = https://github.com/libguestfs/libguestfs-common

3
.gitpublish Normal file
View File

@@ -0,0 +1,3 @@
[gitpublishprofile "default"]
base = master
to = guestfs@lists.libguestfs.org

Submodule .gnulib deleted from 5ac0e2ba90

71
AUTHORS
View File

@@ -1,71 +0,0 @@
Adam Huffman
Angus Salkeld
Ani Peter
Bastien ROUCARIÈS
Cao jin
Charles Duffy
Chen Hanxiao
Cole Robinson
Colin Walters
Cédric Bosdonnat
Dan Lipsitt
Daniel Berrange
Daniel Cabrera
Daniel Exner
Dave Vasilevsky
David Sommerseth
Dawid Zamirski
Douglas Schilling Landgraf
Eric Blake
Erik Nolte
Evaggelos Balaskas
Gabriele Cerami
Geert Warrink
Guido Günther
Hilko Bengen
Hu Tao
infernix
Jaswinder Singh
Jim Meyering
Jiri Popelka
John Eckersberg
Joseph Wang
Karel Klíč
Kashyap Chamarthy
Lars Kellogg-Stedman
Lee Yarwood
Marcin Gibula
Margaret Lewicka
Maros Zatko
Martin Kletzander
Masami HIRATA
Matteo Cafasso
Matthew Booth
Maxim Koltsov
Maxim Perevedentsev
Menanteau Guy
Michael Scherer
Mike Frysinger
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
Robert Antoni Buj Gelonch
Roman Kagan
Sandeep Shedmake
Shahar Havivi
Shahar Lev
Shankar Prasad
Thomas S Hatch
Török Edwin
Wanlong Gao
Wulf C. Krueger

759
BUGS
View File

@@ -1,759 +0,0 @@
NOTE: This file is automatically generated from "update-bugs.sh".
Last updated: 2016-04-14
This contains a local list of the bugs that are open against
libguestfs. Bugs are tracked in the Red Hat Bugzilla database
at https://bugzilla.redhat.com/ and to report a new bug you
should follow this link:
https://bugzilla.redhat.com/enter_bug.cgi?component=libguestfs&product=Virtualization+Tools
When reporting a new bug, please check:
- That the bug has not been reported already.
- That you are testing a recent version.
- Describe the bug accurately, and give a way to reproduce it.
- Include the version of libguestfs, distro version and any other
relevant information.
- Attach the complete output of "libguestfs-test-tool".
--------------------------------------------------
Bugs in NEW or ASSIGNED state are open and waiting for someone to fix.
554829 NEW https://bugzilla.redhat.com/show_bug.cgi?id=554829
SELinux handling could be done better.
572337 NEW https://bugzilla.redhat.com/show_bug.cgi?id=572337
libguestfs should support gptsync
578103 NEW https://bugzilla.redhat.com/show_bug.cgi?id=578103
[RFE] Tool to Compare Windows Registry Entries
637251 NEW https://bugzilla.redhat.com/show_bug.cgi?id=637251
virt-inspector fails to recognize data-only NTFS disk image
693064 NEW https://bugzilla.redhat.com/show_bug.cgi?id=693064
Symbolic links on ntfs-3g are not followed correctly by some commands
745576 NEW https://bugzilla.redhat.com/show_bug.cgi?id=745576
libguestfs (or qemu?) hangs if sparse file runs out of disk space
770075 NEW https://bugzilla.redhat.com/show_bug.cgi?id=770075
FEBOOTSTRAP_MODULES fails if modules directory is not under /lib
770076 NEW https://bugzilla.redhat.com/show_bug.cgi?id=770076
FEBOOTSTRAP_KERNEL causes appliance build to fail
785603 NEW https://bugzilla.redhat.com/show_bug.cgi?id=785603
copy-out "No such file or directory"
790837 NEW https://bugzilla.redhat.com/show_bug.cgi?id=790837
Use of atexit to clean up handles is wrong in multithreaded programs
813290 NEW https://bugzilla.redhat.com/show_bug.cgi?id=813290
mdadm (md-detail) test occasionally fails with 'md device /dev/md125 does not appear to be active.'
824021 NEW https://bugzilla.redhat.com/show_bug.cgi?id=824021
inspection cannot recognize guest which uses btrfs subvolumes for root
832602 NEW https://bugzilla.redhat.com/show_bug.cgi?id=832602
"error in chunked encoding" when trying to extract (tar-out) a truncated ISO image
833362 NEW https://bugzilla.redhat.com/show_bug.cgi?id=833362
virt-make-fs test fails on ppc64 because filesystem block size is 64k
835622 NEW https://bugzilla.redhat.com/show_bug.cgi?id=835622
RFE: virt-sparsify should be able to sparsify onto a thin-provisioned LV
848464 NEW https://bugzilla.redhat.com/show_bug.cgi?id=848464
gobject javascript bindings cannot use 64 bit integers
848926 NEW https://bugzilla.redhat.com/show_bug.cgi?id=848926
virt-v2v should verify that the RHEV-M domain is an export storage domain
855058 NEW https://bugzilla.redhat.com/show_bug.cgi?id=855058
RFE: virt-p2v: display more information about storage devices
857763 NEW https://bugzilla.redhat.com/show_bug.cgi?id=857763
libguestfs 'file-architecture' returns 'ARM' for arm binaries
866994 NEW https://bugzilla.redhat.com/show_bug.cgi?id=866994
tgz-out causes memory leak in guestfsd
887826 NEW https://bugzilla.redhat.com/show_bug.cgi?id=887826
RFE: virt-sparsify cannot handle multi-disk virtual machines (eg. if they use LVM, MD, LDM, etc)
891909 NEW https://bugzilla.redhat.com/show_bug.cgi?id=891909
Can't make install with non-standard prefix as non-root
895898 NEW https://bugzilla.redhat.com/show_bug.cgi?id=895898
RFE: Allow interface to be specified with libvirt attach-method
895946 NEW https://bugzilla.redhat.com/show_bug.cgi?id=895946
Got incorrect block count number when resize ntfs file system via "ntfsresize_opts"
903987 NEW https://bugzilla.redhat.com/show_bug.cgi?id=903987
Command "acl-set-file" is inconvenient to use
906766 NEW https://bugzilla.redhat.com/show_bug.cgi?id=906766
virt-resize cannot resize RHEL 5 guest with GPT partition table type
906777 NEW https://bugzilla.redhat.com/show_bug.cgi?id=906777
In tests, set_label sometimes fails
910115 NEW https://bugzilla.redhat.com/show_bug.cgi?id=910115
RFE: support ntfsresize --bad-sectors option in virt-resize
910117 NEW https://bugzilla.redhat.com/show_bug.cgi?id=910117
virt-v2v removes serial console from securetty list
910269 NEW https://bugzilla.redhat.com/show_bug.cgi?id=910269
Tracker: Bugs in other packages that stop libguestfs working
913815 NEW https://bugzilla.redhat.com/show_bug.cgi?id=913815
febootstrap: no ext2 root device found when running libguestfs-test-tools
917706 NEW https://bugzilla.redhat.com/show_bug.cgi?id=917706
guestfs_umount_local is not thread safe
920617 NEW https://bugzilla.redhat.com/show_bug.cgi?id=920617
RFE: virt-inspector (or another tool) should produce OVF output for oVirt / RHEV
921604 NEW https://bugzilla.redhat.com/show_bug.cgi?id=921604
RFE: virt-v2v: add option to specify spice or VNC and whether to add USB connections
963232 NEW https://bugzilla.redhat.com/show_bug.cgi?id=963232
RFE: v2v: a --no-cleanup would be useful for debugging of disk images that guestfs has issues converting
973138 NEW https://bugzilla.redhat.com/show_bug.cgi?id=973138
RFE: sh & debug sh should be able to capture all output and error return code
982516 NEW https://bugzilla.redhat.com/show_bug.cgi?id=982516
sh "rpm -Va" fails because apparently /dev/shm is not created/bind-mounted correctly
983969 NEW https://bugzilla.redhat.com/show_bug.cgi?id=983969
RFE: virt-sysprep should be SELinux-aware
986242 NEW https://bugzilla.redhat.com/show_bug.cgi?id=986242
golang bindings cannot be compiled if golang-guestfs package is installed
987829 NEW https://bugzilla.redhat.com/show_bug.cgi?id=987829
virt-resize error: "lvm_set_filter: vgchange: Couldn't find device with uuid .. Refusing activation of partial LV"
991641 NEW https://bugzilla.redhat.com/show_bug.cgi?id=991641
virt-sysprep fs-uuids plugin doesn't update UUIDs in fstab, elsewhere
991830 NEW https://bugzilla.redhat.com/show_bug.cgi?id=991830
virt-resize throws ambiguous error when /dev/mapper/VG-LV path is used
994965 NEW https://bugzilla.redhat.com/show_bug.cgi?id=994965
libguestfs doesn't work on armv7hl
1019388 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1019388
firstboot scripts (virt-builder, virt-sysprep) don't work for Debian 6 & 7 guests
1023630 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1023630
enable-valgrind-daemon option breaks UML
1025942 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1025942
Parallel virt-df and virt-alignment-scan tests sometimes deadlock
1027526 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1027526
RFE: Labels for logical partitions lost in Windows 2003 after virt-resize for primary partition
1029134 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1029134
Broken links in virt-builder web man page
1033573 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1033573
libguestfs inspection does not recognize NAS4Free OS installed on QCOW2 image
1040912 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1040912
[ARM] mount-local / FUSE support does not seem to work at all
1051694 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1051694
libguestfs FTBFS on Ubuntu saucy
1056047 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1056047
virt-df generates no output for Solaris 11 x86_64 guest.
1057873 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1057873
libguestfs df/ subdirectory tests fail occasionally
1060423 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1060423
Support setting xattrs via FUSE
1061040 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1061040
RFE: Enable ZFS support
1075594 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1075594
RFE: python-libguestfs should be available on pypi
1079734 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1079734
Tiny Core Linux is not recognized by libguestfs inspection
1089100 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1089100
NetworkManager avc unlink denied for resolv.conf after using --selinux-relabel
1092583 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1092583
guestfish removes query string from URI
1097272 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1097272
Ruby bindings should use RB_GC_GUARD (instead of volatile) for enhanced safety
1099292 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1099292
sfdisk failed by "Device or resource busy" when using one command line
1099475 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1099475
sfdisk: BLKRRPART: Device or resource busy
1100138 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1100138
some operation cause "lvremove" can not find the object
1100140 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1100140
some operation cause "lvremove" can not find the object
1102241 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1102241
[RFE] libguestfs should detect OSTree (project-atomic) qcow2 disk image
1102619 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1102619
lvm-clear-filter failed when has two same name but different uuid's VG
1102620 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1102620
lvm-clear-filter failed when has two same name but different uuid's VG
1103444 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1103444
virt-v2v of RHEL AS release 3(Taroon) VMware VM fails because rpm binary segfaults
1107317 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1107317
Ubuntu package fails to depend on linux-image-extra (causes missing virtio-serial)
1108171 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1108171
RFE: virt-builder should be able to build PXE images for baremetal installation
1114012 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1114012
"yum install guestfish" on fresh Fedora 20 results in broken libguestfs
1118305 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1118305
RFE: Ability to set iSCSI-Initiator-IQN for iSCSI connections
1129110 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1129110
Libguestfs NTFS not setting ACLs
1134726 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1134726
[RFE] virt-builder should support args with the --run command
1136371 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1136371
add apt-rpm support to supermin
1139785 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1139785
virt-sysprep should change UUID fields in /etc/sysconfig/network-scripts/ifcfg-* files
1144137 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1144137
virt-inspector fails on Minix 3 guest
1150298 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1150298
ARM 32 bit on Ubuntu: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
1151902 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1151902
RFE: virt-v2v should do something with <interface type='direct'> (either virtualize it or give an error)
1151903 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1151903
virt tools --csv output should have a meaningful output
1152533 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1152533
RFE: virt-v2v should do something with <disk device='lun'> (either virtualize it or give an error)
1152818 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1152818
llz give ? for the security context of a file, which is wrong
1152819 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1152819
Can not end a running command in virt-rescue by press ^C or other keys, the only way is to exit virt-rescue
1152821 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1152821
Can not end a running command in virt-rescue by press ^C or other keys, the only way is to exit virt-rescue
1152825 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1152825
virt-rescue --selinux can not work well, when enable selinux in the command line the value of 'getenforce' is still Disabled in virt-rescue appliance
1152832 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1152832
virt-rescue --selinux can not work well, when enable selinux in the command line the value of 'getenforce' is still Disabled in virt-rescue appliance
1152833 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1152833
llz give ? for the security context of a file, which is wrong
1153702 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1153702
Using "upload - XXX" doesn't work with remote
1154408 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1154408
libguestfs does not allow registering a qemu+tcp backend
1155229 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1155229
RFE: Allow uploading virt-v2v converted images directly to Cinder
1161019 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1161019
Remove rhev related files(rhsrvany.exe and rhev-apt.exe) after conversion of windows guests to kvm
1164765 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1164765
[RFE] Add a new API to scan devices for a btrfs filesystem
1167916 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1167916
P2V: invalid conversion server prints unexpected end of file waiting for password prompt.
1170771 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1170771
virt-sparsify fails to sparsify CentOS 7 SWAP
1171654 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1171654
Modify a file in virt-rescue with vi on some linux terminal such as yakuake, can lead to abnormal display in virt-rescue shell
1172425 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1172425
[RFE]virt-v2v failed to convert VMware ESX VM with snapshot
1173462 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1173462
virt-resize on RHEL 5.7 fails to resize the raw format disk image
1176526 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1176526
virt-resize cannot shrink ext filesystem by a small amount
1177460 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1177460
virt-customize does not work with fedora atomic
1190666 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1190666
virt-builder should get RHEL images from RHN
1193238 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1193238
Specifying a --source option doesn't overwrite the built-in templates
1195278 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1195278
libguestfs-test-tool fails in nested environment
1195881 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1195881
virt-builder can't docker pull
1197786 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1197786
virt-builder fails --get-kernel on F21 PPC64 iso
1203595 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1203595
No error messages output if append '--format qcow2' after '-a guest.img', guest.img is a raw format image file
1203816 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1203816
virt-sysprep should error if a command line flag is not used because the operation is disabled
1203898 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1203898
Support inspecting docker images without /etc/fstab
1212507 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1212507
sfdisk-disk-geometry fails to display the disk geometry from the partition
1212546 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1212546
rsync-out fails to synchronize filesystem with remote filesystem
1212556 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1212556
The system release info get from 'utsname' is different from the host
1212679 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1212679
Failed to create a augeas handle with flag=8 because of custom lens (guestfs_lvm_conf.aug)
1213274 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1213274
Improve the misunderstanding error messages of virt-tar-in/virt-tar-out/virt-copy-in/virt-copy-out
1213319 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1213319
[RFE]virt-v2v support convert guest with all interface types to others
1213701 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1213701
Fail to import win8/win2012 to rhev with error "selected display type is not supported"
1215803 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1215803
'/var/lib/random-seed: No such file or directory' with virt-tools on images with bind-mount of /var
1217959 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1217959
journal logging support
1220751 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1220751
fusermount returns EBUSY, but unmounts the disk anyway, confusing guestunmount
1221569 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1221569
aarch64: add-drive-opts fails to hot plug a disk
1224795 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1224795
On Ubuntu, virt-builder --install and --update cannot use the network
1224903 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1224903
'guestmount: no operating system was found on this disk' for rhel7 be guest on ppc64le host
1227599 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1227599
P2V invalid password prints unexpected end of file waiting for command prompt.
1229386 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1229386
virt-p2v in non-GUI mode doesn't show any conversion progress or status
1230414 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1230414
Windows inspection fails with hivex_close: do_hivex_close: you must call 'hivex-open' first to initialize the hivex handle
1232477 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1232477
guestfs_add_drive_opts incorrectly quotes query parameters
1233093 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1233093
QXL driver is not installed for some version of windows guest after convert to RHEV
1237250 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1237250
aarch64: libguestfs should now prefer virtio-pci
1242028 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1242028
virt-make-fs cannot set g+s bit on vfat
1245326 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1245326
virt-v2v tests: warning: the target hypervisor does not support a x86_64 KVM guest
1250670 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1250670
libguestfs-test-tool succeeds but guestmount fails
1251499 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1251499
virt-builder --hostname should replace FQDN in /etc/hosts on Ubuntu
1252701 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1252701
virt-p2v cannot convert older HP Smart Array servers which require cciss driver
1253593 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1253593
[RFE]virt-p2v support conversion of citrix xen guest
1255610 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1255610
W2K8R2 FC guest has no VGA driver on RHEV
1264332 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1264332
Parameter '--no-trim all' doesn't work when converting guest via virt-v2v command
1265588 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1265588
Windows guest with dynamic disk cannot show RAID(E:) Disk on rhev after conversion by virt-p2v
1270686 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1270686
libguestfs-1.31.15-1.fc24 FTBFS: cp: missing file operand
1272119 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1272119
virt-v2v on W2K3 32-bit image fails
1273991 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1273991
write-append doesn't expand new lines properly when used in guestfish command line
1277744 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1277744
When a virtual machine from VirtualBox is launched, virt-filesystems shows error, instead of displaying partitions
1284191 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1284191
virt-builder cgroup error when running docker
1291339 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1291339
[RFE] Add support for layered/composable images in virt-builder repos
1292710 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1292710
i686 qemu guest install of Fedora 23 fails or does not boot properly
1293271 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1293271
virt-sysprep --delete fails to delete a symbolic link to a dir
1293516 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1293516
rm-rf can not delete files and dirs in symbolic link dir
1294955 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1294955
set-label fails to set some unicode characters as the NTFS filesystem label
1296595 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1296595
libhivex: use on Windows 7 NTUSER.DAT causes damage that manifests itself with folder rename errors
1301525 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1301525
ll fails to list a symbolic link pointing to a non-existing file
1301593 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1301593
Windows inspection fails with: guestfsd: error: readdir: Invalid or incomplete multibyte or wide character
1308535 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1308535
RFE: v2v: Copy bios.hddOrder to target
1309706 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1309706
error: internal error: Invalid floppy device name: hdb
1311890 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1311890
virt-v2v: error: libguestfs error: hivex_open: hivex failed to open /Windows/System32/config/SOFTWARE: Operation not supported
1314244 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1314244
RFE: virt-p2v log window should process colour escapes and backspaces
1314739 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1314739
The X server of Xen rhel5.11 can't start successfully after converted by virt-p2v
1315237 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1315237
Remove reference info about --dcpath in virt-v2v manual page
1316041 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1316041
virt-rescue fails, but missing error message
1316479 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1316479
v2v cmd cannot exit and "block I/O error in device 'appliance': No space left on device (28)" is printed when specified "-v -x"
1316487 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1316487
virt-v2v: error: libguestfs error: file receive cancelled by daemon when about 100M space left on host while conversion
1317180 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1317180
virt-sysprep fails with immutable files
1318440 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1318440
virt-sysprep will fail detecting OS if "/usr" is a distinct partition mounted in "/" via fstab
1318922 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1318922
The network can't work after convert a rhel7.2 guest by v2v
1318999 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1318999
RFE: virt-v2v should support floppy disks
1319086 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1319086
libguestfs-java: mismatch class version vs java dependency
1322512 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1322512
Libguestfs error: filesize: /var/lib/rpm/Name: No such file or directory
1322837 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1322837
Setting LIBGUESTFS_HV causes security context to be reset
1323151 NEW https://bugzilla.redhat.com/show_bug.cgi?id=1323151
virt-make-fs shrink to 3.4Go
503134 ASSIGNED https://bugzilla.redhat.com/show_bug.cgi?id=503134
guestfish's list splitting does not recognize internal quoting
539746 ASSIGNED https://bugzilla.redhat.com/show_bug.cgi?id=539746
launch fails when run inside a Xen guest, when no non-PV kernels are installed
541618 ASSIGNED https://bugzilla.redhat.com/show_bug.cgi?id=541618
guestfish not able to mount freebsd ufs2 partitions automatically
547488 ASSIGNED https://bugzilla.redhat.com/show_bug.cgi?id=547488
guestfish cannot tab complete filenames that contain spaces
604041 ASSIGNED https://bugzilla.redhat.com/show_bug.cgi?id=604041
guestmount absolute symlinks don't work
619334 ASSIGNED https://bugzilla.redhat.com/show_bug.cgi?id=619334
RFE: Enable coredump capture in the appliance
691389 ASSIGNED https://bugzilla.redhat.com/show_bug.cgi?id=691389
SELinux labels don't work over guestmount (FUSE)
824782 ASSIGNED https://bugzilla.redhat.com/show_bug.cgi?id=824782
virt-resize cannot resize PowerPC guests
845234 ASSIGNED https://bugzilla.redhat.com/show_bug.cgi?id=845234
RFE: virt-ls on Windows guest doesn't support drive letters
988100 ASSIGNED https://bugzilla.redhat.com/show_bug.cgi?id=988100
RFE: journal reader in guestfish
1069966 ASSIGNED https://bugzilla.redhat.com/show_bug.cgi?id=1069966
RFE: let virt-builder etc build ARM guests on x86 host
1109144 ASSIGNED https://bugzilla.redhat.com/show_bug.cgi?id=1109144
virt-builder --get-kernel doesn't fetch the dtb from images
1113153 ASSIGNED https://bugzilla.redhat.com/show_bug.cgi?id=1113153
RFE: Inspection should support systemd mount units
1130506 ASSIGNED https://bugzilla.redhat.com/show_bug.cgi?id=1130506
RFE: virt-sparsify in copying mode should support qemu detect-zeroes
1141631 ASSIGNED https://bugzilla.redhat.com/show_bug.cgi?id=1141631
[RFE] virt-v2v should support convert a guest to a dir-pool with using pool's uuid
1143887 ASSIGNED https://bugzilla.redhat.com/show_bug.cgi?id=1143887
virt-v2v: warning: cannot write files to the NFS server as 36:36
1144138 ASSIGNED https://bugzilla.redhat.com/show_bug.cgi?id=1144138
virt-inspector fails on FreeBSD 9.3 guest
1152369 ASSIGNED https://bugzilla.redhat.com/show_bug.cgi?id=1152369
virt-v2v failed to convert RHEL 6.7 UEFI guest: no grub1/grub-legacy or grub2 configuration file was found
1167623 ASSIGNED https://bugzilla.redhat.com/show_bug.cgi?id=1167623
Remove "If reporting bugs, run virt-v2v with debugging enabled .." message when running virt-p2v
1183493 ASSIGNED https://bugzilla.redhat.com/show_bug.cgi?id=1183493
RFE: virt-rescue: add a flag to autorun the suggested mount commands and chroot, suggested with --suggest
1198344 ASSIGNED https://bugzilla.redhat.com/show_bug.cgi?id=1198344
[RFE] virt-builder should support download resume
1213844 ASSIGNED https://bugzilla.redhat.com/show_bug.cgi?id=1213844
guestfish should reset the console on ^Z
(187 bugs)
--------------------------------------------------
Bugs in MODIFIED, POST or ON_QA state are fixed.
You can help by testing the fixes.
1311373 POST https://bugzilla.redhat.com/show_bug.cgi?id=1311373
Fail to install QXL driver for windows 2008r2 and win7 guest after conversion by virt-v2v
1325825 POST https://bugzilla.redhat.com/show_bug.cgi?id=1325825
virt-v2v should prevent using multiple '-b' and '-n' option appears on the command line
1326266 POST https://bugzilla.redhat.com/show_bug.cgi?id=1326266
virt-v2v should prevent multiple conflicting for "-oa "
1053847 MODIFIED https://bugzilla.redhat.com/show_bug.cgi?id=1053847
Recommended default clock/timer settings
1190669 MODIFIED https://bugzilla.redhat.com/show_bug.cgi?id=1190669
Support virt-v2v conversion of Windows > 7
1213324 MODIFIED https://bugzilla.redhat.com/show_bug.cgi?id=1213324
virt-v2v: warning: unknown guest operating system: windows windows 6.3 when converting win8,win8.1,win2012,win2012R2,win10 to rhev
1290755 MODIFIED https://bugzilla.redhat.com/show_bug.cgi?id=1290755
guestfish should be able to handle LVM thin layouts
1306557 MODIFIED https://bugzilla.redhat.com/show_bug.cgi?id=1306557
Running 'git clone' in virt-builder or virt-customize results in an error message
1308769 MODIFIED https://bugzilla.redhat.com/show_bug.cgi?id=1308769
virt-v2v does not copy additional disks to Glance
1309619 MODIFIED https://bugzilla.redhat.com/show_bug.cgi?id=1309619
Wrong warning info "use standard VGA" shows when converting windows > 7 by virt-v2v
1309796 MODIFIED https://bugzilla.redhat.com/show_bug.cgi?id=1309796
Filter perl provides
1020950 ON_QA https://bugzilla.redhat.com/show_bug.cgi?id=1020950
CVE-2013-4419 libguestfs: insecure temporary directory handling for guestfish's network socket [epel-5]
1064041 ON_QA https://bugzilla.redhat.com/show_bug.cgi?id=1064041
virt-sparsify fails if a btrfs filesystem contains readonly snapshots
1099976 ON_QA https://bugzilla.redhat.com/show_bug.cgi?id=1099976
virt-builder gives GPG warning message with gnupg2
1156298 ON_QA https://bugzilla.redhat.com/show_bug.cgi?id=1156298
Remove files in package libguestfs-bash-completion, these files are bash completion files, some of the virt tool completion are already implement in another file, so can remove its completion file
1164708 ON_QA https://bugzilla.redhat.com/show_bug.cgi?id=1164708
set-label can only set <=127 bytes for btrfs and <=126 bytes for ntfs filesystem which not meet the help message. Also for ntfs it should give a warning message when the length >128 bytes
1166057 ON_QA https://bugzilla.redhat.com/show_bug.cgi?id=1166057
btrfs filesystem will not work well if you create the filesystem with multiple disks at the same time, such as: mkfs-btrfs "/dev/sda1 /dev/sdb1"
1173695 ON_QA https://bugzilla.redhat.com/show_bug.cgi?id=1173695
RFE: allow passing in a pre-opened libvirt connection from python
1174551 ON_QA https://bugzilla.redhat.com/show_bug.cgi?id=1174551
"lstatnslist" and "lstatlist" don't give an error if the API is used wrongly
1180769 ON_QA https://bugzilla.redhat.com/show_bug.cgi?id=1180769
Security context on image file gets reset
1213691 ON_QA https://bugzilla.redhat.com/show_bug.cgi?id=1213691
Win2012R2 guest fails to boot on iscsi data domain after conversion by virt-v2v
1218766 ON_QA https://bugzilla.redhat.com/show_bug.cgi?id=1218766
Rebase libguestfs in RHEL 7.3
1227609 ON_QA https://bugzilla.redhat.com/show_bug.cgi?id=1227609
virt-p2v: Using "Back" button causes output list to be repopulated multiple times
1238053 ON_QA https://bugzilla.redhat.com/show_bug.cgi?id=1238053
v2v:Duplicate disk target set when convert guest with cdrom attached
1239154 ON_QA https://bugzilla.redhat.com/show_bug.cgi?id=1239154
appliance fails to start with "supermin: ext2fs_file_write: /var/log/tallylog: Could not allocate block in ext2 filesystem"
1242853 ON_QA https://bugzilla.redhat.com/show_bug.cgi?id=1242853
mount-loop failed to setup loop device: No such file or directory
1260801 ON_QA https://bugzilla.redhat.com/show_bug.cgi?id=1260801
virt-builder --ssh-inject doesn't set proper permissions on created files
1264835 ON_QA https://bugzilla.redhat.com/show_bug.cgi?id=1264835
ppc64le: virt-customize --install fail to detect the guest arch
1267032 ON_QA https://bugzilla.redhat.com/show_bug.cgi?id=1267032
guestfish copy-in command behaves oddly/unexpectedly with wildcards
1277074 ON_QA https://bugzilla.redhat.com/show_bug.cgi?id=1277074
Virt-p2v client shouldn't present the vdsm option because it's not usable
1277122 ON_QA https://bugzilla.redhat.com/show_bug.cgi?id=1277122
RFE: virt-sparsify: make '--in-place' sparsification safe to abort (gracefully or ungracefully)
1293527 ON_QA https://bugzilla.redhat.com/show_bug.cgi?id=1293527
There should be a reminder to avoid user to edit a guest image by multiple tools at the same time in guestfish man page
1309580 ON_QA https://bugzilla.redhat.com/show_bug.cgi?id=1309580
OS name of win8.1 x64 guest shows incorrect in rhevm3.6 general info
(33 bugs)
--------------------------------------------------
These bugs are in the VERIFIED state.
1164729 VERIFIED https://bugzilla.redhat.com/show_bug.cgi?id=1164729
set-label can only set <=63 bytes for btrfs and ntfs filesystem which not meet the help message. Also for btrfs and ntfs it should give a warning message when the length exceed the limited length
1165564 VERIFIED https://bugzilla.redhat.com/show_bug.cgi?id=1165564
Provide Reboot/Shutdown button after virt-p2v
1165569 VERIFIED https://bugzilla.redhat.com/show_bug.cgi?id=1165569
Disable "cancel conversion" button after virt-p2v conversion finished
1167601 VERIFIED https://bugzilla.redhat.com/show_bug.cgi?id=1167601
"Conversion was successful" pop out even virt-p2v fails
1167774 VERIFIED https://bugzilla.redhat.com/show_bug.cgi?id=1167774
virt-p2v fails with error:"nbd.c:nbd_receive_negotiate():L501: read failed"
1176801 VERIFIED https://bugzilla.redhat.com/show_bug.cgi?id=1176801
File /etc/sysconfig/kernel isn't updated when convert XenPV guest with regular kernel installed
1216298 VERIFIED https://bugzilla.redhat.com/show_bug.cgi?id=1216298
'inspect-get-icon' fails to get the icon form the rhel7.1 image
1216305 VERIFIED https://bugzilla.redhat.com/show_bug.cgi?id=1216305
virt-inspector fails to detect the rhel7 images
1218934 VERIFIED https://bugzilla.redhat.com/show_bug.cgi?id=1218934
virt-sparsify: read all the output from 'qemu-img --help'
1225789 VERIFIED https://bugzilla.redhat.com/show_bug.cgi?id=1225789
Wrong video driver is installed for rhel5.11 guest after conversion to libvirt
1229119 VERIFIED https://bugzilla.redhat.com/show_bug.cgi?id=1229119
Unrelated info in fstab makes virt-v2v fail with unclear error info
1229305 VERIFIED https://bugzilla.redhat.com/show_bug.cgi?id=1229305
virt-sysprep at cleanup deletes /var/spool/at/.SEQ which results in failing at
1261242 VERIFIED https://bugzilla.redhat.com/show_bug.cgi?id=1261242
virt-v2v should prevent using '-of' option appears twice on the command line
1261436 VERIFIED https://bugzilla.redhat.com/show_bug.cgi?id=1261436
No warning shows when convert a win7 guest with AVG AntiVirus installed
1262959 VERIFIED https://bugzilla.redhat.com/show_bug.cgi?id=1262959
virt-builder/virt-customize set password does not work
1287826 VERIFIED https://bugzilla.redhat.com/show_bug.cgi?id=1287826
Remove virt-v2v support for ppc64le
1292437 VERIFIED https://bugzilla.redhat.com/show_bug.cgi?id=1292437
Backport virt-v2v pull dcpath from libvirt <vmware:datacenterpath>
1293276 VERIFIED https://bugzilla.redhat.com/show_bug.cgi?id=1293276
guestfish can not ll a symbolic link dir or edit a file in it
1294956 VERIFIED https://bugzilla.redhat.com/show_bug.cgi?id=1294956
set-label returns wrong error message when set the ext3/ext4 filesystem label
1296606 VERIFIED https://bugzilla.redhat.com/show_bug.cgi?id=1296606
virt-v2v doesn't remove VirtualBox additions correctly because of file quoting
1312254 VERIFIED https://bugzilla.redhat.com/show_bug.cgi?id=1312254
virt-v2v -o libvirt doesn't preserve or use correct <graphics type="vnc|spice">
(21 bugs)
End of BUGS file.

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-2016 Red Hat Inc.
# Copyright (C) 2009-2025 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,83 +20,42 @@ include $(top_srcdir)/common-rules.mk
ACLOCAL_AMFLAGS = -I m4
# The generator - must be before anything else.
SUBDIRS = generator
# Must be the first tests that run.
if ENABLE_APPLIANCE
SUBDIRS += tests/qemu
endif
SUBDIRS = common/mlstdutils generator
# Files and other test data used by the tests. Must be before any
# tests run, except tests/qemu.
# tests run.
SUBDIRS += test-data
# Gnulib - must be built and tested before the library.
SUBDIRS += gnulib/lib
if ENABLE_GNULIB_TESTS
SUBDIRS += gnulib/tests
endif
# Basic source for the library.
SUBDIRS += src docs examples po
SUBDIRS += gnulib/lib
SUBDIRS += common/errnostring common/protocol common/qemuopts
SUBDIRS += common/utils
SUBDIRS += common/structs
SUBDIRS += include lib docs examples
# The daemon and the appliance.
SUBDIRS += common/mlutils
SUBDIRS += common/mlpcre
if ENABLE_DAEMON
SUBDIRS += daemon
SUBDIRS += tests/daemon
endif
if ENABLE_APPLIANCE
SUBDIRS += appliance
endif
# Tests - order is important.
if ENABLE_APPLIANCE
SUBDIRS += tests/c-api
SUBDIRS += tests/tmpdirs
SUBDIRS += tests/protocol
SUBDIRS += tests/events
SUBDIRS += tests/parallel
SUBDIRS += tests/create
SUBDIRS += tests/disks
SUBDIRS += tests/discard
SUBDIRS += tests/mountable
SUBDIRS += tests/network
SUBDIRS += tests/lvm
SUBDIRS += tests/luks
SUBDIRS += tests/md
SUBDIRS += tests/selinux
SUBDIRS += tests/ntfs
SUBDIRS += tests/btrfs
SUBDIRS += tests/xfs
SUBDIRS += tests/charsets
SUBDIRS += tests/xml
SUBDIRS += tests/mount-local
SUBDIRS += tests/9p
SUBDIRS += tests/rsync
SUBDIRS += tests/bigdirs
SUBDIRS += tests/disk-labels
SUBDIRS += tests/hotplug
SUBDIRS += tests/nbd
SUBDIRS += tests/http
SUBDIRS += tests/syslinux
SUBDIRS += tests/journal
SUBDIRS += tests/relative-paths
SUBDIRS += tests/gdisk
SUBDIRS += tests/regressions
SUBDIRS += tests/tsk
endif
# Tests.
SUBDIRS += tests
# libguestfs-test-tool
SUBDIRS += test-tool
# Common code used by the tools.
SUBDIRS += common/edit
SUBDIRS += common/options
SUBDIRS += common/parallel
SUBDIRS += common/progress
SUBDIRS += common/visit
SUBDIRS += common/windows
# Guestfish.
SUBDIRS += fish
# virt-tools in C.
SUBDIRS += align cat diff df edit format inspector make-fs rescue
if HAVE_P2V
SUBDIRS += p2v
endif
# Small tools written in C.
SUBDIRS += test-tool fish rescue
# bash-completion
SUBDIRS += bash
@@ -135,53 +94,38 @@ endif
if HAVE_GOLANG
SUBDIRS += golang golang/examples
endif
if HAVE_RUST
SUBDIRS += rust
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.
if HAVE_OCAML
SUBDIRS += \
mllib \
customize \
builder builder/website \
dib \
get-kernel \
resize \
sparsify \
sysprep \
v2v
if HAVE_OCAML_PKG_LIBVIRT
SUBDIRS += v2v/test-harness
endif
endif
# Perl tools.
if HAVE_TOOLS
SUBDIRS += tools
endif
# guestmount
if HAVE_FUSE
SUBDIRS += fuse
endif
# After all source files were used we can generate the translation strings
SUBDIRS += po
# po-docs must come after tools, inspector.
if HAVE_PO4A
SUBDIRS += po-docs
endif
EXTRA_DIST = \
BUGS HACKING TODO \
AUTHORS HACKING TODO \
.github/workflows/main.yml \
.gitignore \
.gitpublish \
.lvimrc \
.mailmap \
bootstrap \
bugs-in-changelog.sh \
autogen.sh \
bindtests \
cfg.mk \
check-mli.sh \
common/.gitignore \
common/README \
contrib/autobuild/autobuild.sh \
contrib/intro/libguestfs-intro.html \
contrib/intro/overview.png \
@@ -209,12 +153,10 @@ EXTRA_DIST = \
libtool-kill-dependency_libs.sh \
logo/fish.svg logo/fish.png \
logo/fish-5yrs.svg logo/fish-5yrs.png \
logo/fish-10yrs.svg logo/fish-10yrs.png \
logo/virt-builder.svg \
m4/.gitignore \
ocaml-link.sh \
tests/automake2junit.ml \
podcheck.pl \
tmp/.gitignore \
update-bugs.sh \
valgrind-suppressions \
website/bugs.png \
website/communicate.png \
@@ -225,22 +167,20 @@ EXTRA_DIST = \
website/easytoread.css \
website/feed.css \
website/fish-5yrs.svg \
website/fish-10yrs.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
website/standard.css
WEBSITESDIR = $(HOME)/d/websites
# XXX Eventually move builder/website under website/ top level directory.
BUILDERFILES = \
builder/website/README \
builder/website/index \
builder/website/index.asc
WEBSITEDIR = $(HOME)/d/websites/libguestfs
website/download/builder/README \
website/download/builder/index \
website/download/builder/index.asc
noinst_DATA = \
website/index.html \
@@ -254,69 +194,45 @@ website/TODO.txt: TODO
cp $< $@
maintainer-upload-website:
cp website/*.{css,html,png,svg,txt} $(WEBSITEDIR)/
cp $(BUILDERFILES) $(WEBSITEDIR)/download/builder/
cp website/*.{css,html,png,svg,txt} $(WEBSITESDIR)/libguestfs/
cp $(BUILDERFILES) $(WEBSITESDIR)/libguestfs-builder/
# When doing 'make dist' update a few files automatically.
#
# AUTHORS - list of authors (created from git)
# 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
# po-docs/libguestfs-docs.pot
# - combined list of strings from documentation
dist-hook: AUTHORS BUGS ChangeLog docs/C_SOURCE_FILES po/POTFILES po/POTFILES-ml
cp AUTHORS $(distdir)/AUTHORS
cp BUGS $(distdir)/BUGS
cp ChangeLog $(distdir)/ChangeLog
AUTHORS: configure.ac
rm -f $@ $@-t
git shortlog -s | $(AWK) -F'\t' '{print $$2}' | sort -f > $@-t
mv $@-t $@
BUGS: configure.ac
rm -f $@ $@-t
$(top_srcdir)/update-bugs.sh > $@-t
mv $@-t $@
ChangeLog: configure.ac
rm -f $@ $@-t
git log --decorate=false > $@-t
mv $@-t $@
dist-hook: docs/C_SOURCE_FILES po/POTFILES
rm -f po-docs/libguestfs-docs.pot
$(MAKE) -C po-docs libguestfs-docs.pot
# This has to be in the top-level Makefile.am so that we have access
# to DIST_SUBDIRS.
docs/C_SOURCE_FILES: configure.ac
rm -f $@ $@-t
find $(DIST_SUBDIRS) -name '*.c' | \
grep -v -E '^(builder/index-parse.c|builder/index-scan.c|examples/|gnulib/|gobject/|perl/|tests/|test-data/)' | \
grep -v -E '/((guestfs|rc)_protocol\.c)$$' | \
grep -v -E '.*/errnostring\.c$$' | \
grep -v -E '.*-gperf\.c$$' | \
LC_ALL=C sort > $@-t
find $(DIST_SUBDIRS) -name '*.[ch]' | \
grep -v -E '^(builder/index-parse\.|builder/index-scan\.|examples/|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\.' | \
grep -v -E '/dummy.c$$' | \
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|gobject/docs|perl/(blib|examples)|po-docs|tests|test-data)/' | \
grep -v -E '/((guestfs|rc)_protocol\.c)$$' | \
find $(DIST_SUBDIRS) -name '*.c' | \
grep -v -E '^(examples|perl/(blib|examples)|po-docs|tests|test-data)/' | \
grep -v -E '/((guestfs|rc)_protocol\.c|dummy\.c)$$' | \
grep -v -E '^python/utils\.c$$' | \
LC_ALL=C sort > $@-t
mv $@-t $@
po/POTFILES-ml: configure.ac
rm -f $@ $@-t
cd $(srcdir); \
find builder customize dib get-kernel mllib resize sparsify sysprep v2v -name '*.ml' | \
LC_ALL=C sort > $@-t
grep -v -E '^perl/lib/Sys/Guestfs\.c$$' | \
grep -v -E '.*-(tests|gperf)\.c$$' | \
LC_ALL=C sort -u > $@-t
mv $@-t $@
# Try to stop people using 'make install' without 'DESTDIR'.
@@ -339,21 +255,21 @@ 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 = \
*~ \
CLEANFILES += \
pod2htm?.tmp \
podwrapper.1 \
qemu-wrapper.sh \
tmp/disk* \
tmp/run-* \
@@ -368,8 +284,6 @@ clean-local:
-rm -rf tmp/null.*
-find tmp -type s -delete
-find . -name '*~' -delete
-find . -name '*.bak' -delete
-find . -name '*.orig' -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
@@ -384,11 +298,8 @@ check-all:
$(MAKE) -j1 \
check \
check-valgrind \
check-valgrind-local-guests \
check-direct \
check-valgrind-direct \
check-uml \
check-valgrind-uml \
check-with-upstream-qemu \
check-with-upstream-libvirt \
check-slow
@@ -410,15 +321,6 @@ check-valgrind: build-test-guests
done; \
exit $$(( $$errors ? 1 : 0 ))
check-valgrind-local-guests:
@GUESTS=`$(top_builddir)/run ./pick-guests.pl 5`; \
errors=0; \
for f in `grep -l '^$@:' $(SUBDIRS:%=%/Makefile.am)`; do \
echo $(MAKE) GUESTS="$$GUESTS" -C `dirname $$f` $@; \
$(MAKE) GUESTS="$$GUESTS" -C `dirname $$f` $@ || (( errors++ )); \
done; \
exit $$(( $$errors ? 1 : 0 ))
check-direct:
@backend=`$(top_builddir)/run ./fish/guestfish get-backend`; \
if [ "$$backend" != "direct" ]; then \
@@ -435,24 +337,6 @@ check-valgrind-direct:
check-valgrind-with-appliance: check-valgrind-direct
# Tests which currently fail under UML:
# - blockdev --setro seems to have no effect on /dev/ubd* devices [*]
# - RHBZ#914931: test is sent a SIGTERM, apparently by UML [*]
# - tests/md/test-inspect-fstab-md.sh hangs at various places during the
# test, eg. running mdadm, mounting MD filesystem [*]
# [*] = likely to be a bug in UML itself
SKIP_TESTS_FAILING_IN_UML = \
SKIP_TEST_BLOCKDEV_GETRO=1 \
SKIP_TEST_BLOCKDEV_SETRO=1 \
SKIP_TEST_RHBZ914931=1 \
SKIP_TEST_INSPECT_FSTAB_MD_SH=1
check-uml:
$(MAKE) LIBGUESTFS_BACKEND=uml $(SKIP_TESTS_FAILING_IN_UML) check
check-valgrind-uml:
$(MAKE) LIBGUESTFS_BACKEND=uml $(SKIP_TESTS_FAILING_IN_UML) check-valgrind
QEMUDIR = $(HOME)/d/qemu
QEMUBINARY = $(QEMUDIR)/x86_64-softmmu/qemu-system-x86_64
@@ -486,9 +370,27 @@ 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 test-data/phony-guests check
# Some tests which run at the top level.
TESTS = check-mli.sh
# Print subdirs.
#
# If you want to selectively run tests, or if the test suite fails half
@@ -513,23 +415,56 @@ 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 | \
( git ls-files ; \
cd common; git ls-files | sed 's,^,common/,' ) | \
grep -v '^common$$' | \
grep -v '^common/mlcustomize/' | \
grep -v '^common/mldrivers/' | \
grep -v '^common/mlgettext/' | \
grep -v '^common/mlprogress/' | \
grep -v '^common/mltools/' | \
grep -v '^common/mlvisit/' | \
grep -v '^common/mlxml/' | \
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 | grep -v '^common/mlcustomize'`; 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.
@@ -541,16 +476,14 @@ help:
@echo "make -k check ... and display all errors at once."
@echo
@echo "make check-valgrind Run a subset of the tests under valgrind."
@echo "make check-valgrind-local-guests Test under valgrind using local guests."
@echo "make check-direct Test using direct backend."
@echo "make check-valgrind-direct Test valgrind + direct backend."
@echo "make check-uml Test using User-Mode Linux."
@echo "make check-valgrind-uml Test valgrind + User-Mode Linux."
@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 installcheck Test installed libguestfs packages."

4
README
View File

@@ -6,7 +6,7 @@ disk images. For more information see the home page:
For discussion, development, patches, etc. please use the mailing
list:
http://www.redhat.com/mailman/listinfo/libguestfs
https://lists.libguestfs.org
To find out how to build libguestfs from source, read:
@@ -14,7 +14,7 @@ To find out how to build libguestfs from source, read:
http://libguestfs.org/guestfs-building.1.html
man docs/guestfs-building.1
Copyright (C) 2009-2016 Red Hat Inc.
Copyright (C) 2009-2025 Red Hat Inc.
The library is distributed under the LGPLv2+. The programs are
distributed under the GPLv2+. Please see the files COPYING and

56
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
@@ -81,20 +75,6 @@ Such as:
initrd-extract
initrd-replace
virt-rescue pty
---------------
See:
http://search.cpan.org/~rgiersig/IO-Tty-1.08/Pty.pm
http://www.perlmonks.org/index.pl?node_id=582185
Note that pty requires cooperation inside the C code too (there are
two sides to a pty, and one has to be handled after the fork).
[I tried to implement this in the new C virt-rescue, but it doesn't
work. qemu is implementing its own ptys, and they are broken. Need
to fix qemu.]
Port to Windows
---------------
@@ -181,16 +161,6 @@ Could we make guestfish interactive if commands are used without params?
Image name? disk.img
Size of image? 10M
Better support for encrypted devices
------------------------------------
Currently LUKS support only works if the device contains volume
groups. If it contains, eg., partitions, you cannot access them.
We would like to add:
- Direct access to the /dev/mapper device (eg. if it contains
anything apart from VGs).
Display image as PS
-------------------
@@ -209,6 +179,19 @@ might be replaced by direct use of the library (if this is easier).
But it is very hard to be compatible between RHEL6 and RHEL5 when
using the library directly.
Properly fix device name translation
------------------------------------
Currently for Device parameters we pass a string name like "/dev/sda"
or "/dev/sdb2" or "/dev/VG/LV" to the daemon. Since Linux broke
device enumeration (RHBZ#1804207) this works less well, requiring
non-trivial translation within the daemon.
It would be far better if in the generator we mapped "/dev/XXX" to a
proper structure. Device index + partition | LV | MD | ...
This would be then used everywhere inside the daemon and mean we would
no longer need device name translation at all.
Visualization
-------------
@@ -501,14 +484,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).
Reimplement some APIs to avoid protocol limits
----------------------------------------------
Mostly this item was done (eg. commits a69f44f56f and before). The
most notable API with a protocol limit remaining is:
- guestfs_readdir
hivex
-----
@@ -549,11 +524,6 @@ virt-builder
- /etc/resolv.conf handling works but is best described as a hack:
https://github.com/libguestfs/libguestfs/commit/9521422ce60578f7196cc8b7977d998159238c19
- let's make UML work
+ SLIRP is insecure, but we could allow just a bare web proxy which
gets proxied over virtio-serial to the outside world (except
virtio-serial can't be multiplexed)
- sometimes (not always) aug_init takes ages, why?
Midnight Commander (mc) extension

View File

@@ -1,104 +0,0 @@
# libguestfs virt alignment tools
# Copyright (C) 2011 Red Hat Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
include $(top_srcdir)/subdir-rules.mk
EXTRA_DIST = \
test-virt-alignment-scan.sh \
test-virt-alignment-scan-guests.sh \
virt-alignment-scan.pod
CLEANFILES = \
stamp-virt-alignment-scan.pod \
virt-alignment-scan.1
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 \
-I$(top_srcdir)/src -I$(top_builddir)/src \
-I$(top_srcdir)/df \
-I$(top_srcdir)/fish \
-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 \
$(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)/website/virt-alignment-scan.1.html
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)/website/virt-alignment-scan.1.html \
--license GPLv2+ \
--warning safe \
$<
touch $@
# Tests.
TESTS_ENVIRONMENT = $(top_builddir)/run --test
TESTS =
if ENABLE_APPLIANCE
TESTS += \
test-virt-alignment-scan.sh \
test-virt-alignment-scan-guests.sh
endif
check-valgrind:
$(MAKE) VG="$(top_builddir)/run @VG@" check

View File

@@ -1,369 +0,0 @@
/* virt-alignment-scan
* Copyright (C) 2011 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 <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <inttypes.h>
#include <unistd.h>
#include <getopt.h>
#include <errno.h>
#include <error.h>
#include <locale.h>
#include <assert.h>
#include <libintl.h>
#include <pthread.h>
#ifdef HAVE_LIBVIRT
#include <libvirt/libvirt.h>
#include <libvirt/virterror.h>
#endif
#include "guestfs.h"
#include "options.h"
#include "parallel.h"
#include "domains.h"
/* This just needs to be larger than any alignment we care about. */
static size_t worst_alignment = UINT_MAX;
static pthread_mutex_t worst_alignment_mutex = PTHREAD_MUTEX_INITIALIZER;
static int scan (guestfs_h *g, const char *prefix, FILE *fp);
#ifdef HAVE_LIBVIRT
static int scan_work (guestfs_h *g, size_t i, FILE *fp);
#endif
/* These globals are shared with options.c. */
guestfs_h *g;
int read_only = 1;
int live = 0;
int verbose = 0;
int keys_from_stdin = 0;
int echo_keys = 0;
const char *libvirt_uri = NULL;
int inspector = 0;
static int quiet = 0; /* --quiet */
static int uuid = 0; /* --uuid */
static void __attribute__((noreturn))
usage (int status)
{
if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
guestfs_int_program_name);
else {
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"
" -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"),
guestfs_int_program_name, guestfs_int_program_name,
guestfs_int_program_name, guestfs_int_program_name);
}
exit (status);
}
int
main (int argc, char *argv[])
{
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEBASEDIR);
textdomain (PACKAGE);
enum { HELP_OPTION = CHAR_MAX + 1 };
static const char *options = "a:c:d:P:qvVx";
static const struct option long_options[] = {
{ "add", 1, 0, 'a' },
{ "connect", 1, 0, 'c' },
{ "domain", 1, 0, 'd' },
{ "format", 2, 0, 0 },
{ "help", 0, 0, HELP_OPTION },
{ "long-options", 0, 0, 0 },
{ "quiet", 0, 0, 'q' },
{ "short-options", 0, 0, 0 },
{ "uuid", 0, 0, 0 },
{ "verbose", 0, 0, 'v' },
{ "version", 0, 0, 'V' },
{ 0, 0, 0, 0 }
};
struct drv *drvs = NULL;
const char *format = NULL;
bool format_consumed = true;
int c;
int option_index;
int exit_code;
size_t max_threads = 0;
int r;
g = guestfs_create ();
if (g == NULL)
error (EXIT_FAILURE, errno, "guestfs_create");
for (;;) {
c = getopt_long (argc, argv, options, long_options, &option_index);
if (c == -1) break;
switch (c) {
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
error (EXIT_FAILURE, 0,
_("unknown long option: %s (%d)"),
long_options[option_index].name, option_index);
break;
case 'a':
OPTION_a;
break;
case 'c':
OPTION_c;
break;
case 'd':
OPTION_d;
break;
case 'P':
if (sscanf (optarg, "%zu", &max_threads) != 1)
error (EXIT_FAILURE, 0, _("-P option is not numeric"));
break;
case 'q':
quiet = 1;
break;
case 'v':
OPTION_v;
break;
case 'V':
OPTION_V;
break;
case 'x':
OPTION_x;
break;
case HELP_OPTION:
usage (EXIT_SUCCESS);
default:
usage (EXIT_FAILURE);
}
}
/* These are really constants, but they have to be variables for the
* options parsing code. Assert here that they have known-good
* values.
*/
assert (read_only == 1);
assert (inspector == 0);
assert (live == 0);
/* Must be no extra arguments on the command line. */
if (optind != argc)
usage (EXIT_FAILURE);
CHECK_OPTION_format_consumed;
/* virt-alignment-scan has two modes. If the user didn't specify
* any drives, then we do the scan on every libvirt guest. That's
* the if-clause below. If the user specified domains/drives, then
* we assume they belong to a single guest. That's the else-clause
* below.
*/
if (drvs == NULL) {
#if defined(HAVE_LIBVIRT)
get_all_libvirt_domains (libvirt_uri);
r = start_threads (max_threads, g, scan_work);
free_domains ();
if (r == -1)
exit (EXIT_FAILURE);
#else
error (EXIT_FAILURE, 0, _("compiled without support for libvirt"));
#endif
} else { /* Single guest. */
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');
if (guestfs_launch (g) == -1)
exit (EXIT_FAILURE);
/* Free up data structures, no longer needed after this point. */
free_drives (drvs);
/* Perform the scan. */
r = scan (g, NULL, stdout);
guestfs_close (g);
if (r == -1)
exit (EXIT_FAILURE);
}
/* Decide on an appropriate exit code. */
if (worst_alignment < 10) /* 2^10 = 4096 */
exit_code = 3;
else if (worst_alignment < 16) /* 2^16 = 65536 */
exit_code = 2;
else
exit_code = 0;
exit (exit_code);
}
static int
scan (guestfs_h *g, const char *prefix, FILE *fp)
{
size_t i, j;
size_t alignment;
uint64_t start;
int err;
CLEANUP_FREE_STRING_LIST char **devices = guestfs_list_devices (g);
if (devices == NULL)
return -1;
for (i = 0; devices[i] != NULL; ++i) {
CLEANUP_FREE char *name = NULL;
CLEANUP_FREE_PARTITION_LIST struct guestfs_partition_list *parts = NULL;
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]);
if (name == NULL)
return -1;
for (j = 0; j < parts->len; ++j) {
/* Start offset of the partition in bytes. */
start = parts->val[j].part_start;
if (!quiet) {
if (prefix)
fprintf (fp, "%s:", prefix);
fprintf (fp, "%s%d %12" PRIu64 " ",
name, (int) parts->val[j].part_num, start);
}
/* What's the alignment? */
if (start == 0) /* Probably not possible, but anyway. */
alignment = 64;
else
for (alignment = 0; (start & 1) == 0; alignment++, start /= 2)
;
if (!quiet) {
if (alignment < 10)
fprintf (fp, "%12" PRIu64 " ", UINT64_C(1) << alignment);
else if (alignment < 64)
fprintf (fp, "%12" PRIu64 "K ", UINT64_C(1) << (alignment - 10));
else
fprintf (fp, "- ");
}
err = pthread_mutex_lock (&worst_alignment_mutex);
assert (err == 0);
if (alignment < worst_alignment)
worst_alignment = alignment;
err = pthread_mutex_unlock (&worst_alignment_mutex);
assert (err == 0);
if (alignment < 12) { /* Bad in general: < 4K alignment */
if (!quiet)
fprintf (fp, "bad (%s)\n", _("alignment < 4K"));
} else if (alignment < 16) { /* Bad on NetApps: < 64K alignment */
if (!quiet)
fprintf (fp, "bad (%s)\n", _("alignment < 64K"));
} else {
if (!quiet)
fprintf (fp, "ok\n");
}
}
}
return 0;
}
#if defined(HAVE_LIBVIRT)
/* The multi-threaded version. This callback is called from the code
* in "parallel.c".
*/
static int
scan_work (guestfs_h *g, size_t i, FILE *fp)
{
struct guestfs_add_libvirt_dom_argv optargs;
optargs.bitmask =
GUESTFS_ADD_LIBVIRT_DOM_READONLY_BITMASK |
GUESTFS_ADD_LIBVIRT_DOM_READONLYDISK_BITMASK;
optargs.readonly = 1;
optargs.readonlydisk = "read";
if (guestfs_add_libvirt_dom_argv (g, domains[i].dom, &optargs) == -1)
return -1;
if (guestfs_launch (g) == -1)
return -1;
return scan (g, !uuid ? domains[i].name : domains[i].uuid, fp);
}
#endif /* HAVE_LIBVIRT */

View File

@@ -1,35 +0,0 @@
#!/bin/bash -
# libguestfs
# Copyright (C) 2013 Red Hat Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
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 ../test-data/phony-guests && pwd)"
libvirt_uri="test://$guestsdir/guests-all-good.xml"
$VG virt-alignment-scan -c "$libvirt_uri"
r=$?
# 0, 2 and 3 are reasonable non-error exit codes. Others are errors.
if [ $r -ne 0 -a $r -ne 2 -a $r -ne 3 ]; then
exit $r
fi

View File

@@ -1,399 +0,0 @@
=head1 NAME
virt-alignment-scan - Check alignment of virtual machine partitions
=head1 SYNOPSIS
virt-alignment-scan [--options] -d domname
virt-alignment-scan [--options] -a disk.img [-a disk.img ...]
virt-alignment-scan [--options]
=head1 DESCRIPTION
When older operating systems install themselves, the partitioning
tools place partitions at a sector misaligned with the underlying
storage (commonly the first partition starts on sector C<63>).
Misaligned partitions can result in an operating system issuing more
I/O than should be necessary.
The virt-alignment-scan tool checks the alignment of partitions in
virtual machines and disk images and warns you if there are alignment
problems.
Currently there is no virt tool for fixing alignment problems. You
can only reinstall the guest operating system. The following NetApp
document summarises the problem and possible solutions:
L<http://media.netapp.com/documents/tr-3747.pdf>
=head1 OUTPUT
To run this tool on a disk image directly, use the I<-a> option:
$ virt-alignment-scan -a winxp.img
/dev/sda1 32256 512 bad (alignment < 4K)
$ virt-alignment-scan -a fedora16.img
/dev/sda1 1048576 1024K ok
/dev/sda2 2097152 2048K ok
/dev/sda3 526385152 2048K ok
To run the tool on a guest known to libvirt, use the I<-d> option and
possibly the I<-c> option:
# virt-alignment-scan -d RHEL5
/dev/sda1 32256 512 bad (alignment < 4K)
/dev/sda2 106928640 512 bad (alignment < 4K)
$ virt-alignment-scan -c qemu:///system -d Win7TwoDisks
/dev/sda1 1048576 1024K ok
/dev/sda2 105906176 1024K ok
/dev/sdb1 65536 64K ok
Run virt-alignment-scan without any I<-a> or I<-d> options to scan all
libvirt domains.
# virt-alignment-scan
F16x64:/dev/sda1 1048576 1024K ok
F16x64:/dev/sda2 2097152 2048K ok
F16x64:/dev/sda3 526385152 2048K ok
The output consists of 4 or more whitespace-separated columns. Only
the first 4 columns are significant if you want to parse this from a
program. The columns are:
=over 4
=item col 1
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
column is prefixed by the libvirt name or UUID (if I<--uuid> is
given). eg: C<WinXP:/dev/sda1>
=item col 2
the start of the partition in bytes
=item col 3
the alignment in bytes or Kbytes (eg. C<512> or C<4K>)
=item col 4
C<ok> if the alignment is best for performance, or C<bad> if the
alignment can cause performance problems
=item cols 5+
optional free-text explanation.
=back
The exit code from the program changes depending on whether poorly
aligned partitions were found. See L</EXIT STATUS> below.
If you just want the exit code with no output, use the I<-q> option.
=head1 OPTIONS
=over 4
=item B<--help>
Display brief help.
=item B<-a> file
=item B<--add> file
Add I<file> which should be a disk image from a virtual machine.
The format of the disk image is auto-detected. To override this and
force a particular format use the I<--format=..> option.
=item B<-a URI>
=item B<--add URI>
Add a remote disk. See L<guestfish(1)/ADDING REMOTE STORAGE>.
=item B<-c> URI
=item B<--connect> URI
If using libvirt, connect to the given I<URI>. If omitted, then we
connect to the default libvirt hypervisor.
If you specify guest block devices directly (I<-a>), then libvirt is
not used at all.
=item B<-d> guest
=item B<--domain> guest
Add all the disks from the named libvirt guest. Domain UUIDs can be
used instead of names.
=item B<--format=raw|qcow2|..>
=item B<--format>
The default for the I<-a> option is to auto-detect the format of the
disk image. Using this forces the disk format for I<-a> options which
follow on the command line. Using I<--format> with no argument
switches back to auto-detection for subsequent I<-a> options.
For example:
virt-alignment-scan --format=raw -a 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 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
security problem with malicious guests (CVE-2010-3851).
=item B<-P> nr_threads
Since libguestfs 1.22, virt-alignment-scan is multithreaded and
examines guests in parallel. By default the number of threads to use
is chosen based on the amount of free memory available at the time
that virt-alignment-scan is started. You can force
virt-alignment-scan to use at most C<nr_threads> by using the I<-P>
option.
Note that I<-P 0> means to autodetect, and I<-P 1> means to use a
single thread.
=item B<-q>
=item B<--quiet>
Don't produce any output. Just set the exit code
(see L</EXIT STATUS> below).
=item B<--uuid>
Print UUIDs instead of names. This is useful for following a guest
even when the guest is migrated or renamed, or when two guests happen
to have the same name.
This option only applies when listing all libvirt domains (when no
I<-a> or I<-d> options are specified).
=item B<-v>
=item B<--verbose>
Enable verbose messages for debugging.
=item B<-V>
=item B<--version>
Display version number and exit.
=item B<-x>
Enable tracing of libguestfs API calls.
=back
=head1 RECOMMENDED ALIGNMENT
Operating systems older than Windows 2008 and Linux before ca.2010
place the first sector of the first partition at sector 63, with a 512
byte sector size. This happens because of a historical accident.
Drives have to report a cylinder / head / sector (CHS) geometry to the
BIOS. The geometry is completely meaningless on modern drives, but it
happens that the geometry reported always has 63 sectors per track.
The operating system therefore places the first partition at the start
of the second "track", at sector 63.
When the guest OS is virtualized, the host operating system and
hypervisor may prefer accesses aligned to one of:
=over 4
=item * 512 bytes
if the host OS uses local storage directly on hard drive partitions,
and the hard drive has 512 byte physical sectors.
=item * 4 Kbytes
for local storage on new hard drives with 4Kbyte physical sectors; for
file-backed storage on filesystems with 4Kbyte block size; or for some
types of network-attached storage.
=item * 64 Kbytes
for high-end network-attached storage. This is the optimal block size
for some NetApp hardware.
=item * 1 Mbyte
see L</1 MB PARTITION ALIGNMENT> below.
=back
Partitions which are not aligned correctly to the underlying
storage cause extra I/O. For example:
sect#63
┌──────────────────────────┬ ─ ─ ─ ─
│ guest │
│ filesystem block │
─ ┬──────────────────┴──────┬───────────────────┴─────┬ ─ ─
│ host block │ host block │
│ │ │
─ ┴─────────────────────────┴─────────────────────────┴ ─ ─
In this example, each time a 4K guest block is read, two blocks on the
host must be accessed (so twice as much I/O is done). When a 4K guest
block is written, two host blocks must first be read, the old and new
data combined, and the two blocks written back (4x I/O).
=head2 LINUX HOST BLOCK AND I/O SIZE
New versions of the Linux kernel expose the physical and logical block
size, and minimum and recommended I/O size.
For a typical consumer hard drive with 512 byte sectors:
$ cat /sys/block/sda/queue/hw_sector_size
512
$ cat /sys/block/sda/queue/physical_block_size
512
$ cat /sys/block/sda/queue/logical_block_size
512
$ cat /sys/block/sda/queue/minimum_io_size
512
$ cat /sys/block/sda/queue/optimal_io_size
0
For a new consumer hard drive with 4Kbyte sectors:
$ cat /sys/block/sda/queue/hw_sector_size
4096
$ cat /sys/block/sda/queue/physical_block_size
4096
$ cat /sys/block/sda/queue/logical_block_size
4096
$ cat /sys/block/sda/queue/minimum_io_size
4096
$ cat /sys/block/sda/queue/optimal_io_size
0
For a NetApp LUN:
$ cat /sys/block/sdc/queue/logical_block_size
512
$ cat /sys/block/sdc/queue/physical_block_size
512
$ cat /sys/block/sdc/queue/minimum_io_size
4096
$ cat /sys/block/sdc/queue/optimal_io_size
65536
The NetApp allows 512 byte accesses (but they will be very
inefficient), prefers a minimum 4K I/O size, but the optimal I/O size
is 64K.
For detailed information about what these numbers mean, see
L<http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Storage_Administration_Guide/newstorage-iolimits.html>
[Thanks to Matt Booth for providing 4K drive data. Thanks to Mike
Snitzer for providing NetApp data and additional information.]
=head2 1 MB PARTITION ALIGNMENT
Microsoft picked 1 MB as the default alignment for all partitions
starting with Windows 2008 Server, and Linux has followed this.
Assuming 512 byte sectors in the guest, you will now see the first
partition starting at sector 2048, and subsequent partitions (if any)
will start at a multiple of 2048 sectors.
1 MB alignment is compatible with all current alignment requirements
(4K, 64K) and provides room for future growth in physical block sizes.
=head2 SETTING ALIGNMENT
L<virt-resize(1)> can change the alignment of the partitions of some
guests. Currently it can fully align all the partitions of all
Windows guests, and it will fix the bootloader where necessary. For
Linux guests, it can align the second and subsequent partitions, so
the majority of OS accesses except at boot will be aligned.
Another way to correct partition alignment problems is to reinstall
your guest operating systems. If you install operating systems from
templates, ensure these have correct partition alignment too.
For older versions of Windows, the following NetApp document contains
useful information: L<http://media.netapp.com/documents/tr-3747.pdf>
For Red Hat Enterprise Linux E<le> 5, use a Kickstart script that
contains an explicit C<%pre> section that creates aligned partitions
using L<parted(8)>. Do not use the Kickstart C<part> command. The
NetApp document above contains an example.
=head1 EXIT STATUS
This program returns:
=over 4
=item *
0
successful exit, all partitions are aligned E<ge> 64K for best performance
=item *
1
an error scanning the disk image or guest
=item *
2
successful exit, some partitions have alignment E<lt> 64K which can result
in poor performance on high end network storage
=item *
3
successful exit, some partitions have alignment E<lt> 4K which can result
in poor performance on most hypervisors
=back
=head1 SEE ALSO
L<guestfs(3)>,
L<guestfish(1)>,
L<virt-filesystems(1)>,
L<virt-rescue(1)>,
L<virt-resize(1)>,
L<http://libguestfs.org/>.
=head1 AUTHOR
Richard W.M. Jones L<http://people.redhat.com/~rjones/>
=head1 COPYRIGHT
Copyright (C) 2011 Red Hat Inc.

View File

@@ -1,5 +1,5 @@
# libguestfs
# Copyright (C) 2009-2016 Red Hat Inc.
# Copyright (C) 2009-2025 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
@@ -32,8 +32,6 @@ include $(top_srcdir)/subdir-rules.mk
EXTRA_DIST = \
99-guestfs-serial.rules \
excludefiles.in \
guestfs_lvm_conf.aug \
guestfs_shadow.aug \
hostfiles.in \
init \
libguestfs-make-fixed-appliance.in \
@@ -81,20 +79,52 @@ make.sh: make.sh.in $(top_builddir)/config.log $(top_builddir)/config.status
PACKAGELIST_CPP_FLAGS = -D$(DISTRO)=1 -DEXTRA_PACKAGES="$(EXTRA_PACKAGES)"
packagelist: packagelist.in Makefile
if HAVE_RPM
QUERY_FILES_CMD := xargs rpm -qf --qf '%{name}\n'
else
if HAVE_DPKG
QUERY_FILES_CMD := sed -e 's,^/,\*/,' | xargs dpkg -S | cut -d: -f1
else
if HAVE_PACMAN
QUERY_FILES_CMD := xargs pacman -Qo | sed -r 's/.* is owned by ([^ ]+) .*/\1/'
else
$(error Error: Unknown Linux distribution "$(DISTRO)". Please add support to m4/guestfs-appliance.m4 and appliance/Makefile.am and send a patch upstream to guestfs@lists.libguestfs.org)
endif !HAVE_PACMAN
endif !HAVE_DPKG
endif !HAVE_RPM
# Automatically generate library dependency list
guestfsd.deps: ../daemon/guestfsd
/sbin/ldconfig -p > ld.so.cache.txt
objdump -p $^ |\
sed -ne '/NEEDED/{s/ *NEEDED *//; p;}' |\
xargs -i grep -F {} ld.so.cache.txt |\
sed -ne '/ => /{s/.* => *//; p;}' |\
$(QUERY_FILES_CMD) |\
sort -u > $@.t
rm -f ld.so.cache.txt
mv $@.t $@
@echo "guestfsd.deps:"
@cat $@
packagelist: packagelist.in Makefile guestfsd.deps
m4 $(PACKAGELIST_CPP_FLAGS) $< | \
grep -v '^[[:space:]]*$$' | grep -v '^#' > $@-t
cmp -s $@ $@-t || mv $@-t $@
rm -f $@-t
supermin.d/daemon.tar.gz: ../daemon/guestfsd guestfs_lvm_conf.aug guestfs_shadow.aug
# Use stable owner/group and mtimes (RHBZ#2320025).
TAR_OPTIONS := \
-z \
--owner=0 --group=0 \
$${SOURCE_DATE_EPOCH:+--mtime=@"$$SOURCE_DATE_EPOCH"}
supermin.d/daemon.tar.gz: ../daemon/guestfsd
rm -f $@ $@-t
rm -rf tmp-d
mkdir -p tmp-d$(DAEMON_SUPERMIN_DIR) tmp-d/etc tmp-d/usr/share/guestfs
mkdir -p tmp-d$(DAEMON_SUPERMIN_DIR) tmp-d/etc
ln ../daemon/guestfsd tmp-d$(DAEMON_SUPERMIN_DIR)/guestfsd
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
( cd tmp-d && tar $(TAR_OPTIONS) -cf - * ) > $@-t
rm -r tmp-d
mv $@-t $@
@@ -115,7 +145,7 @@ supermin.d/hostfiles: hostfiles.in Makefile
supermin.d/init.tar.gz: init
rm -f $@ $@-t
( cd $(srcdir) && tar zcf - init ) > $@-t
( cd $(srcdir) && tar $(TAR_OPTIONS) -cf - init ) > $@-t
mv $@-t $@
# We should put this file in /lib/udev/rules.d, but put it in /etc so
@@ -125,7 +155,7 @@ supermin.d/udev-rules.tar.gz: 99-guestfs-serial.rules
rm -rf tmp-u
mkdir -p tmp-u/etc/udev/rules.d
for f in $^; do ln $$f tmp-u/etc/udev/rules.d/$$(basename $$f); done
( cd tmp-u && tar zcf - etc ) > $@-t
( cd tmp-u && tar $(TAR_OPTIONS) -cf - etc ) > $@-t
rm -r tmp-u
mv $@-t $@
@@ -155,13 +185,8 @@ stamp-libguestfs-make-fixed-appliance.pod: libguestfs-make-fixed-appliance.pod
# Make clean.
CLEANFILES = \
*~ \
libguestfs-make-fixed-appliance.1 \
stamp-libguestfs-make-fixed-appliance.pod
DISTCLEANFILES = \
DISTCLEANFILES += \
make.sh \
guestfsd.deps \
packagelist \
stamp-supermin \
supermin.d/*

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,72 +0,0 @@
(*
Module: Shadow
Parses /etc/shadow
Author: Lorenzo M. Catucci <catucci@ccd.uniroma2.it>
Original Author: Free Ekanayaka <free@64studio.com>
About: Reference
- man 5 shadow
- man 3 getspnam
About: License
This file is licensed under the LGPL v2+, like the rest of Augeas.
About:
Each line in the shadow files represents the additional shadow-defined attributes
for the corresponding user, as defined in the passwd file.
*)
module Guestfs_Shadow =
autoload xfm
(************************************************************************
* USEFUL PRIMITIVES
*************************************************************************)
let eol = Util.eol
let comment = Util.comment
let empty = Util.empty
let dels = Util.del_str
let colon = Sep.colon
let word = Rx.word
let integer = Rx.integer
let sto_to_col = Passwd.sto_to_col
let sto_to_eol = Passwd.sto_to_eol
(************************************************************************
* Group: ENTRIES
*************************************************************************)
(* View: entry *)
let entry = [ key word
. colon
. [ label "password" . sto_to_col? . colon ]
. [ label "lastchange_date" . store integer? . colon ]
. [ label "minage_days" . store integer? . colon ]
. [ label "maxage_days" . store integer? . colon ]
. [ label "warn_days" . store integer? . colon ]
. [ label "inactive_days" . store integer? . colon ]
. [ label "expire_date" . store integer? . colon ]
. [ label "flag" . store integer? ]
. eol ]
(************************************************************************
* LENS
*************************************************************************)
let lns = (comment|empty|entry) *
let filter
= incl "/shadow"
. Util.stdexcl
let xfm = transform lns filter

View File

@@ -5,13 +5,17 @@ dnl
dnl This file is processed by m4 with one of the
dnl following symbols defined (depending on the distro):
dnl
dnl REDHAT=1 For Fedora, RHEL, EPEL and workalikes.
dnl DEBIAN=1 For Debian.
dnl UBUNTU=1 For Ubuntu.
dnl ARCHLINUX=1 For Archlinux.
dnl SUSE=1 For OpenSUSE.
dnl FRUGALWARE=1 For Frugalware.
dnl MAGEIA=1 For Mageia.
dnl REDHAT=1 For Fedora, RHEL, EPEL and workalikes.
dnl DEBIAN=1 For Debian.
dnl UBUNTU=1 For Ubuntu.
dnl ARCHLINUX=1 For Archlinux.
dnl SUSE=1 For OpenSUSE.
dnl FRUGALWARE=1 For Frugalware.
dnl MAGEIA=1 For Mageia.
dnl OPENMANDRIVA=1 For OpenMandriva.
dnl OPENCLOUDOS=1 For OpenCloudOS.
dnl TENCENTOS=1 For TencentOS.
/etc/ld.so.cache
/lib/lsb/*
/usr/share/augeas/lenses/*.aug

View File

@@ -17,26 +17,12 @@ if [ ! -d /tmp ] || [ ! -d /var/tmp ]; then
chmod 1777 /tmp /var/tmp
fi
# Make sure to find all the libraries, also those in non-standard place
# but with a proper ld.so configuration pointing at them
ldconfig
# Try to print a stack trace for segfaults inside the appliance.
for d in /lib64 /lib; do
f=$d/libSegFault.so
if [ -f "$f" ]; then
LD_PRELOAD=$f
export LD_PRELOAD
break
fi
done
mkdir -p /sysroot
# Mount /proc.
if [ ! -d /proc ]; then rm -f /proc; fi
mkdir -p /proc
mkdir -p /proc /sys
mount -t proc /proc /proc
mount -t sysfs /sys /sys
# devtmpfs is required since udev 176
mount -t devtmpfs /dev /dev
ln -s /proc/self/fd /dev/fd
# Parse the kernel command line early (must be after /proc is mounted).
cmdline=$(</proc/cmdline)
@@ -58,27 +44,51 @@ 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
mkdir -p /dev/pts /dev/shm
mount -t devpts /dev/pts /dev/pts
mount -t tmpfs -o mode=1777 shmfs /dev/shm
mkdir -p /sysroot
# On Fedora 42+ fix symlinks in /usr/sbin
# https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/thread/PCU2WWLEGLGIOY4TCCBIHLYS6ZCZ4GSS/
# Probably we can remove this eventually.
if test -f /etc/fedora-release &&
test -f /etc/os-release &&
! test -L /usr/sbin ; then
ver="$(sed -n 's/^VERSION_ID=\(.*\)/\1/p' < /etc/os-release)"
if (( $ver >= 42 )); then
for f in /usr/bin/*; do
if test -x "$f"; then
ln -s "$f" /usr/sbin/
fi
done
fi
fi
# taken from initramfs-tools/init --Hilko Bengen
mkdir -p /run
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
ln -s /proc/mounts /etc/mtab
# devtmpfs is required since udev 176
mount -t devtmpfs /dev /dev
if [[ $cmdline == *selinux=1* ]]; then
mount -t selinuxfs none /sys/fs/selinux
fi
# 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
# For openssl (RHBZ#2133884).
if test -d /etc/crypto-policies/back-ends &&
! test -f /etc/crypto-policies/back-ends/opensslcnf.config &&
test -f /usr/share/crypto-policies/DEFAULT/opensslcnf.txt ; then
ln -sf /usr/share/crypto-policies/DEFAULT/opensslcnf.txt /etc/crypto-policies/back-ends/opensslcnf.config
fi
# Static nodes must happen before udev is started.
# Set up kmod static-nodes (RHBZ#1011907).
@@ -90,16 +100,16 @@ 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 --create --boot
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
@@ -110,8 +120,6 @@ udevadm settle --timeout=600
# 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
shopt -u nullglob
# Set up the network.
@@ -119,22 +127,53 @@ ip addr add 127.0.0.1/8 brd + dev lo scope host
ip link set dev lo up
if test "$guestfs_network" = 1; then
iface=$(ls -I all -I default -I lo /proc/sys/net/ipv4/conf)
iface=$(ls -I all -I default -I lo -I sit0 /proc/sys/net/ipv4/conf)
# Two workarounds for Ubuntu:
touch /etc/fstab
rm -f /etc/dhcp/dhclient-enter-hooks.d/resolved
# Prevent dhcpcd from failing when /etc/resolv.conf is a dangling symlink.
if [ -L "/etc/resolv.conf" ] && [ ! -e "/etc/resolv.conf" ]; then
rm -f /etc/resolv.conf
fi
if dhclient --version >/dev/null 2>&1; then
dhclient $iface
else
dhcpcd $iface
elif dhcpcd $iface; then
# https://github.com/NetworkConfiguration/dhcpcd/issues/258
for i in `seq 0 10`; do
if grep nameserver /etc/resolv.conf; then break; fi
sleep 1
done
fi
fi
# Scan for MDs.
mdadm -As --auto=yes --run
# Scan for MDs but don't run arrays unless all expected drives are present
mdadm -As --auto=yes --no-degraded
# Set up a clean LVM environment.
# Empty LVM configuration file means "all defaults".
mkdir -p /tmp/lvm
touch /tmp/lvm/lvm.conf
# If lvm2 supports a "devices file", we need to disable its use
# (RHBZ#1965941).
if command -v lvmdevices || command -v vgimportdevices; then
{
printf 'devices {\n'
printf '\tuse_devicesfile = 0\n'
printf '}\n'
} >> /tmp/lvm/lvm.conf
fi
LVM_SYSTEM_DIR=/tmp/lvm
export LVM_SYSTEM_DIR
lvmetad
# Scan for LVM.
modprobe dm_mod ||:
lvmetad ||:
lvm pvscan --cache --activate ay
lvm vgchange -aay --sysinit
# Scan for MDs and run all found arrays even they are in degraded state
mdadm -As --auto=yes --run
# Scan for Windows dynamic disks.
ldmtool create all
@@ -144,11 +183,16 @@ if test "$guestfs_verbose" = 1 && test "$guestfs_boot_analysis" != 1; then
uname -a
ls -lR /dev
cat /proc/mounts
cat /proc/mdstat
lsblk
blkid
lvm config
lvm pvs
lvm vgs
lvm lvs
ip a
ip r
cat /etc/resolv.conf
lsmod
#hwclock -r
date
@@ -159,45 +203,84 @@ if test "$guestfs_verbose" = 1 && test "$guestfs_boot_analysis" != 1; then
echo -n "uptime: "; cat /proc/uptime
fi
if ! test "$guestfs_rescue" = 1; then
# Run the daemon.
cmd="guestfsd"
eval `grep -Eo 'guestfs_channel=[^[:space:]]+' /proc/cmdline`
if test "x$guestfs_channel" != "x"; then
# 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
fi
if test "$guestfs_verbose" = 1; then
cmd="$cmd --verbose"
fi
if test "$guestfs_network" = 1; then
fi
if test "$guestfs_network" = 1; then
cmd="$cmd --network"
fi
echo $cmd
$cmd
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

View File

@@ -151,4 +151,4 @@ Richard W.M. Jones (C<rjones at redhat dot com>)
=head1 COPYRIGHT
Copyright (C) 2009-2016 Red Hat Inc.
Copyright (C) 2009-2025 Red Hat Inc.

View File

@@ -1,6 +1,6 @@
#!/bin/bash -
# @configure_input@
# Copyright (C) 2009-2016 Red Hat Inc.
# Copyright (C) 2009-2025 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

@@ -4,13 +4,15 @@ dnl
dnl This file is processed by m4 with one of the
dnl following symbols defined (depending on the distro):
dnl
dnl REDHAT=1 For Fedora, RHEL, EPEL and workalikes.
dnl DEBIAN=1 For Debian.
dnl UBUNTU=1 For Ubuntu.
dnl ARCHLINUX=1 For Archlinux.
dnl SUSE=1 For OpenSUSE.
dnl FRUGALWARE=1 For Frugalware.
dnl MAGEIA=1 For Mageia.
dnl REDHAT=1 For Fedora, RHEL, EPEL and workalikes.
dnl DEBIAN=1 For Debian.
dnl UBUNTU=1 For Ubuntu.
dnl ARCHLINUX=1 For Archlinux.
dnl SUSE=1 For OpenSUSE.
dnl FRUGALWARE=1 For Frugalware.
dnl MAGEIA=1 For Mageia.
dnl OPENCLOUDOS=1 For OpencloudOS.
dnl TENCENTOS=1 For TencentOS.
dnl
dnl There is also a list of packages which are excluded if they appear
dnl as dependencies of the packages below. See: excludelist.in
@@ -23,43 +25,44 @@ dnl Basically the same with a few minor tweaks.
ifelse(UBUNTU,1,`define(`DEBIAN',1)')
ifelse(REDHAT,1,
augeas-libs
btrfs-progs
clevis-luks
cryptsetup
cryptsetup-luks dnl old name used before Fedora 17
dhclient
genisoimage
dhcpcd
gfs-utils
gfs2-utils
glibc-gconv-extra dnl syslinux requires IBM850 iconv converter
grub
hfsplus-tools
hivex
iproute
iputils
kernel
libcap
libldm dnl only Fedora for now, others later
libldm
nilfs-utils
ntfsprogs
ntfs-3g
ntfs-3g-system-compression
openssh-clients
pcre
policycoreutils
reiserfs-utils
libselinux
rpm-libs
syslinux-extlinux
systemd dnl for /sbin/reboot and udevd
vim-minimal
xz
yajl
zfs-fuse
zstd
)
ifelse(DEBIAN,1,
bsdmainutils
dnl old name used in Jessie and earlier
btrfs-tools
clevis-luks
cryptsetup
dash
extlinux
genisoimage
fdisk
dnl gfs-tools, gfs2-tools have been renamed to gfs2-utils
gfs-tools
gfs2-tools
@@ -72,19 +75,16 @@ dnl iproute has been renamed to iproute2
iputils-ping
iputils-arping
iputils-tracepath
dnl isc-dhcp-client has been replaced with dhcpcd-base
isc-dhcp-client
libaugeas0
dhcpcd-base
ldmtool
libc-bin
libcap2
libhivex0
libpcre3
libsystemd0
libsystemd-id128-0
libsystemd-journal0
libyajl2
librpm9
linux-image
dnl syslinux 'suggests' mtools, but in reality it's a hard dependency:
mtools
mount dnl util-linux subpackage containing mount cmd
nilfs-tools
ntfs-3g
openssh-client
@@ -94,65 +94,63 @@ dnl iproute has been renamed to iproute2
ufsutils
vim-tiny
xz-utils
zfs-fuse
zstd
uuid-runtime
)
ifelse(ARCHLINUX,1,
augeas
btrfs-progs
cdrkit
cdrtools
clevis
cryptsetup
dhclient
dhcpcd
gptfdisk
grub
hivex
iproute2
iputils
libcap
linux
lrzip
dnl syslinux has mtools as optional dependency, but in reality it's
dnl a hard one:
mtools
nilfs-utils
ntfsprogs
ntfs-3g
pcre
ntfs-3g-system-compression
reiserfsprogs
systemd
vim
xz
yajl
zfs-fuse
zstd
)
ifelse(SUSE,1,
augeas
dnl It seems no other augeas package depends on it.
augeas-lenses
btrfsprogs
cdrkit-cdrtools-compat
clevis
cryptsetup
dhcpcd
genisoimage
dhcp-client
glibc-locale
gptfdisk
hivex
initviocons
iproute2
iputils
libcap2
libselinux1
libyajl2
mkisofs
ntfsprogs
ntfs-3g
reiserfs
squashfs
sysconfig-netconfig
systemd
systemd-sysvinit
vim
xz
zstd
)
ifelse(FRUGALWARE,1,
augeas
btrfs-progs
cryptsetup-luks
cdrkit
dhclient
@@ -161,67 +159,129 @@ ifelse(FRUGALWARE,1,
iproute2
iputils
kernel
libcap
ntfsprogs
ntfs-3g
openssh
pcre
reiserfsprogs
systemd
vim
xz
yajl
xfsprogs-acl
xfsprogs-attr
gptfdisk
)
ifelse(MAGEIA,1,
augeas
btrfs-progs
cryptsetup
chkconfig /* for /etc/init.d */
cdrkit-genisoimage
cdrkit-isotools
dhcp-client
extlinux
gfs2-utils
grub
hfsplus-tools
hivex
iproute2
iputils
libcap
libyajl
libldm
dnl syslinux uses mtools without depending on it
mtools
nilfs-utils
ntfsprogs
ntfs-3g
ntfs-3g-system-compression
openssh-clients
pcre
reiserfs-utils
libselinux
rpm /* for "supermin: ext2fs_namei: parent directory not found: /var/lib/rpm: File not found by ext2_lookup" */
systemd /* for /sbin/reboot and udevd */
vim-minimal
xz
yajl
zstd
)
ifelse(OPENMANDRIVA,1,
cryptsetup
chkconfig /* for /etc/init.d */
dhcp-client
extlinux
grub2
iproute2
iputils
libldm
dnl syslinux uses mtools without depending on it
mtools
nilfs-utils
ntfs-3g
openssh-clients
systemd /* for /sbin/reboot and udevd */
vim-minimal
xz
zstd
)
ifelse(OPENCLOUDOS,1,
clevis-luks
cryptsetup
cryptsetup-luks
dhclient
gfs2-utils
glibc-gconv-extra
hfsplus-tools
iproute
iputils
kernel
ntfsprogs
ntfs-3g
openssh-clients
policycoreutils
rpm-libs
syslinux-extlinux
systemd
vim-minimal
xz
zstd
)
ifelse(TENCENTOS,1,
clevis-luks
cryptsetup
cryptsetup-luks
dhclient
gfs2-utils
glibc-gconv-extra
hfsplus-tools
iproute
iputils
kernel
ntfsprogs
ntfs-3g
openssh-clients
policycoreutils
rpm-libs
syslinux-extlinux
systemd
vim-minimal
xz
zstd
)
include(guestfsd.deps)
acl
attr
bash
binutils
btrfs-progs
bzip2
coreutils
cpio
diffutils
dosfstools
e2fsprogs
f2fs-tools
file
findutils
gawk
gdisk
gostsum
grep
gzip
jfsutils
@@ -238,6 +298,7 @@ dnl Enabling this pulls out 140 extra packages
dnl into the appliance:
dnl ocfs2-tools
parted
pciutils
procps
procps-ng
psmisc
@@ -245,6 +306,7 @@ rsync
scrub
sed
sleuthkit
squashfs-tools
strace
syslinux
tar
@@ -254,33 +316,11 @@ util-linux-ng
xfsprogs
zerofree
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
dnl (virt-dib) tools optionally used for elements
debootstrap
dnl exFAT is not usually available in free software repos
exfat-fuse
exfat-utils
exfatprogs
fuse-exfat
dnl Define this by doing: ./configure --with-extra-packages="..."
EXTRA_PACKAGES

View File

@@ -1,51 +0,0 @@
#!/bin/bash -
# libguestfs
# Copyright (C) 2009 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.
#
# Rebuild the autotools environment.
set -e
set -v
# Ensure that whenever we pull in a gnulib update or otherwise change to a
# different version (i.e., when switching branches), we also rerun ./bootstrap.
curr_status=.git-module-status
t=$(git submodule status|sed 's/^[ +-]//;s/ .*//')
if test "$t" = "$(cat $curr_status 2>/dev/null)"; then
: # good, it's up to date
else
echo running bootstrap...
./bootstrap && echo "$t" > $curr_status
fi
CONFIGUREDIR=.
# Run configure in BUILDDIR if it's set
if [ ! -z "$BUILDDIR" ]; then
mkdir -p $BUILDDIR
cd $BUILDDIR
CONFIGUREDIR=..
fi
# If no arguments were specified and configure has run before, use the previous
# arguments
if test $# -eq 0 && test -x ./config.status; then
./config.status --recheck
else
$CONFIGUREDIR/configure "$@"
fi

View File

@@ -1,5 +1,5 @@
# libguestfs
# Copyright (C) 2013 Red Hat Inc.
# Copyright (C) 2013-2025 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,41 +20,30 @@ include $(top_srcdir)/subdir-rules.mk
scripts = \
guestfish \
guestmount \
virt-alignment-scan \
virt-rescue \
virt-resize \
virt-v2v
guestunmount \
libguestfs-test-tool \
virt-rescue
# Some of the scripts are simply symbolic links.
symlinks = \
virt-builder \
virt-cat \
virt-df \
virt-edit \
virt-filesystems \
virt-format \
virt-inspector \
virt-log \
virt-ls \
virt-sparsify \
virt-sysprep
virt-copy-in \
virt-copy-out \
virt-tar-in \
virt-tar-out
# Note: Don't distribute the symbolic links, only the real files.
EXTRA_DIST = \
README \
$(scripts)
$(scripts) \
$(TESTS)
CLEANFILES = \
CLEANFILES += \
$(symlinks)
# Some of the scripts are simply symbolic links.
virt-cat virt-df virt-edit virt-filesystems virt-format virt-inspector \
virt-log virt-ls virt-sysprep:
# guestfish is handled specially.
virt-copy-in virt-copy-out virt-tar-in virt-tar-out:
rm -f $@
$(LN_S) virt-alignment-scan $@
virt-builder virt-sparsify:
rm -f $@
$(LN_S) virt-resize $@
$(LN_S) guestfish $@
if HAVE_BASH_COMPLETION
@@ -68,9 +57,19 @@ all-local: $(scripts) $(symlinks)
install-data-local:
$(mkdir_p) $(DESTDIR)$(bashcompletiondir)
cp -d $(scripts) $(symlinks) $(DESTDIR)$(bashcompletiondir)
cp -P $(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-2016 Red Hat Inc.
# Copyright (C) 2010-2025 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
@@ -73,5 +73,12 @@ _guestfish ()
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-2016 Red Hat Inc.
# Copyright (C) 2010-2025 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

@@ -1,5 +1,5 @@
# virt-tools bash completion script -*- shell-script -*-
# Copyright (C) 2010-2016 Red Hat Inc.
# Copyright (C) 2010-2025 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
@@ -36,10 +36,29 @@ _guestfs_virttools ()
_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
@@ -60,24 +79,54 @@ _guestfs_virttools ()
esac
}
_guestunmount ()
{
_guestfs_virttools "guestunmount" 1
} &&
complete -o default -F _guestunmount guestunmount
_virt_alignment_scan ()
{
_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" 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" 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" 0
@@ -96,26 +145,50 @@ _virt_format ()
} &&
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" 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" 1
} &&
complete -o default -F _virt_ls virt-ls
_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" 0
} &&
complete -o default -F _virt_sysprep virt-sysprep
_virt_log ()
_virt_tail ()
{
_guestfs_virttools "virt-log" 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-v2v bash completion script -*- shell-script -*-
# Copyright (C) 2014 Red Hat Inc.
# libguestfs-test-tool bash completion script -*- shell-script -*-
# Copyright (C) 2014-2025 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,45 +15,39 @@
# 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 ()
_guestfs_options_only ()
{
local cur prev words cword split
local shortopts longopts items
local shortopts longopts tool="$1"
_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)"
longopts="$($tool --long-options)"
COMPREPLY=( $(compgen -W "$longopts" -- "$cur") )
return ;;
-*)
# -o and --options
shortopts="$(virt-v2v --short-options)"
longopts="$(virt-v2v --long-options)"
shortopts="$($tool --short-options)"
longopts="$($tool --long-options)"
COMPREPLY=( $(compgen -W "$shortopts $longopts" -- "$cur") )
return ;;
*)
COMPREPLY=( $(compgen "$cur") )
return ;;
esac
}
_virt_win_reg ()
{
_guestfs_options_only "virt-win-reg"
} &&
complete -o default -F _virt_v2v virt-v2v
complete -o default -F _virt_win_reg virt-win-reg
_libguestfs-test-tool ()
{
_guestfs_options_only "libguestfs-test-tool"
} &&
complete -o default -F _libguestfs-test-tool libguestfs-test-tool

43
bash/test-complete-in-script.sh Executable file
View File

@@ -0,0 +1,43 @@
#!/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.
source ../tests/functions.sh
set -e
set -x
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-rescue bash completion script -*- shell-script -*-
# Copyright (C) 2010-2016 Red Hat Inc.
# Copyright (C) 2010-2025 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

@@ -1,78 +0,0 @@
# virt-resize, virt-builder, virt-sparsify bash completion script
# -*- shell-script -*-
# Copyright (C) 2010-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.
_guestfs_options_only ()
{
local cur prev words cword split
local shortopts longopts tool="$1"
_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 ;;
--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
}
_virt_builder ()
{
_guestfs_options_only "virt-builder"
} &&
complete -o default -F _virt_builder virt-builder
_virt_resize ()
{
_guestfs_options_only "virt-resize"
} &&
complete -o default -F _virt_resize virt-resize
_virt_sparsify ()
{
_guestfs_options_only "virt-sparsify"
} &&
complete -o default -F _virt_sparsify virt-sparsify

119
bootstrap
View File

@@ -1,119 +0,0 @@
#!/bin/sh
usage() {
echo >&2 "\
Usage: $0 [OPTION]...
Bootstrap this package from the checked-out sources.
"
}
for option
do
case $option in
--help)
usage
exit;;
*)
echo >&2 "$0: $option: unknown option"
exit 1;;
esac
done
# Get gnulib files.
echo "$0: getting gnulib files..."
git submodule init || exit $?
git submodule update || exit $?
GNULIB_SRCDIR=.gnulib
# Autoreconf runs aclocal before libtoolize, which causes spurious
# warnings if the initial aclocal is confused by the libtoolized
# (or worse out-of-date) macro directory.
libtoolize --copy --install
gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
<$gnulib_tool || exit
modules='
accept4
areadlink
areadlinkat
arpa_inet
base64
byteswap
c-ctype
cloexec
closeout
connect
dup3
error
filevercmp
fstatat
fsusage
fts
full-read
full-write
futimens
getaddrinfo
getline
gitlog-to-changelog
glob
gnu-make
gnumakefile
hash
hash-pjw
human
iconv
ignore-value
lock
maintainer-makefile
manywarnings
memmem
mkdtemp
mkstemps
netdb
netinet_in
openat
perror
pipe2
pread
ptsname_r
read-file
readlink
select
setenv
sleep
socket
stat-time
strchrnul
strerror
strndup
symlinkat
sys_select
sys_wait
vasprintf
vc-list-files
warnings
xalloc
xalloc-die
xgetcwd
xstrtol
xstrtoll
xvasprintf
'
# If any tests fail, avoid including them by adding them to
# this list.
avoid="--avoid=dummy --avoid=getlogin_r-tests"
$gnulib_tool \
$avoid \
--with-tests \
--m4-base=m4 \
--source-base=gnulib/lib \
--tests-base=gnulib/tests \
--libtool \
--import $modules
# Disable autopoint and libtoolize, since they were already done above.
AUTOPOINT=true LIBTOOLIZE=true autoreconf --verbose --install

View File

@@ -1,6 +1,6 @@
#!/bin/bash -
# bugs-in-changelog.sh
# Copyright (C) 2009-2016 Red Hat Inc.
# Copyright (C) 2009-2025 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,10 +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.
# Used when preparing the guestfs-release-notes(1) man page. This
# script looks at the bugs noted in the git changelog since the last
# stable release (or any release). To use it, the only parameter
# should be the git commit range, eg:
# Used when preparing the release notes. This script looks at the
# bugs noted in the git changelog since the last stable release (or
# any release). To use it, the only parameter should be the git
# commit range, eg:
#
# ./bugs-in-changelog.sh "1.0.89.."
@@ -30,8 +30,9 @@ fi
# Comma-separated list of Bugzilla IDs.
bugids=$(
git log "$1" | egrep -o 'RHBZ#[0-9]+' |
sed 's/RHBZ#//' |
git log "$1" |
grep -Eio 'RHBZ#[0-9]+|https?://bugzilla.redhat.com/[a-z\.\?/_=]*[0-9]+' |
sed 's/^[^0-9]*//' |
sort -u |
tr '\n' ',' |
sed 's/,$//'
@@ -39,9 +40,16 @@ bugids=$(
#echo bugids "$bugids"
# Filter out any bugs which may still be in NEW or ASSIGNED:
bugzilla query -b "$bugids" \
-t MODIFIED,POST,ON_QA,PASSES_QA,VERIFIED,RELEASE_PENDING,CLOSED \
# Filter out any bugs which may still be in NEW or ASSIGNED.
#
# Ensure user is logged in, otherwise bugzilla will silently truncate
# the number of responses. To log in, see "API KEYS" in bugzilla(1).
bugzilla \
--ensure-logged-in \
query \
-b "$bugids" \
-s MODIFIED,POST,ON_QA,PASSES_QA,VERIFIED,RELEASE_PENDING,CLOSED \
--component libguestfs \
--outputformat='%{bug_id} %{short_desc}' |
sort -n -r |
perl -pe '
@@ -49,3 +57,31 @@ bugzilla query -b "$bugids" \
sprintf ("=item L<https://bugzilla.redhat.com/%s>\n\n%s\n",
$1, $2)
}xe'
# We can't fetch Jira subjects or github issues, but we can at least
# list them.
jiraids=$(
git log "$1" |
grep -Eio 'RHEL-[0-9]{3,}' |
sort -u
)
for id in $jiraids ; do
echo "=item L<https://issues.redhat.com/browse/$id>"
echo
echo "XXX"
echo
done
issues=$(
git log "$1" |
grep -Eio 'https?://github\.com/libguestfs/libguestfs/issues/[0-9]+' |
sort -u
)
for issue in $issues ; do
echo "=item L<$issue>"
echo
echo "XXX"
echo
done

View File

@@ -3,7 +3,7 @@
scriptversion=2013-07-13.22; # UTC
# Copyright (C) 2011-2016 Free Software Foundation, Inc.
# Copyright (C) 2011-2025 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
@@ -81,6 +81,11 @@ if test x"$missing_opts" != x; then
usage_error "the following mandatory options are missing:$missing_opts"
fi
# Don't print absolute paths in test output
# Without this, C program tests were printed like
# PASS: /path/to/libguestfs.git/tests/c-api/.libs/test-just-header
test_name=$(echo "$test_name" | sed "s|$(pwd)/||")
if test $# -eq 0; then
usage_error "missing argument"
fi

View File

@@ -1,392 +0,0 @@
# libguestfs virt-builder tool
# Copyright (C) 2013-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.
include $(top_srcdir)/subdir-rules.mk
AM_YFLAGS = -d
EXTRA_DIST = \
$(SOURCES_MLI) $(SOURCES_ML) $(SOURCES_C) \
libguestfs.gpg \
opensuse.gpg \
test-index \
test-simplestreams/streams/v1/index.json \
test-simplestreams/streams/v1/net.cirros-cloud_released_download.json \
test-virt-builder.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 \
virt-builder.pod \
virt-index-validate.pod \
yajl_tests.ml
CLEANFILES = \
*~ \
*.annot \
*.cache \
*.cmi \
*.cmo \
*.cmx \
*.cmxa \
*.log \
*.o \
virt-builder
SOURCES_MLI = \
cache.mli \
cmdline.mli \
downloader.mli \
checksums.mli \
index.mli \
index_parser.mli \
ini_reader.mli \
languages.mli \
list_entries.mli \
pxzcat.mli \
setlocale.mli \
sigchecker.mli \
simplestreams_parser.mli \
sources.mli \
yajl.mli
SOURCES_ML = \
utils.ml \
pxzcat.ml \
setlocale.ml \
checksums.ml \
index.ml \
ini_reader.ml \
yajl.ml \
paths.ml \
languages.ml \
cache.ml \
sources.ml \
downloader.ml \
sigchecker.ml \
index_parser.ml \
simplestreams_parser.ml \
list_entries.ml \
cmdline.ml \
builder.ml
SOURCES_C = \
../mllib/fsync-c.c \
../mllib/uri-c.c \
../mllib/mkdtemp-c.c \
../customize/perl_edit-c.c \
../customize/crypt-c.c \
../fish/uri.c \
../fish/file-edit.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
bin_PROGRAMS += virt-builder
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)/src \
-I$(top_srcdir)/fish
virt_builder_CFLAGS = \
-pthread \
$(WARN_CFLAGS) $(WERROR_CFLAGS) \
-Wno-unused-macros \
$(LIBLZMA_CFLAGS) \
$(LIBTINFO_CFLAGS) \
$(LIBXML2_CFLAGS) \
$(YAJL_CFLAGS)
BOBJECTS = \
$(top_builddir)/mllib/libdir.cmo \
$(top_builddir)/mllib/guestfs_config.cmo \
$(top_builddir)/mllib/common_gettext.cmo \
$(top_builddir)/mllib/common_utils.cmo \
$(top_builddir)/mllib/fsync.cmo \
$(top_builddir)/mllib/planner.cmo \
$(top_builddir)/mllib/regedit.cmo \
$(top_builddir)/mllib/JSON.cmo \
$(top_builddir)/mllib/uRI.cmo \
$(top_builddir)/mllib/mkdtemp.cmo \
$(top_builddir)/customize/customize_utils.cmo \
$(top_builddir)/customize/urandom.cmo \
$(top_builddir)/customize/random_seed.cmo \
$(top_builddir)/customize/hostname.cmo \
$(top_builddir)/customize/timezone.cmo \
$(top_builddir)/customize/firstboot.cmo \
$(top_builddir)/customize/perl_edit.cmo \
$(top_builddir)/customize/crypt.cmo \
$(top_builddir)/customize/password.cmo \
$(top_builddir)/customize/ssh_key.cmo \
$(top_builddir)/customize/subscription_manager.cmo \
$(top_builddir)/customize/customize_cmdline.cmo \
$(top_builddir)/customize/customize_run.cmo \
$(SOURCES_ML:.ml=.cmo)
XOBJECTS = $(BOBJECTS:.cmo=.cmx)
# -I $(top_builddir)/src/.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)/gnulib/lib/.libs \
-I $(top_builddir)/ocaml \
-I $(top_builddir)/mllib \
-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
OCAMLCLIBS = \
-pthread -lpthread \
-lutils \
$(LIBTINFO_LIBS) \
$(LIBCRYPT_LIBS) \
$(LIBLZMA_LIBS) \
$(LIBXML2_LIBS) \
$(YAJL_LIBS) \
$(LIBINTL) \
-lgnu
OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR)
if !HAVE_OCAMLOPT
OBJECTS = $(BOBJECTS)
BEST = c
OCAMLLINKFLAGS = mlguestfs.cma -custom
else
OBJECTS = $(XOBJECTS)
BEST = opt
OCAMLLINKFLAGS = mlguestfs.cmxa
endif
virt_builder_DEPENDENCIES = $(OBJECTS) $(top_srcdir)/ocaml-link.sh
virt_builder_LINK = \
$(top_srcdir)/ocaml-link.sh -cclib '$(OCAMLCLIBS)' -- \
$(OCAMLFIND) $(BEST) $(OCAMLFLAGS) $(OCAMLPACKAGES) $(OCAMLLINKFLAGS) \
$(OBJECTS) -o $@
.mli.cmi:
$(OCAMLFIND) ocamlc $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@
.ml.cmo:
$(OCAMLFIND) ocamlc $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@
if HAVE_OCAMLOPT
.ml.cmx:
$(OCAMLFIND) ocamlopt $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@
endif
# Manual pages and HTML files for the website.
man_MANS += virt-builder.1
noinst_DATA += $(top_builddir)/website/virt-builder.1.html
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)/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 virt-builder.1
# Tests.
TESTS_ENVIRONMENT = $(top_builddir)/run --test
disk_images := \
$(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: ../test-data/phony-guests/fedora.img
rm -f $@ $@-t
qemu-img convert -f raw -O qcow2 $< $@-t
mv $@-t $@
fedora.qcow2.xz: fedora.qcow2
rm -f $@ $@-t
xz --best -c $< > $@-t
mv $@-t $@
%.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)
# 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)
else
yajl_tests_THEOBJECTS = $(yajl_tests_BOBJECTS)
yajl_tests.cmo: OCAMLPACKAGES += $(OCAMLPACKAGES_TESTS)
endif
yajl_tests_DEPENDENCIES = $(yajl_tests_THEOBJECTS) $(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 $@
TESTS = \
test-virt-builder-list.sh \
test-virt-index-validate.sh
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
TESTS += yajl_tests
endif
check-valgrind:
$(MAKE) VG="$(top_builddir)/run @VG@" check
check-slow:
$(MAKE) TESTS="test-virt-builder-planner.sh" check
# Dependencies.
depend: .depend
.depend: $(wildcard $(abs_srcdir)/*.mli) $(wildcard $(abs_srcdir)/*.ml)
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
mv $@-t $@
-include .depend
endif
DISTCLEANFILES = .depend
.PHONY: depend docs
# virt-builder's default repository
repoconfdir = $(sysconfdir)/xdg/virt-builder/repos.d
repoconf_DATA = libguestfs.conf libguestfs.gpg \
opensuse.conf opensuse.gpg
install-exec-hook:
$(LN_S) -f xdg/virt-builder $(DESTDIR)$(sysconfdir)/virt-builder
# Build a small C index validator program.
bin_PROGRAMS += virt-index-validate
virt_index_validate_SOURCES = \
index-parse.y \
index-scan.l \
index-struct.h \
index-struct.c \
index-validate.c
virt_index_validate_CPPFLAGS = \
-DLOCALEBASEDIR=\""$(datadir)/locale"\" \
-I. \
-I$(top_builddir) \
-I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \
-I$(top_srcdir)/src
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)/website/virt-index-validate.1.html
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)/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 \
virt-index-validate.1
if HAVE_OCAML
# Automake-generated makefile has a rule ".y.c" but lacks a rule ".y.h".
index-parse.h: index-parse.y
touch $(srcdir)/index-parse.y
$(MAKE) index-parse.c
# 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
endif
# Apparently there's no clean way with Automake to not have them
# in the distribution, so just remove them from the distdir.
dist-hook:
rm -f $(distdir)/index-parse.c $(distdir)/index-parse.h $(distdir)/index-scan.c

View File

@@ -1,741 +0,0 @@
(* virt-builder
* Copyright (C) 2013-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.
*)
open Common_gettext.Gettext
module G = Guestfs
open Common_utils
open Password
open Planner
open Utils
open Cmdline
open Customize_cmdline
open Unix
open Printf
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.arch = arch; revision = revision }) ->
let id = name, arch in
try
let rev = Hashtbl.find nseen id in
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.arch = arch; revision = revision }) ->
let id = name, arch in
try
let rev = Hashtbl.find nseen (name, arch) in
(* Take the first occurrency with the higher revision,
* removing it from the hash so the other occurrencies
* are ignored.
*)
if revision = rev then (
Hashtbl.remove nseen id;
true
) else
false
with Not_found ->
(* Already taken, so ignore. *)
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 = 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 cmdline = parse_cmdline () in
(* If debugging, echo the command line arguments and the sources. *)
if verbose () then (
printf "command line:";
List.iter (printf " %s") (Array.to_list Sys.argv);
print_newline ();
iteri (
fun i (source, fingerprint) ->
printf "source[%d] = (%S, %S)\n" i source fingerprint
) cmdline.sources
);
(* Handle some modes here, some later on. *)
let mode =
match cmdline.mode with
| `Get_kernel -> (* --get-kernel is really a different program ... *)
let cmd =
sprintf "virt-get-kernel%s%s%s%s --add %s"
(if verbose () then " --verbose" else "")
(if trace () then " -x" else "")
(match cmdline.format with
| None -> ""
| Some format -> sprintf " --format %s" (quote format))
(match cmdline.output with
| None -> ""
| Some output -> sprintf " --output %s" (quote output))
(quote cmdline.arg) in
if verbose () then printf "%s\n%!" cmd;
exit (Sys.command cmd)
| `Delete_cache -> (* --delete-cache *)
(match cmdline.cache with
| Some cachedir ->
message (f_"Deleting: %s") cachedir;
Cache.clean_cachedir cachedir;
exit 0
| None ->
error (f_"could not find cache directory. Is $HOME set?")
)
| (`Install|`List|`Notes|`Print_cache|`Cache_all) as mode -> mode in
(* Check various programs/dependencies are installed. *)
(* Check that gpg is installed. Optional as long as the user
* disables all signature checks.
*)
let cmd = sprintf "%s --help >/dev/null 2>&1" cmdline.gpg in
if Sys.command cmd <> 0 then (
if cmdline.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")
);
(* Check that curl works. *)
let cmd = sprintf "%s --help >/dev/null 2>&1" cmdline.curl in
if Sys.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
error (f_"virt-resize is not installed (or does not work)");
(* Create the cache. *)
let cache =
match cmdline.cache with
| None -> None
| Some 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
(* Download the sources. *)
let downloader = Downloader.create ~curl:cmdline.curl ~cache 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;
format = Sources.FormatNative;
}
) cmdline.sources in
let sources = List.append sources repos in
let index : Index.index =
List.concat (
List.map (
fun source ->
let sigchecker =
Sigchecker.create ~gpg:cmdline.gpg
~check_signature:cmdline.check_signature
~gpgkey:source.Sources.gpgkey 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
(* Now handle the remaining modes. *)
let mode =
match mode with
| `List -> (* --list *)
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.hidden = hidden }) ->
hidden <> true
) index in
let l = List.map (
fun (name, { Index.revision = revision; arch = arch }) ->
(name, arch, revision)
) l in
Cache.print_item_status cache ~header:true l
| None -> printf (f_"no cache directory\n")
);
exit 0
| `Cache_all -> (* --cache-all-templates *)
(match cache with
| None ->
error (f_"no cache directory")
| Some _ ->
List.iter (
fun (name,
{ Index.revision = revision; file_uri = file_uri;
proxy = 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
);
| (`Install|`Notes) as mode -> mode in
(* Which os-version (ie. index entry)? *)
let item = selected_cli_item cmdline index in
let arg = fst item in
let entry = snd item in
let sigchecker = entry.Index.sigchecker in
(match mode with
| `Notes -> (* --notes *)
let notes =
Languages.find_notes (Languages.languages ()) entry.Index.notes in
(match notes with
| notes :: _ ->
print_endline notes
| [] ->
printf (f_"There are no notes for %s\n") arg
);
exit 0
| `Install ->
() (* fall through to create the guest *)
);
(* --- If we get here, we want to create a guest. --- *)
(* Download the template, or it may be in the cache. *)
let template =
let template, delete_on_exit =
let { Index.revision = revision; file_uri = file_uri;
proxy = 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
(* Check the signature of the file. *)
let () =
match entry with
(* New-style: Using a checksum. *)
| { Index.checksums = Some csums } ->
Checksums.verify_checksums csums template
| { Index.checksums = None } ->
(* Old-style: detached signature. *)
let sigfile =
match entry with
| { Index.signature_uri = None } -> None
| { Index.signature_uri = Some signature_uri } ->
let sigfile, delete_on_exit =
Downloader.download downloader signature_uri in
if delete_on_exit then unlink_on_exit sigfile;
Some sigfile in
Sigchecker.verify_detached sigchecker template sigfile in
(* For an explanation of the Planner, see:
* http://rwmj.wordpress.com/2013/12/14/writing-a-planner-to-solve-a-tricky-programming-optimization-problem/
*)
(* Planner: Input tags. *)
let itags =
let { Index.size = size; format = format } = entry in
let format_tag =
match format with
| None -> []
| Some format -> [`Format, format] in
let compression_tag =
match detect_file_type template with
| `XZ -> [ `XZ, "" ]
| `GZip | `Tar | `Zip ->
error (f_"input file (%s) has an unsupported type") template
| `Unknown -> [] in
[ `Template, ""; `Filename, template; `Size, Int64.to_string size ] @
format_tag @ compression_tag in
(* Planner: Goal. *)
let output_filename, output_format =
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
| Some output, None -> output, "raw"
| Some output, Some format -> output, format in
if is_char_device output_filename then
error (f_"cannot output to a character device or /dev/null");
let blockdev_getsize64 dev =
let cmd = sprintf "blockdev --getsize64 %s" (quote dev) in
let lines = external_command cmd in
assert (List.length lines >= 1);
Int64.of_string (List.hd lines)
in
let output_is_block_dev, blockdev_size =
let b = is_block_device output_filename in
let sz = if b then blockdev_getsize64 output_filename else 0L in
b, sz in
let output_size =
let { Index.size = original_image_size } = entry in
let size =
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
(* --size parameter missing, block device: use block device size *)
| None -> blockdev_size in
if size < original_image_size then
error (f_"images cannot be shrunk, the output size is too small for this image. Requested size = %s, minimum size = %s")
(human_size size) (human_size original_image_size)
else if output_is_block_dev && output_format = "raw" && size > blockdev_size then
error (f_"output size is too large for this block device. Requested size = %s, output block device = %s, output block device size = %s")
(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
(* MUST NOT *)
let goal_must_not = [ `Template, ""; `XZ, "" ] in
goal_must, goal_must_not in
let cache_dir = (open_guestfs ())#get_cachedir () in
(* Planner: Transitions. *)
let transitions itags =
let is t = List.mem_assoc t itags in
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.
*)
(* 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 ~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);
(* 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)
*)
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);
);
if is `XZ then (
(* If the input is XZ-compressed, then we can run xzcat, either
* to the output file or to a temp file.
*)
if not output_is_block_dev then
tr `Pxzcat 80
((`Filename, output_filename) :: remove `XZ (remove `Template itags));
tr `Pxzcat 80
((`Filename, tempfile) :: remove `XZ (remove `Template itags));
)
else (
(* If the input is NOT compressed then we could run virt-resize
* if it makes sense to resize the image. Note that virt-resize
* can do both size and format conversions.
*)
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
((`Size, Int64.to_string output_size) ::
(`Filename, output_filename) ::
(`Format, output_format) :: (remove `Template itags));
tr `Virt_resize 100
((`Size, Int64.to_string output_size) ::
(`Filename, tempfile) ::
(`Format, output_format) :: (remove `Template itags))
)
(* If the size increase is smaller than the amount of headroom
* inside the disk image, then virt-resize won't work. However
* we can do a disk resize (using 'qemu-img resize') instead,
* although it won't resize the filesystems for the user.
*
* 'qemu-img resize' works on the file in-place and won't change
* the format. It must not be run on a template directly.
*
* 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);
(* qemu-img convert is always possible, and quicker. It doesn't
* resize, but it does change the format.
*)
tr `Convert 60
((`Filename, output_filename) :: (`Format, output_format) ::
(remove `Template itags));
tr `Convert 60
((`Filename, tempfile) :: (`Format, output_format) ::
(remove `Template itags));
);
(* Return the list of possible transitions. *)
!ret
in
(* Plan how to create the disk 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
(* Print out the plan. *)
if verbose () then (
let print_tags tags =
(try
let v = List.assoc `Filename tags in printf " +filename=%s" v
with Not_found -> ());
(try
let v = List.assoc `Size tags in printf " +size=%s" v
with Not_found -> ());
(try
let v = List.assoc `Format tags in printf " +format=%s" v
with Not_found -> ());
if List.mem_assoc `Template tags then printf " +template";
if List.mem_assoc `XZ tags then printf " +xz"
in
let print_task = function
| `Copy -> printf "cp"
| `Rename -> printf "mv"
| `Pxzcat -> printf "pxzcat"
| `Virt_resize -> printf "virt-resize"
| `Disk_resize -> printf "qemu-img resize"
| `Convert -> printf "qemu-img convert"
in
iteri (
fun i (itags, task, otags) ->
printf "%d: itags:" i;
print_tags itags;
printf "\n";
printf "%d: task : " i;
print_task task;
printf "\n";
printf "%d: otags:" i;
print_tags otags;
printf "\n\n%!"
) plan
);
(* Delete the output file before we finish. However don't delete it
* if it's block device, or if --no-delete-on-failure is set.
*)
let delete_output_file =
ref (cmdline.delete_on_failure && not output_is_block_dev) in
let delete_file () =
if !delete_output_file then
try unlink output_filename with _ -> ()
in
at_exit delete_file;
(* Carry out the plan. *)
List.iter (
function
| itags, `Copy, otags ->
let ifile = List.assoc `Filename itags in
let ofile = List.assoc `Filename otags in
message (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
| itags, `Rename, 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
| itags, `Pxzcat, otags ->
let ifile = List.assoc `Filename itags in
let ofile = List.assoc `Filename otags in
message (f_"Uncompressing");
Pxzcat.pxzcat ifile ofile
| itags, `Virt_resize, otags ->
let ifile = List.assoc `Filename itags in
let iformat =
try Some (List.assoc `Format itags) with Not_found -> None in
let ofile = List.assoc `Filename otags in
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.expand = expand; lvexpand = 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 = open_guestfs () in
g#disk_create ?preallocation ofile oformat osize in
let cmd =
sprintf "virt-resize%s%s%s --output-format %s%s%s --unknown-filesystems error %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
| 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
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
| itags, `Convert, otags ->
let ifile = List.assoc `Filename itags in
let iformat =
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
(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 (qemu_input_filename 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
) plan;
(* Now mount the output disk so we can make changes. *)
message (f_"Opening the new disk");
let g =
let g = open_guestfs () in
may g#set_memsize cmdline.memsize;
may g#set_smp cmdline.smp;
g#set_network cmdline.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;
(* The output disk is being created, so use cache=unsafe here. *)
g#add_drive_opts ~format:output_format ~cachemode:"unsafe" output_filename;
(* Attach ISOs, if we have any. *)
List.iter (
fun (format, file) ->
g#add_drive_opts ?format ~readonly:true file;
) cmdline.attach;
g#launch ();
g in
(* Inspect the disk and mount it up. *)
let root =
match Array.to_list (g#inspect_os ()) with
| [root] ->
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 g root cmdline.ops;
(* Collect some stats about the final output file.
* Notes:
* - These are virtual disk stats.
* - Never fail here.
*)
let stats =
if not (quiet ()) then (
try
(* Calculate the free space (in bytes) across all mounted
* filesystems in the guest.
*)
let free_bytes, total_bytes =
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 } ->
bfree *^ bsize, blocks *^ bsize
) stats in
List.fold_left (
fun (f,t) (f',t') -> f +^ f', t +^ t'
) (0L, 0L) stats in
let free_percent = 100L *^ free_bytes /^ total_bytes in
Some (
String.concat "\n" [
sprintf "%30s: %s" (s_"Output file") output_filename;
sprintf "%30s: %s" (s_"Output size") (human_size output_size);
sprintf "%30s: %s" (s_"Output format") output_format;
sprintf "%30s: %s" (s_"Total usable space")
(human_size total_bytes);
sprintf "%30s: %s (%Ld%%)" (s_"Free space")
(human_size free_bytes) free_percent;
] ^ "\n"
)
with
_ -> None
)
else None in
(* Unmount everything and we're done! *)
message (f_"Finishing off");
g#umount_all ();
g#shutdown ();
g#close ();
(* Because we used cache=unsafe when writing the output file, the
* file might not be committed to disk. This is a problem if qemu is
* immediately used afterwards with cache=none (which uses O_DIRECT
* and therefore bypasses the host cache). In general you should not
* use cache=none.
*)
if cmdline.sync then
Fsync.file output_filename;
(* Now that we've finished the build, don't delete the output file on
* exit.
*)
delete_output_file := false;
(* Print the stats calculated above. *)
Pervasives.flush Pervasives.stdout;
Pervasives.flush Pervasives.stderr;
may print_string stats
let () = run_main_and_handle_errors main

View File

@@ -1,58 +0,0 @@
(* virt-builder
* Copyright (C) 2013-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.
*)
open Common_gettext.Gettext
open Common_utils
open Utils
open Unix
open Printf
let clean_cachedir dir =
let cmd = sprintf "rm -rf %s" (quote dir) in
ignore (Sys.command cmd);
type t = {
directory : string;
}
let create ~directory =
if not (is_directory directory) then
mkdir_p directory 0o755;
{
directory = directory;
}
let cache_of_name t 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
Sys.file_exists filename
let print_item_status t ~header l =
if header then (
printf (f_"cache directory: %s\n") t.directory
);
List.iter (
fun (name, arch, revision) ->
let cached = is_cached t name arch revision in
printf "%-24s %-10s %s\n" name arch
(if cached then s_"cached" else (*s_*)"no")
) l

View File

@@ -1,45 +0,0 @@
(* virt-builder
* Copyright (C) 2013-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.
*)
(** This module represents a local cache. *)
val clean_cachedir : string -> unit
(** [clean_cachedir dir] clean the specified cache directory. *)
type t
(** The abstract data type. *)
val create : directory:string -> t
(** Create the abstract type. *)
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 -> 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 * 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).
If [~header:true] then display a header with the path of the
cache. *)

View File

@@ -1,58 +0,0 @@
(* 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 Common_gettext.Gettext
open Common_utils
open Utils
open Printf
type csum_t =
| SHA256 of string
| SHA512 of string
let string_of_csum_t = function
| SHA256 _ -> "sha256"
| SHA512 _ -> "sha512"
let string_of_csum = function
| SHA256 c -> c
| SHA512 c -> c
let verify_checksum csum filename =
let prog, csum_ref =
match csum with
| SHA256 c -> "sha256sum", c
| SHA512 c -> "sha512sum", c
in
let cmd = sprintf "%s %s" prog (quote filename) in
if verbose () then printf "%s\n%!" cmd;
let lines = external_command cmd in
match lines with
| [] ->
error (f_"%s did not return any output") prog
| line :: _ ->
let csum_actual = fst (String.split " " line) in
if csum_ref <> csum_actual then
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!")
(string_of_csum_t csum) csum_actual csum_ref
let verify_checksums checksums filename =
List.iter (fun c -> verify_checksum c filename) checksums

View File

@@ -1,327 +0,0 @@
(* virt-builder
* Copyright (C) 2013-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.
*)
(* Command line argument parsing. *)
open Common_gettext.Gettext
open Common_utils
open Customize_cmdline
open Utils
module G = Guestfs
open Unix
open Printf
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;
delete_on_failure : bool;
format : string option;
gpg : string;
list_format : [`Short|`Long|`Json];
memsize : int option;
network : bool;
ops : Customize_cmdline.ops;
output : string option;
size : int64 option;
smp : int option;
sources : (string * string) list;
sync : bool;
}
let parse_cmdline () =
let mode = ref `Install in
let list_mode () = mode := `List in
let notes_mode () = mode := `Notes in
let get_kernel_mode () = mode := `Get_kernel in
let cache_all_mode () = mode := `Cache_all in
let print_cache_mode () = mode := `Print_cache in
let delete_cache_mode () = mode := `Delete_cache in
let arch = ref "" in
let attach = ref [] in
let attach_format = ref None in
let set_attach_format = function
| "auto" -> attach_format := None
| s -> attach_format := Some s
in
let attach_disk s = attach := (!attach_format, s) :: !attach in
let cache = ref Paths.xdg_cache_home in
let set_cache arg = cache := Some arg in
let no_cache () = cache := None in
let check_signature = ref true in
let curl = ref "curl" in
let delete_on_failure = ref true in
let fingerprints = ref [] in
let add_fingerprint arg = fingerprints := arg :: !fingerprints in
let format = ref "" in
let gpg = ref "gpg" in
let list_format = ref `Short in
let list_set_long () = list_format := `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
let machine_readable = ref false in
let memsize = ref None in
let set_memsize arg = memsize := Some arg in
let network = ref true in
let output = ref "" in
let size = ref None 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 sync = ref true 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)";
"--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";
"--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";
] 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 = set_standard_options argspec in
let args = ref [] in
let anon_fun s = args := s :: !args in
let usage_msg =
sprintf (f_"\
%s: build virtual machine images quickly
virt-builder OS-VERSION
virt-builder -l
virt-builder --notes OS-VERSION
virt-builder --print-cache
virt-builder --cache-all-templates
virt-builder --delete-cache
virt-builder --get-kernel IMAGE
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;
(* Dereference options. *)
let args = List.rev !args in
let mode = !mode in
let arch = !arch in
let attach = List.rev !attach in
let cache = !cache in
let check_signature = !check_signature in
let curl = !curl in
let delete_on_failure = !delete_on_failure in
let fingerprints = List.rev !fingerprints in
let format = match !format with "" -> None | s -> Some s in
let gpg = !gpg in
let list_format = !list_format in
let machine_readable = !machine_readable in
let memsize = !memsize in
let network = !network in
let ops = get_customize_ops () in
let output = match !output with "" -> None | s -> Some s in
let size = !size in
let smp = !smp in
let sources = List.rev !sources in
let sync = !sync in
(* No arguments and machine-readable mode? Print some facts. *)
if args = [] && machine_readable then (
printf "virt-builder\n";
printf "arch\n";
printf "config-file\n";
printf "customize\n";
printf "json-list\n";
if Pxzcat.using_parallel_xzcat () then printf "pxzcat\n";
exit 0
);
(* Check options. *)
let arg =
match mode with
| `Install ->
(match args with
| [arg] -> arg
| [] ->
error (f_"virt-builder os-version\nMissing 'os-version'. Use '--list' to list available template names.")
| _ ->
error (f_"too many parameters, expecting 'os-version'")
)
| `List ->
if format <> None then
error (f_"--list: use '--list-format', not '--format'");
(match args with
| [arg] -> arg
| [] -> ""
| _ ->
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_"--notes: too many parameters, expecting 'os-version'");
)
| `Cache_all
| `Print_cache
| `Delete_cache ->
(match args with
| [] -> ""
| _ ->
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_"--get-kernel: too many parameters")
) in
(* Check source(s) and fingerprint(s). *)
let sources =
let rec repeat x = function
| 0 -> [] | 1 -> [x]
| n -> x :: repeat x (n-1)
in
let nr_sources = List.length sources in
let fingerprints =
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");
(* Combine the sources and fingerprints into a single list of pairs. *)
List.combine sources fingerprints in
(* Check the architecture. *)
let arch =
match arch with
| "" -> 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 has_set_root_password = List.exists (
function `RootPassword _ -> true | _ -> false
) ops.ops in
if has_set_root_password then ops
else (
let pw = Password.parse_selector "random" in
{ ops with ops = ops.ops @ [ `RootPassword pw ] }
) in
{ mode = mode; arg = arg;
arch = arch; attach = attach; cache = cache;
check_signature = check_signature; curl = curl;
delete_on_failure = delete_on_failure; format = format;
gpg = gpg; list_format = list_format; memsize = memsize;
network = network; ops = ops; output = output;
size = size; smp = smp; sources = sources; sync = sync;
}

View File

@@ -1,44 +0,0 @@
(* virt-builder
* Copyright (C) 2013-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.
*)
(** 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;
delete_on_failure : bool;
format : string option;
gpg : string;
list_format : [`Short|`Long|`Json];
memsize : int option;
network : bool;
ops : Customize_cmdline.ops;
output : string option;
size : int64 option;
smp : int option;
sources : (string * string) list;
sync : bool;
}
val parse_cmdline : unit -> cmdline

View File

@@ -1,149 +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
open Unix
open Printf
type uri = string
type filename = string
type t = {
curl : string;
cache : Cache.t option; (* cache for templates *)
}
type proxy_mode =
| UnsetProxy
| SystemProxy
| ForcedProxy of string
let create ~curl ~cache = {
curl = curl;
cache = cache;
}
let rec download t ?template ?progress_bar ?(proxy = SystemProxy) uri =
match template with
| None -> (* no cache, simple download *)
(* Create a temporary name. *)
let tmpfile = Filename.temp_file "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 ?progress_bar ~proxy uri
| Some cache ->
let filename = Cache.cache_of_name cache name arch revision in
(* Is the requested template name + revision in the cache already?
* If not, download it.
*)
if not (Sys.file_exists filename) then
download_to t ?progress_bar ~proxy uri filename;
(filename, false)
and download_to t ?(progress_bar = false) ~proxy uri filename =
let parseduri =
try URI.parse_uri uri
with Invalid_argument "URI.parse_uri" ->
error (f_"error parsing URI '%s'. Look for error messages printed above.")
uri in
(* Note because there may be parallel virt-builder instances running
* and also to avoid partial downloads in the cache if the network
* 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
unlink_on_exit filename_new;
(match parseduri.URI.protocol with
| "file" ->
let path = parseduri.URI.path in
let cmd = sprintf "cp%s %s %s"
(if verbose () then " -v" else "")
(quote path) (quote filename_new) in
let r = Sys.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
(* Get the status code first to ensure the file exists. *)
let cmd = sprintf "%s%s%s -L --max-redirs 5 -g -o /dev/null -I -w '%%{http_code}' %s"
outenv
t.curl
(if verbose () then "" else " -s -S")
(quote uri) in
if verbose () then printf "%s\n%!" cmd;
let lines = external_command cmd 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
let bad_status_code = function
| "" -> true
| s when s.[0] = '4' -> true (* 4xx *)
| s when s.[0] = '5' -> true (* 5xx *)
| _ -> false
in
if bad_status_code status_code then
error (f_"failed to download %s: HTTP status code %s") uri status_code;
(* Now download the file. *)
let cmd = sprintf "%s%s%s -L --max-redirs 5 -g -o %s %s"
outenv
t.curl
(if verbose () then "" else if progress_bar then " -#" else " -s -S")
(quote filename_new) (quote uri) in
if 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;
);
(* 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

@@ -1,53 +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.
*)
(** This module is a wrapper around curl, plus local caching. *)
type uri = string
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 : curl:string -> cache:Cache.t option -> t
(** Create the abstract type. *)
val download : t -> ?template:(string*string*Utils.revision) -> ?progress_bar:bool -> ?proxy:proxy_mode -> 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
caller (otherwise it's in the cache and you shouldn't delete it).
For templates, you must supply [~template:(name, arch, revision)].
This causes the cache to be used (if possible). Name, arch(itecture)
and revision are used for cache control (see the man page for details).
If [~progress_bar:true] then display a progress bar if the file
doesn't come from the cache. In verbose mode, progress messages
are always displayed.
[proxy] specifies the type of proxy to be used in the transfer,
if possible. *)

View File

@@ -1,183 +0,0 @@
/* libguestfs virt-builder tool -*- fundamental -*-
* 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.
*/
%{
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#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);
/* Join two strings with \n */
static char *
concat_newline (const char *str1, const char *str2)
{
size_t len1, len2, len;
char *ret;
if (str2 == NULL)
return strdup (str1);
len1 = strlen (str1);
len2 = strlen (str2);
len = len1 + 1 /* \n */ + len2 + 1 /* \0 */;
ret = malloc (len);
memcpy (ret, str1, len1);
ret[len1] = '\n';
memcpy (ret + len1 + 1, str2, len2);
ret[len-1] = '\0';
return ret;
}
%}
%code requires {
#ifndef YY_TYPEDEF_YY_SCANNER_T
#define YY_TYPEDEF_YY_SCANNER_T
typedef void *yyscan_t;
#endif
}
%locations
%union {
struct section *section;
struct field *field;
char *str;
}
%token <str> SECTION_HEADER
%token <field> FIELD
%token <str> VALUE_CONT
%token EMPTY_LINE
%token PGP_PROLOGUE
%token PGP_EPILOGUE
%token UNKNOWN_LINE
%type <section> sections section
%type <field> fields field
%type <str> continuations
%pure-parser
%lex-param { yyscan_t scanner }
%parse-param { yyscan_t scanner }
%parse-param { struct parse_context *context }
%destructor { section_free ($$); } <section>
%destructor { field_free ($$); } <field>
%%
index:
sections
{ context->parsed_index = $1; }
| PGP_PROLOGUE sections PGP_EPILOGUE
{ context->parsed_index = $2; }
sections:
emptylines section emptylines
{ $$ = $2; }
| emptylines section EMPTY_LINE emptylines sections
{ $$ = $2; $$->next = $5; }
| emptylines
{ $$ = NULL; }
section:
SECTION_HEADER fields
{ $$ = malloc (sizeof (struct section));
$$->next = NULL;
$$->name = $1;
$$->fields = $2; }
fields:
/* empty */
{ $$ = NULL; }
| field fields
{ $$ = $1; $$->next = $2; }
field: FIELD continuations
{ $$ = $1;
char *old_value = $$->value;
$$->value = concat_newline (old_value, $2);
free (old_value);
free ($2); }
continuations:
/* empty */
{ $$ = NULL; }
| VALUE_CONT continuations
{ $$ = concat_newline ($1, $2);
free ($1);
free ($2); }
emptylines:
/* empty */
{}
| EMPTY_LINE 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;
fprintf (stderr, "%s%s%s%ssyntax error at line %d: %s%s%s\n",
context->progname ? context->progname : "",
context->progname ? ": " : "",
context->input_file ? context->input_file : "",
context->input_file ? ": " : "",
yylloc->first_line, msg,
has_suffix ? " " : "",
has_suffix ? context->error_suffix : "");
}
int
do_parse (struct parse_context *context, FILE *in)
{
yyscan_t scanner;
int res;
scanner_init (&scanner, context, in);
res = yyparse (scanner, context);
scanner_destroy (scanner);
return res;
}

View File

@@ -1,122 +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.
*/
/**
* 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>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <caml/alloc.h>
#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)
{
CAMLparam2 (progv, filenamev);
CAMLlocal5 (rv, v, sv, sv2, fv);
struct section *sections;
size_t i, nr_sections;
struct parse_context context;
FILE *in;
parse_context_init (&context);
context.progname = String_val (progv);
context.input_file = String_val (filenamev);
context.error_suffix = String_val (error_suffixv);
in = fopen (String_val (filenamev), "r");
if (in == NULL)
unix_error (errno, (char *) "fopen", filenamev);
if (do_parse (&context, in) != 0) {
fclose (in);
caml_invalid_argument ("parse error");
}
if (fclose (in) == EOF)
unix_error (errno, (char *) "fclose", filenamev);
/* Convert the parsed data to OCaml structures. */
nr_sections = 0;
for (sections = context.parsed_index; sections != NULL; sections = sections->next)
nr_sections++;
rv = caml_alloc (nr_sections, 0);
for (i = 0, sections = context.parsed_index; sections != NULL;
i++, sections = sections->next) {
struct field *fields;
size_t j, nr_fields;
nr_fields = 0;
for (fields = sections->fields; fields != NULL; fields = fields->next)
nr_fields++;
fv = caml_alloc (nr_fields, 0);
for (j = 0, fields = sections->fields; fields != NULL;
j++, fields = fields->next) {
v = caml_alloc_tuple (3);
sv = caml_copy_string (fields->key);
Store_field (v, 0, sv); /* (key, Some subkey, value) */
if (fields->subkey) {
sv2 = caml_copy_string (fields->subkey);
sv = caml_alloc (1, 0);
Store_field (sv, 0, sv2);
} else
sv = Val_int (0);
Store_field (v, 1, sv);
sv = caml_copy_string (fields->value);
Store_field (v, 2, sv);
Store_field (fv, j, v); /* assign to return array of fields */
}
v = caml_alloc_tuple (2);
sv = caml_copy_string (sections->name);
Store_field (v, 0, sv); /* (name, fields) */
Store_field (v, 1, fv);
Store_field (rv, i, v); /* assign to return array of sections */
}
/* Free parsed data. */
parse_context_free (&context);
CAMLreturn (rv);
}

View File

@@ -1,144 +0,0 @@
/* libguestfs virt-builder tool -*- fundamental -*-
* 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.
*/
%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);
%}
%option nounput
%option noyywrap
%option yylineno
%option reentrant
%option bison-bridge
%option bison-locations
%%
/* Apart from the PGP prologue/epilogue which is a hack, the
* scanning strategy is to deal with the file strictly line by
* line, and pass those lines up to the parser which deals with
* whether they appear in the right order to be meaningful.
* Note that flex does longest-match.
*/
/* Ignore comments - '#' MUST appear at the start of a line. */
^"#".*\n { yyextra->seen_comments++; }
/* An empty line is significant. */
^\n { return EMPTY_LINE; }
/* [...] marks beginning of a section. */
^"["[-A-Za-z0-9._]+"]"\n {
yylval->str = strndup (yytext+1, yyleng-3);
return SECTION_HEADER;
}
/* field=value or field[subfield]=value */
^[A-Za-z0-9_.]+("["[A-Za-z0-9_,.]+"]")?"=".*\n {
size_t i = strcspn (yytext, "=[");
yylval->field = malloc (sizeof (struct field));
yylval->field->next = NULL;
yylval->field->key = strndup (yytext, i);
if (yytext[i] == '[') {
size_t j = strcspn (yytext+i+1, "]");
yylval->field->subkey = strndup (yytext+i+1, j);
i += 1+j+1;
} else {
yylval->field->subkey = NULL;
}
/* Note we chop the final \n off here. */
yylval->field->value = strndup (yytext+i+1, yyleng-(i+2));
return FIELD;
}
/* Continuation line for multi-line values. */
^[[:blank:]].*\n {
yylval->str = strndup (yytext+1, yyleng-2);
return VALUE_CONT;
}
/* Hack to eat the PGP prologue. */
^"-----BEGIN PGP SIGNED MESSAGE-----\n" {
int c, prevnl = 0;
/* Eat everything to the first blank line. */
while ((c = input (yyscanner)) != EOF) {
if (c == '\n' && prevnl)
break;
prevnl = c == '\n';
}
return PGP_PROLOGUE;
}
/* Hack to eat the PGP epilogue. */
^"-----BEGIN PGP SIGNATURE-----\n" {
/* Eat everything to the end of the file. */
while (input (yyscanner) != EOF)
;
return PGP_EPILOGUE;
}
/* anything else is an error */
. {
return UNKNOWN_LINE;
}
%%
void
scanner_init (yyscan_t *scanner, struct parse_context *context, FILE *in)
{
yylex_init (scanner);
yyset_extra (context, *scanner);
yyset_in (in, *scanner);
}
void
scanner_destroy (yyscan_t scanner)
{
yylex_destroy (scanner);
}

View File

@@ -1,60 +0,0 @@
/* libguestfs virt-builder tool
* 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.
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "index-struct.h"
void
parse_context_init (struct parse_context *context)
{
memset (context, 0, sizeof *context);
}
void
parse_context_free (struct parse_context *context)
{
section_free (context->parsed_index);
}
void
section_free (struct section *section)
{
if (section) {
section_free (section->next);
free (section->name);
field_free (section->fields);
free (section);
}
}
void
field_free (struct field *field)
{
if (field) {
field_free (field->next);
free (field->key);
free (field->subkey);
free (field->value);
free (field);
}
}

View File

@@ -1,67 +0,0 @@
/* libguestfs virt-builder tool
* 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.
*/
/* The data structures produced when parsing the index file. */
#ifndef INDEX_STRUCT_H
#define INDEX_STRUCT_H
/* A section or list of sections. */
struct section {
struct section *next;
char *name;
struct field *fields;
};
/* A field or list of fields. */
struct field {
struct field *next;
char *key;
char *subkey;
char *value;
};
/* A struct holding the data needed during the parsing. */
struct parse_context {
struct section *parsed_index; /* The result of the parsing. */
/* yyparse sets this if any comments were seen. Required for checking
* compatibility with virt-builder 1.24.
*/
int seen_comments;
const char *input_file;
const char *progname;
const char *error_suffix;
};
/* Initialize the content of a parse_context. */
extern void parse_context_init (struct parse_context *state);
/* Free the content of a parse_context. The actual pointer is not freed. */
extern void parse_context_free (struct parse_context *state);
/* Free the content of a section, recursively freeing also its fields.
* The actual pointer is not freed.
*/
extern void section_free (struct section *section);
/* Free the content of a field, recursively freeing also its next field.
* The actual pointer is not freed.
*/
extern void field_free (struct field *field);
#endif /* INDEX_STRUCT_H */

View File

@@ -1,185 +0,0 @@
/* libguestfs virt-builder tool
* 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.
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#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 "index-struct.h"
#include "index-parse.h"
extern int do_parse (struct parse_context *context, FILE *in);
static void
usage (int exit_status)
{
printf ("%s index\n", guestfs_int_program_name);
exit (exit_status);
}
int
main (int argc, char *argv[])
{
enum { HELP_OPTION = CHAR_MAX + 1 };
static const char *options = "V";
static const struct option long_options[] = {
{ "help", 0, 0, HELP_OPTION },
{ "compat-1.24.0", 0, 0, 0 },
{ "compat-1.24.1", 0, 0, 0 },
{ "version", 0, 0, 'V' },
{ 0, 0, 0, 0 }
};
int c;
int option_index;
int compat_1_24_0 = 0;
int compat_1_24_1 = 0;
const char *input;
struct section *sections;
struct parse_context context;
FILE *in;
int ret;
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEBASEDIR);
textdomain (PACKAGE);
parse_context_init (&context);
for (;;) {
c = getopt_long (argc, argv, options, long_options, &option_index);
if (c == -1) break;
switch (c) {
case 0: /* options which are long only */
if (STREQ (long_options[option_index].name, "compat-1.24.0"))
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
error (EXIT_FAILURE, 0,
_("unknown long option: %s (%d)"),
long_options[option_index].name, option_index);
break;
case 'V':
printf ("%s %s%s\n",
guestfs_int_program_name,
PACKAGE_VERSION, PACKAGE_VERSION_EXTRA);
exit (EXIT_SUCCESS);
case HELP_OPTION:
usage (EXIT_SUCCESS);
default:
usage (EXIT_FAILURE);
}
}
if (optind != argc-1)
usage (EXIT_FAILURE);
input = argv[optind++];
in = fopen (input, "r");
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"),
guestfs_int_program_name, input);
}
if (ret != 0) {
parse_context_free (&context);
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);
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. */
for (sections = context.parsed_index; sections != NULL; sections = sections->next) {
int seen_sig = 0;
struct field *fields;
if (compat_1_24_0) {
if (strchr (sections->name, '_')) {
parse_context_free (&context);
error (EXIT_FAILURE, 0,
_("%s: section [%s] has invalid characters which will not work with virt-builder 1.24.0"),
input, sections->name);
}
}
for (fields = sections->fields; fields != NULL; fields = fields->next) {
if (compat_1_24_0) {
if (strchr (fields->key, '[') ||
strchr (fields->key, ']')) {
parse_context_free (&context);
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);
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"))
seen_sig = 1;
}
if (compat_1_24_0 && !seen_sig) {
parse_context_free (&context);
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);
}
}
/* Free the parsed data. */
parse_context_free (&context);
printf ("%s validated OK\n", input);
exit (EXIT_SUCCESS);
}

View File

@@ -1,96 +0,0 @@
(* virt-builder
* Copyright (C) 2013-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.
*)
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 *)
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 : Downloader.proxy_mode;
}
let print_entry chan (name, { printable_name = printable_name;
file_uri = file_uri;
arch = arch;
osinfo = osinfo;
signature_uri = signature_uri;
checksums = checksums;
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;
may (fp "name=%s\n") printable_name;
may (fp "osinfo=%s\n") osinfo;
fp "file=%s\n" file_uri;
fp "arch=%s\n" arch;
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);
may (fp "format=%s\n") format;
fp "size=%Ld\n" size;
may (fp "compressed_size=%Ld\n") compressed_size;
may (fp "expand=%s\n") expand;
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;
(match aliases with
| None -> ()
| Some l -> fp "aliases=%s\n" (String.concat " " l)
);
if hidden then fp "hidden=true\n"

View File

@@ -1,41 +0,0 @@
(* virt-builder
* Copyright (C) 2013-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.
*)
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 : Downloader.proxy_mode;
}
val print_entry : out_channel -> (string * entry) -> unit

View File

@@ -1,230 +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
open Printf
open Unix
let get_index ~downloader ~sigchecker
{ Sources.uri = uri; proxy = 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
in
let rec get_index () =
(* Get the index page. *)
let tmpfile, delete_tmpfile = Downloader.download downloader ~proxy uri in
(* Check index file signature (also verifies it was fully
* downloaded and not corrupted in transit).
*)
Sigchecker.verify sigchecker tmpfile;
(* Try parsing the file. *)
let sections = Ini_reader.read_ini tmpfile in
if delete_tmpfile then
(try Unix.unlink tmpfile with _ -> ());
(* Check for repeated os-version+arch combination. *)
let name_arch_map = List.map (
fun (n, fields) ->
let rec find_arch = function
| ("arch", None, value) :: y -> value
| _ :: y -> find_arch y
| [] -> ""
in
n, (find_arch fields)
) sections in
let nseen = Hashtbl.create 13 in
List.iter (
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;
corrupt_file ()
);
Hashtbl.add nseen id true
) name_arch_map;
(* Check for repeated fields. *)
List.iter (
fun (n, fields) ->
let fseen = Hashtbl.create 13 in
List.iter (
fun (field, subkey, _) ->
let hashkey = (field, subkey) in
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
| None ->
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
) fields
) sections;
(* Turn the sections into the final index. *)
let entries =
List.map (
fun (n, fields) ->
let fields = List.map (fun (k, sk, v) -> (k, sk), v) fields in
let printable_name =
try Some (List.assoc ("name", None) fields) with Not_found -> None in
let osinfo =
try Some (List.assoc ("osinfo", None) fields) with Not_found -> None in
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;
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;
corrupt_file () in
let signature_uri =
try Some (make_absolute_uri (List.assoc ("sig", None) fields))
with Not_found -> None in
let checksum_sha512 =
try Some (List.assoc ("checksum", Some "sha512") fields)
with Not_found ->
try Some (List.assoc ("checksum", None) fields)
with Not_found -> None in
let revision =
try Rev_int (int_of_string (List.assoc ("revision", None) fields))
with
| Not_found -> Rev_int 1
| Failure "int_of_string" ->
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
let size =
try Int64.of_string (List.assoc ("size", None) fields)
with
| Not_found ->
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;
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")
prog n;
corrupt_file () in
let expand =
try Some (List.assoc ("expand", None) fields) with Not_found -> None in
let lvexpand =
try Some (List.assoc ("lvexpand", None) fields) with Not_found -> None in
let notes =
let rec loop = function
| [] -> []
| (("notes", subkey), value) :: xs ->
let subkey = match subkey with
| None -> ""
| Some v -> v in
(subkey, value) :: loop xs
| _ :: xs -> loop xs in
List.sort (
fun (k1, _) (k2, _) ->
String.compare k1 k2
) (loop fields) in
let hidden =
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")
prog n;
corrupt_file () in
let aliases =
let l =
try String.nsplit " " (List.assoc ("aliases", None) fields)
with Not_found -> [] in
match l with
| [] -> None
| l -> Some l in
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;
checksums = checksums;
revision = revision;
format = format;
size = size;
compressed_size = compressed_size;
expand = expand;
lvexpand = lvexpand;
notes = notes;
hidden = hidden;
aliases = aliases;
proxy = proxy;
sigchecker = sigchecker } in
n, entry
) sections in
if verbose () then (
printf "index file (%s) after parsing (C parser):\n" uri;
List.iter (Index.print_entry Pervasives.stdout) entries
);
entries
(* Verify same-origin policy for the file= and sig= fields. *)
and make_absolute_uri path =
if String.length path = 0 then (
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;
corrupt_file ()
)
else if path.[0] = '/' then (
eprintf (f_"%s: you must use relative paths (not '%s') in the index file\n") prog path;
corrupt_file ()
)
else (
(* Construct the URI. *)
try
let i = String.rindex uri '/' in
String.sub uri 0 (i+1) ^ path
with
Not_found -> uri // path
)
in
get_index ()

View File

@@ -1,19 +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.
*)
val get_index : downloader:Downloader.t -> sigchecker:Sigchecker.t -> Sources.source -> Index.index

View File

@@ -1,40 +0,0 @@
(* virt-builder
* Copyright (C) 2013-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.
*)
open Common_utils
type sections = section list
and section = string * fields (* [name] + fields *)
and fields = field list
and field = string * string option * string (* key + subkey + value *)
(* Types returned by the C index parser. *)
type c_sections = c_section array
and c_section = string * c_fields (* [name] + fields *)
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 ?(error_suffix = "") file =
let sections = parse_index ~prog ~error_suffix file in
let sections = Array.to_list sections in
List.map (
fun (n, fields) ->
n, Array.to_list fields
) sections

View File

@@ -1,57 +0,0 @@
(* virt-builder
* Copyright (C) 2013-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.
*)
open Common_utils
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
let territory = match_or_empty 3 in
(match territory with
| "" -> ()
| territory -> l := (lang ^ "_" ^ territory) :: !l);
l := lang :: !l;
);
l := "" :: !l;
List.rev !l
let languages () =
match Setlocale.setlocale Setlocale.LC_MESSAGES None with
| None -> [""]
| Some locale -> split_locale locale
let find_notes languages notes =
let notes = List.fold_left (
fun acc lang ->
let res = List.filter (
fun (langkey, _) ->
match langkey with
| "C" -> lang = ""
| langkey -> langkey = lang
) notes in
match res with
| (_, noteskey) :: _ -> noteskey :: acc
| [] -> acc
) [] languages in
List.rev notes

View File

@@ -1,3 +0,0 @@
[libguestfs.org]
uri=http://libguestfs.org/download/builder/index.asc
gpgkey=file://@SYSCONFDIR@/xdg/virt-builder/repos.d/libguestfs.gpg

View File

@@ -1,64 +0,0 @@
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.14 (GNU/Linux)
mQINBE6UMMEBEADM811hfTulaF4JpkVpAI10FImyb4ArvOiu8NdcUwTFo+cyWno3
U85B86H1Bsk/LgLTYtthSrTgsCtdxy+i5OaMjxZDIwKQ2+IYI3FCn9T3Mn28Idyh
kLHzrO9ph0Dv0BNfrlDZhQEC53aAFe/QxN7+A49BNBV7D1VAOOCsHjxMEDzcZkCa
oCrtXw1aNm2vkkj5ukbfukHAyLcQL7kow0qKPSVa1G4lfQP0WiG259Ydy+sUmbVb
TGdb6MEC84PQRDuw6/ZeoV04tn7ZNtQEMOS0uiciHOGfr2hBxQf9VIPNrHg42yaL
dOv51D99GuaxZ9E0HSoH/RwB1oXgd6rFdqVNYaBIQnnkwJANUEeGBArtIOZNCADT
Bt8vkSDm+lLEAFS+V8CACyW/LMIrGCvLdHeqtoAv0GDVyR2GPxldYfdtEmCUMWcb
Jlf71V9iAse2gUdoiHp5FfpGMkA5j7idKuxIws11XxRZJXXbBqiBqmVEAQ/v0m6p
kdo0MYTHydmecLuUK2bAGhpysfX97EfTSrxfrYphYWjTfKRD9GrADeZNfuz1DbKs
7LSqVaQJSjQrfgAwcnZLRaU0V4P5zxiz50gz1Aj3AZRL+Y3meZenzZTXcLFdnusg
wUfhhCuL3tluMtEh6tznumyxb43WO1yLwj6J6LtveiuJN1Z+KSQ6OieZcwARAQAB
tCVSaWNoYXJkIFcuTS4gSm9uZXMgPHJpY2hAYW5uZXhpYS5vcmc+iQI4BBMBAgAi
BQJOlDDBAhsDBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAKCRCRc49z4bdooHQY
D/wJLklSZNyXIW+rG5sUbg7j9cTIF5p/lB9kI2yx6KodJp/2knKyvnmzz0gBw/OE
HL4E4UW26oWKo+36I8wkBnuGa6UtANeITcJqFE19VpHEXHsxre64jNQnO8/w748W
1ROW+Ry43xmrlRWKuCm4oPYUzlp0fq9ATAne8eblfG+NOs8DYuA8xZNQzFaI2kDC
QLD4YoXLoNsP27Koga36b0KwxPFD9tyVZiu9XDH/3hMN7Nb15B66PFr+HcMmQ67G
nUIN5ulcIwj38i40cyaTs1VRheOzTHXE/a6Q2AhMKiKqOoEjQ73/mV7cAVoPtM3o
83Q/8aVKBH0bVRwAeV1tju6b14fqKoG0zNBEcXdlSkht6ScxJYIc/LPUxAMDwgSE
OWshjmeRzKXypBbHn/DP8QVyM2gk5wY+mMSH7MpR0p/hgj+rFO8H9L7pC4dCog3E
qzrYhRN+TaP6MPH3WkOwPH4d4IfQRFnHp+VPYPijKEiLrUl/o8k3DyAanAPBpJ/x
na4wXAjlFBctOq6g+SrCUiHpwk7b2YNwGgr5Vl3GmZELzK/G8gg3uJYKQ9Bpv16t
WWOz+IFiOFa0UULeo0QPmFAIMZiDojNsY1SwBKB3ZL1YWZezgMdQAbpze/IXoSt7
zxWJoKH2jK7q9mvFiaY12l2YnKuCcegWVAViLxRpBnrbz7QmUmljaGFyZCBXLk0u
IEpvbmVzIDxyam9uZXNAcmVkaGF0LmNvbT6JAjgEEwECACIFAk6UOQsCGwMGCwkI
BwMCBhUIAgkKCwQWAgMBAh4BAheAAAoJEJFzj3Pht2igIUYQAKomI0edLakahsUQ
MxOZuhBbXJ4/VWF8bXYChDNPKvJp5nB7fBXujJ+39cIUM5fe2ViO6qSDpFC29imx
F5pPbAqspZBPBkLLiZLji8R42hGarntdtTW0UWSBpq+nC5+G1psrnATI3uXGNxKQ
R99c5HoMY7dBC2Y8TCGE64NINZ/XVh472s6IGLPn8MTn26YdRKC9BrVkCFMP2OBr
6D4IprnyTAWAzb68ew20QmyWO+NBi9MplaDNQVl8PIOgfpyWlkgX1z9m67pcSDkw
46hksp0yuOD1VwR4iVZ2/CmIsGRUlx41vWD6BIp9KxKyDIU1CYTRhq72dahHsl/8
BjCndV5PO0GphqfCzmCv4DXjUwmrMTbH/GFnt5rfwcMcXUgcK0vV9vQ2SOU56Zd1
fb27ZCFJKZc0Fu8krwFldCp/NYILf6ogUL/C1hfuCGSSuyDVY16Gg3dla1x+6zpF
asnWQlaw8xT5LlMWvTZs5WsoSVHu7dVZWlgxINP++hlZrTz/S8l38yyQ15YFFl3W
9M7dzkegOeDTPfx6B89WgfvfJjA/D0/FYxxWPXEtrn9DlJ4daEJqNsrvfLErz9R8
4IQmfmhR93j+rdotner+6keC/wVByEfbW1wmXtmFKXQ6srdpj8VKRFrvkyXVgepM
DypLgRH2v7lL2kdWhUu2y4EAgrwzuQINBE6UMMEBEADxQxMgUuDrw5GT4tqARTPI
SSdNcUsRxRhVA8srYOyECliE+B3TwcRDFBs+MyPFJVEuX8fi4eGj/AK5t1GHerfk
orUGlz72q4c7LLhkfZrsuJbk2dgkjvldKJnIazQJa6epGLqdsE5RlmSgwedIbtMd
naGJBQH8aKP/Wi1+wUxsm5N3p7+R2WRx48VfpEhYB+Zf/FkFm1Ycjwh57KQ0+OHw
ykf8VfMisxuH30tDxOCV+VptWKfOF2rDNdaNPWhij2YIjhJXRpkuRR+1PpI4jLaD
JxcVZmG/0zucacupUN2g5OUH59ySU/totD6YMnmp3FONoyF1uIEJo6Vs30npHGkO
XgBo3Pxt7oLJeykLPtdSLgm3cwXIYMWarVsAkKNXitQIVGpVRLeaK373VwmXFqoi
M2SMHeawTUdOORFjpQzkknlJWM1TmUVtHHKt8Pl9+/5+wXKyt2IDdcUkMrB6K5qF
fb7EwVhoI8ehJQK+eeDCjFwCAiwB3iV8JlyW+tEU7JuyXOQlwY1VWm/WqMD8gaRi
rT+RFDFliZ3tQbW2pqUoZBROV5HN4tieDfwxGKCvk6Tsdb30zA9DPQp93+238bYf
312sg9R+CD0AqxoxFG5FJu4HShcPRrPnYtRZqKRe40GDWvBEArXZprwL1qrP+Kl/
mRrEQpxAGIoFG8HbVvD3EQARAQABiQIfBBgBAgAJBQJOlDDBAhsMAAoJEJFzj3Ph
t2igSLQP/2uIrAY2CDr0kWBJiD3TztiHy8IdxwUpyTBTebwmAbi44/EvtJfIisrG
YjKIEv/w0E61gO7O1JBG4+IG93W+v9fTT/e39JMyxsYqoZZHUhP11Okx5grDS5b0
O8VXOmXVRMdVNfstRBr10HD9uNDq7ruKD18TxYTwN0GPD4gj1dbHQDR77Tr5cyBs
6Ou5PBOH4r3qcqf/cJUSMeUUu75xLwixux6E7tD2S+t6F07wlWxntUcPtzyAHj20
J89orUC+dT6r6MypBoI0jdJCp9JPGtR7i+fE5Gm4E5+AUSubLPtZGRY9Um2eMoS2
DnQpGOKx1VvsixR/Kw44j2tRAvmYMS4iDKcuZU+nZ+xokAgObILj/b9n/Qe2/fXy
CFdcgSvbm+dV1fZxsdMF/P9OU8aqdT9A9Fv5y+cDMEg4DVnhwMJTxGh/TCkw/H+A
frHEtRc98lSQN5odpITNG17mG6JOdHM+wA57qHH0uy4+5RsbyAJahcdBcmObK/RF
i4WZlThpbHftX5O/LH98aYQ2fJayIxv1EAjzOBOQ0MfBHI0KCJR1pysEisX28sJA
Ic73gnJJ3BLZbqfBRgxjNMNroxC+5Tw6uPGFHa3YnuIAxxw0HcDVZ9vnTWBWFPGw
ZvXkQ3FVJwZoLmHw47vvlVpLD/4gi1SuHWieRvZ+UdDq00E348pm
=neBW
-----END PGP PUBLIC KEY BLOCK-----

View File

@@ -1,159 +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 Printf
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
and list_entries_short index =
List.iter (
fun (name, { Index.printable_name = printable_name;
arch = arch;
hidden = hidden }) ->
if not hidden then (
printf "%-24s" name;
printf " %-10s" arch;
may (printf " %s") printable_name;
printf "\n"
)
) index
and list_entries_long ~sources index =
let langs = Languages.languages () in
List.iter (
fun { Sources.uri = uri; gpgkey = gpgkey } ->
printf (f_"Source URI: %s\n") uri;
(match gpgkey with
| Utils.No_Key -> ()
| Utils.Fingerprint fp ->
printf (f_"Fingerprint: %s\n") fp;
| Utils.KeyFile kf ->
printf (f_"Key: %s\n") kf;
);
printf "\n"
) sources;
List.iter (
fun (name, { Index.printable_name = printable_name;
arch = arch;
size = size;
compressed_size = compressed_size;
notes = notes;
aliases = aliases;
hidden = hidden }) ->
if not hidden then (
printf "%-24s %s\n" "os-version:" name;
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);
);
let notes = Languages.find_notes langs notes in
(match notes with
| notes :: _ ->
printf "\n";
printf (f_"Notes:\n\n%s\n") notes
| [] -> ()
);
printf "\n"
)
) index
and list_entries_json ~sources index =
let json_sources =
List.map (
fun { Sources.uri = uri; gpgkey = gpgkey } ->
let item = [ "uri", JSON.String uri ] in
let item =
match gpgkey with
| Utils.No_Key -> item
| Utils.Fingerprint fp ->
("fingerprint", JSON.String fp) :: item
| Utils.KeyFile kf ->
("key", JSON.String kf) :: item in
JSON.Dict item
) sources in
let json_templates =
List.map (
fun (name, { Index.printable_name = printable_name;
arch = arch;
size = size;
compressed_size = compressed_size;
notes = notes;
aliases = aliases;
osinfo = osinfo;
hidden = hidden }) ->
let item = [ "os-version", JSON.String name ] in
let item =
match printable_name with
| None -> item
| Some str -> ("full-name", JSON.String str) :: item in
let item = ("arch", JSON.String arch) :: item in
let item = ("size", JSON.Int64 size) :: item in
let item =
match compressed_size with
| None -> item
| Some n -> ("compressed-size", JSON.String (Int64.to_string n)) :: item in
let item =
let json_notes =
List.fold_right (
fun (lang, langnotes) acc ->
let lang =
match lang with
| "" -> "C"
| x -> x in
(lang, JSON.String langnotes) :: acc
) notes [] in
if List.length json_notes = 0 then item
else ("notes", JSON.Dict json_notes) :: item in
let item =
match aliases with
| None -> item
| 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
let doc = [
"version", JSON.Int 1;
"sources", JSON.List json_sources;
"templates", JSON.List json_templates;
] in
print_string (JSON.string_of_doc ~fmt:JSON.Indented doc);
print_newline ()

View File

@@ -1,19 +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.
*)
val list_entries : list_format:([ `Short | `Long | `Json ]) -> sources:Sources.source list -> Index.index -> unit

View File

@@ -1,3 +0,0 @@
[opensuse.org]
uri=http://download.opensuse.org/repositories/Virtualization:/virt-builder-images/images/index
gpgkey=file://@SYSCONFDIR@/xdg/virt-builder/repos.d/opensuse.gpg

View File

@@ -1,21 +0,0 @@
-----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-----

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_utils
let xdg_cache_home =
try Some (Sys.getenv "XDG_CACHE_HOME" // "virt-builder")
with Not_found ->
try Some (Sys.getenv "HOME" // ".cache" // "virt-builder")
with Not_found ->
None (* no cache directory *)
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 () =
let dirs =
try Sys.getenv "XDG_CONFIG_DIRS"
with Not_found -> "/etc/xdg" in
let dirs = String.nsplit ":" dirs in
let dirs = List.filter (fun x -> x <> "") dirs in
List.map (fun x -> x // prog) dirs

View File

@@ -1,716 +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.
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <pthread.h>
#include <caml/alloc.h>
#include <caml/fail.h>
#include <caml/memory.h>
#include <caml/mlvalues.h>
#include "guestfs.h"
#include "guestfs-internal-frontend.h"
#include "ignore-value.h"
#if HAVE_LIBLZMA
#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) && \
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)
{
return PARALLEL_XZCAT ? Val_true : Val_false;
}
#if PARALLEL_XZCAT
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)
{
CAMLparam2 (inputfilev, outputfilev);
#if PARALLEL_XZCAT
/* Parallel implementation of xzcat (pxzcat). */
/* XXX Make number of threads configurable? */
long i;
unsigned nr_threads;
i = sysconf (_SC_NPROCESSORS_ONLN);
if (i <= 0) {
perror ("could not get number of cores");
i = 1;
}
nr_threads = (unsigned) i;
/* NB: This might throw an exception if something fails. If it
* does, this function won't return as a regular C function.
*/
pxzcat (inputfilev, outputfilev, nr_threads);
#else /* !PARALLEL_XZCAT */
/* Fallback: use regular xzcat. */
int fd;
pid_t pid;
int status;
fd = open (String_val (outputfilev), O_WRONLY|O_CREAT|O_TRUNC|O_NOCTTY, 0666);
if (fd == -1)
unix_error (errno, (char *) "open", outputfilev);
pid = fork ();
if (pid == -1) {
int err = errno;
close (fd);
unix_error (err, (char *) "fork", Nothing);
}
if (pid == 0) { /* child - run xzcat */
dup2 (fd, 1);
execlp (XZCAT, XZCAT, String_val (inputfilev), NULL);
perror (XZCAT);
_exit (EXIT_FAILURE);
}
close (fd);
if (waitpid (pid, &status, 0) == -1)
unix_error (errno, (char *) "waitpid", Nothing);
if (!WIFEXITED (status) || WEXITSTATUS (status) != 0)
caml_failwith (XZCAT " program failed, see earlier error messages");
#endif /* !PARALLEL_XZCAT */
CAMLreturn (Val_unit);
}
#if PARALLEL_XZCAT
#define DEBUG 0
#if DEBUG
#define debug(fs,...) fprintf (stderr, "pxzcat: debug: " fs "\n", ## __VA_ARGS__)
#else
#define debug(fs,...) /* nothing */
#endif
/* Size of buffers used in decompression loop. */
#define BUFFER_SIZE (64*1024)
#define XZ_HEADER_MAGIC "\xfd" "7zXZ\0"
#define XZ_HEADER_MAGIC_LEN 6
static int check_header_magic (int fd);
static lzma_index *parse_indexes (value filenamev, int fd);
static void iter_blocks (lzma_index *idx, unsigned nr_threads, value filenamev, int fd, value outputfilev, int ofd);
static void
pxzcat (value filenamev, value outputfilev, unsigned nr_threads)
{
int fd, ofd;
uint64_t size;
lzma_index *idx;
/* Open the file. */
fd = open (String_val (filenamev), O_RDONLY);
if (fd == -1)
unix_error (errno, (char *) "open", filenamev);
guestfs_int_fadvise_noreuse (fd);
guestfs_int_fadvise_random (fd);
/* Check file magic. */
if (!check_header_magic (fd)) {
close (fd);
caml_invalid_argument ("input file is not an xz file");
}
/* Read and parse the indexes. */
idx = parse_indexes (filenamev, fd);
/* Get the file uncompressed size, create the output file. */
size = lzma_index_uncompressed_size (idx);
debug ("uncompressed size = %" PRIu64 " bytes", size);
/* Avoid annoying ext4 auto_da_alloc which causes a flush on close
* unless we are very careful about not truncating a regular file
* from non-zero size to zero size. (Thanks Eric Sandeen)
*/
ofd = open (String_val (outputfilev), O_WRONLY|O_CREAT|O_NOCTTY, 0644);
if (ofd == -1) {
int err = errno;
close (fd);
unix_error (err, (char *) "open", outputfilev);
}
guestfs_int_fadvise_random (ofd);
if (ftruncate (ofd, 1) == -1) {
int err = errno;
close (fd);
unix_error (err, (char *) "ftruncate", outputfilev);
}
if (lseek (ofd, 0, SEEK_SET) == -1) {
int err = errno;
close (fd);
unix_error (err, (char *) "lseek", outputfilev);
}
if (write (ofd, "\0", 1) == -1) {
int err = errno;
close (fd);
unix_error (err, (char *) "write", outputfilev);
}
if (ftruncate (ofd, size) == -1) {
int err = errno;
close (fd);
unix_error (err, (char *) "ftruncate", outputfilev);
}
/* Iterate over blocks. */
iter_blocks (idx, nr_threads, filenamev, fd, outputfilev, ofd);
lzma_index_end (idx, NULL);
if (close (fd) == -1)
unix_error (errno, (char *) "close", filenamev);
if (close (ofd) == -1)
unix_error (errno, (char *) "close", outputfilev);
}
static int
check_header_magic (int fd)
{
char buf[XZ_HEADER_MAGIC_LEN];
if (lseek (fd, 0, SEEK_SET) == -1)
return 0;
if (read (fd, buf, XZ_HEADER_MAGIC_LEN) != XZ_HEADER_MAGIC_LEN)
return 0;
if (memcmp (buf, XZ_HEADER_MAGIC, XZ_HEADER_MAGIC_LEN) != 0)
return 0;
return 1;
}
/* For explanation of this function, see src/xz/list.c:parse_indexes
* in the xz sources.
*/
static lzma_index *
parse_indexes (value filenamev, int fd)
{
lzma_ret r;
off_t pos, index_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;
ssize_t n;
lzma_index *combined_index = NULL;
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, (char *) "lseek", filenamev);
if ((pos & 3) != 0)
caml_invalid_argument ("input not an xz file: size is not a multiple of 4 bytes");
/* Jump backwards through the file identifying each stream. */
while (pos > 0) {
debug ("looping through streams: pos = %" PRIu64, (uint64_t) pos);
if (pos < LZMA_STREAM_HEADER_SIZE)
caml_invalid_argument ("corrupted xz file");
if (lseek (fd, -LZMA_STREAM_HEADER_SIZE, SEEK_CUR) == -1)
unix_error (errno, (char *) "lseek", filenamev);
if (read (fd, footer, LZMA_STREAM_HEADER_SIZE) != LZMA_STREAM_HEADER_SIZE)
unix_error (errno, (char *) "read", filenamev);
/* Skip stream padding. */
if (footer[8] == 0 && footer[9] == 0 &&
footer[10] == 0 && footer[11] == 0) {
stream_padding += 4;
pos -= 4;
continue;
}
pos -= LZMA_STREAM_HEADER_SIZE;
nr_streams++;
debug ("decode stream footer at pos = %" PRIu64, (uint64_t) pos);
/* Does the stream footer look reasonable? */
r = lzma_stream_footer_decode (&footer_flags, footer);
if (r != LZMA_OK) {
fprintf (stderr, "invalid stream footer - error %u\n", r);
caml_invalid_argument ("invalid stream footer");
}
debug ("backward_size = %" PRIu64, (uint64_t) footer_flags.backward_size);
index_size = footer_flags.backward_size;
if (pos < index_size + LZMA_STREAM_HEADER_SIZE)
caml_invalid_argument ("invalid stream footer");
pos -= index_size;
debug ("decode index at pos = %" PRIu64, (uint64_t) pos);
/* Seek backwards to the index of this stream. */
if (lseek (fd, pos, SEEK_SET) == -1)
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 %u\n", r);
caml_invalid_argument ("invalid stream index");
}
do {
strm.avail_in = index_size;
if (strm.avail_in > BUFSIZ)
strm.avail_in = BUFSIZ;
n = read (fd, buf, strm.avail_in);
if (n == -1)
unix_error (errno, (char *) "read", filenamev);
index_size -= strm.avail_in;
strm.next_in = buf;
r = lzma_code (&strm, LZMA_RUN);
} while (r == LZMA_OK);
if (r != LZMA_STREAM_END) {
fprintf (stderr, "could not parse index - error %u\n", r);
caml_invalid_argument ("could not parse index");
}
pos -= lzma_index_total_size (this_index) + LZMA_STREAM_HEADER_SIZE;
debug ("decode stream header at pos = %" PRIu64, (uint64_t) pos);
/* Read and decode the stream header. */
if (lseek (fd, pos, SEEK_SET) == -1)
unix_error (errno, (char *) "lseek", filenamev);
if (read (fd, header, LZMA_STREAM_HEADER_SIZE) != LZMA_STREAM_HEADER_SIZE)
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 %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 %u\n",
r);
caml_invalid_argument ("header and footer of stream are not equal");
}
/* 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 %u\n", r);
caml_invalid_argument ("cannot read stream_flags from index");
}
/* Store the amount of stream padding so far. Needed to calculate
* compressed offsets correctly in multi-stream files.
*/
r = lzma_index_stream_padding (this_index, stream_padding);
if (r != LZMA_OK) {
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 %u\n", r);
caml_invalid_argument ("cannot combine indexes");
}
}
combined_index = this_index;
this_index = NULL;
}
lzma_end (&strm);
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.
*/
lzma_index_iter iter;
lzma_bool iter_finished;
pthread_mutex_t iter_mutex;
/* Note that all threads are accessing these fds, so you have
* to use pread/pwrite instead of lseek!
*/
/* Input file. */
const char *filename;
int fd;
/* Output file. */
const char *outputfile;
int ofd;
};
struct per_thread_state {
unsigned thread_num;
struct global_state *global;
int status;
};
/* Create threads to iterate over the blocks and uncompress. */
static void *worker_thread (void *vp);
static void
iter_blocks (lzma_index *idx, unsigned nr_threads,
value filenamev, int fd, value outputfilev, int ofd)
{
struct global_state global;
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, (char *) "pthread_mutex_init", Nothing);
global.filename = String_val (filenamev);
global.fd = fd;
global.outputfile = String_val (outputfilev);
global.ofd = ofd;
for (u = 0; u < nr_threads; ++u) {
per_thread[u].thread_num = u;
per_thread[u].global = &global;
}
/* Start the 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, (char *) "pthread_create", Nothing);
}
/* Wait for the threads to exit. */
nr_errors = 0;
for (u = 0; u < nr_threads; ++u) {
err = pthread_join (thread[u], &status);
if (err != 0) {
fprintf (stderr, "pthread_join (%u): %s\n", u, strerror (err));
nr_errors++;
}
if (*(int *)status == -1)
nr_errors++;
}
if (nr_errors > 0)
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)
{
struct per_thread_state *state = vp;
struct global_state *global = state->global;
lzma_index_iter iter;
int err;
off_t position, oposition;
CLEANUP_FREE uint8_t *header = NULL;
ssize_t n;
lzma_block block;
CLEANUP_FREE lzma_filter *filters = NULL;
lzma_ret r;
lzma_stream strm = LZMA_STREAM_INIT;
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);
if (err != 0) abort ();
iter_finished = global->iter_finished;
if (!iter_finished) {
iter_finished = global->iter_finished =
lzma_index_iter_next (&global->iter, LZMA_INDEX_ITER_NONEMPTY_BLOCK);
if (!iter_finished)
/* Take a local copy of this iterator since another thread will
* update the global version.
*/
iter = global->iter;
}
err = pthread_mutex_unlock (&global->iter_mutex);
if (err != 0) abort ();
if (iter_finished)
break;
/* Read the block header. Start by reading a single byte which
* tell us how big the block header is.
*/
position = iter.block.compressed_file_offset;
n = pread (global->fd, header, 1, position);
if (n == 0) {
fprintf (stderr,
"%s: read: unexpected end of file reading block header byte\n",
global->filename);
return &state->status;
}
if (n == -1) {
perror (String_val (global->filename));
return &state->status;
}
position++;
if (header[0] == '\0') {
fprintf (stderr,
"%s: read: unexpected invalid block in file, header[0] = 0\n",
global->filename);
return &state->status;
}
block.version = 0;
block.check = iter.stream.flags->check;
block.filters = filters;
block.header_size = lzma_block_header_size_decode (header[0]);
/* Now read and decode the block header. */
n = pread (global->fd, &header[1], block.header_size-1, position);
if (n >= 0 && n != (ssize_t) block.header_size-1) {
fprintf (stderr,
"%s: read: unexpected end of file reading block header\n",
global->filename);
return &state->status;
}
if (n == -1) {
perror (global->filename);
return &state->status;
}
position += n;
r = lzma_block_header_decode (&block, NULL, header);
if (r != LZMA_OK) {
fprintf (stderr, "%s: invalid block header (error %u)\n",
global->filename, r);
return &state->status;
}
/* What this actually does is it checks that the block header
* matches the index.
*/
r = lzma_block_compressed_size (&block, iter.block.unpadded_size);
if (r != LZMA_OK) {
fprintf (stderr,
"%s: cannot calculate compressed size (error %u)\n",
global->filename, r);
return &state->status;
}
/* Where we will start writing to. */
oposition = iter.block.uncompressed_file_offset;
/* Read the block data and uncompress it. */
r = lzma_block_decoder (&strm, &block);
if (r != LZMA_OK) {
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 = BUFFER_SIZE;
for (;;) {
lzma_action action = LZMA_RUN;
if (strm.avail_in == 0) {
strm.next_in = buf;
n = pread (global->fd, buf, BUFFER_SIZE, position);
if (n == -1) {
perror (global->filename);
return &state->status;
}
position += n;
strm.avail_in = n;
if (n == 0)
action = LZMA_FINISH;
}
r = lzma_code (&strm, action);
if (strm.avail_out == 0 || r == LZMA_STREAM_END) {
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 (xpwrite (global->ofd, outbuf, wsz, oposition) == -1) {
perror (global->outputfile);
return &state->status;
}
}
oposition += wsz;
strm.next_out = 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 %u)\n",
global->filename, r);
return &state->status;
}
}
lzma_end (&strm);
for (i = 0; filters[i].id != LZMA_VLI_UNKNOWN; ++i)
free (filters[i].options);
}
state->status = 0;
return &state->status;
}
#endif /* PARALLEL_XZCAT */

View File

@@ -1,20 +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.
*)
external pxzcat : string -> string -> unit = "virt_builder_pxzcat"
external using_parallel_xzcat : unit -> bool = "virt_builder_using_parallel_xzcat" "noalloc"

View File

@@ -1,61 +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.
*/
#include <config.h>
#include <locale.h>
#include <caml/alloc.h>
#include <caml/fail.h>
#include <caml/memory.h>
#include <caml/mlvalues.h>
static const int lc_string_table[7] = {
LC_ALL,
LC_CTYPE,
LC_NUMERIC,
LC_TIME,
LC_COLLATE,
LC_MONETARY,
LC_MESSAGES
};
#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)
{
CAMLparam2 (val_category, val_name);
CAMLlocal2 (rv, rv2);
char *ret, *locstring;
int category;
category = lc_string_table[Int_val (val_category)];
locstring = val_name == Val_none ? NULL : String_val (Field (val_name, 0));
ret = setlocale (category, locstring);
if (ret) {
rv2 = caml_copy_string (ret);
rv = caml_alloc (1, 0);
Store_field (rv, 0, rv2);
} else
rv = Val_none;
CAMLreturn (rv);
}

View File

@@ -1,232 +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
open Printf
open Unix
type t = {
gpg : string;
fingerprint : string;
subkeys_fingerprints : string list;
check_signature : bool;
gpghome : string;
}
(* Import the specified key file. *)
let import_keyfile ~gpg ~gpghome ?(trust = true) keyfile =
let status_file = Filename.temp_file "vbstat" ".txt" in
unlink_on_exit status_file;
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 r <> 0 then
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
if verbose () then printf "%s\n%!" cmd;
let r = Sys.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
if verbose () then printf "%s\n%!" cmd;
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 (
subkeys := id :: !subkeys;
);
current := None
)
| _ -> ()
) lines;
!subkeys in
!fingerprint, subkeys
let rec create ~gpg ~gpgkey ~check_signature =
(* Create a temporary directory for gnupg. *)
let tmpdir = Mkdtemp.temp_dir "vb.gpghome." "" in
rmdir_on_exit tmpdir;
(* 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, 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
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.");
match gpgkey with
| No_Key ->
assert false
| KeyFile kf ->
import_keyfile gpg tmpdir kf
| Fingerprint fp ->
let filename = Filename.temp_file "vbpubkey" ".asc" in
unlink_on_exit filename;
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 r <> 0 then
error (f_"could not export public key\nUse the '-v' option and look for earlier error messages.");
import_keyfile gpg tmpdir filename
) else
"", [] in
{
gpg = gpg;
fingerprint = fingerprint;
subkeys_fingerprints = subkeys;
check_signature = check_signature;
gpghome = tmpdir;
}
(* Compare two strings of hex digits ignoring whitespace and case. *)
and equal_fingerprints fp1 fp2 =
let len1 = String.length fp1 and len2 = String.length fp2 in
let rec loop i j =
if i = len1 && j = len2 then true (* match! *)
else if i = len1 || j = len2 then false (* no match - different lengths *)
else (
let x1 = getxdigit fp1.[i] and x2 = getxdigit fp2.[j] in
match x1, x2 with
| Some x1, Some x2 when x1 = x2 -> loop (i+1) (j+1)
| Some x1, Some x2 -> false (* no match - different content *)
| Some _, None -> loop i (j+1)
| None, Some _ -> loop (i+1) j
| None, None -> loop (i+1) (j+1)
)
in
loop 0 0
and getxdigit = function
| '0'..'9' as c -> Some (Char.code c - Char.code '0')
| 'a'..'f' as c -> Some (Char.code c - Char.code 'a')
| '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
do_verify t args
)
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 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 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 "vbfile" ".asc" in
unlink_on_exit asc_file;
let cmd = sprintf "cp %s %s" (quote filename) (quote asc_file) in
if verbose () then printf "%s\n%!" cmd;
if Sys.command cmd <> 0 then exit 1;
let out_file = Filename.temp_file "vbfile" "" in
unlink_on_exit out_file;
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 "vbstat" ".txt" in
unlink_on_exit status_file;
let cmd =
sprintf "%s --homedir %s %s%s --status-file %s %s"
t.gpg t.gpghome
(if verify_only then "--verify" else "")
(if verbose () then "" else " --batch -q --logger-file /dev/null")
(quote status_file) args in
if verbose () then printf "%s\n%!" cmd;
let r = Sys.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!");
(* Check the fingerprint is who it should be. *)
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:]" :: "VALIDSIG" :: fp :: _ -> fingerprint := fp
| _ -> ()
) status;
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

View File

@@ -1,36 +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.
*)
type t
val create : gpg:string -> gpgkey:Utils.gpgkey_type -> check_signature:bool -> 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). *)
val verify_detached : t -> string -> string option -> unit
(** Verify the file is signed against the detached signature
(if check_signature is true). *)
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

@@ -1,204 +0,0 @@
(* 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 Common_gettext.Gettext
open Common_utils
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 object_find_optional key = function
| Yajl_object o ->
(match List.filter (fun (k, _) -> k = key) (Array.to_list o) with
| [(k, v)] -> Some v
| [] -> None
| _ -> error (f_"more than value for the key '%s'") key)
| _ -> error (f_"the value of the key '%s' is not an object") key
let object_find key yv =
match object_find_optional key yv with
| None -> error (f_"missing value for the key '%s'") key
| Some v -> v
let object_get_string key yv =
match object_find key yv with
| Yajl_string s -> s
| _ -> error (f_"the value for the key '%s' is not a string") key
let object_find_object key yv =
match object_find key yv with
| Yajl_object _ as o -> o
| _ -> error (f_"the value for the key '%s' is not an object") key
let object_find_objects fn = function
| Yajl_object o -> filter_map fn (Array.to_list o)
| _ -> error (f_"the value is not an object")
let object_get_object key yv =
match object_find_object key yv with
| Yajl_object o -> o
| _ -> assert false (* object_find_object already errors out. *)
let object_get_number key yv =
match object_find key yv with
| Yajl_number n -> n
| Yajl_double d -> Int64.of_float d
| _ -> error (f_"the value for the key '%s' is not an integer") key
let objects_get_string key yvs =
let rec loop = function
| [] -> None
| x :: xs ->
(match object_find_optional key x with
| Some (Yajl_string s) -> Some s
| Some _ -> error (f_"the value for key '%s' is not a string as expected") key
| None -> loop xs
)
in
match loop yvs with
| Some s -> s
| None -> error (f_"the key '%s' was not found in a list of objects") key
let get_index ~downloader ~sigchecker
{ Sources.uri = uri; proxy = proxy } =
let uri = ensure_trailing_slash uri in
let download_and_parse uri =
let tmpfile, delete_tmpfile = Downloader.download downloader ~proxy uri in
if delete_tmpfile then
unlink_on_exit tmpfile;
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
| ("sha256", Yajl_string c) -> Some (Checksums.SHA256 c)
| ("sha512", Yajl_string c) -> Some (Checksums.SHA512 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

@@ -1,157 +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 Printf
open Unix
type source = {
name : string;
uri : string;
gpgkey : Utils.gpgkey_type;
proxy : Downloader.proxy_mode;
format : source_format;
}
and source_format =
| FormatNative
| FormatSimpleStreams
module StringSet = Set.Make (String)
let parse_conf file =
if verbose () then (
printf (f_"%s: trying to read %s\n") prog file;
);
let sections = Ini_reader.read_ini ~error_suffix:"[ignored]" file in
let sources = List.fold_right (
fun (n, fields) acc ->
let give_source n fields =
let fields = List.map (fun (k, sk, v) -> (k, sk), v) fields in
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;
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
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
) in
let proxy =
try
(match (List.assoc ("proxy", None) fields) with
| "no" | "off" -> Downloader.UnsetProxy
| "system" -> Downloader.SystemProxy
| _ as proxy -> Downloader.ForcedProxy proxy
)
with
Not_found -> Downloader.SystemProxy in
let format =
try
(match (List.assoc ("format", None) fields) with
| "native" | "" -> FormatNative
| "simplestreams" -> FormatSimpleStreams
| fmt ->
if verbose () then (
eprintf (f_"%s: unknown repository type '%s' in %s, skipping it\n") prog 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);
);
sources
let merge_sources current_sources new_sources =
List.fold_right (
fun source acc ->
if List.exists (fun { name = n } -> n = source.name) acc then
acc
else
source :: acc
) new_sources current_sources
let filter_filenames filename =
Filename.check_suffix filename ".conf"
let read_sources () =
let dirs = Paths.xdg_config_dirs () in
let dirs =
match Paths.xdg_config_home () with
| None -> dirs
| Some dir -> dir :: dirs in
let dirs = List.map (fun x -> x // "repos.d") dirs in
let fnseen = ref StringSet.empty in
List.fold_left (
fun acc dir ->
let files =
try List.filter filter_filenames (Array.to_list (Sys.readdir dir))
with Sys_error _ -> [] in
let files = List.filter (fun x -> StringSet.mem x !fnseen <> true) files in
List.fold_left (
fun acc file ->
try (
let s = merge_sources acc (parse_conf (dir // file)) in
(* Add the current file name to the set only if its parsing
* was successful.
*)
fnseen := StringSet.add file !fnseen;
s
) with
| Unix_error (code, fname, _) ->
if verbose () then (
printf (f_"%s: file error: %s: %s\n") prog fname (error_message code)
);
acc
| Invalid_argument msg ->
if verbose () then (
printf (f_"%s: internal error: invalid argument: %s\n") prog msg
);
acc
) acc files
) [] dirs

View File

@@ -1,30 +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.
*)
type source = {
name : string;
uri : string;
gpgkey : Utils.gpgkey_type;
proxy : Downloader.proxy_mode;
format : source_format;
}
and source_format =
| FormatNative
| FormatSimpleStreams
val read_sources : unit -> source list

View File

@@ -1,2 +0,0 @@
[test-index]
uri=file://@abs_top_builddir@/builder/test-index

View File

@@ -1,66 +0,0 @@
[phony-debian]
name=Phony Debian
arch=x86_64
file=debian.xz
format=raw
size=536870912
expand=/dev/sda2
lvexpand=/dev/debian/root
notes=Phony Debian look-alike used for testing.
[phony-fedora]
name=Phony Fedora
arch=x86_64
file=fedora.xz
format=raw
size=1073741824
expand=/dev/sda2
lvexpand=/dev/VG/Root
notes=Phony Fedora look-alike used for testing.
[phony-fedora-qcow2]
name=Phony Fedora qcow2
arch=x86_64
file=fedora.qcow2.xz
format=qcow2
size=1073741824
expand=/dev/sda2
lvexpand=/dev/VG/Root
notes=Phony Fedora look-alike used for testing.
[phony-fedora-qcow2-uncompressed]
name=Phony Fedora qcow2 uncompressed
arch=x86_64
file=fedora.qcow2
format=qcow2
size=1073741824
expand=/dev/sda2
lvexpand=/dev/VG/Root
notes=Phony Fedora look-alike used for testing.
[phony-fedora-no-format]
name=Phony Fedora
arch=x86_64
file=fedora.qcow2.xz
size=1073741824
expand=/dev/sda2
lvexpand=/dev/VG/Root
notes=Phony Fedora look-alike used for testing.
[phony-ubuntu]
name=Phony Ubuntu
arch=x86_64
file=ubuntu.xz
format=raw
size=536870912
expand=/dev/sda2
notes=Phony Ubuntu look-alike used for testing.
[phony-windows]
name=Phony Windows
arch=x86_64
file=windows.xz
format=raw
size=536870912
expand=/dev/sda2
notes=Phony Windows look-alike used for testing.

View File

@@ -1,18 +0,0 @@
{
"format": "index:1.0",
"updated": "Fri, 08 May 2015 13:20:51 +0000",
"index": {
"net.cirros-cloud:released:download": {
"products": [
"net.cirros-cloud:standard:0.3:i386",
"net.cirros-cloud:standard:0.3:x86_64",
"net.cirros-cloud:standard:0.3:powerpc",
"net.cirros-cloud:standard:0.3:arm"
],
"datatype": "image-downloads",
"format": "products:1.0",
"updated": "Fri, 08 May 2015 13:20:51 +0000",
"path": "streams/v1/net.cirros-cloud_released_download.json"
}
}
}

View File

@@ -1,429 +0,0 @@
{
"products": {
"net.cirros-cloud:standard:0.3:i386": {
"arch": "i386",
"versions": {
"20140908": {
"items": {
"lxc.tar.gz": {
"ftype": "lxc.tar.gz",
"md5": "785c524f55bf2493dcddeedba25172f1",
"sha256": "bc20b950cc20e66e0b915748ad6b1ea2360ec03f08ffe6c68dc1b4a82331ab66",
"size": 3204602,
"path": "0.3.3/cirros-0.3.3-i386-lxc.tar.gz"
},
"disk.img": {
"ftype": "disk.img",
"md5": "283c77db6fc79b2d47c585ec241e7edc",
"sha256": "837cc3c79de14de62b8691c08a6913b7c0c62427870c7c1921ac43b9580748a9",
"size": 12268032,
"path": "0.3.3/cirros-0.3.3-i386-disk.img"
},
"uec.tar.gz": {
"ftype": "uec.tar.gz",
"md5": "861ef94d90ea220ae72b84d258ff5620",
"sha256": "5c7e685d42f0f1c5c70398e8b7388fc21b84dcbb4dc4a37c1c1645fe5c5ed3a4",
"size": 8231317,
"path": "0.3.3/cirros-0.3.3-i386-uec.tar.gz"
}
},
"version": "0.3.3",
"pubname": "cirros-0.3.3-i386"
},
"20150422": {
"items": {
"lxc.tar.gz": {
"ftype": "lxc.tar.gz",
"md5": "ffe02ef2b49cb34881f96e2b4c69383c",
"sha256": "5760cae9b9701dc09f495c3787f1da271800dcbc040eb793ddf4eb636689148a",
"size": 3210378,
"path": "0.3.4/cirros-0.3.4-i386-lxc.tar.gz"
},
"disk.img": {
"ftype": "disk.img",
"md5": "79b4436412283bb63c2cba4ac796bcd9",
"sha256": "48c279ff502ea4c5e3e09d58c9e3a2ab615452dae2ed8fe347f68c136c6a5a0b",
"size": 12506112,
"path": "0.3.4/cirros-0.3.4-i386-disk.img"
},
"uec.tar.gz": {
"ftype": "uec.tar.gz",
"md5": "c1630b33986cc09df2e0cbca7f5c5346",
"sha256": "f1cad519da6632b1d0ebad2f892534b732b5f9dd54d27f532d2963a0748f246e",
"size": 8241360,
"path": "0.3.4/cirros-0.3.4-i386-uec.tar.gz"
}
},
"version": "0.3.4",
"pubname": "cirros-0.3.4-i386"
},
"20140317": {
"items": {
"lxc.tar.gz": {
"ftype": "lxc.tar.gz",
"md5": "55023b89a6121b30603859bb80f5c8d3",
"sha256": "136f8dfff85b8d509a0d0a0264aea79ae94d9b7c3ea5745fbd478ae600adeb20",
"size": 3201206,
"path": "0.3.2/cirros-0.3.2-i386-lxc.tar.gz"
},
"disk.img": {
"ftype": "disk.img",
"md5": "b0a256d40e078d66576f7ae91c296e2b",
"sha256": "f0803c2d179c8a02d029239d35fc3e752cc81ad3436ea52b757e11685ca7c074",
"size": 12336128,
"path": "0.3.2/cirros-0.3.2-i386-disk.img"
},
"uec.tar.gz": {
"ftype": "uec.tar.gz",
"md5": "dcbcc559fc3bc468d9149bd7191aaa0c",
"sha256": "74ba8b67e0dce67f16a6bc5942bee90cbe31381f932aac1ba51bbc774aad5046",
"size": 8221995,
"path": "0.3.2/cirros-0.3.2-i386-uec.tar.gz"
}
},
"version": "0.3.2",
"pubname": "cirros-0.3.2-i386"
},
"20111020": {
"items": {
"lxc.tar.gz": {
"ftype": "lxc.tar.gz",
"md5": "e760bf470841f57c2c1bb426d407d169",
"sha256": "cac7887628527604b65a89e8caa34096d51c2dc1acfe405c15db2fc58495142a",
"size": 1845928,
"path": "0.3.0/cirros-0.3.0-i386-lxc.tar.gz"
},
"disk.img": {
"ftype": "disk.img",
"md5": "90169ba6f09b5906a7f0755bd00bf2c3",
"sha256": "3309675d0d409128b1c2651d576bc8092ca9ab93e15f3d3aa458f40947569b61",
"size": 9159168,
"path": "0.3.0/cirros-0.3.0-i386-disk.img"
},
"uec.tar.gz": {
"ftype": "uec.tar.gz",
"md5": "115ca6afa47089dc083c0dc9f9b7ff03",
"sha256": "b57e0acb32852f89734ff11a511ae0897e8cecb41882d03551649289b6854a1b",
"size": 6596586,
"path": "0.3.0/cirros-0.3.0-i386-uec.tar.gz"
}
},
"version": "0.3.0",
"pubname": "cirros-0.3.0-i386"
},
"20130207": {
"items": {
"lxc.tar.gz": {
"ftype": "lxc.tar.gz",
"md5": "fc404d9fc9dc5f0eb33ebaa03920a046",
"sha256": "70a8c9c175589f7ac7054c6151cf2bb7eb9e210cefbe310446df2fb1a436b504",
"size": 3191593,
"path": "0.3.1/cirros-0.3.1-i386-lxc.tar.gz"
},
"disk.img": {
"ftype": "disk.img",
"md5": "6ba617eafc992e33e7c141c679225e53",
"sha256": "b8aa1ce5d11939eaa01205fc31348532a31b82790921d45ceb397fbe76492787",
"size": 12251136,
"path": "0.3.1/cirros-0.3.1-i386-disk.img"
},
"uec.tar.gz": {
"ftype": "uec.tar.gz",
"md5": "52845de5142e58faf211e135d2b45721",
"sha256": "88dda2e505b862a95d0e0044013addcaa3200e602150c9d73e32c2e29345d6f3",
"size": 8197543,
"path": "0.3.1/cirros-0.3.1-i386-uec.tar.gz"
}
},
"version": "0.3.1",
"pubname": "cirros-0.3.1-i386"
}
},
"stream": "released"
},
"net.cirros-cloud:standard:0.3:x86_64": {
"arch": "x86_64",
"versions": {
"20140908": {
"items": {
"lxc.tar.gz": {
"ftype": "lxc.tar.gz",
"md5": "600363faf89daa6adea87e2dd77263b4",
"sha256": "66255c2f9404484996e646bb825fd2f1fd9d66583fecd3e9e0789376cf055fd4",
"size": 3544884,
"path": "0.3.3/cirros-0.3.3-x86_64-lxc.tar.gz"
},
"disk.img": {
"ftype": "disk.img",
"md5": "133eae9fb1c98f45894a4e60d8736619",
"sha256": "f11286e2bd317ee1a1d0469a6b182b33bda4af6f35ba224ca49d75752c81e20a",
"size": 13200896,
"path": "0.3.3/cirros-0.3.3-x86_64-disk.img"
},
"uec.tar.gz": {
"ftype": "uec.tar.gz",
"md5": "4f3371e52d60e5d47a6fbdd7d6a33973",
"sha256": "6bd27854862c30e25f0312defb9e86f9176b503751f040e323ab83322aa07dae",
"size": 8668951,
"path": "0.3.3/cirros-0.3.3-x86_64-uec.tar.gz"
}
},
"version": "0.3.3",
"pubname": "cirros-0.3.3-x86_64"
},
"20150422": {
"items": {
"lxc.tar.gz": {
"ftype": "lxc.tar.gz",
"md5": "6554ba2d15401c8caa90212ace985593",
"sha256": "e8172c603fad47f4c95e67bd2751c2977e07164c9ebdfcf3f9c1d7ff598ed217",
"size": 3555536,
"path": "0.3.4/cirros-0.3.4-x86_64-lxc.tar.gz"
},
"disk.img": {
"ftype": "disk.img",
"md5": "ee1eca47dc88f4879d8a229cc70a07c6",
"sha256": "34987d0d5702f8813f3ff9efe90e9e39e6926ec78658763580a79face67f3394",
"size": 13287936,
"path": "0.3.4/cirros-0.3.4-x86_64-disk.img"
},
"uec.tar.gz": {
"ftype": "uec.tar.gz",
"md5": "067d511efcc4acd034f7d64b716273bf",
"sha256": "95e77c7deaf0f515f959ffe329918d5dd23e417503d1d45e926a888853c90710",
"size": 8683894,
"path": "0.3.4/cirros-0.3.4-x86_64-uec.tar.gz"
}
},
"version": "0.3.4",
"pubname": "cirros-0.3.4-x86_64"
},
"20140317": {
"items": {
"lxc.tar.gz": {
"ftype": "lxc.tar.gz",
"md5": "174a08e827f22b20ebd774f90f1c9181",
"sha256": "03eff2a3603164fa02c00ca76fdcbd611b2ae8a6a80406753ec35eb275648d2e",
"size": 3538286,
"path": "0.3.2/cirros-0.3.2-x86_64-lxc.tar.gz"
},
"disk.img": {
"ftype": "disk.img",
"md5": "64d7c1cd2b6f60c92c14662941cb7913",
"sha256": "a2ca56aeded5a5bcaa6104fb14ec07b1ceb65222e2890bef8a89b8d2da729ad5",
"size": 13167616,
"path": "0.3.2/cirros-0.3.2-x86_64-disk.img"
},
"uec.tar.gz": {
"ftype": "uec.tar.gz",
"md5": "b369559e3ffa9208b4eb2224c949f579",
"sha256": "f462729fc2f071081dbc55932e07437e265263ef2e688306c353a1f152162b03",
"size": 8655821,
"path": "0.3.2/cirros-0.3.2-x86_64-uec.tar.gz"
}
},
"version": "0.3.2",
"pubname": "cirros-0.3.2-x86_64"
},
"20111020": {
"items": {
"lxc.tar.gz": {
"ftype": "lxc.tar.gz",
"md5": "1a480e5150db4d93be2aa3c9ced94fa1",
"sha256": "0e78796a30641dd7184f752c302a87d66f1eba9985c876911e4f26b4d8ba4a88",
"size": 2115217,
"path": "0.3.0/cirros-0.3.0-x86_64-lxc.tar.gz"
},
"disk.img": {
"ftype": "disk.img",
"md5": "50bdc35edb03a38d91b1b071afb20a3c",
"sha256": "648782e9287288630250d07531fed9944ecc3986764a6664f0bf6c050ec06afd",
"size": 9761280,
"path": "0.3.0/cirros-0.3.0-x86_64-disk.img"
},
"uec.tar.gz": {
"ftype": "uec.tar.gz",
"md5": "f56d3cffa47b7d209d2b6905628f07b9",
"sha256": "043a3e090a5d76d23758a3919fcaff93f77ce7b97594d9d10fc8d00e85f83191",
"size": 6957349,
"path": "0.3.0/cirros-0.3.0-x86_64-uec.tar.gz"
}
},
"version": "0.3.0",
"pubname": "cirros-0.3.0-x86_64"
},
"20130207": {
"items": {
"lxc.tar.gz": {
"ftype": "lxc.tar.gz",
"md5": "38252f1a49fec0ebedebc820854497e0",
"sha256": "a086fcf2758468972d45957dc78ec6317c06f356930dbbc6cad6a8d1855f135e",
"size": 3534564,
"path": "0.3.1/cirros-0.3.1-x86_64-lxc.tar.gz"
},
"disk.img": {
"ftype": "disk.img",
"md5": "d972013792949d0d3ba628fbe8685bce",
"sha256": "e01302fb2d2b13ae65226a0300335172e4487bbe60bb1e5c8b0843a25f126d34",
"size": 13147648,
"path": "0.3.1/cirros-0.3.1-x86_64-disk.img"
},
"uec.tar.gz": {
"ftype": "uec.tar.gz",
"md5": "e1849016cb71a00808093b7bf986f36a",
"sha256": "51eb03b83123a68d4f866c7c15b195204e62db9e33475509a38b79b3122cde38",
"size": 8633554,
"path": "0.3.1/cirros-0.3.1-x86_64-uec.tar.gz"
}
},
"version": "0.3.1",
"pubname": "cirros-0.3.1-x86_64"
}
},
"stream": "released"
},
"net.cirros-cloud:standard:0.3:powerpc": {
"arch": "powerpc",
"versions": {
"20150422": {
"items": {
"lxc.tar.gz": {
"ftype": "lxc.tar.gz",
"md5": "7e3a147b5665a1e14fe6d0ffef9ca410",
"sha256": "b1ab58ebb2a3f253d15cfa13f0cd0de883ce6e80f42ce2e3889e880423e95462",
"size": 3603000,
"path": "0.3.4/cirros-0.3.4-powerpc-lxc.tar.gz"
},
"disk.img": {
"ftype": "disk.img",
"md5": "453b21916c47c6ff8c615f8a5f7b76d2",
"sha256": "5445d77104d19ccdc2dbc943a3d0735c0dadd1227466a3f3e109c19671065f18",
"size": 17145856,
"path": "0.3.4/cirros-0.3.4-powerpc-disk.img"
},
"uec.tar.gz": {
"ftype": "uec.tar.gz",
"md5": "2f8a48928a6b0b2c9afbcb7255ff2aec",
"sha256": "80444c3ac8277d87eed0963567206ea5b009ecf4fdbc71fe8c4df020b42e3215",
"size": 12032417,
"path": "0.3.4/cirros-0.3.4-powerpc-uec.tar.gz"
}
}
}
},
"version": "0.3.4",
"stream": "released",
"pubname": "cirros-0.3.4-powerpc"
},
"net.cirros-cloud:standard:0.3:arm": {
"arch": "arm",
"versions": {
"20140908": {
"items": {
"lxc.tar.gz": {
"ftype": "lxc.tar.gz",
"md5": "7f2fe450d9a0b1688f2a4df6748690f5",
"sha256": "c839db36d5c96651d1dbcfc8a553678b010c7bb49416ac3099282858003fa021",
"size": 3482025,
"path": "0.3.3/cirros-0.3.3-arm-lxc.tar.gz"
},
"uec.tar.gz": {
"ftype": "uec.tar.gz",
"md5": "0437419d2371771b7406fade2d6db7d1",
"sha256": "4a0987818f3a834d9907b93729beb79426e58be9d46b3c207241bc4b1ceec52f",
"size": 7351177,
"path": "0.3.3/cirros-0.3.3-arm-uec.tar.gz"
}
},
"version": "0.3.3",
"pubname": "cirros-0.3.3-arm"
},
"20150422": {
"items": {
"lxc.tar.gz": {
"ftype": "lxc.tar.gz",
"md5": "5fd856d158dc6787264a1b4236126aab",
"sha256": "06c780e8c7166e16154bd0d3a6d1b0031e219269e990c5b8864a82925285486c",
"size": 3489736,
"path": "0.3.4/cirros-0.3.4-arm-lxc.tar.gz"
},
"uec.tar.gz": {
"ftype": "uec.tar.gz",
"md5": "1a2aea370f9f2d95d837f6b84bef658d",
"sha256": "6dd3bad904671aee13317c187d933b3efb1ac39a0d81fd5ac9a1fc694e3cb7ff",
"size": 7357906,
"path": "0.3.4/cirros-0.3.4-arm-uec.tar.gz"
}
},
"version": "0.3.4",
"pubname": "cirros-0.3.4-arm"
},
"20140317": {
"items": {
"lxc.tar.gz": {
"ftype": "lxc.tar.gz",
"md5": "bfb2ecb203cf27f4786b43a558b1ffe8",
"sha256": "a916b3d268793977001e2f09638e4a3e3953cc51d0d53d0bfb8c14cfa7105e86",
"size": 3474403,
"path": "0.3.2/cirros-0.3.2-arm-lxc.tar.gz"
},
"uec.tar.gz": {
"ftype": "uec.tar.gz",
"md5": "171719bfd4b3ec613f5fac321e4216de",
"sha256": "7f74826638e153ec58230bae9eb21805f875ed12eab299140f978e45597cb5cd",
"size": 7340357,
"path": "0.3.2/cirros-0.3.2-arm-uec.tar.gz"
}
},
"version": "0.3.2",
"pubname": "cirros-0.3.2-arm"
},
"20111020": {
"items": {
"lxc.tar.gz": {
"ftype": "lxc.tar.gz",
"md5": "91add49e56cbe6b5004015a4d2f51dbc",
"sha256": "fcd3723c956a1c232730dc28513b466657cbe984232ba2fcc30a4e1f55aa91e9",
"size": 2043822,
"path": "0.3.0/cirros-0.3.0-arm-lxc.tar.gz"
},
"uec.tar.gz": {
"ftype": "uec.tar.gz",
"md5": "c31e05f7829ad45f9d9995c35d232769",
"sha256": "b871823406f818430f57744333b1bb17ce0047e551a316f316641f1bd70d9152",
"size": 5761642,
"path": "0.3.0/cirros-0.3.0-arm-uec.tar.gz"
}
},
"version": "0.3.0",
"pubname": "cirros-0.3.0-arm"
},
"20130207": {
"items": {
"lxc.tar.gz": {
"ftype": "lxc.tar.gz",
"md5": "7ddea367ecb7ecb91554e18bed7c71bd",
"sha256": "2060e59e642b3b2bdf6e34aba3ed15f468bc6f9a8417fc196d01d29b2075493e",
"size": 3466149,
"path": "0.3.1/cirros-0.3.1-arm-lxc.tar.gz"
},
"uec.tar.gz": {
"ftype": "uec.tar.gz",
"md5": "d04e6f26aed123bba2c096581b269e7f",
"sha256": "09dcd3ea6f1d48b3519232973e4dc00fc5e73cbea974cda6b5f7cfa380c6b428",
"size": 7314471,
"path": "0.3.1/cirros-0.3.1-arm-uec.tar.gz"
}
},
"version": "0.3.1",
"pubname": "cirros-0.3.1-arm"
}
},
"stream": "released"
}
},
"datatype": "image-downloads",
"format": "products:1.0",
"updated": "Fri, 08 May 2015 13:20:51 +0000",
"content_id": "net.cirros-cloud:released:download"
}

View File

@@ -1,3 +0,0 @@
[test-cirros]
uri=file://@abs_top_builddir@/builder/test-simplestreams
format=simplestreams

View File

@@ -1,108 +0,0 @@
#!/bin/bash -
# libguestfs virt-builder test script
# 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.
export LANG=C
set -e
abs_builddir=$(pwd)
export XDG_CONFIG_HOME=
export XDG_CONFIG_DIRS="$abs_builddir/test-simplestreams"
short_list=$($VG virt-builder --no-check-signature --no-cache --list)
if [ "$short_list" != "net.cirros-cloud:standard:0.3:i386 i386 cirros-0.3.4-i386
net.cirros-cloud:standard:0.3:x86_64 x86_64 cirros-0.3.4-x86_64
net.cirros-cloud:standard:0.3:powerpc powerpc cirros-0.3.4-powerpc" ]; then
echo "$0: unexpected --list output:"
echo "$short_list"
exit 1
fi
long_list=$(virt-builder --no-check-signature --no-cache --list --long)
if [ "$long_list" != "Source URI: file://$abs_builddir/test-simplestreams
os-version: net.cirros-cloud:standard:0.3:i386
Full name: cirros-0.3.4-i386
Architecture: i386
Minimum/default size: 11.9M
Aliases: cirros-0.3.4-i386
os-version: net.cirros-cloud:standard:0.3:x86_64
Full name: cirros-0.3.4-x86_64
Architecture: x86_64
Minimum/default size: 12.7M
Aliases: cirros-0.3.4-x86_64
os-version: net.cirros-cloud:standard:0.3:powerpc
Full name: cirros-0.3.4-powerpc
Architecture: powerpc
Minimum/default size: 16.4M
Aliases: cirros-0.3.4-powerpc" ]; then
echo "$0: unexpected --list --long output:"
echo "$long_list"
exit 1
fi
json_list=$(virt-builder --no-check-signature --no-cache --list --list-format json)
if [ "$json_list" != "{
\"version\": 1,
\"sources\": [
{
\"uri\": \"file://$abs_builddir/test-simplestreams\"
}
],
\"templates\": [
{
\"os-version\": \"net.cirros-cloud:standard:0.3:i386\",
\"full-name\": \"cirros-0.3.4-i386\",
\"arch\": \"i386\",
\"size\": 12506112,
\"aliases\": [
\"cirros-0.3.4-i386\"
],
\"hidden\": false
},
{
\"os-version\": \"net.cirros-cloud:standard:0.3:x86_64\",
\"full-name\": \"cirros-0.3.4-x86_64\",
\"arch\": \"x86_64\",
\"size\": 13287936,
\"aliases\": [
\"cirros-0.3.4-x86_64\"
],
\"hidden\": false
},
{
\"os-version\": \"net.cirros-cloud:standard:0.3:powerpc\",
\"full-name\": \"cirros-0.3.4-powerpc\",
\"arch\": \"powerpc\",
\"size\": 17145856,
\"aliases\": [
\"cirros-0.3.4-powerpc\"
],
\"hidden\": false
}
]
}" ]; then
echo "$0: unexpected --list --format json output:"
echo "$json_list"
exit 1
fi

View File

@@ -1,199 +0,0 @@
#!/bin/bash -
# libguestfs virt-builder test script
# 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.
# Test the virt-builder --list [--long] options.
export LANG=C
set -e
abs_builddir=$(pwd)
export XDG_CONFIG_HOME=
export XDG_CONFIG_DIRS="$abs_builddir/test-config"
short_list=$($VG virt-builder --no-check-signature --no-cache --list)
if [ "$short_list" != "phony-debian x86_64 Phony Debian
phony-fedora x86_64 Phony Fedora
phony-fedora-qcow2 x86_64 Phony Fedora qcow2
phony-fedora-qcow2-uncompressed x86_64 Phony Fedora qcow2 uncompressed
phony-fedora-no-format x86_64 Phony Fedora
phony-ubuntu x86_64 Phony Ubuntu
phony-windows x86_64 Phony Windows" ]; then
echo "$0: unexpected --list output:"
echo "$short_list"
exit 1
fi
long_list=$(virt-builder --no-check-signature --no-cache --list --long)
if [ "$long_list" != "Source URI: file://$abs_builddir/test-index
os-version: phony-debian
Full name: Phony Debian
Architecture: x86_64
Minimum/default size: 512.0M
Notes:
Phony Debian look-alike used for testing.
os-version: phony-fedora
Full name: Phony Fedora
Architecture: x86_64
Minimum/default size: 1.0G
Notes:
Phony Fedora look-alike used for testing.
os-version: phony-fedora-qcow2
Full name: Phony Fedora qcow2
Architecture: x86_64
Minimum/default size: 1.0G
Notes:
Phony Fedora look-alike used for testing.
os-version: phony-fedora-qcow2-uncompressed
Full name: Phony Fedora qcow2 uncompressed
Architecture: x86_64
Minimum/default size: 1.0G
Notes:
Phony Fedora look-alike used for testing.
os-version: phony-fedora-no-format
Full name: Phony Fedora
Architecture: x86_64
Minimum/default size: 1.0G
Notes:
Phony Fedora look-alike used for testing.
os-version: phony-ubuntu
Full name: Phony Ubuntu
Architecture: x86_64
Minimum/default size: 512.0M
Notes:
Phony Ubuntu look-alike used for testing.
os-version: phony-windows
Full name: Phony Windows
Architecture: x86_64
Minimum/default size: 512.0M
Notes:
Phony Windows look-alike used for testing." ]; then
echo "$0: unexpected --list --long output:"
echo "$long_list"
exit 1
fi
json_list=$(virt-builder --no-check-signature --no-cache --list --list-format json)
if [ "$json_list" != "{
\"version\": 1,
\"sources\": [
{
\"uri\": \"file://$abs_builddir/test-index\"
}
],
\"templates\": [
{
\"os-version\": \"phony-debian\",
\"full-name\": \"Phony Debian\",
\"arch\": \"x86_64\",
\"size\": 536870912,
\"notes\": {
\"C\": \"Phony Debian look-alike used for testing.\"
},
\"hidden\": false
},
{
\"os-version\": \"phony-fedora\",
\"full-name\": \"Phony Fedora\",
\"arch\": \"x86_64\",
\"size\": 1073741824,
\"notes\": {
\"C\": \"Phony Fedora look-alike used for testing.\"
},
\"hidden\": false
},
{
\"os-version\": \"phony-fedora-qcow2\",
\"full-name\": \"Phony Fedora qcow2\",
\"arch\": \"x86_64\",
\"size\": 1073741824,
\"notes\": {
\"C\": \"Phony Fedora look-alike used for testing.\"
},
\"hidden\": false
},
{
\"os-version\": \"phony-fedora-qcow2-uncompressed\",
\"full-name\": \"Phony Fedora qcow2 uncompressed\",
\"arch\": \"x86_64\",
\"size\": 1073741824,
\"notes\": {
\"C\": \"Phony Fedora look-alike used for testing.\"
},
\"hidden\": false
},
{
\"os-version\": \"phony-fedora-no-format\",
\"full-name\": \"Phony Fedora\",
\"arch\": \"x86_64\",
\"size\": 1073741824,
\"notes\": {
\"C\": \"Phony Fedora look-alike used for testing.\"
},
\"hidden\": false
},
{
\"os-version\": \"phony-ubuntu\",
\"full-name\": \"Phony Ubuntu\",
\"arch\": \"x86_64\",
\"size\": 536870912,
\"notes\": {
\"C\": \"Phony Ubuntu look-alike used for testing.\"
},
\"hidden\": false
},
{
\"os-version\": \"phony-windows\",
\"full-name\": \"Phony Windows\",
\"arch\": \"x86_64\",
\"size\": 536870912,
\"notes\": {
\"C\": \"Phony Windows look-alike used for testing.\"
},
\"hidden\": false
}
]
}" ]; then
echo "$0: unexpected --list --format json output:"
echo "$json_list"
exit 1
fi

View File

@@ -1,52 +0,0 @@
#!/bin/bash -
# libguestfs virt-builder test script
# 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.
export LANG=C
set -e
abs_builddir=$(pwd)
export XDG_CONFIG_HOME=
export XDG_CONFIG_DIRS="$abs_builddir/test-config"
if [ ! -f fedora.xz -o ! -f fedora.qcow2 -o ! -f fedora.qcow2.xz ]; then
echo "$0: test skipped because there is no fedora.xz, fedora.qcow2 or fedora.qcow2.xz in the build directory"
exit 77
fi
if [ "$(guestfish get-backend)" = "uml" ]; then
echo "$0: test skipped because backend is UML"
exit 77
fi
rm -f planner-output
for input in phony-fedora phony-fedora-qcow2 phony-fedora-qcow2-uncompressed phony-fedora-no-format; do
for size in none 1G 1.1G 2G; do
for format in none raw qcow2; do
args="--output planner-output --no-cache --no-check-signature"
if [ "$size" != "none" ]; then args="$args --size $size"; fi
if [ "$format" != "none" ]; then args="$args --format $format"; fi
echo $VG virt-builder $input $args
$VG virt-builder $input $args
done
done
done
rm planner-output

View File

@@ -1,123 +0,0 @@
#!/bin/bash -
# libguestfs virt-builder test script
# 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.
export LANG=C
set -e
abs_builddir=$(pwd)
export XDG_CONFIG_HOME=
export XDG_CONFIG_DIRS="$abs_builddir/test-config"
if [ -n "$SKIP_TEST_VIRT_BUILDER_SH" ]; then
echo "$0: skipping test because environment variable is set."
exit 77
fi
if [ ! -f fedora.xz ]; then
echo "$0: test skipped because there is no fedora.xz in the build directory"
exit 77
fi
output=phony-fedora.img
format=qcow2
if [ "$(guestfish get-backend)" = "uml" ]; then
format=raw
# XXX We specifically want virt-builder to work with the UML
# backend. However currently it fails with:
# error: uml backend does not support networking
# We should be able to make uml have a network backend, but in
# the meantime add this:
no_network=--no-network
fi
rm -f $output
# Test as many options as we can!
#
# Note we cannot test --install, --run since the phony Fedora doesn't
# have a real OS inside just some configuration files. Just about
# every other option is fair game.
$VG virt-builder phony-fedora \
-v --no-cache --no-check-signature $no_network \
-o $output --size 2G --format $format \
--arch x86_64 \
--hostname test.example.com \
--timezone Europe/London \
--root-password password:123456 \
--mkdir /etc/foo/bar/baz \
--write '/etc/foo/bar/baz/foo:Hello World' \
--upload Makefile:/Makefile \
--edit '/Makefile: s{^#.*}{}' \
--upload Makefile:/etc/foo/bar/baz \
--delete /Makefile \
--link /etc/foo/bar/baz/foo:/foo \
--link /etc/foo/bar/baz/foo:/foo1:/foo2:/foo3 \
--firstboot Makefile --firstboot-command 'echo "hello"' \
--firstboot-install "minicom,inkscape"
# Check that some modifications were made.
$VG guestfish --ro -i -a $output > test-virt-builder.out <<EOF
# Uploaded files
is-file /etc/foo/bar/baz/Makefile
cat /etc/foo/bar/baz/foo
is-symlink /foo
is-symlink /foo1
is-symlink /foo2
is-symlink /foo3
echo -----
# Hostname
cat /etc/sysconfig/network | grep HOSTNAME=
echo -----
# Timezone
is-file /usr/share/zoneinfo/Europe/London
is-symlink /etc/localtime
readlink /etc/localtime
echo -----
# Password
is-file /etc/shadow
cat /etc/shadow | sed -r '/^root:/!d;s,^(root:\\\$6\\\$).*,\\1,g'
EOF
if [ "$(cat test-virt-builder.out)" != "true
Hello World
true
true
true
true
-----
HOSTNAME=test.example.com
-----
true
true
/usr/share/zoneinfo/Europe/London
-----
true
root:\$6\$" ]; then
echo "$0: unexpected output:"
cat test-virt-builder.out
exit 1
fi
rm $output
rm test-virt-builder.out

View File

@@ -1,8 +0,0 @@
name=Phony Fedora
arch=x86_64
file=fedora.xz
format=raw
size=1073741824
expand=/dev/sda2
lvexpand=/dev/VG/Root
notes=Phony Fedora look-alike used for testing.

View File

@@ -1,2 +0,0 @@
# All lines commented out.
# [foo]

View File

@@ -1,4 +0,0 @@
# Empty lines before the first section
[foo]
key=value

View File

@@ -1,25 +0,0 @@
#!/bin/bash -
# test virt-index-validate
# 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.
export LANG=C
set -e
! $VG virt-index-validate test-virt-index-validate-bad-1
$VG virt-index-validate test-virt-index-validate-good-1
$VG virt-index-validate test-virt-index-validate-good-2
$VG virt-index-validate test-virt-index-validate-good-3

View File

@@ -1,3 +0,0 @@
[libguestfs.org]
uri=file://@abs_top_srcdir@/builder/website/index.asc
gpgkey=file://@abs_top_srcdir@/builder/libguestfs.gpg

File diff suppressed because it is too large Load Diff

View File

@@ -1,90 +0,0 @@
=head1 NAME
virt-index-validate - Validate virt-builder index file
=head1 SYNOPSIS
virt-index-validate index
=head1 DESCRIPTION
L<virt-builder(1)> uses an index file to store metadata about templates
that it knows how to use. This index file has a specific format which
virt-index-validate knows how to validate.
Note that virt-index-validate can validate either the signed or
unsigned index file (ie. either F<index> or F<index.asc>). It can
only validate a local file, not a URL.
=head1 OPTIONS
=over 4
=item B<--compat-1.24.0>
Check for compatibility with virt-builder 1.24.0. (Using this option
implies I<--compat-1.24.1>, so you don't need to use both.)
In particular:
=over 4
=item *
This version of virt-builder could not handle C<[...]>
(square brackets) in field names (eg. C<checksum[sha512]=...>).
=item *
It required detached signatures (C<sig=...>).
=back
=item B<--compat-1.24.1>
Check for compatibility with virt-builder E<ge> 1.24.1.
In particular:
=over 4
=item *
This version of virt-builder could not handle C<.> (period) in field
names or C<,> (comma) in subfield names.
=item *
It could not handle comments appearing in the file.
=back
=item B<--help>
Display help.
=item B<-V>
=item B<--version>
Display version number and exit.
=back
=head1 EXIT STATUS
This program returns 0 if the index file validates, or non-zero if
there was an error.
=head1 SEE ALSO
L<virt-builder(1)>,
L<http://libguestfs.org/>.
=head1 AUTHOR
Richard W.M. Jones L<http://people.redhat.com/~rjones/>
=head1 COPYRIGHT
Copyright (C) 2013 Red Hat Inc.

View File

@@ -1 +0,0 @@
*.xz

View File

@@ -1,53 +0,0 @@
# libguestfs virt-builder tool
# 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.
include $(top_srcdir)/subdir-rules.mk
EXTRA_DIST = \
.gitignore \
compress.sh \
test-guest.sh \
validate.sh \
README \
index \
index.asc \
centos.sh \
debian.preseed \
debian.sh \
fedora.sh \
fedora-aarch64.sh \
fedora-armv7l.sh \
fedora-i686.sh \
fedora-ppc64.sh \
fedora-ppc64le.sh \
rhel.sh \
rhel-aarch64.sh \
rhel-ppc64.sh \
rhel-ppc64le.sh \
scientificlinux.sh \
ubuntu.preseed \
ubuntu.sh \
ubuntu-ppc64le.sh
CLEANFILES = *~
# Validates the index file.
TESTS_ENVIRONMENT = $(top_builddir)/run --test
TESTS = validate.sh
check-valgrind:
$(MAKE) VG="$(top_builddir)/run @VG@" check

View File

@@ -1,42 +0,0 @@
If you are looking at this file at http://libguestfs.org/download/builder
-------------------------------------------------------------------------
This directory is used by the libguestfs 'virt-builder' to store the
clean, signed OS templates used for building new virtual machines.
The index file is the default source URL and links to the other OS
templates. It has the canonical URL:
http://libguestfs.org/download/builder/index.asc
If you are looking at this file in the git repository
-----------------------------------------------------
libguestfs.git/builder/website/ contains a copy of the website, minus
the huge OS template files (because of their size, they are stored
elsewhere and merged into the website when it is uploaded).
When you use the ./run script to run virt-builder without installing,
the ./run script sets $VIRT_BUILDER_SOURCE to point to this directory.
If you actually want to use this configuration for anything except
simple testing, you will have to download one or more OS templates
from the libguestfs website and put them into the builder/website/
directory.
ie:
./run virt-builder fedora-20
will fail unless you have downloaded fedora-20.xz here.
Fedora guests
-------------
The general plan for using kickstart and virt-install is outlined
by Kashyap here:
http://kashyapc.wordpress.com/2011/08/18/unattended-guest-install-with-a-local-kickstart/
If you want to reproduce the builds then the kickstart files are
located in fedora-<N>.ks and the virt-install + other commands are in
fedora-<N>.sh.

View File

@@ -1,99 +0,0 @@
#!/bin/bash -
# virt-builder
# Copyright (C) 2013-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.
unset CDPATH
export LANG=C
set -e
set -x
if [ $# -ne 1 ]; then
echo "$0 VERSION"
exit 1
fi
version=$1
output=centos-$version
tmpname=tmp-$(tr -cd 'a-f0-9' < /dev/urandom | head -c 8)
case $version in
6)
# We rebuild this every time there is a new 6.x release, and bump
# the revision in the index.
tree=http://mirror.bytemark.co.uk/centos/$version/os/x86_64/
major=6
;;
7.*)
major=7
# XXX This always points to the latest CentOS 7, so
# effectively the minor number is always ignored.
tree=http://mirror.centos.org/centos-7/$major/os/x86_64/
;;
esac
rm -f $output $output.old $output.xz
# Generate the kickstart to a temporary file.
ks=$(mktemp)
cat > $ks <<'EOF'
install
text
reboot
lang en_US.UTF-8
keyboard us
network --bootproto dhcp
rootpw builder
firewall --enabled --ssh
selinux --enforcing
timezone --utc America/New_York
bootloader --location=mbr --append="console=tty0 console=ttyS0,115200 rd_NO_PLYMOUTH"
zerombr
clearpart --all --initlabel
part /boot --fstype=ext4 --size=512 --asprimary
part swap --size=1024 --asprimary
part / --fstype=ext4 --size=1024 --grow --asprimary
# Halt the system once configuration has finished.
poweroff
%packages
@core
%end
EOF
# Clean up function.
cleanup ()
{
rm -f $ks
virsh undefine $tmpname ||:
}
trap cleanup INT QUIT TERM EXIT ERR
virt-install \
--name=$tmpname \
--ram=2048 \
--cpu=host --vcpus=2 \
--os-type=linux --os-variant=rhel$major \
--initrd-inject=$ks \
--extra-args="ks=file:/`basename $ks` console=tty0 console=ttyS0,115200 proxy=$http_proxy" \
--disk $(pwd)/$output,size=6,format=raw \
--serial pty \
--location=$tree \
--nographics \
--noreboot
source $(dirname "$0")/compress.sh $output

View File

@@ -1,38 +0,0 @@
#!/bin/bash -
# 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.
# Common code which syspreps, sparsifies and compresses the templates.
output=$1
# Sysprep (removes logfiles and so on).
# Note this also touches /.autorelabel so the further installation
# changes that we make will be labelled properly at first boot.
virt-sysprep -a $output
# Sparsify.
mv $output $output.old
virt-sparsify $output.old $output
rm $output.old
# Compress.
xz --best --block-size=16777216 $output
# Result. These can be copied into the index file directly.
echo -n compressed_size= ; stat -c %s $output.xz
echo -n checksum= ; sha512sum $output.xz | awk '{print $1}'

View File

@@ -1,385 +0,0 @@
#### Contents of the preconfiguration file (for wheezy)
### Localization
# Preseeding only locale sets language, country and locale.
d-i debian-installer/locale string en_US
# The values can also be preseeded individually for greater flexibility.
#d-i debian-installer/language string en
#d-i debian-installer/country string NL
#d-i debian-installer/locale string en_GB.UTF-8
# Optionally specify additional locales to be generated.
#d-i localechooser/supported-locales multiselect en_US.UTF-8, nl_NL.UTF-8
# Keyboard selection.
# keymap is an alias for keyboard-configuration/xkb-keymap
d-i keymap select us
# d-i keyboard-configuration/toggle select No toggling
### Network configuration
# Disable network configuration entirely. This is useful for cdrom
# installations on non-networked devices where the network questions,
# warning and long timeouts are a nuisance.
d-i netcfg/enable boolean true
# netcfg will choose an interface that has link if possible. This makes it
# skip displaying a list if there is more than one interface.
d-i netcfg/choose_interface select auto
# To pick a particular interface instead:
#d-i netcfg/choose_interface select eth1
# To set a different link detection timeout (default is 3 seconds).
# Values are interpreted as seconds.
#d-i netcfg/link_detection_timeout string 10
# If you have a slow dhcp server and the installer times out waiting for
# it, this might be useful.
#d-i netcfg/dhcp_timeout string 60
#d-i netcfg/dhcpv6_timeout string 60
# If you prefer to configure the network manually, uncomment this line and
# the static network configuration below.
#d-i netcfg/disable_autoconfig boolean true
# If you want the preconfiguration file to work on systems both with and
# without a dhcp server, uncomment these lines and the static network
# configuration below.
#d-i netcfg/dhcp_failed note
#d-i netcfg/dhcp_options select Configure network manually
# Static network configuration.
#
# IPv4 example
#d-i netcfg/get_ipaddress string 192.168.1.42
#d-i netcfg/get_netmask string 255.255.255.0
#d-i netcfg/get_gateway string 192.168.1.1
#d-i netcfg/get_nameservers string 192.168.1.1
#d-i netcfg/confirm_static boolean true
#
# IPv6 example
#d-i netcfg/get_ipaddress string fc00::2
#d-i netcfg/get_netmask string ffff:ffff:ffff:ffff::
#d-i netcfg/get_gateway string fc00::1
#d-i netcfg/get_nameservers string fc00::1
#d-i netcfg/confirm_static boolean true
# Any hostname and domain names assigned from dhcp take precedence over
# values set here. However, setting the values still prevents the questions
# from being shown, even if values come from dhcp.
d-i netcfg/get_hostname string unassigned-hostname
d-i netcfg/get_domain string unassigned-domain
# If you want to force a hostname, regardless of what either the DHCP
# server returns or what the reverse DNS entry for the IP is, uncomment
# and adjust the following line.
#d-i netcfg/hostname string somehost
# Disable that annoying WEP key dialog.
d-i netcfg/wireless_wep string
# The wacky dhcp hostname that some ISPs use as a password of sorts.
#d-i netcfg/dhcp_hostname string radish
# If non-free firmware is needed for the network or other hardware, you can
# configure the installer to always try to load it, without prompting. Or
# change to false to disable asking.
#d-i hw-detect/load_firmware boolean true
### Network console
# Use the following settings if you wish to make use of the network-console
# component for remote installation over SSH. This only makes sense if you
# intend to perform the remainder of the installation manually.
#d-i anna/choose_modules string network-console
#d-i network-console/authorized_keys_url string http://10.0.0.1/openssh-key
#d-i network-console/password password r00tme
#d-i network-console/password-again password r00tme
### Mirror settings
# If you select ftp, the mirror/country string does not need to be set.
#d-i mirror/protocol string ftp
d-i mirror/country string manual
d-i mirror/http/hostname string ftp.uk.debian.org
d-i mirror/http/directory string /debian
d-i mirror/http/proxy string @CACHE@
# Suite to install.
#d-i mirror/suite string testing
# Suite to use for loading installer components (optional).
#d-i mirror/udeb/suite string testing
### Account setup
# Skip creation of a root account (normal user account will be able to
# use sudo).
#d-i passwd/root-login boolean false
# Alternatively, to skip creation of a normal user account.
d-i passwd/make-user boolean false
# Root password, either in clear text
d-i passwd/root-password password builder
d-i passwd/root-password-again password builder
# or encrypted using an MD5 hash.
#d-i passwd/root-password-crypted password [MD5 hash]
# To create a normal user account.
#d-i passwd/user-fullname string Debian User
#d-i passwd/username string debian
# Normal user's password, either in clear text
#d-i passwd/user-password password insecure
#d-i passwd/user-password-again password insecure
# or encrypted using an MD5 hash.
#d-i passwd/user-password-crypted password [MD5 hash]
# Create the first user with the specified UID instead of the default.
#d-i passwd/user-uid string 1010
# The user account will be added to some standard initial groups. To
# override that, use this.
#d-i passwd/user-default-groups string audio cdrom video
### Clock and time zone setup
# Controls whether or not the hardware clock is set to UTC.
d-i clock-setup/utc boolean true
# You may set this to any valid setting for $TZ; see the contents of
# /usr/share/zoneinfo/ for valid values.
d-i time/zone string US/Eastern
# Controls whether to use NTP to set the clock during the install
d-i clock-setup/ntp boolean true
# NTP server to use. The default is almost always fine here.
#d-i clock-setup/ntp-server string ntp.example.com
### Partitioning
## Partitioning example
# If the system has free space you can choose to only partition that space.
# This is only honoured if partman-auto/method (below) is not set.
#d-i partman-auto/init_automatically_partition select biggest_free
# Alternatively, you may specify a disk to partition. If the system has only
# one disk the installer will default to using that, but otherwise the device
# name must be given in traditional, non-devfs format (so e.g. /dev/hda or
# /dev/sda, and not e.g. /dev/discs/disc0/disc).
# For example, to use the first SCSI/SATA hard disk:
#d-i partman-auto/disk string /dev/sda
# In addition, you'll need to specify the method to use.
# The presently available methods are:
# - regular: use the usual partition types for your architecture
# - lvm: use LVM to partition the disk
# - crypto: use LVM within an encrypted partition
d-i partman-auto/method string regular
# If one of the disks that are going to be automatically partitioned
# contains an old LVM configuration, the user will normally receive a
# warning. This can be preseeded away...
d-i partman-lvm/device_remove_lvm boolean true
# The same applies to pre-existing software RAID array:
d-i partman-md/device_remove_md boolean true
# And the same goes for the confirmation to write the lvm partitions.
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
# You can choose one of the three predefined partitioning recipes:
# - atomic: all files in one partition
# - home: separate /home partition
# - multi: separate /home, /usr, /var, and /tmp partitions
d-i partman-auto/choose_recipe select atomic
# Or provide a recipe of your own...
# If you have a way to get a recipe file into the d-i environment, you can
# just point at it.
#d-i partman-auto/expert_recipe_file string /hd-media/recipe
# If not, you can put an entire recipe into the preconfiguration file in one
# (logical) line. This example creates a small /boot partition, suitable
# swap, and uses the rest of the space for the root partition:
#d-i partman-auto/expert_recipe string \
# boot-root :: \
# 40 50 100 ext3 \
# $primary{ } $bootable{ } \
# method{ format } format{ } \
# use_filesystem{ } filesystem{ ext3 } \
# mountpoint{ /boot } \
# . \
# 500 10000 1000000000 ext3 \
# method{ format } format{ } \
# use_filesystem{ } filesystem{ ext3 } \
# mountpoint{ / } \
# . \
# 64 512 300% linux-swap \
# method{ swap } format{ } \
# .
# The full recipe format is documented in the file partman-auto-recipe.txt
# included in the 'debian-installer' package or available from D-I source
# repository. This also documents how to specify settings such as file
# system labels, volume group names and which physical devices to include
# in a volume group.
# This makes partman automatically partition without confirmation, provided
# that you told it what to do using one of the methods above.
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
## Partitioning using RAID
# The method should be set to "raid".
#d-i partman-auto/method string raid
# Specify the disks to be partitioned. They will all get the same layout,
# so this will only work if the disks are the same size.
#d-i partman-auto/disk string /dev/sda /dev/sdb
# Next you need to specify the physical partitions that will be used.
#d-i partman-auto/expert_recipe string \
# multiraid :: \
# 1000 5000 4000 raid \
# $primary{ } method{ raid } \
# . \
# 64 512 300% raid \
# method{ raid } \
# . \
# 500 10000 1000000000 raid \
# method{ raid } \
# .
# Last you need to specify how the previously defined partitions will be
# used in the RAID setup. Remember to use the correct partition numbers
# for logical partitions. RAID levels 0, 1, 5, 6 and 10 are supported;
# devices are separated using "#".
# Parameters are:
# <raidtype> <devcount> <sparecount> <fstype> <mountpoint> \
# <devices> <sparedevices>
#d-i partman-auto-raid/recipe string \
# 1 2 0 ext3 / \
# /dev/sda1#/dev/sdb1 \
# . \
# 1 2 0 swap - \
# /dev/sda5#/dev/sdb5 \
# . \
# 0 2 0 ext3 /home \
# /dev/sda6#/dev/sdb6 \
# .
# For additional information see the file partman-auto-raid-recipe.txt
# included in the 'debian-installer' package or available from D-I source
# repository.
# This makes partman automatically partition without confirmation.
d-i partman-md/confirm boolean true
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
## Controlling how partitions are mounted
# The default is to mount by UUID, but you can also choose "traditional" to
# use traditional device names, or "label" to try filesystem labels before
# falling back to UUIDs.
#d-i partman/mount_style select uuid
### Base system installation
# Configure APT to not install recommended packages by default. Use of this
# option can result in an incomplete system and should only be used by very
# experienced users.
#d-i base-installer/install-recommends boolean false
# The kernel image (meta) package to be installed; "none" can be used if no
# kernel is to be installed.
#d-i base-installer/kernel/image string linux-image-486
### Apt setup
# You can choose to install non-free and contrib software.
#d-i apt-setup/non-free boolean true
#d-i apt-setup/contrib boolean true
# Uncomment this if you don't want to use a network mirror.
#d-i apt-setup/use_mirror boolean false
# Select which update services to use; define the mirrors to be used.
# Values shown below are the normal defaults.
#d-i apt-setup/services-select multiselect security, volatile
#d-i apt-setup/security_host string security.debian.org
#d-i apt-setup/volatile_host string volatile.debian.org
# Additional repositories, local[0-9] available
#d-i apt-setup/local0/repository string \
# http://local.server/debian stable main
#d-i apt-setup/local0/comment string local server
# Enable deb-src lines
#d-i apt-setup/local0/source boolean true
# URL to the public key of the local repository; you must provide a key or
# apt will complain about the unauthenticated repository and so the
# sources.list line will be left commented out
#d-i apt-setup/local0/key string http://local.server/key
# By default the installer requires that repositories be authenticated
# using a known gpg key. This setting can be used to disable that
# authentication. Warning: Insecure, not recommended.
#d-i debian-installer/allow_unauthenticated boolean true
### Package selection
#tasksel tasksel/first multiselect standard, web-server
# If the desktop task is selected, install the kde and xfce desktops
# instead of the default gnome desktop.
#tasksel tasksel/desktop multiselect kde, xfce
# Individual additional packages to install
#d-i pkgsel/include string openssh-server build-essential
# Whether to upgrade packages after debootstrap.
# Allowed values: none, safe-upgrade, full-upgrade
#d-i pkgsel/upgrade select none
# Some versions of the installer can report back on what software you have
# installed, and what software you use. The default is not to report back,
# but sending reports helps the project determine what software is most
# popular and include it on CDs.
popularity-contest popularity-contest/participate boolean false
### Finishing up the installation
# During installations from serial console, the regular virtual consoles
# (VT1-VT6) are normally disabled in /etc/inittab. Uncomment the next
# line to prevent this.
#d-i finish-install/keep-consoles boolean true
# Avoid that last message about the install being complete.
d-i finish-install/reboot_in_progress note
# This will prevent the installer from ejecting the CD during the reboot,
# which is useful in some situations.
#d-i cdrom-detect/eject boolean false
# This is how to make the installer shutdown when finished, but not
# reboot into the installed system.
#d-i debian-installer/exit/halt boolean true
# This will power off the machine instead of just halting it.
#d-i debian-installer/exit/poweroff boolean true
### Preseeding other packages
# Depending on what software you choose to install, or if things go wrong
# during the installation process, it's possible that other questions may
# be asked. You can preseed those too, of course. To get a list of every
# possible question that could be asked during an install, do an
# installation, and then run these commands:
# debconf-get-selections --installer > file
# debconf-get-selections >> file
#### Advanced options
### Running custom commands during the installation
# d-i preseeding is inherently not secure. Nothing in the installer checks
# for attempts at buffer overflows or other exploits of the values of a
# preconfiguration file like this one. Only use preconfiguration files from
# trusted locations! To drive that home, and because it's generally useful,
# here's a way to run any shell command you'd like inside the installer,
# automatically.
# This first command is run as early as possible, just after
# preseeding is read.
#d-i preseed/early_command string anna-install some-udeb
# This command is run immediately before the partitioner starts. It may be
# useful to apply dynamic partitioner preseeding that depends on the state
# of the disks (which may not be visible when preseed/early_command runs).
#d-i partman/early_command \
# string debconf-set partman-auto/disk "$(list-devices disk | head -n1)"
# This command is run just before the install finishes, but when there is
# still a usable /target directory. You can chroot to /target and use it
# directly, or use the apt-install and in-target commands to easily install
# packages and run commands in the target system.
#d-i preseed/late_command string apt-install zsh; in-target chsh -s /bin/zsh

View File

@@ -1,84 +0,0 @@
#!/bin/bash -
# libguestfs
# Copyright (C) 2013-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.
# The basic plan comes from:
# http://honk.sigxcpu.org/con/Preseeding_Debian_virtual_machines_with_virt_install.html
# https://wiki.debian.org/DebianInstaller/Preseed
unset CDPATH
export LANG=C
set -e
set -x
if [ $# -ne 2 ]; then
echo "$0 VERSION DIST"
exit 1
fi
# Some configuration.
version=$1
dist=$2
if [ "$dist" = "jessie" ]; then
# Until virt-install learns about debianjessie.
osvariant=debianwheezy
else
osvariant=debian$dist
fi
location=http://ftp.uk.debian.org/debian/dists/$dist/main/installer-amd64
output=debian-$version
tmpname=tmp-$(tr -cd 'a-f0-9' < /dev/urandom | head -c 8)
rm -f $output $output.old $output.xz
# Make sure it's being run from the correct directory.
if [ ! -f debian.preseed ]; then
echo "You are running this script from the wrong directory."
exit 1
fi
# Note that the injected file must be called "/preseed.cfg" in order
# for d-i to pick it up.
sed -e "s,@CACHE@,$http_proxy,g" < debian.preseed > preseed.cfg
# Clean up function.
cleanup ()
{
rm -f preseed.cfg
virsh undefine $tmpname ||:
}
trap cleanup INT QUIT TERM EXIT ERR
virt-install \
--name=$tmpname \
--ram=1024 \
--os-type=linux --os-variant=$osvariant \
--initrd-inject=$(pwd)/preseed.cfg \
--extra-args="auto console=tty0 console=ttyS0,115200" \
--disk=$(pwd)/$output,size=4,format=raw \
--serial pty \
--location=$location \
--nographics \
--noreboot
# Remove apt proxy configuration (thanks: Daniel Miranda).
guestfish -a $output -i <<EOF
rm /etc/apt/apt.conf
touch /etc/apt/apt.conf
EOF
source $(dirname "$0")/compress.sh $output

View File

@@ -1,106 +0,0 @@
#!/bin/bash -
# virt-builder
# Copyright (C) 2013-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.
# Build Fedora images for aarch64 (secondary arch).
unset CDPATH
export LANG=C
set -e
set -x
if [ $# -ne 1 ]; then
echo "$0 VERSION"
exit 1
fi
version=$1
tree=https://download.fedoraproject.org/pub/fedora-secondary/releases/$version/Server/aarch64/os/
output=fedora-$version-aarch64
tmpname=tmp-$(tr -cd 'a-f0-9' < /dev/urandom | head -c 8)
rm -f $output $output.old $output.xz
# Generate the kickstart to a temporary file.
ks=$(mktemp)
cat > $ks <<'EOF'
install
text
reboot
lang en_US.UTF-8
keyboard us
network --bootproto dhcp
rootpw builder
firewall --enabled --ssh
selinux --enforcing
timezone --utc America/New_York
bootloader --location=mbr --append="console=ttyAMA0 earlyprintk=pl011,0x9000000 ignore_loglevel no_timer_check printk.time=1 rd_NO_PLYMOUTH"
zerombr
clearpart --all --initlabel
autopart --type=plain
# Halt the system once configuration has finished.
poweroff
%packages
@core
%end
%post
# Rerun dracut for the installed kernel (not the running kernel):
KERNEL_VERSION=$(rpm -q kernel --qf '%{version}-%{release}.%{arch}\n')
dracut -f /boot/initramfs-$KERNEL_VERSION.img $KERNEL_VERSION
# Ensure the installation is up-to-date:
dnf -y --best upgrade
%end
EOF
# Clean up function.
cleanup ()
{
rm -f $ks
virsh undefine --nvram $tmpname ||:
}
trap cleanup INT QUIT TERM EXIT ERR
# virt-install nvram_template option is broken for non-root users
# https://bugzilla.redhat.com/show_bug.cgi?id=1189143
# work around it:
vars=$(mktemp)
cp /usr/share/edk2.git/aarch64/vars-template-pflash.raw $vars
virt-install \
--name=$tmpname \
--ram=4096 \
--cpu=host --vcpus=2 \
--os-type=linux --os-variant=fedora21 \
--boot loader=/usr/share/edk2.git/aarch64/QEMU_EFI-pflash.raw,loader_ro=yes,loader_type=pflash,nvram=$vars \
--initrd-inject=$ks \
--extra-args="ks=file:/`basename $ks` earlyprintk=pl011,0x9000000 ignore_loglevel console=ttyAMA0 no_timer_check printk.time=1 proxy=$http_proxy" \
--disk $(pwd)/$output,size=6,format=raw \
--serial pty \
--location=$tree \
--nographics \
--noreboot
# NB: We need to preserve the nvram after installation since
# it contains the EFI boot variables set by grub.
cp $vars $output-nvram
xz --best $output-nvram
source $(dirname "$0")/compress.sh $output

View File

@@ -1,95 +0,0 @@
#!/bin/bash -
# virt-builder
# Copyright (C) 2013-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.
# Build Fedora images for armv7l.
unset CDPATH
export LANG=C
set -e
set -x
if [ $# -ne 1 ]; then
echo "$0 VERSION"
exit 1
fi
version=$1
tree=http://mirror.ox.ac.uk/sites/download.fedora.redhat.com/pub/fedora/linux/releases/$version/Server/armhfp/os/
output=fedora-$version-armv7l
tmpname=tmp-$(tr -cd 'a-f0-9' < /dev/urandom | head -c 8)
rm -f $output $output.old $output.xz
# Generate the kickstart to a temporary file.
ks=$(mktemp)
cat > $ks <<'EOF'
install
text
reboot
lang en_US.UTF-8
keyboard us
network --bootproto dhcp
rootpw builder
firewall --enabled --ssh
selinux --enforcing
timezone --utc America/New_York
bootloader --location=mbr --append="console=tty0 console=ttyAMA0,115200 rd_NO_PLYMOUTH"
zerombr
clearpart --all --initlabel
autopart --type=plain
# Halt the system once configuration has finished.
poweroff
%packages
@core
%end
%post
# Rerun dracut for the installed kernel (not the running kernel):
KERNEL_VERSION=$(rpm -q kernel --qf '%{version}-%{release}.%{arch}\n')
dracut -f /boot/initramfs-$KERNEL_VERSION.img $KERNEL_VERSION
# Ensure the installation is up-to-date:
dnf -y --best upgrade
%end
EOF
# Clean up function.
cleanup ()
{
rm -f $ks
virsh undefine $tmpname ||:
}
trap cleanup INT QUIT TERM EXIT ERR
virt-install \
--name=$tmpname \
--ram=1024 \
--vcpus=1 \
--arch armv7l \
--os-type=linux --os-variant=fedora22 \
--initrd-inject=$ks \
--extra-args="ks=file:/`basename $ks` console=tty0 console=ttyAMA0,115200 proxy=$http_proxy" \
--disk $(pwd)/$output,size=6,format=raw \
--serial pty \
--location=$tree \
--nographics \
--noreboot
source $(dirname "$0")/compress.sh $output

View File

@@ -1,103 +0,0 @@
#!/bin/bash -
# virt-builder
# Copyright (C) 2013-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.
# This script was used to create the Fedora templates used by
# virt-builder.
unset CDPATH
export LANG=C
set -e
set -x
if [ $# -ne 1 ]; then
echo "$0 VERSION"
exit 1
fi
version=$1
if [ $version -lt 21 ]; then
tree=http://mirror.bytemark.co.uk/fedora/linux/releases/$version/Fedora/i386/os/
else
tree=http://mirror.bytemark.co.uk/fedora/linux/releases/$version/Server/i386/os/
fi
output=fedora-$version-i686
tmpname=tmp-$(tr -cd 'a-f0-9' < /dev/urandom | head -c 8)
rm -f $output $output.old $output.xz
# Generate the kickstart to a temporary file.
ks=$(mktemp)
cat > $ks <<'EOF'
install
text
reboot
lang en_US.UTF-8
keyboard us
network --bootproto dhcp
rootpw builder
firewall --enabled --ssh
selinux --enforcing
timezone --utc America/New_York
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
%post
# Enable Xen domU support:
pushd /etc/dracut.conf.d
echo 'add_drivers+="xen:vbd xen:vif"' > virt-builder-xen-drivers.conf
popd
# Rerun dracut for the installed kernel (not the running kernel):
KERNEL_VERSION=$(rpm -q kernel --qf '%{version}-%{release}.%{arch}\n')
dracut -f /boot/initramfs-$KERNEL_VERSION.img $KERNEL_VERSION
# Ensure the installation is up-to-date:
dnf -y --best upgrade
%end
EOF
# Clean up function.
cleanup ()
{
rm -f $ks
virsh undefine $tmpname ||:
}
trap cleanup INT QUIT TERM EXIT ERR
virt-install \
--name=$tmpname \
--ram=2048 \
--cpu=host --vcpus=2 \
--os-type=linux --os-variant=fedora22 \
--initrd-inject=$ks \
--extra-args="ks=file:/`basename $ks` console=tty0 console=ttyS0,115200 proxy=$http_proxy" \
--disk $(pwd)/$output,size=6,format=raw \
--serial pty \
--location=$tree \
--nographics \
--noreboot
source $(dirname "$0")/compress.sh $output

View File

@@ -1,95 +0,0 @@
#!/bin/bash -
# virt-builder
# Copyright (C) 2013-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.
# Build Fedora images for ppc64 big endian (secondary arch).
unset CDPATH
export LANG=C
set -e
set -x
if [ $# -ne 1 ]; then
echo "$0 VERSION"
exit 1
fi
version=$1
tree=https://download.fedoraproject.org/pub/fedora-secondary/releases/$version/Server/ppc64/os/
output=fedora-$version-ppc64
tmpname=tmp-$(tr -cd 'a-f0-9' < /dev/urandom | head -c 8)
rm -f $output $output.old $output.xz
# Generate the kickstart to a temporary file.
ks=$(mktemp)
cat > $ks <<'EOF'
install
text
reboot
lang en_US.UTF-8
keyboard us
network --bootproto dhcp
rootpw builder
firewall --enabled --ssh
selinux --enforcing
timezone --utc America/New_York
bootloader --location=mbr --append="console=tty0 console=hvc0 rd_NO_PLYMOUTH"
zerombr
clearpart --all --initlabel
autopart --type=lvm
# Halt the system once configuration has finished.
poweroff
%packages
@core
%end
%post
# Rerun dracut for the installed kernel (not the running kernel):
KERNEL_VERSION=$(rpm -q kernel --qf '%{version}-%{release}.%{arch}\n')
dracut -f /boot/initramfs-$KERNEL_VERSION.img $KERNEL_VERSION
# Ensure the installation is up-to-date:
dnf -y --best upgrade
%end
EOF
# Clean up function.
cleanup ()
{
rm -f $ks
virsh undefine $tmpname ||:
}
trap cleanup INT QUIT TERM EXIT ERR
virt-install \
--name=$tmpname \
--ram=4096 \
--vcpus=1 \
--os-type=linux --os-variant=fedora22 \
--arch ppc64 --machine pseries \
--initrd-inject=$ks \
--extra-args="ks=file:/`basename $ks` console=tty0 console=hvc0 proxy=$http_proxy" \
--disk $(pwd)/$output,size=6,format=raw \
--serial pty \
--location=$tree \
--nographics \
--noreboot
source $(dirname "$0")/compress.sh $output

Some files were not shown because too many files have changed in this diff Show More