]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
2 years agodocs: Remind users to remove --timeout option without socket activation
Martin Kletzander [Wed, 26 Oct 2022 14:19:25 +0000 (16:19 +0200)]
docs: Remind users to remove --timeout option without socket activation

There is part of our man page that describes how to switch to the
traditional (non-socket) activation but it might still happens sometimes that
there is an extra --timeout option specified for the daemon.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoRemove Before=libvirt-guests.service from other services
Martin Kletzander [Wed, 26 Oct 2022 12:43:39 +0000 (14:43 +0200)]
Remove Before=libvirt-guests.service from other services

libvirt-guests has After= dependency for all the sockets and that is enough.
With the extra Before= in the service file systemd postpones the start of the
socket activated service (when libvirt-guests is trying to connect to the
socket) until after libvirt-guests is stopped effectively making `systemctl stop
libvirt-guests` deadlock.  The reason for that is that all stop jobs are
scheduled before any start job.  Removing the redundant Before= specification
fixes this behaviour.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoNEWS: Document my contributions for upcoming release
Michal Privoznik [Wed, 26 Oct 2022 08:25:04 +0000 (10:25 +0200)]
NEWS: Document my contributions for upcoming release

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoTranslated using Weblate (Ukrainian)
Yuri Chornoivan [Wed, 26 Oct 2022 23:20:15 +0000 (01:20 +0200)]
Translated using Weblate (Ukrainian)

Currently translated at 100.0% (10386 of 10386 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/uk/

Co-authored-by: Yuri Chornoivan <yurchor@ukr.net>
Signed-off-by: Yuri Chornoivan <yurchor@ukr.net>
2 years agoTranslated using Weblate (Korean)
김인수 [Wed, 26 Oct 2022 23:20:14 +0000 (01:20 +0200)]
Translated using Weblate (Korean)

Currently translated at 100.0% (10386 of 10386 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/ko/

Co-authored-by: 김인수 <simmon@nplob.com>
Signed-off-by: 김인수 <simmon@nplob.com>
2 years agonode_device_driver.h: Drop nodeDeviceLock() and nodeDeviceUnlock() fwd declarations
Michal Privoznik [Tue, 25 Oct 2022 13:56:33 +0000 (15:56 +0200)]
node_device_driver.h: Drop nodeDeviceLock() and nodeDeviceUnlock() fwd declarations

The node_device_driver.h declares nodeDeviceLock() and
nodeDeviceUnlock() functions which used to exist, but after
rework to automatic mutex management they exist no more. Their
last use was removed in v8.1.0-rc1~122.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agonode_device: Move fwd declaration of udevNodeRegister() into correct header file
Michal Privoznik [Tue, 25 Oct 2022 14:27:14 +0000 (16:27 +0200)]
node_device: Move fwd declaration of udevNodeRegister() into correct header file

Currently, udevNodeRegister() is forward declared in
node_device_driver.h even though the function is implemented in
node_device_udev.c which warrants node_device_udev.h header file.
Move the declaration into the correct file.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agonode_device_udev.h: Drop include of libudev.h
Michal Privoznik [Tue, 25 Oct 2022 08:20:10 +0000 (10:20 +0200)]
node_device_udev.h: Drop include of libudev.h

Nothing in the header file requires the include of libudev.h, as
the former header file is now empty.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agonode_device: Move DMI_DEVPATH into node_device_udev.c
Michal Privoznik [Tue, 25 Oct 2022 08:19:46 +0000 (10:19 +0200)]
node_device: Move DMI_DEVPATH into node_device_udev.c

The DMI_DEVPATH macro is used exclusively within
node_device_udev.c. There's no need to expose it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agonode_device_udev.h: Drop unused macro
Michal Privoznik [Tue, 25 Oct 2022 08:04:34 +0000 (10:04 +0200)]
node_device_udev.h: Drop unused macro

The SYSFS_DATA_SIZE macro is Unused since its introduction in
v0.7.3~48. Sorry Dave.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agoUpdate translation files
Weblate [Tue, 25 Oct 2022 11:11:14 +0000 (13:11 +0200)]
Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/

Co-authored-by: Weblate <noreply@weblate.org>
Signed-off-by: Fedora Weblate Translation <i18n@lists.fedoraproject.org>
2 years agoRevert "cgroup/LXC: Do not condition availability of v2 by controllers"
Pavel Hrdina [Tue, 25 Oct 2022 09:34:43 +0000 (11:34 +0200)]
Revert "cgroup/LXC: Do not condition availability of v2 by controllers"

This reverts commit e49313b54ed2a149c71f9073659222742ff3ffb0.
This reverts commit a0f37232b9c4296ca16955cc625f75eb848ace39.

Revert them together to not break build.

This fix of the issue is incorrect and breaks usage of other controllers
in hybrid mode that systemd creates, specifically usage of devices and
cpuacct controllers as they are now assumed to be part of the cgroup v2
topology which is not true.

We need to find different solution to the issue.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agopo: Refresh potfile for v8.9.0
Jiri Denemark [Tue, 25 Oct 2022 11:00:12 +0000 (13:00 +0200)]
po: Refresh potfile for v8.9.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2 years agoci: integration: Bundle only failed Avocado test results
Erik Skultety [Thu, 13 Oct 2022 08:59:08 +0000 (10:59 +0200)]
ci: integration: Bundle only failed Avocado test results

Latest versions of Avocado create 'by-status' symlink shortcuts to test
results, IOW:

 # this is the main test results directory containing all data
 $ ls <path>/avocado/job-results/latest/test-results/
 01-scripts_networks_050-transient-lifecycle.t
 02-scripts_networks_051-transient-autostart.t
 ...
 22-scripts_networks_400-guest-bandwidth.t
 by_status/

 # list only the failed tests
 $ ls -l <path>/avocado/job-results/latest/test-results/by-status/FAIL
 19-scripts_networks_360-guest-network-vepa.t ->
    <path>/avocado/job-results/latest/test-results/19-scripts_networks_360-guest-network-vepa.t

Therefore, let's bundle only the failed ones, it's going to make the
log artifacts more obvious when looking for libvirt errors.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoci: integration: Create the avocado logs artifact dir conditionally
Erik Skultety [Fri, 14 Oct 2022 10:24:59 +0000 (12:24 +0200)]
ci: integration: Create the avocado logs artifact dir conditionally

Don't create an avocado directory in the resulting log artifacts
if Avocado didn't even run (e.g. libvirt errored out on service
restart).

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoci: integration: Use 'set +e' in the log collecting job
Erik Skultety [Fri, 14 Oct 2022 10:36:06 +0000 (12:36 +0200)]
ci: integration: Use 'set +e' in the log collecting job

All 'script' blocks are defined as 'set -e' and so a single failed
return value means we won't collect some of the logs. Because of
the nature of the original job's failure some of the log sources
might not be available, but that's fine, however, the gitlab
after_script job cannot finish prematurely.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoci: integration: Only create a coredump log when a core exists
Erik Skultety [Fri, 14 Oct 2022 07:35:04 +0000 (09:35 +0200)]
ci: integration: Only create a coredump log when a core exists

It could be quite confusing looking at the job log artifacts and having
an empty coredump log in there, IOW it doesn't really give much
confidence that the reporting mechanism actually works.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoci: integration: Fix the test on avocado directory existence
Erik Skultety [Fri, 14 Oct 2022 10:33:28 +0000 (12:33 +0200)]
ci: integration: Fix the test on avocado directory existence

It's a directory, so -d should be used with 'test'.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoci: integration: Add an extra level of quoting for augeas set options
Erik Skultety [Wed, 12 Oct 2022 15:33:27 +0000 (17:33 +0200)]
ci: integration: Add an extra level of quoting for augeas set options

Both log filters and log outputs expect string values, however, augeas
apparently requires an extra level of quotes apart from the ones we
pass via shell (see comment [1]) to work properly, otherwise augeas
ignores the value and returns 0.
Without this fix we don't set libvirt's log level to debug, we don't
set logging to a file and hence we don't include the logs in CI
artifacts in case the test suite fails.

[1] https://github.com/hercules-team/augeas/issues/301#issuecomment-143699880

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoci: integration: Add virtnetworkd to the list of restarted services
Erik Skultety [Wed, 12 Oct 2022 11:21:40 +0000 (13:21 +0200)]
ci: integration: Add virtnetworkd to the list of restarted services

It was missing from the set. While at it, order the daemon set
alphabetically.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agodocs: Update best practices wrt "Fixes:" and GitLab
Michal Privoznik [Mon, 24 Oct 2022 11:45:23 +0000 (13:45 +0200)]
docs: Update best practices wrt "Fixes:" and GitLab

We document that a commit fixing an issue tracked in GitLab
should put just "Fixes: #NNN" into its commit message. But when
viewing git log, having full URL which is directly clickable is
more developer friendly and GitLab is capable of handling both.
Therefore, document that users should put full URL, just like
when fixing a bug tracked in other sites.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu: fix conversion specifier in qemuBuildVsockDevProps
Ján Tomko [Mon, 24 Oct 2022 13:31:06 +0000 (15:31 +0200)]
qemu: fix conversion specifier in qemuBuildVsockDevProps

vhostfd is a signed integer.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu: do not attempt to pass unopened vsock FD
Ján Tomko [Thu, 20 Oct 2022 14:19:20 +0000 (16:19 +0200)]
qemu: do not attempt to pass unopened vsock FD

On normal vm startup, we open a file descriptor
for the vsock device in qemuProcessPrepareHost.

However, when doing domxml-to-native, no file descriptors are open.

Only pass the fd if it's not -1, to make domxml-to-native work.

https://bugzilla.redhat.com/show_bug.cgi?id=1777212

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoNEWS: Document daemon crash on reconnect
Jiri Denemark [Fri, 14 Oct 2022 12:54:12 +0000 (14:54 +0200)]
NEWS: Document daemon crash on reconnect

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: Do not crash when canceling migration on reconnect
Jiri Denemark [Wed, 12 Oct 2022 15:45:38 +0000 (17:45 +0200)]
qemu: Do not crash when canceling migration on reconnect

When libvirtd is restarted during an active outgoing migration (or
snapshot, save, or dump which are internally implemented as migration)
it wants to cancel the migration. But by a mistake in commit
v8.7.0-57-g2d7b22b561 the qemuMigrationSrcCancel function is called with
wait == true, which leads to an instant crash by dereferencing NULL
pointer stored in priv->job.current.

When canceling migration to file (snapshot, save, dump), we don't need
to wait until it is really canceled as no migration capabilities or
parameters need to be restored.

On the other hand we need to wait when canceling outgoing migration and
since we don't have virDomainJobData at this point, we have to
temporarily restore the migration job to make sure we can process
MIGRATION events from QEMU.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu_migration: Properly wait for migration to be canceled
Jiri Denemark [Tue, 11 Oct 2022 12:00:13 +0000 (14:00 +0200)]
qemu_migration: Properly wait for migration to be canceled

In my commit v8.7.0-57-g2d7b22b561 I attempted to make
qemuMigrationSrcCancel synchronous, but failed. When we are canceling
migration after some kind of error which is detected in
in qemuMigrationSrcWaitForCompletion, jobData->status will be set to
VIR_DOMAIN_JOB_STATUS_FAILED regardless on QEMU state. So instead of
relying on the translated jobData->status in qemuMigrationSrcIsCanceled
we need to check the migration status we get from QEMU MIGRATION event.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovircgroup: Remove unused variables in virCgroupV2Available
Peter Krempa [Mon, 24 Oct 2022 11:41:34 +0000 (13:41 +0200)]
vircgroup: Remove unused variables in virCgroupV2Available

After recent commit 'contFile' and 'contStr' became unused breaking
build with clang:

../../../libvirt/src/util/vircgroupv2.c:72:26: error: unused variable 'contFile' [-Werror,-Wunused-variable]
        g_autofree char *contFile = NULL;
                         ^
../../../libvirt/src/util/vircgroupv2.c:73:26: error: unused variable 'contStr' [-Werror,-Wunused-variable]
        g_autofree char *contStr = NULL;
                         ^

Fixes: a0f37232b9c4296ca16955cc625f75eb848ace39
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2 years agocgroup/LXC: Do not condition availability of v2 by controllers
Eric van Blokland [Sun, 23 Oct 2022 12:08:28 +0000 (14:08 +0200)]
cgroup/LXC: Do not condition availability of v2 by controllers

systemd in hybrid mode uses v1 hierarchies for controllers and v2 for
process tracking.

The LXC code uses virCgroupAddMachineProcess() to move processes into
appropriate cgroup by manipulating cgroupfs directly. (Note, despite
libvirt also supports talking to systemd directly via
org.freedesktop.machine1 API.)

If this path is taken, libvirt/lxc must convince systemd that processes
really belong to new cgroup, i.e. also the tracking v2 hierarchy must
undergo migration too.

The current check would evaluate v2 backend as unavailable with hybrid
mode (because there are no available controllers). Simplify the
condition and consider the mounted cgroup2 as sufficient to touch v2
hierarchy.

This consequently creates an issue with binding the V2 mount. In hybrid
mode the V2 filesystem may be mounted upon the V1 filesystem. By reversing
the order in which backends are mounted in virCgroupBindMount this problem
is circumvented.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/182
Signed-off-by: Eric van Blokland <mail@ericvanblokland.nl>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoAdded translation using Weblate (Croatian)
Gogo Gogsi [Thu, 20 Oct 2022 10:47:01 +0000 (12:47 +0200)]
Added translation using Weblate (Croatian)

Co-authored-by: Gogo Gogsi <linux.hr@protonmail.com>
Signed-off-by: Gogo Gogsi <linux.hr@protonmail.com>
2 years agobuild: drop LINUGAS sorting rule
Ján Tomko [Thu, 20 Oct 2022 13:04:11 +0000 (15:04 +0200)]
build: drop LINUGAS sorting rule

A recent merge request from Weblate adding a new file fails syntax-check
because it adds a new language at the end of LINGUAS, instead of sorting
it alphabetically. Rather than trying to work around it, drop this
pointless rule.

Reverts: 8d160b7979ad2f5dcac79ffe85f79e5c3ae330d6
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agoqemuxml2argvtest: Don't re-parse and re-generate commandline for QAPI schema validation
Peter Krempa [Wed, 19 Oct 2022 15:10:45 +0000 (17:10 +0200)]
qemuxml2argvtest: Don't re-parse and re-generate commandline for QAPI schema validation

The removal of the special internal flag for '-netdev' validatition now
allows us to use the same virCommand object for validation of the
schema.

Pass it into the validator instead of re-parsing and re-generating
everything.

This improved the runtime of qemuxml2argvtest by ~25% on my box.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2 years agoqemu: Enable for vCPUs on hotplug
Michal Privoznik [Thu, 11 Aug 2022 10:12:35 +0000 (12:12 +0200)]
qemu: Enable for vCPUs on hotplug

As advertised in the previous commit, QEMU_SCHED_CORE_VCPUS case
is implemented for hotplug case. The implementation is very
similar to the cold boot case, except here we fork off for every
vCPU (because the implementation is done in
qemuProcessSetupVcpu() which is also the function that's called
from hotplug code). But that's okay because our hotplug APIs
allow hotplugging one device at the time.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2074559
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agoqemu: Enable SCHED_CORE for vCPUs
Michal Privoznik [Thu, 11 Aug 2022 13:25:24 +0000 (15:25 +0200)]
qemu: Enable SCHED_CORE for vCPUs

For QEMU_SCHED_CORE_VCPUS case, the vCPU threads should be placed
all into one scheduling group, but not the emulator or any of its
threads. Therefore, as soon as vCPU TIDs are detected, fork off a
child which then creates a separate scheduling group and adds all
vCPU threads into it.

Please note, this commit only handles the cold boot case. Hotplug
is going to be implemented in the next commit.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agoqemu: Enable SCHED_CORE for helper processes
Michal Privoznik [Thu, 11 Aug 2022 14:12:24 +0000 (16:12 +0200)]
qemu: Enable SCHED_CORE for helper processes

For QEMU_SCHED_CORE_FULL case, all helper processes should be
placed into the same scheduling group as the QEMU process they
serve. It may happen though, that a helper process is started
before QEMU (cold start of a domain). But we have the dummy
process running from which the QEMU process will inherit the
scheduling group, so we can use the dummy process PID as an
argument to virCommandSetRunAmong().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agoqemu_process: Enable SCHED_CORE for QEMU process
Michal Privoznik [Thu, 11 Aug 2022 09:57:54 +0000 (11:57 +0200)]
qemu_process: Enable SCHED_CORE for QEMU process

For QEMU_SCHED_CORE_EMULATOR or QEMU_SCHED_CORE_FULL the QEMU
process (and its vCPU threads) should be placed into its own
scheduling group. Since we have the dummy process running for
exactly this purpose use its PID as an argument to
virCommandSetRunAmong().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agoqemu_domain: Introduce qemuDomainSchedCoreStart()
Michal Privoznik [Wed, 10 Aug 2022 15:17:42 +0000 (17:17 +0200)]
qemu_domain: Introduce qemuDomainSchedCoreStart()

The aim of this helper function is to spawn a child process in
which new scheduling group is created. This dummy process will
then used to distribute scheduling group from (e.g. when starting
helper processes or QEMU itself). The process is not needed for
QEMU_SCHED_CORE_NONE case (obviously) nor for
QEMU_SCHED_CORE_VCPUS case (because in that case a slightly
different child will be forked off).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agoqemu_conf: Introduce a knob to set SCHED_CORE
Michal Privoznik [Tue, 26 Apr 2022 14:57:03 +0000 (16:57 +0200)]
qemu_conf: Introduce a knob to set SCHED_CORE

Ideally, we would just pick the best default and users wouldn't
have to intervene at all. But in some cases it may be handy to
not bother with SCHED_CORE at all or place helper processes into
the same group as QEMU. Introduce a knob in qemu.conf to allow
users control this behaviour.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agovirCommand: Introduce APIs for core scheduling
Michal Privoznik [Wed, 27 Apr 2022 10:22:24 +0000 (12:22 +0200)]
virCommand: Introduce APIs for core scheduling

There are two modes of core scheduling that are handy wrt
virCommand:

1) create new trusted group when executing a virCommand

2) place freshly executed virCommand into the trusted group of
   another process.

Therefore, implement these two new operations as new APIs:
virCommandSetRunAlone() and virCommandSetRunAmong(),
respectively.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agovirprocess: Core Scheduling support
Michal Privoznik [Tue, 26 Apr 2022 12:05:27 +0000 (14:05 +0200)]
virprocess: Core Scheduling support

Since its 5.14 release the Linux kernel allows userspace to
define trusted groups of processes/threads that can run on
sibling Hyper Threads (HT) at the same time. This is to mitigate
side channel attacks like L1TF or MDS. If there are no tasks to
fully utilize all HTs, then a HT will idle instead of running a
task from another (un-)trusted group.

On low level, this is implemented by cookies (effectively an UL
value): processes in the same trusted group share the same cookie
and cookie is unique to the group. There are four basic
operations:

1) PR_SCHED_CORE_GET -- get cookie of given PID,
2) PR_SCHED_CORE_CREATE -- create a new unique cookie for PID,
3) PR_SCHED_CORE_SHARE_TO -- push cookie of the caller onto
   another PID,
4) PR_SCHED_CORE_SHARE_FROM -- pull cookie of another PID into
   the caller.

Since a system where the code is built can be different to the
one where the code is ran let's provide declaration of some
values. It's not unusual for distros to ship older linux-headers
than the actual kernel.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agoqemu: Refresh rx-filters more often
Michal Privoznik [Fri, 30 Sep 2022 14:28:24 +0000 (16:28 +0200)]
qemu: Refresh rx-filters more often

There are couple of scenarios where we need to reflect MAC change
done in the guest:

  1) domain restore from a file (here, we don't store updated MAC
     in the save file and thus on restore create the macvtap with
     the original MAC),
  2) reconnecting to a running domain (here, the guest might have
     changed the MAC while we were not running),
  3) migration (here, guest might change the MAC address but we
     fail to respond to it,

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: Refresh state after restore from a save image
Michal Privoznik [Tue, 18 Oct 2022 07:44:54 +0000 (09:44 +0200)]
qemu: Refresh state after restore from a save image

When restoring a domain from a save image, we need to query QEMU
for some runtime information that is not stored in status XML, or
even if it is, it's not parsed (e.g. virtio-mem actual size, or
soon rx-filters for macvtaps).

During migration, this is done in qemuMigrationDstFinishFresh(),
or in case of newly started domain in qemuProcessStart(). Except,
the way that the code is written, when restoring from a save
image (which is effectively a migration), the state is never
refreshed, because qemuProcessStart() sees incoming migration so
it does not refresh the state thinking it'll be done in the
finish phase. But restoring from a save image has no finish
phase. Therefore, refresh the state explicitly after the domain
was restored but before vCPUs are resumed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: Acquire QUERY job instead of MODIFY when handling NIC_RX_FILTER_CHANGED event
Michal Privoznik [Fri, 7 Oct 2022 14:47:10 +0000 (16:47 +0200)]
qemu: Acquire QUERY job instead of MODIFY when handling NIC_RX_FILTER_CHANGED event

We are not updating domain XML to new MAC address, just merely
setting host side of macvtap. But we don't need a MODIFY job for
that, QUERY is just fine.

This allows us to process the event should it occur during
migration.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: Move parts of NIC_RX_FILTER_CHANGED event handling into a function
Michal Privoznik [Fri, 30 Sep 2022 14:01:38 +0000 (16:01 +0200)]
qemu: Move parts of NIC_RX_FILTER_CHANGED event handling into a function

Parts of the code that responds to the NIC_RX_FILTER_CHANGED
event are going to be re-used. Separate them into a function
(qemuDomainSyncRxFilter()) and move the code into qemu_domain.c
so that it can be re-used from other places of the driver.

There's one slight change though: instead of passing device alias
from the just received event to qemuMonitorQueryRxFilter(), I've
switched to using the alias stored in our domain definition. But
these two are guaranteed to be equal. virDomainDefFindDevice()
made sure about that, if nothing else.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoprocessNicRxFilterChangedEvent: Free @guestFilter and @hostFilter automatically
Michal Privoznik [Fri, 30 Sep 2022 13:55:46 +0000 (15:55 +0200)]
processNicRxFilterChangedEvent: Free @guestFilter and @hostFilter automatically

There's no need to call virNetDevRxFilterFree() explicitly, when
corresponding variables can be declared as
g_autoptr(virNetDevRxFilter).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agotest: Fix parsing nested <volume> XML
Cole Robinson [Mon, 17 Oct 2022 16:11:22 +0000 (12:11 -0400)]
test: Fix parsing nested <volume> XML

Reproducer:

./build/tools/virsh \
    --connect test:///`pwd`/examples/xml/test/testnodeinline.xml \
    vol-list default-pool

Fixes: b3e33a0ef7e62169175280c647aa9ac361bd554d
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2 years agoexamples: testdriver: Add a nested inline <volume> example
Cole Robinson [Mon, 17 Oct 2022 16:10:36 +0000 (12:10 -0400)]
examples: testdriver: Add a nested inline <volume> example

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2 years agoexamples: testdriver: Add xmlns runstate example
Cole Robinson [Mon, 17 Oct 2022 16:08:49 +0000 (12:08 -0400)]
examples: testdriver: Add xmlns runstate example

The testdriver has xmlns support for overriding object default
state. demo it by pausing a VM

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2 years agovircgroup: rework virCgroupNewSelf
Pavel Hrdina [Wed, 19 Oct 2022 10:57:49 +0000 (12:57 +0200)]
vircgroup: rework virCgroupNewSelf

With the introduction of `libvirt` sub-directory to the cgroup topology
some of the cgroup configuration was moved into that sub-directory
together with the VM processes.

LXC uses virCgroupNewSelf() in the container process to detect cgroups
in order to report various data from cgroups inside the container.

We need to properly detect the new `libvirt` sub-directory here
otherwise LXC will report incorrect data.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agovircgroupmock: fix cgroup v1 mocking
Pavel Hrdina [Wed, 19 Oct 2022 11:54:18 +0000 (13:54 +0200)]
vircgroupmock: fix cgroup v1 mocking

The `legacy` mode is also valid so we need to take it into account as
well.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agodocs: Do not support non-socket activated modular daemons with systemd
Martin Kletzander [Tue, 18 Oct 2022 12:15:38 +0000 (14:15 +0200)]
docs: Do not support non-socket activated modular daemons with systemd

Due to the setup of the modular daemon service files the reverting to non-socket
activated daemons could have never worked.  The reason is that masking the
socket files prevents starting the daemons since they require (as in Requires=
rather than Wants= in the service file) the sockets.  On top of that it creates
issues with some libvirt-guests setups and needlessly increases our support
matrix.

Nothing prevents users to modify their setup in a way that will still work
without socket activation, but supporting such setup only creates burden on our
part.

This technically reverts most of commit 59d30adacd1d except the change made to
the libvirtd manpage since the monolithic daemon still supports traditional mode
of starting even on systemd.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2 years agoqemu_driver: add new stats worker qemuDomainGetStatsVm
Amneesh Singh [Wed, 7 Sep 2022 10:34:23 +0000 (16:04 +0530)]
qemu_driver: add new stats worker qemuDomainGetStatsVm

This patch adds a new worker qemuDomainGetStatsVm which reports the
stats returned by "query-stats" via qemuMonitorQueryStats for the VM
target.

Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
2 years agoqemu_driver: add the vCPU stats by KVM to the current stats
Amneesh Singh [Wed, 7 Sep 2022 10:34:22 +0000 (16:04 +0530)]
qemu_driver: add the vCPU stats by KVM to the current stats

This patch adds the stats queried by qemuMonitorQueryStats for vCPU and
add them according to their QOM device path

Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
2 years agoqemu_monitor: add qemuMonitorGetStatsByQOMPath
Amneesh Singh [Wed, 7 Sep 2022 10:34:21 +0000 (16:04 +0530)]
qemu_monitor: add qemuMonitorGetStatsByQOMPath

This function returns the virJSONValue object which has the
same qom_path as specified.

Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
2 years agoqemu_domain: add statsSchema to qemuDomainObjPrivate
Amneesh Singh [Wed, 7 Sep 2022 10:34:20 +0000 (16:04 +0530)]
qemu_domain: add statsSchema to qemuDomainObjPrivate

This patch adds a hashtable for storing the stats schema and a function
to refresh it by querying "query-stats-schemas" using
qemuMonitorQueryStatsSchema

Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
2 years agoqemu_capabilities: add "query-stats-schemas" QMP command to the QEMU capabilities
Amneesh Singh [Wed, 7 Sep 2022 10:34:19 +0000 (16:04 +0530)]
qemu_capabilities: add "query-stats-schemas" QMP command to the QEMU capabilities

Related: https://gitlab.com/libvirt/libvirt/-/issues/276

Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
2 years agoqemu_monitor: add qemuMonitorQueryStatsSchema
Amneesh Singh [Wed, 7 Sep 2022 10:34:18 +0000 (16:04 +0530)]
qemu_monitor: add qemuMonitorQueryStatsSchema

Related: https://gitlab.com/libvirt/libvirt/-/issues/276

This patch adds a simple API for "query-stats-schemas" QMP command

Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
2 years agoqemu_driver: Fix indentation in qemuDomainGetStatsVcpu
Martin Kletzander [Wed, 19 Oct 2022 12:41:39 +0000 (14:41 +0200)]
qemu_driver: Fix indentation in qemuDomainGetStatsVcpu

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2 years agocputestdata: Fix test data for EPYC 7502
Tim Wiederhake [Mon, 17 Oct 2022 09:09:03 +0000 (11:09 +0200)]
cputestdata: Fix test data for EPYC 7502

Commit 5c17a7ba41 introduced a new feature (ibrs) but did not update
existing cputestdata.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2 years agoNEWS: Mention new channel and redirdev devices in domcaps
Jim Fehlig [Mon, 17 Oct 2022 17:48:34 +0000 (11:48 -0600)]
NEWS: Mention new channel and redirdev devices in domcaps

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoconf: Add channel devices to domain capabilities
Jim Fehlig [Fri, 2 Sep 2022 22:22:31 +0000 (16:22 -0600)]
conf: Add channel devices to domain capabilities

As qemu becomes more modularized, it is important for libvirt to advertise
availability of the modularized functionality through capabilities. This
change adds channel devices to domain capabilities, allowing clients such
as virt-install to avoid using spicevmc channel devices when not supported
by the target qemu.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agodocs: formatdomain: fix since tag for TPM PCR banks
Ján Tomko [Mon, 17 Oct 2022 12:26:23 +0000 (14:26 +0200)]
docs: formatdomain: fix since tag for TPM PCR banks

Fixes: a5bbe1a8b6321852634817c423695e58518c4f4f
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: validate: Clarify error messages for unsupported 3d video acceleration
Peter Krempa [Fri, 14 Oct 2022 07:49:12 +0000 (09:49 +0200)]
qemu: validate: Clarify error messages for unsupported 3d video acceleration

The error message doesn't really convey the information that 3d
acceleration works only for the 'virtio' model and similarly the same
error would be reported if qemu doesn't support acceleration, which is
hard to debug.

Split and clarify the errors.

Noticed in https://gitlab.com/libvirt/libvirt/-/issues/388

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2 years agocapabilities: use g_autofree in capabilities.c
Jiang Jiacheng [Sat, 15 Oct 2022 09:18:01 +0000 (17:18 +0800)]
capabilities: use g_autofree in capabilities.c

Use g_autofree in capabilities.c for some pointers still using manual cleanup,
and remove unnecessary cleanup.

Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agovirvhba.c: use g_autofree
ttxine [Sun, 16 Oct 2022 10:47:49 +0000 (13:47 +0300)]
virvhba.c: use g_autofree

Change strings to use g_autofree.

Signed-off-by: Maxim Kostin <ttxinee@outlook.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: Create base hugepages path on memory hotplug
Michal Privoznik [Tue, 11 Oct 2022 14:48:38 +0000 (16:48 +0200)]
qemu: Create base hugepages path on memory hotplug

Users can play all sorts of games with mount points. For
instance, they can unmount and mount back a hugetlbfs and only
after that attempt to hotplug memory.

This has an unfortunate consequence though. During memory
hotplug, when qemuProcessBuildDestroyMemoryPaths() is called the
path is created with very restrictive mode (0700) because under
the hood g_mkdir_with_parents(path, 0700) is called.

Therefore, create the driver generic portion of the path
separately.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2134009
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2 years agoqemu: Separate out hugepages basedir making
Michal Privoznik [Tue, 11 Oct 2022 14:41:35 +0000 (16:41 +0200)]
qemu: Separate out hugepages basedir making

During its initialization, the QEMU driver iterates over
hugetlbfs mount points, creating the driver specific path in each
of them ($prefix/libvirt/qemu). This path is created with very
wide mode (0777) because per-domain directories are then created
under it.

Separate this code into a function so that it can be re-used.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2 years agoqemu: Use command line to properly check for spice support
Jim Fehlig [Wed, 31 Aug 2022 23:10:55 +0000 (17:10 -0600)]
qemu: Use command line to properly check for spice support

domcapabilities reports spice graphics support even against a minimal
qemu installation without spice modules. Checking for 'query-spice'
in the list of qmp commands supported by qemu is not sufficient to
determine spice support. Checking the command line produces acurrate
results.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoconf: Add USB redirect devices to domain capabilities
Jim Fehlig [Tue, 30 Aug 2022 21:29:14 +0000 (15:29 -0600)]
conf: Add USB redirect devices to domain capabilities

As qemu becomes more modularized, it is important for libvirt to advertise
availability of the modularized functionality through capabilities. This
change adds USB redirect devices to domain capabilities, allowing clients
such as virt-install to avoid using redirdev devices when not supported
by the target qemu.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoschema: Re-structure schema for <filesystem> to avoid broken validation
Peter Krempa [Thu, 13 Oct 2022 12:01:24 +0000 (14:01 +0200)]
schema: Re-structure schema for <filesystem> to avoid broken validation

The validation of a '<filesystem type='mount'>' device fails if the
elements inside are not ordered in the order in the schema despite using
<interleave>. This is a bug in libxml2's validator as removing the
'<optional>' property from the definition of the 'type' attribute with
'mount' variable fixes the problem.

I've reported it as another instance of a seemingly related issue:

  https://gitlab.gnome.org/GNOME/libxml2/-/issues/131

Meanwhile libvirt can re-arrange the schema by extracting the common
bits into a new definition and referencing them from each of the choice
groups explicitly.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/392
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agotests: refactor pseries features parse failure tests
Daniel Henrique Barboza [Thu, 15 Sep 2022 16:22:08 +0000 (13:22 -0300)]
tests: refactor pseries features parse failure tests

The qemuxml2argvtest pseries-feature parse failure tests uses a symlink
to the pseries-features.xml test domain and control which feature it is
supposed to fail by excluding it from the capabilities list. The
advantage of this approach is that the same XML can be used in multiple
tests.

One downside is that any new pseries capability must be declared in all
existent tests, otherwise all other tests can break if this new
capability happens to be validated early in qemu_validate.c. Any new
parse_error test must declare all other existent capabilities.

Another downside is the fact that we're testing fairly improbable
scenarios: all pseries capabilities being tested here were introduced by
the same QEMU version, 4.2.0, at least as far as libvirt is aware of.
This means that it's no possible to have a scenario where, for example,
ccf-assist is not present but cfpc is. And last, but not the least, it's
getting in the way of our effort to convert all pseries tests to not use
explicit capabilities.

Changing all these tests to use DO_TEST_PARSE_ERROR_NOCAPS() will allow
us to test exactly what we want to test, which is the parse error given
for each feature if the binary does not have support for it. The XML
being used for each test can be simplified to just declare a single
feature. In the end we'll end up with more XML lines, but less
complexity inside qemuxml2argvtest.c.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2 years agotests: change qemuxml2argv pseries tests to TEST_CAPS_LATEST
Daniel Henrique Barboza [Tue, 13 Sep 2022 14:30:35 +0000 (11:30 -0300)]
tests: change qemuxml2argv pseries tests to TEST_CAPS_LATEST

Eliminate most of the pseries tests that are using explicit qemu caps
instead of CAPS_LATEST. The remaining tests will be handled in the next
patch.

The changes made are trivial: rename the .args/.err files to
ppc64-latest.(args/err) and do the required changes to match the newest
capabilities.

A notable expection were tests pseries-console-native,
pseries-serial-compat and pseries-serial+console-native. These are
aliases of the pseries-serial-native tests.  In this case we needed to
re-create the symlink accordingly.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2 years agotests: qemucapabilities: bump ppc64 caps with qemu 7.1.0
Daniel Henrique Barboza [Sat, 10 Sep 2022 10:26:50 +0000 (06:26 -0400)]
tests: qemucapabilities: bump ppc64 caps with qemu 7.1.0

No significant changes from the 7.0.0 capabilities.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2 years agoci: Install python RPMs from libvirt/libvirt-python CI artifacts
Peter Krempa [Mon, 10 Oct 2022 08:51:01 +0000 (10:51 +0200)]
ci: Install python RPMs from libvirt/libvirt-python CI artifacts

After addition of the new libvirt-client-qemu sub-package which is using
python bindings (thus creating a circular dependency between the libvirt
and libvirt-python projects) the integration jobs fail with:

  Error:
   Problem: conflicting requests
    - nothing provides python3-libvirt >= 8.9.0-1.el9 needed by libvirt-client-qemu-8.9.0-1.el9.x86_64

The libvirt-python project now provides the RPMs in artifacts:
 https://gitlab.com/libvirt/libvirt-python/-/merge_requests/96

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2 years agospec: change gettext requires to gettext-runtime for F37
Jens Petersen [Thu, 25 Aug 2022 07:56:50 +0000 (15:56 +0800)]
spec: change gettext requires to gettext-runtime for F37

See https://fedoraproject.org/wiki/Changes/GettextRuntimeSubpackage

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2 years agoqemu: Init address before qemuProcessShutdownOrReboot during reconnect process
Jiang Jiacheng [Wed, 28 Sep 2022 13:53:28 +0000 (21:53 +0800)]
qemu: Init address before qemuProcessShutdownOrReboot during reconnect process

When libvirt is restarted, the qemuProcessShutdownReboot command is
executed to restore the VM that is being restarted. In this case, a
coredump may occur when we hotplug a pci device since the PCI address
hasn't be inited yet. Moving the initialization of address to the front
of qemuProcessShutdownOrReboot to ensure that we have the address inited.

Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: Fix race condition when detaching a device
Pierre LIBEAU [Wed, 31 Aug 2022 12:22:51 +0000 (14:22 +0200)]
qemu: Fix race condition when detaching a device

If QEMU replies to device_del command with "DeviceNotFound"
error, then libvirt doesn't clean the device from the live
configuration.

This is because qemuMonitorDelDevice() returns -2 to
qemuDomainDeleteDevice() and instead of calling
qemuDomainRemoveDevice() the qemuDomainDetachDeviceLive() jumps
right onto cleanup label.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/359
Signed-off-by: Pierre LIBEAU <pierre.libeau@corp.ovh.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agocpu_map: Introduce Neoverse N1/N2/V1
Zhenyu Zhang [Thu, 29 Sep 2022 02:27:38 +0000 (22:27 -0400)]
cpu_map: Introduce Neoverse N1/N2/V1

Add Neoverse N1/N2/V1 as a supported cpu model.

Signed-off-by: Zhenyu Zhang <zhenyzha@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agoci: potfile: Add 'variables' to definition
Peter Krempa [Tue, 11 Oct 2022 07:27:24 +0000 (09:27 +0200)]
ci: potfile: Add 'variables' to definition

The 'potfile' job is lacking the 'variables' section which defines the
'NAME' variable used by the 'image' property resulting in the 'potfile'
job failing with:

 Pulling docker image registry.gitlab.com/libvirt/libvirt/ci-:latest ...
 WARNING: Failed to pull image with policy "always": invalid reference format (manager.go:235:0s)
 ERROR: Job failed: failed to pull image "registry.gitlab.com/libvirt/libvirt/ci-:latest" with specified policies [always]: invalid reference format (manager.go:235:0s)

Fixes: 491d918502e50bf15c75d183bb41e3c0de5a0e1b
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: Avoid memory leak in virQEMUCapsCPUDefsToModels
Michal Privoznik [Mon, 10 Oct 2022 13:37:17 +0000 (15:37 +0200)]
qemu: Avoid memory leak in virQEMUCapsCPUDefsToModels

The @vendor variable inside virQEMUCapsCPUDefsToModels() is
allocated, but never freed. But there is actually no need for it
to be allocated, because it merely passes a retval of
virCPUGetVendorForModel() (which returns a const string) to
virDomainCapsCPUModelsAdd() (which ten accepts the argument as
const string). Therefore, drop the g_strdup() call and fix the
type of the variable.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2 years agomeson: Bump minimal required meson version
Michal Privoznik [Fri, 7 Oct 2022 07:31:25 +0000 (09:31 +0200)]
meson: Bump minimal required meson version

Bump the minimal required version to 0.56.0. Looking into our CI
this is the oldest version we install.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoReplace dep.get_pkgconfig_variable() with dep.get_variable(pkgconfig:)
Michal Privoznik [Fri, 7 Oct 2022 07:48:00 +0000 (09:48 +0200)]
Replace dep.get_pkgconfig_variable() with dep.get_variable(pkgconfig:)

The get_pkgconfig_variable() method is deprecated in 0.56.0 and
we're recommended to use get_variable(pkgconfig : ...) instead.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agomeson: Replace external_program.path() with external_program.full_path()
Michal Privoznik [Fri, 7 Oct 2022 07:43:33 +0000 (09:43 +0200)]
meson: Replace external_program.path() with external_program.full_path()

The path() method is deprecated in 0.55.0 and we're recommended
to use full_path() instead. Interestingly, we were already doing
do in couple of places, but not all of them.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agomeson: Replace meson.source_root() with meson.project_source_root()
Michal Privoznik [Fri, 7 Oct 2022 07:37:43 +0000 (09:37 +0200)]
meson: Replace meson.source_root() with meson.project_source_root()

The source_root() method is deprecated in 0.56.0 and we're
recommended to use project_source_root() instead.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agomeson: Replace meson.build_root() with meson.project_build_root()
Michal Privoznik [Fri, 7 Oct 2022 07:31:32 +0000 (09:31 +0200)]
meson: Replace meson.build_root() with meson.project_build_root()

The build_root() method is deprecated in 0.56.0 and we're
recommended to use project_build_root() instead.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoNEWS: Document CPU reporting improvements
Jiri Denemark [Fri, 30 Sep 2022 11:08:11 +0000 (13:08 +0200)]
NEWS: Document CPU reporting improvements

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirsh: Add completer for hypervisor-cpu-baseline --model
Jiri Denemark [Thu, 6 Oct 2022 15:12:24 +0000 (17:12 +0200)]
virsh: Add completer for hypervisor-cpu-baseline --model

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirsh: Add --model option for hypervisor-cpu-baseline
Jiri Denemark [Thu, 6 Oct 2022 14:29:32 +0000 (16:29 +0200)]
virsh: Add --model option for hypervisor-cpu-baseline

This option can be used as a shortcut for creating a single XML with
just a CPU model name and no features:

    $ virsh hypervisor-cpu-baseline --model Skylake-Server
    <cpu mode='custom' match='exact'>
      <model fallback='forbid'>Skylake-Server</model>
      <feature policy='disable' name='avx512f'/>
      <feature policy='disable' name='avx512dq'/>
      <feature policy='disable' name='clwb'/>
      <feature policy='disable' name='avx512cd'/>
      <feature policy='disable' name='avx512bw'/>
      <feature policy='disable' name='avx512vl'/>
      <feature policy='disable' name='pku'/>
    </cpu>

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu_capabilities: Translate CPU blockers
Jiri Denemark [Fri, 30 Sep 2022 15:59:06 +0000 (17:59 +0200)]
qemu_capabilities: Translate CPU blockers

Since commit "cpu_x86: Disable blockers from unusable CPU models"
(v3.8.0-99-g9c9620af1d) we explicitly disable CPU features reported by
QEMU as usability blockers for a particular CPU model when creating
baseline or host-model CPU definition. When QEMU changed canonical names
for some features (mostly those with '_' in their names), we forgot to
translate the blocker lists to names used by libvirt and the renamed
features would no longer be explicitly disabled in the created CPU model
even if they were reported as blockers by QEMU.

For example, on a host where EPYC CPU model has the following blockers

    <blocker name='sha-ni'/>
    <blocker name='mmxext'/>
    <blocker name='fxsr-opt'/>
    <blocker name='cr8legacy'/>
    <blocker name='sse4a'/>
    <blocker name='misalignsse'/>
    <blocker name='osvw'/>

we would fail to disable 'fxsr-opt':

    <cpu mode='custom' match='exact'>
      <model fallback='forbid'>EPYC</model>
      <feature policy='disable' name='sha-ni'/>
      <feature policy='disable' name='mmxext'/>
      <feature policy='disable' name='cr8legacy'/>
      <feature policy='disable' name='sse4a'/>
      <feature policy='disable' name='misalignsse'/>
      <feature policy='disable' name='osvw'/>
      <feature policy='disable' name='monitor'/>
    </cpu>

The 'monitor' feature is disabled even though it is not reported as a
blocker by QEMU because libvirt's definition of EPYC includes the
feature while it is missing in EPYC definition in QEMU.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoDocument specifics of virConnectBaselineHypervisorCPU
Jiri Denemark [Fri, 7 Oct 2022 16:36:50 +0000 (18:36 +0200)]
Document specifics of virConnectBaselineHypervisorCPU

The API can be used to get usability blockers for an unusable CPU model,
which is not obvious. Let's explicitly document this behavior as it is
now mentioned in the documentation of domain capabilities XML.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agodocs: Enhance documentation of CPU models in domain caps
Jiri Denemark [Fri, 7 Oct 2022 16:16:09 +0000 (18:16 +0200)]
docs: Enhance documentation of CPU models in domain caps

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agocpu_arm: Don't implement virCPUGetVendorForModel
Jiri Denemark [Thu, 29 Sep 2022 19:54:34 +0000 (21:54 +0200)]
cpu_arm: Don't implement virCPUGetVendorForModel

This patch is effectively a no-op, but I wanted to initialize
.getVendorForModel explicitly as implementing this function does not
even make sense on ARM. The CPU models in our CPU map are only used for
describing host CPU in capabilities XML and cannot be used for guest CPU
definition in domain XML anyway. The CPU models listed as supported in
domain capabilities XML are just passed through from QEMU.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agocpu_ppc64: Implement virCPUGetVendorForModel
Jiri Denemark [Thu, 29 Sep 2022 19:51:22 +0000 (21:51 +0200)]
cpu_ppc64: Implement virCPUGetVendorForModel

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agocpu_x86: Implement virCPUGetVendorForModel
Jiri Denemark [Thu, 29 Sep 2022 19:40:40 +0000 (21:40 +0200)]
cpu_x86: Implement virCPUGetVendorForModel

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoIntroduce virCPUGetVendorForModel and use it in QEMU driver
Jiri Denemark [Thu, 29 Sep 2022 14:32:27 +0000 (16:32 +0200)]
Introduce virCPUGetVendorForModel and use it in QEMU driver

So far QEMU driver does not get CPU model vendor from QEMU directly and
it has to ask the CPU driver for the info stored in CPU map.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agodomain_capabilities: Add vendor attribute for CPU models
Jiri Denemark [Fri, 30 Sep 2022 09:46:29 +0000 (11:46 +0200)]
domain_capabilities: Add vendor attribute for CPU models

Even though several CPU models from various vendors are reported as
usable on a given host, user may still want to use only those that match
the host vendor. Currently the only place where users can check the
vendor of each CPU model is our CPU map, which is considered internal
and users should not really be using it directly. So to allow for such
filtering we now advertise the vendor of each CPU model in domain
capabilities.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: Do not pass qemuCaps to virQEMUCapsCPUFeature{To,From}QEMU
Jiri Denemark [Fri, 30 Sep 2022 16:34:05 +0000 (18:34 +0200)]
qemu: Do not pass qemuCaps to virQEMUCapsCPUFeature{To,From}QEMU

The only part of qemuCaps both functions are interested in is the CPU
architecture. Changing them to expect just virArch makes the functions
more reusable.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agocpu_ppc64: Avoid repeated loading of CPU map
Jiri Denemark [Fri, 30 Sep 2022 09:03:15 +0000 (11:03 +0200)]
cpu_ppc64: Avoid repeated loading of CPU map

The ppc64 CPU code still has to load and parse the CPU map everytime it
needs to look at it, which can make some operations pretty slow. Other
archs already switched to loading the CPU map once and keeping the
parsed structure in memory. Let's switch ppc64 as well.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: virDomainCapsCPUModelsAdd never fails
Jiri Denemark [Thu, 29 Sep 2022 14:30:19 +0000 (16:30 +0200)]
conf: virDomainCapsCPUModelsAdd never fails

Since the function always returns 0, we can just return void and make
callers simpler.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirNetServerProgramDispatchCall: Avoid calling xdr_free(_, NULL)
Michal Privoznik [Fri, 7 Oct 2022 11:05:03 +0000 (13:05 +0200)]
virNetServerProgramDispatchCall: Avoid calling xdr_free(_, NULL)

In recent commit of v8.8.0-41-g41eb0f446c I've suggested during
review to put both xdr_free() calls under error label, assuming
that xdr_free() accepts NULL and thus is a NOP when the control
jumps onto the label even before either of @arg or @ret was
allocated. Well, turns out, xdr_free() does no accept NULL and
thus we have to guard its call. But since @dispatcher is already
set by the time either of the variables is allocated, we can
replace the condition from 'if (dispatcher)' to 'if (arg)' and
'if (ret)'.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agosrc: warn if client hits the max requests limit
Daniel P. Berrangé [Wed, 24 Aug 2022 15:15:24 +0000 (16:15 +0100)]
src: warn if client hits the max requests limit

Since they are simply normal RPC messages, the keep alive packets are
subject to the "max_client_requests" limit just like any API calls.

Thus, if a client hits the 'max_client_requests' limit and all the
pending API calls take a long time to complete, it may result in
keep-alives firing and dropping the client connection.

This has been seen by a number of users with the default value of
max_client_requests=5, by issuing 5 concurrent live migration
operations.

By printing a warning message when this happens, admins will be alerted
to the fact that their active clients are exceeding the default client
requests limit.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>