We will no longer support overriding the qemu binary at compile time.
Instead we will pick a suitable default qemu at runtime (see other
commits) or allow the user to override qemu at runtime by calling
guestfs_set_hv() or setting LIBGUESTFS_HV.
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.
For the libvirt backend we no longer need to determine if we're using
a custom hypervisor using black magic. Instead we can simply check if
g->hv is non-NULL.
In a following commit, g->hv may now be NULL if the user does not
explicitly either call guestfs_set_hv or set LIBGUESTFS_HV.
There were multiple places in the code that assumed g->hv was not
NULL, so they were all revised so that now g->hv is only not NULL if
set by the user and (in the normal case) is NULL meaning "use the
default hypervisor".
For the direct backend we call get_default_hv_direct early on and set
data->qemu in the handle. We need to modify the KVM test so that the
current qemu binary is passed along.
We also have to change execve to execvpe since the path to qemu is not
absolute.
With the libvirt backend this test will fail since we don't (and
can't) know the default qemu until the appliance has launched.
Since this is a deprecated API, delete the test.
Change the implementation of guestfs_get_hv so that if a custom
hypervisor was not set (eg. by an earlier call to guestfs_set_hv) then
we will return the default hypervisor reported by the backend.
This changes the API slightly because we can now return an error here
in the libvirt backend case if the appliance has not been launched
yet.
Add a generic way for backends to report the default hypervisor
(ie. QEMU) back to the main code.
The direct implemention reflects the current way that the hypervisor
is chosen at configure time (see m4/guestfs-qemu.m4).
For the libvirt backend, we are already getting this from libvirt
domcapabilities, so we can just return that field.
Note this may return NULL (roughly "no data"), particularly in the
libvirt case because that requires us to have launched the appliance
already.
I'm not sure what versions of qemu lack virtio-serial support, but
it's not ones that we have ever seen, so remove this test. Also
virtio-serial doesn't work without kernel support, but we never tested
that.
If qemu or the guest kernel really lacks virtio-serial (likely it has
been compiled out) then we'll see it as soon as someone uses
libguestfs.
This also removes QEMU_OPTIONS_FOR_CONFIGURE, and the test of the qemu
version, since both are no longer used after we remove this test.
Pulls in the following commits:
Cole Robinson (2):
virtio-win: Install blnsvr.exe to C:\Windows\Drivers\VirtIO
build: mark some ocaml commands with $(AM_V_GEN)
Richard W.M. Jones (6):
mlstdutils: Export List.assoc_opt
mlcustomize/firstboot.ml: Be more careful about quoting
mlcustomize: Create a sentinel file when firstboot completes
mlutils/c_utils-c.c: Throw Unix_error on failure
Use caml_unix_error instead of unix_error
mlutils/unix_utils.ml: statvfs_is_network_filesystem should not be noalloc
grass-lu (1):
Add support for Kylin, NeoKylin and Anolis Linux
shivanayak (5):
common: fix FILE stream leak in worker_thread on guestfs_create failure (#27)
options: fix memory leak in read_key on getline failure (#30)
edit: check WIFEXITED before WEXITSTATUS in edit_file_editor and edit_file_perl (#31)
mlutils: fix pattern leak in mkdtemp wrapper on failure
qemuopts: check for write errors in qemuopts_to_channel and qemuopts_to_config_channel (#33)
When strdup() fails partway through the loop, caml_raise_out_of_memory()
longjmps without freeing the previously allocated strings or the array.
Free all prior allocations before raising the exception.
Co-authored-by: Claude <noreply@anthropic.com>
When guestfs_impl_add_drive_opts is called outside CONFIG state, the
hotplug error path returns -1 without freeing the already-allocated
drv structure.
Co-authored-by: Claude Local LLM <noreply@anthropic.com>
When realpath() succeeds but subsequent operations fail, the
allocated path is leaked. Add free(ret) before returning -1
on both error paths.
Co-authored-by: Claude <norep@anthropic.com>
blkid.c: In function ‘test_blkid_p_i_opt’:
blkid.c:105:3: error: label ‘command_failed’ defined but not used [-Werror=unused-label]
105 | command_failed:
| ^~~~~~~~~~~~~~
Fixes: https://github.com/libguestfs/libguestfs/pull/315
Fixes: commit ff4467a1a4
Add missing NULL check after fdopen in both rc_listen and rc_remote.
In rc_listen, fdopen failure on a valid fd indicates something
fundamentally broken, so abort. In rc_remote, return an error to
the caller.
Co-authored-by: Claude <nor@anthropic.com>
In rlc_insert and xac_insert (lib/fuse.c), both functions take
ownership of a parameter (link and xattrs respectively) but fail to
free it when their own malloc calls fail. Under memory pressure in a
long-running FUSE process, each failed cache insertion leaks the
owned resource.
Co-authored-by: Claude <nore@anthro.com>
When popen or do_inotify_read fails, the file descriptor created by
mkstemp is never closed before returning. Add close(fd) to both
error paths to prevent file descriptor leaks.
Co-authored-by: Claude <noreply@anthropic.com>
- debug.c: fix memory leak of out buffer on opendir failure in
debug_fds. After fclose on open_memstream, the out buffer is
allocated and must be freed.
- file.c: add missing reply_with_perror on strdup failure in
do_zfile, so callers get a proper error message instead of
silent NULL return.
- blkid.c: fix wrong error variable used at command_failed label
in test_blkid_p_i_opt. The second commandr stores its error in
err2, but goto command_failed would report err from the first
command. Inline the error reporting with the correct variable.
Co-authored-by: Claude <noreply@anthropic.com>
The string allocated by generic_qmp_test via safe_strdup is passed to
parse_has_kvm but never freed afterwards, leaking memory on every KVM
capability check. Use CLEANUP_FREE to ensure automatic cleanup.
Co-authored-by: Claude <noreply@anthropic.com>
When vgcfgbackup fails or subsequent file operations fail, the
temporary file created by mkstemp is never unlinked. Add unlink(tmp)
to all error paths after mkstemp to prevent temp files accumulating
in /tmp.
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
When realloc fails, vp is NULL so free(vp) is a no-op. The original
matches array (and all r strings allocated by aug_match) is leaked.
Use free_stringslen to properly free the array and its contents.
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
The build emits a lot of warnings like this:
po4a-translate is deprecated. The unified po4a(1) program is more convenient and less error prone. Once
configured, `po4a --no-update` can be used as a drop-in replacement to `po4a-translate`.
po4a::pod: A new SimplePod parser is now available. Please consider using it instead of the current Pod
module. If you encounter any bugs, your reports would be greatly appreciated. To use it, add
the following line at the top of your po4a configuration file: "[po4a_alias:Pod] SimplePod".
You can disable this message by setting the no-warn-simple option. Sorry for the noise, and
thank you!
But we can suppress them with some options to the po4a tools.
Actually fixing it is tracked here:
https://github.com/libguestfs/libguestfs/issues/312
(cherry picked from virt-v2v commit
865f1ced9fedd9c3121b44b2f3461727ce9dfadc)
Signed-off-by: Cole Robinson <crobinso@redhat.com>
Fails for me with:
No rule to make target 'com_redhat_et_libguestfs_GuestFS.h'
libguestfs_jni_la_SOURCES is inside the `HAVE_JAVA` conditional,
but apparently with automake that doesn't matter, and _SOURCES
will always be copied into Makefile.in, making `make dist` fail
even if we never built anything in the java/ directory.
That header is in BUILT_SOURCES already which apparently does
what we want (and is _not_ copied unconditionally to Makefile.in).
So just drop the offending line
Signed-off-by: Cole Robinson <crobinso@redhat.com>
+ start branch names with `ci/` to easily test in a fork
+ add `workflow_dispatch` to allow manually triggering jobs on
any branch
Signed-off-by: Cole Robinson <crobinso@redhat.com>
(cherry picked from commit v2v
df23b503c22579468d7c544c1724507ede84948d)
Qemu will refuse to start on some (all?) architectures if firmware
files are missing, or for other reasons, and complain to stderr. Those
messages should be made visible to the user as part of the error message.
+ ubuntu
+ fix build by adding --disable-ruby
+ fix a test failure due to missing python libvirt import
+ fedora
+ use `--privileged` docker flag which also handles seccomp disable
+ this makes some network tests work, so enable them
+ exclude a flakey test
+ better document remaining disabled tests
Signed-off-by: Cole Robinson <crobinso@redhat.com>
The `su -c` usage seems to be leftover from someone else's
CI config that was used for inspiration. Drop it. Test suite
in containers now run as root.
The libvirt pieces and new test exclusions were what I needed
to get the test suite working under root
Signed-off-by: Cole Robinson <crobinso@redhat.com>
This was added in 2014, we can safely depend on it being available
now. Existing tests will ensure it doesn't regress
Signed-off-by: Cole Robinson <crobinso@redhat.com>
When building lists of things in Makefiles it's convenient to have a
list terminator to avoid hanging backslash problems. eg:
EXTRA_DIST = \
thing1 \
thing2 \
$(NULL)
Cherry picked from virt-v2v commit 09b86c07bf19beba9ccb8fcca0ebfae34dd56406
Cherry picked from guestfs-tools commit dad8c0d3803dcbc91e22ca35c630d9e8a01df81b
While debugging some udev issues, I found use of 'udevadm monitor' to
be fairly useful. Add a suggested debugging command that might be
used, but comment it out.
Thanks: Alasdair Kergon
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
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
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>