Commit Graph

12202 Commits

Author SHA1 Message Date
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. v1.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. v1.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. v1.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. v1.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. v1.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