Commit Graph

609 Commits

Author SHA1 Message Date
Richard W.M. Jones
77e447a516 lib: Remove configure-time QEMU
Remove the configure-time QEMU definition.  No longer initialize g->hv
= QEMU.  g->hv may now be NULL if the user does not explicitly either
call guestfs_set_hv or set LIBGUESTFS_HV.

Remove any assumptions in the code that g->hv is always non-NULL.

Fix one test that relied on the QEMU definition.
2026-03-17 19:07:32 +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
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
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
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
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
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
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
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
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
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
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
9b32056061 Fix miscellaneous spelling mistakes
$ git ls-files | xargs codespell
2025-04-29 19:05:07 +01: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
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
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
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
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
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
Richard W.M. Jones
40f43cc8ea tests: Test guestfish --key all:... selector 2023-12-14 09:15:08 +00: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
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
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
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
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
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
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
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