Commit Graph

11903 Commits

Author SHA1 Message Date
Richard W.M. Jones
166e4e90ee 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.

(cherry picked from commit 4a79c023e5)
2024-07-09 14:42:43 +01:00
Richard W.M. Jones
25108090a1 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.

(cherry picked from commit 7e1d7c1330)
2024-07-09 14:42:43 +01:00
Jürgen Hötzel
8aafa0631b 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

(cherry picked from commit 1274452d22)
2024-07-09 14:42:43 +01:00
Richard W.M. Jones
744a257083 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));
      |            ^~~~~~

(cherry picked from commit ca20f27cb0)
2024-07-09 14:42:43 +01:00
Laszlo Ersek
56d7564eaa 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>
(cherry picked from commit 32408a9c36)
2024-07-09 14:42:43 +01:00
Laszlo Ersek
826cf6d68e 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>
(cherry picked from commit 58e2640233)
2024-07-09 14:42:43 +01:00
Richard W.M. Jones
d9ba056079 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
(cherry picked from commit f0f8e6c5fe)
2024-07-09 14:42:43 +01:00
Richard W.M. Jones
d4be44928a 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
(cherry picked from commit 7503eeebed)
2024-07-09 14:42:43 +01:00
Richard W.M. Jones
b875668bfa RHEL: Reject use of libguestfs-winsupport features except for virt-* tools (RHBZ#1240276).
Fix the tests: it doesn't let us use guestfish for arbitrary Windows
edits.
2024-07-09 14:42:43 +01:00
Richard W.M. Jones
66b9338e3d RHEL: Disable unsupported remote drive protocols (RHBZ#962113).
This disables support for unsupported remote drive protocols:

 * ftp
 * ftps
 * http
 * https
 * tftp
 * gluster
 * iscsi
 * sheepdog
 * ssh

Note 'nbd' is not disabled, and of course 'file' works.

We hope to gradually add some of these back over the lifetime of RHEL.
2024-07-09 14:42:43 +01:00
Andrey Drobyshev
d2f8308813 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>
(cherry picked from commit d0d8e67384)
2024-07-09 14:42:43 +01:00
Andrey Drobyshev
917455b158 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>
(cherry picked from commit 152d6e4bdf)
2024-07-09 14:42:43 +01:00
Andrey Drobyshev
d2e6dce96a 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>
(cherry picked from commit 9ced5fac8c)
2024-07-09 14:42:43 +01:00
Richard W.M. Jones
8c59660293 Version 1.50.2. v1.50.2 2024-07-09 14:39:03 +01:00
Richard W.M. Jones
a0cc87c1f6 Update common submodule
This pulls in:

  d61cd820b Add support for OCaml 5.0
  b636c3f20 options/keys: introduce unescape_device_mapper_lvm()
  1b4b1ce47 options/keys: key_store_import_key(): un-constify "key" parameter
  38e6988c1 mlcustomize/SELinux_relabel.ml: Use Array.mem
  17ef57a9b mlcustomize: skip SELinux relabeling if it's disabled

which should be neutral for libguestfs 1.50 stable branch.
2024-07-09 14:08:41 +01:00
Richard W.M. Jones
fd31d30b75 daemon/findfs.ml: Fix whitespace
(cherry picked from commit 4c5c0782af)
(cherry picked from commit 37a47a9b5d)
2024-07-09 14:08:41 +01:00
Richard W.M. Jones
6c14ceef31 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
(cherry picked from commit 882ef4d93a)
(cherry picked from commit 285b8fa92b)
2024-07-09 14:08:41 +01:00
Richard W.M. Jones
e8a0a2f919 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

(cherry picked from commit 27deba4074)
(cherry picked from commit c76fc5447e)
2024-07-09 14:08:41 +01:00
Richard W.M. Jones
48984f30ca 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.

(cherry picked from commit c7fe9fd917)
(cherry picked from commit f970f093fb)
2024-07-09 14:08:41 +01:00
Richard W.M. Jones
55a6c32c46 daemon: Add an OCaml binding for get_random_uuid function
(cherry picked from commit a25f419802)
(cherry picked from commit ae2344f8f2)
2024-07-09 14:08:41 +01:00
Richard W.M. Jones
99d1ee44fe generator: Allow String(GUID) parameter in daemon OCaml bindings
(cherry picked from commit 53eb96099a)
(cherry picked from commit f29092e8f4)
2024-07-09 14:08:41 +01:00
Richard W.M. Jones
f9a070f827 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.

(cherry picked from commit d5c6e15180)
(cherry picked from commit d400b0637e)
2024-07-09 14:08:41 +01:00
Richard W.M. Jones
f2bfa98f05 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.

(cherry picked from commit 2811e42b43)
(cherry picked from commit cbfe36b7c7)
2024-07-09 14:08:41 +01:00
Richard W.M. Jones
c56d8e9da1 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.

(cherry picked from commit 857615d6d2)
(cherry picked from commit c749314646)
2024-07-09 14:08:41 +01:00
Richard W.M. Jones
fa6767ef5c gobject: tests: Don't erase error messages
(cherry picked from commit e0ffe31e96)
(cherry picked from commit 073fd0aa86)
2024-07-09 14:08:41 +01:00
Richard W.M. Jones
1b1ba3b4c6 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.

(cherry picked from commit 574a87f889)
(cherry picked from commit 8cd31e58fd)
2024-07-09 14:08:41 +01:00
Richard W.M. Jones
0e9d0371d6 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.

(cherry picked from commit 87b4d19f85)
(cherry picked from commit 17061cf496)
2024-07-09 14:08:41 +01:00
Richard W.M. Jones
8205084902 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
(cherry picked from commit d755070346)
(cherry picked from commit bebec890e2)
2024-07-09 14:08:41 +01:00
Richard W.M. Jones
dacbc82718 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
(cherry picked from commit d829778529)
(cherry picked from commit 4a04ab9255)
2024-07-09 14:08:41 +01:00
Richard W.M. Jones
ef18637581 python: Fix exception name in example
Fixes: https://github.com/libguestfs/libguestfs/issues/138
(cherry picked from commit 1d760b0d8f)
(cherry picked from commit b56b5ca46c)
2024-07-09 14:08:41 +01:00
Richard W.M. Jones
96ec0b08bb 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
(cherry picked from commit 7211aac047)
(cherry picked from commit 6cfcbfd9a2)
2024-07-09 14:08:41 +01:00
Richard W.M. Jones
c7c0c97e3e daemon: parted: Print field we are extracting in error message
(cherry picked from commit c8cefa6f0f)
(cherry picked from commit 4fdc89fb51)
2024-07-09 14:08:41 +01:00
Richard W.M. Jones
5c3ca4ec85 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>
(cherry picked from commit f8cbd71400)
2024-07-09 14:08:41 +01:00
Richard W.M. Jones
13578ecdba 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

(cherry picked from commit 3cb094083e)
2024-07-09 14:06:52 +01:00
Laszlo Ersek
89b6c8b458 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>
(cherry picked from commit be11d25b3e)
2023-05-04 10:09:47 +01:00
Laszlo Ersek
5c672d1541 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>
(cherry picked from commit 7414ac40c7)
2023-05-04 10:09:43 +01:00
Richard W.M. Jones
4ca2ed3f69 Version 1.50.1. v1.50.1 2023-02-21 22:18:14 +00:00
Richard W.M. Jones
4a4fc84b5e 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
(cherry picked from commit ab52362320)
2023-02-21 20:58:25 +00:00
Richard W.M. Jones
91303865c7 website: Fix paths to development and stable releases on the website
(cherry picked from commit b6a3689d89)
2023-02-21 20:57:52 +00:00
Richard W.M. Jones
b2d32cda03 Update common submodule to latest
(cherry picked from commit cfe7d39b40)
2023-02-21 20:42:45 +00:00
Richard W.M. Jones
46bd83b8a5 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)

(cherry picked from commit 4ed83ffdbe)
2023-02-21 20:42:41 +00:00
Richard W.M. Jones
59ac5ba943 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)

(cherry picked from commit ede3632612)
2023-02-21 20:42:35 +00:00
Richard W.M. Jones
75c30fe750 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

(cherry picked from commit 250ee85839)
2023-02-21 20:42:25 +00:00
Richard W.M. Jones
2cfb5420fe 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>
(cherry picked from commit afa4d64fca)
2023-02-21 20:42:20 +00:00
Richard W.M. Jones
1b2e354359 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>
(cherry picked from commit e07304de86)
2023-02-21 20:42:14 +00:00
Richard W.M. Jones
3328fe3820 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.

(cherry picked from commit f68752462e)
2023-02-21 20:41:34 +00:00
Richard W.M. Jones
b4f4df07fb 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.

(cherry picked from commit c7d54697ca)
2023-02-21 20:40:56 +00:00
Richard W.M. Jones
ecd0395a7c 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.

(cherry picked from commit b9ccfe3e03)
2023-02-21 20:40:41 +00:00
Richard W.M. Jones
8578c62dc9 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
(cherry picked from commit bbf396fc55)
2023-02-21 20:39:59 +00:00
Richard W.M. Jones
86df8c9a1c 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
(cherry picked from commit 6ef5837e2d)
2023-02-21 20:39:53 +00:00