Sections about resource limits are currently placed across the file
in between various device examples. To make it easier to follow,
group them into a single section. This also allows to give
an introduction on the rctl(8) framework once instead of repeating
it for every resource type.
Also, document the memory limitation support added in libvirt 12.4.0.
Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
The time_t type can be 32bit or 64bit signed integer. There are
systems where it's defined as long, or long long (32bit systems
usually). Therefore, using just 'l' length modifier is not good
enough. Also, using 'u' conversion specifier is also wrong
(though, values stored in qemuNbdkitCaps struct reflect mtime of
some files, so there won't be a negative value).
Anyway, do what we already do for virQEMUCaps - use '%lld' printf
format and typecast to long long.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
There are some features/improvements/bug fixes I've either
contributed or reviewed/merged. Document them for upcoming
release.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
When running qemuxmlconftest under valgrind, it fails with a
symbol lookup error:
valgrind: symbol lookup error: libvirt.git/_build/tests/libqemuxml2argvmock.so: undefined symbol: virTestMakeDummyFD
This occurs because qemuxml2argvmock uses the
virTestMakeDummyFD() function (implemented in testutils.c) but
does not explicitly link against test_utils_lib. Fix this by
linking the test utils library to the mock library, statically.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
The devel@lists.libvirt.org mailing list rewrites the From: header
for DMARC reasons, so patches submitted via the list land in git as
'<Real Name> via Devel <devel@lists.libvirt.org>'. This currently
affects 30 commits across 13 distinct contributors, all of whom are
identifiable by their Signed-off-by trailer.
Add mailmap entries that remap each mangled identity back to the
author's real name and address, matching the approach used by the
Linux kernel for the same problem.
Beyond cosmetic cleanup, this keeps contribution statistics
(git shortlog, contributor graphs) accurate and ensures contributors
get proper credit for their work, which is valuable when they look
for new positions or otherwise need a verifiable record of upstream
activity.
This approach is standard for such situations in Linux kernel. I have
seen this several times.
Signed-off-by: Denis V. Lunev <den@openvz.org>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Similarly to previous commits use real FDs so that we don't risk
collisions.
Note that for the test cases passing multiple tap and vhost FDs the
helpers which stabilize the output don't actually work, as the FDs are
concatenated. For now we'll not deal with this and simply leave them
censored by the 'XXXXXXX' string.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
The code was refactored to allow any FD numbers so the code to map them
to specific numbers is no longer needed.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
While VDPA disks did use real FDs they used convoluted infrastructure
for mapping them to specific numbers. Remove that since we can now mask
them from the output args instead.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Use virTestMakeDummyFD() to get a real FD for the test in
qemuxmlconftest.
Use virTestMakeDummyFD() also in qemuhotplugmock.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Use 'virTestMakeDummyFD()' to create real FDs both for 'tpmfd' and
'cancelfd'.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Initialize the chardev backends for vhost-user graphics to use real FDs.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Use the virTestMakeDummyFD() function to setup real FDs for all chardev
backends which are set up via testQemuPrepareHostBackendChardevOne.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Thanks to real FD testing we no longer need to inject test
infrastructure into production code. Remove it.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Switch over to 'virTestMakeDummyFD' which allows to use real FDs in the
test and also allows to track them in the output files in a stable way.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Switch to 'virTestMakeDummyFD' which uses a real FD. No otuputs are
changed thanks to the code which censors 'fd' field of --add-fd.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Use 'testCompareXMLToArgvStabilizeOne' to provide stable test outputs
even when we'll switch to real FDs in tests.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Install hanlder to stabilize 'vhostfd' fds in -device so that we can
later switch tests to use real FDs.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Install the handler to stabilize output files on '-object' with
'iommufd' qom type which references a FD directly via the 'fd' property.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Use 'testCompareXMLToArgvStabilizeOne' to censor FD values in '-chardev'
commands for stable test outputs without the need for fake FDs.
For monitor sockets this also creates a hint '@mon-fd@' to be used as
substitution to prevent any further churn on basically every .args file.
The substitution is done by temporarily using another fake FD (1764)
instead of 1729 so that it's unique.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Add code which walks the generated argument list and allows to strip out
and replace by a substitution any field in either JSON or legacy qemu
argument string.
Use it to stabilize 'fd' field of '-add-fd'
This will allow us to rip out code which tries to allocate stable FD
numbers, which doesn't work reliably (e.g. if the environment passes
some FDs).
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Upcoming patches will introduce use of real FDs for tests. Since the
test will go through many FDs they will collide with the fake ones
allocated randomly in qemuxml2argvmock.
Move them out for now until they are replaced and masked out from the
tests.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
The helper makes a dummy (file) FD to be used as FD in tests which want
to handle a FD but don't really use it. It also optionally records the
FD number along with a hint in a hash table which can be later
used to fetch the hint and stabilize test outputs.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Add a helper which replaces the value part of a JSON object key. This
will be helpful in tests where we'll want to rewrite some outputs (e.g.
fds) to stabilize output files.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Access the args directly rather than fetching a copy since we have a new
helper now.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Introduce virCommandArgListAccess which returns 'args' and 'nargs'
Upcoming patches will add code which censores/stabilizes FD numbers in
test outputs. This will be done by rewriting the argument of the command
before comparing it with test output. Add a test-only function to
directly access 'args' and 'nargs' of a virCommand to do this
modification.
This accessor will also be used instead of 'virCommandGetArgList' in
'testCompareXMLToArgvValidateSchema' to avoid needles copy of all
arguments.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
The 'virCommandPass' mock in 'qemuxml2argvmock.so' skipped passing most
FDs to the real implementation of 'virCommandPass', except for few fake
FDs that were hardcoded.
This meant that if a test case had an valid FD that it used for testing
that FD would be leaked. At the same time fake fds 1730, 1731, 1732
would be actually passed to the virCommand itself although the FD was
invalid.
Since neither of the above makes sense fix the implementation the
following way:
- refuse to pass any STDIO fds
They are real and they would break test program output. Some tests
do try to use them errorneously; they will be addressed later.
- pass real FDs to virCommand
Real FDs can be properly handled by virCommand. Especially they will
be closed once the virCommand object is disposed of.
- don't pass fake FDs
They create extra noise e.g. in valgrind. Skip those as it makes no
sense to handle those.
This patch addresses most failures that valgrind reports with
--track-fds=all.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Some test cases (qemuxmlconftest) currently use made up descriptors,
which cause e.g. valgrind to be unhappy:
==831186== File descriptor 1729 Invalid file descriptor
==831186== at 0x531042E: fgetxattr (in /usr/lib64/libc.so.6)
==831186== by 0x5AE2846: ??? (in /usr/lib64/libselinux.so.1)
==831186== by 0x5AE7093: fgetfilecon_raw (in /usr/lib64/libselinux.so.1)
==831186== by 0x4EB736F: qemuFDPassLogFDInfo (qemu_fd.c:92)
==831186== by 0x4EB7B8E: qemuFDPassDirectTransferCommand (qemu_fd.c:443)
when tracking FDs. Since 'qemuFDPassLogFDInfo' just logs information
about the FD we can simply not query the FD if it's made up.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Extract the lookup of used FDs and their setup to virCommandMassClose
rather than duplicate it in the two functions we have for using
different modes of FD closing.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
The tests now use 'testQemuPrepareHostBackendChardevOne' which replaces
'qemuProcessPrepareHostBackendChardevOne' which is skipped as it is a
host setup step.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
When entering an interactive session, that is, without a command
specified:
virsh --connect $URI
virsh currently segfaults because it tries to access
ctl->cmd->def->handler and the ctl->cmd is NULL.
Fix by checking if ctl->cmd is not NULL before doing further checks.
Fixes: b489eb8d6b
Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
The --engine flag was being added to positional_args before the "run"
subcommand, which resulted in incorrect lcitool invocations:
lcitool container --engine podman run ... (wrong)
This caused "invalid choice: 'podman'" errors because lcitool expected
a COMMAND argument at that position.
Fix by moving the --engine flag to opts array, which is added after
the "run" subcommand, resulting in the correct command structure:
lcitool container run --engine podman ... (correct)
Example:
$ ./ci/helper run fedora-44 --job codestyle --engine podman
usage: lcitool container [-h] COMMAND ...
lcitool container: error: argument COMMAND: invalid choice: 'podman' (choose from engines, build, run, shell)
The same error happens if "--engine" option is set to different
than "auto" value.
Signed-off-by: Radoslaw Smigielski <rsmigiel@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Emit the channel lifecycle event on VSERPORT_CHANGE
and when refreshing virtio state.
On "org.qemu.guest_agent.0" channel state change both
agent and channel lifecycle events are emitted in that order.
Signed-off-by: Lucas Kornicki <lucas.kornicki@nutanix.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Add support for a new domain event which can be used to track
the state of any virtio channel.
Previously one could only monitor the "org.qemu.guest_agent.0" channel
which had a dedicated agent lifecycle event. The channel lifecycle event
will be emitted alongside the agent specific one.
Signed-off-by: Lucas Kornicki <lucas.kornicki@nutanix.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Factor out all rctl(8) execution code to bhyve_rctl.c.
Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Implement the domainGetMemoryParameters() API for the bhyve driver.
To parse live limits execute rctl(8) to list the active rules and parse
them.
Introduce the bhyve_rctl.c for working with rctl(8).
Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Add support of the memtune's hard_limit configuration:
<memtune>
<hard_limit ... >
</memtune>
to the bhyve driver.
Just like in the block I/O tuning case, memory limits are set using the
rctl(8) tool.
Syntax for that is:
rctl -a process:<pid>:memoryuse:deny=1073741824
Extend bhyveSetResourceLimits() to execute this command if it's
requested by the domain XML.
Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>