]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
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>
2 years agotools: add virt-qemu-qmp-proxy for proxying QMP via libvirt QEMU guests
Daniel P. Berrangé [Fri, 27 May 2022 09:34:47 +0000 (10:34 +0100)]
tools: add virt-qemu-qmp-proxy for proxying QMP via libvirt QEMU guests

Libvirt provides QMP passthrough APIs for the QEMU driver and these are
exposed in virsh. It is not especially pleasant, however, using the raw
QMP JSON syntax. QEMU has a tool 'qmp-shell' which can speak QMP and
exposes a human friendly interactive shell. It is not possible to use
this with libvirt managed guest, however, since only one client can
attach to the QMP socket at any point in time. While it would be
possible to configure a second QMP socket for a VM, it may not be
an known requirement at the time the guest is provisioned.

The virt-qmp-proxy tool aims to solve this problem. It opens a UNIX
socket and listens for incoming client connections, speaking QMP on
the connected socket. It will forward any QMP commands received onto
the running libvirt QEMU guest, and forward any replies back to the
QMP client. It will also forward back events.

  $ virsh start demo
  $ virt-qmp-proxy demo demo.qmp &
  $ qmp-shell demo.qmp
  Welcome to the QMP low-level shell!
  Connected to QEMU 6.2.0

  (QEMU) query-kvm
  {
      "return": {
          "enabled": true,
          "present": true
      }
  }

Note this tool of course has the same risks as the raw libvirt
QMP passthrough. It is safe to run query commands to fetch information
but commands which change the QEMU state risk disrupting libvirt's
management of QEMU, potentially resulting in data loss/corruption in
the worst case. Any use of this tool will cause the guest to be marked
as tainted as an warning that it could be in an unexpected state.

Since this tool introduces a python dependency it is not desirable
to include it in any of the existing RPMs in libvirt. This tool is
also QEMU specific, so isn't appropriate to bundle with the generic
tools. Thus a new RPM is introduced 'libvirt-clients-qemu', to
contain additional QEMU specific tools, with extra external deps.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agoci: refresh with latest lcitool manifest
Daniel P. Berrangé [Fri, 30 Sep 2022 08:50:04 +0000 (04:50 -0400)]
ci: refresh with latest lcitool manifest

This refresh switches the CI for contributors to be triggered by merge
requests. Pushing to a branch in a fork will no longer run CI pipelines,
in order to avoid consuming CI minutes. To regain the original behaviour
contributors can opt-in to a pipeline on push

   git push <remote> -o ci.variable=RUN_PIPELINE=1

This variable can also be set globally on the repository, through the
web UI options Settings -> CI/CD -> Variables, though this is not
recommended. Upstream repo pushes to branches will run CI.

The use of containers has changed in this update, with only the upstream
repo creating containers, in order to avoid consuming contributors'
limited storage quotas. A fork with existing container images may delete
them. Containers will be rebuilt upstream when pushing commits with CI
changes to the default branch. Any other scenario with CI changes will
simply install build pre-requisite packages in a throaway environment,
using the ci/buildenv/ scripts. These scripts may also be used on a
contributor's local machines.

With pipelines triggered by merge requests, it is also now possible to
workaround the inability of contributors to run pipelines if they have
run out of CI quota. A project member can trigger a pipeline from the
merge request, which will run in context of upstream, however, note
this should only be done after reviewing the code for any malicious
CI changes.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agoutil: xml: Remove virXMLParseStringCtxtRoot
Peter Krempa [Fri, 23 Sep 2022 13:38:49 +0000 (15:38 +0200)]
util: xml: Remove virXMLParseStringCtxtRoot

Remove the seldom used helper in favor of full virXMLParse.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agotest_driver: Make callers of testOpenParse ensure the root element name
Peter Krempa [Fri, 23 Sep 2022 13:16:22 +0000 (15:16 +0200)]
test_driver: Make callers of testOpenParse ensure the root element name

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agosecurity: aa-helper: Use virXMLParse instead of virXMLParseString
Peter Krempa [Fri, 23 Sep 2022 13:11:59 +0000 (15:11 +0200)]
security: aa-helper: Use virXMLParse instead of virXMLParseString

Use the helper with more features to validate the root XML element name
instead of open-coding it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: savecookie: Remove virSaveCookieParseNode
Peter Krempa [Fri, 23 Sep 2022 13:03:19 +0000 (15:03 +0200)]
conf: savecookie: Remove virSaveCookieParseNode

The function provided just checking of the root XML node name which can
be easily moved into the caller wich doesn't do that already and
checking of the pointers which is trivial. Remove the helper.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoutil: xml: Remove virXMLParseCtxt
Peter Krempa [Fri, 23 Sep 2022 12:53:21 +0000 (14:53 +0200)]
util: xml: Remove virXMLParseCtxt

Convert the two outstanding uses to virXMLParseFileCtxt as they always
pass a filename and remove the helper macro.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoutil: xml: Remove virXMLParseFile
Peter Krempa [Fri, 23 Sep 2022 12:49:01 +0000 (14:49 +0200)]
util: xml: Remove virXMLParseFile

Most callers prefer using the XPath context. Convert the last user to
use virXMLParseFileCtxt and remove the helper macro.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: capabilities: Convert virQEMUCapsLoadCache to virXMLParse
Peter Krempa [Fri, 23 Sep 2022 12:47:12 +0000 (14:47 +0200)]
qemu: capabilities: Convert virQEMUCapsLoadCache to virXMLParse

Use virXMLParse so that the code doesn't have to explicitly allocate
an XPath context and validate the root element.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoutil: xml: Remove virXMLParseString
Peter Krempa [Fri, 23 Sep 2022 12:44:25 +0000 (14:44 +0200)]
util: xml: Remove virXMLParseString

Most callers use virXMLParseStringCtxt. Convert the last use case
and remove the helper.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirsh: Use proper helper for parsing XML in virshDumpXML
Peter Krempa [Fri, 23 Sep 2022 12:42:18 +0000 (14:42 +0200)]
virsh: Use proper helper for parsing XML in virshDumpXML

Use virXMLParseStringCtxt instead of virXMLParseString since the code
requires a XPath context anyways.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirDomainDefParseNode: Pass only the XPath context as argument
Peter Krempa [Fri, 23 Sep 2022 12:38:39 +0000 (14:38 +0200)]
virDomainDefParseNode: Pass only the XPath context as argument

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: domain: Simplify validation in virDomainDefParse
Peter Krempa [Fri, 23 Sep 2022 11:42:44 +0000 (13:42 +0200)]
conf: domain: Simplify validation in virDomainDefParse

Use virXMLParse's features to validate the top level element and fetch
the XPath context.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: domain: Remove virDomainObjParseNode
Peter Krempa [Fri, 23 Sep 2022 11:34:36 +0000 (13:34 +0200)]
conf: domain: Remove virDomainObjParseNode

virDomainObjParseFile is the only caller of virDomainObjParseNode.
The code can be merged into it, simplified by using virXMLParse and
the function removed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: network: Provide only virNetworkDefParse
Peter Krempa [Fri, 23 Sep 2022 11:28:44 +0000 (13:28 +0200)]
conf: network: Provide only virNetworkDefParse

Replace virNetworkDefParseString/File by direct calls to
virNetworkDefParse.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: network: Remove virNetworkDefParseNode
Peter Krempa [Fri, 23 Sep 2022 11:17:25 +0000 (13:17 +0200)]
conf: network: Remove virNetworkDefParseNode

Both callers can be easily converted to call virNetworkDefParseXML
directly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: interface: Remove virInterfaceDefParseFile
Peter Krempa [Fri, 23 Sep 2022 11:09:58 +0000 (13:09 +0200)]
conf: interface: Remove virInterfaceDefParseFile

The function was not used. Remove it and merge virInterfaceDefParse
into virInterfaceDefParseString.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: interface: Remove virInterfaceDefParseNode
Peter Krempa [Fri, 23 Sep 2022 11:07:36 +0000 (13:07 +0200)]
conf: interface: Remove virInterfaceDefParseNode

Both callers be easily made to call virInterfaceDefParseXML directly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: nodedev: Provide only virNodeDeviceDefParse
Peter Krempa [Fri, 23 Sep 2022 09:52:23 +0000 (11:52 +0200)]
conf: nodedev: Provide only virNodeDeviceDefParse

Replace the thin wrappers virNodeDeviceDefParseString/File by directly
calling the main parser.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: node_device: Remove virNodeDeviceDefParseNode
Peter Krempa [Fri, 23 Sep 2022 08:44:13 +0000 (10:44 +0200)]
conf: node_device: Remove virNodeDeviceDefParseNode

Both callers be easily made to call virNodeDeviceDefParseXML directly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: nwfilter: Provide only virNWFilterDefParse
Peter Krempa [Fri, 23 Sep 2022 08:36:36 +0000 (10:36 +0200)]
conf: nwfilter: Provide only virNWFilterDefParse

Replace virNWFilterDefParseString/File with the common function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: nwfilter: Remove virNWFilterDefParseNode
Peter Krempa [Fri, 23 Sep 2022 08:32:52 +0000 (10:32 +0200)]
conf: nwfilter: Remove virNWFilterDefParseNode

Use virXMLParse to fetch the XML context and validate the top level XML
element name so that virNWFilterDefParseNode is no longer needed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: backup: Remove virDomainBackupDefParseNode
Peter Krempa [Thu, 22 Sep 2022 16:02:50 +0000 (18:02 +0200)]
conf: backup: Remove virDomainBackupDefParseNode

Rename virDomainBackupDefParse to virDomainBackupDefParseXML and use
it in place of virDomainBackupDefParseNode. This is possible as
virXMLParse can be used to replace XPath context allocation and root
node checking.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: checkpoint: Remove virDomainCheckpointDefParseNode
Peter Krempa [Thu, 22 Sep 2022 15:56:53 +0000 (17:56 +0200)]
conf: checkpoint: Remove virDomainCheckpointDefParseNode

Replace all it does by properly using virXMLParse.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoprlsdkParseSnapshotTree: Simplify XML parsing code
Peter Krempa [Thu, 22 Sep 2022 15:53:04 +0000 (17:53 +0200)]
prlsdkParseSnapshotTree: Simplify XML parsing code

Use features of virXMLParse to validate root node and fetch XPath
context.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: secret: Provide only virSecretDefParse
Peter Krempa [Thu, 22 Sep 2022 15:42:00 +0000 (17:42 +0200)]
conf: secret: Provide only virSecretDefParse

Replace the virSecretDefParseFile/String shims by calls to
virSecretDefParse.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: secret: Refactor secretXMLParseNode
Peter Krempa [Thu, 22 Sep 2022 15:38:36 +0000 (17:38 +0200)]
conf: secret: Refactor secretXMLParseNode

Rename it to virSecretParseXML and move the root node validation and
context fetching into the caller (by properly calling virXMLParse).

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: snapshot: Remove virDomainSnapshotDefParseNode
Peter Krempa [Thu, 22 Sep 2022 15:33:56 +0000 (17:33 +0200)]
conf: snapshot: Remove virDomainSnapshotDefParseNode

Check the root XML node name and fetch XPath context by properly
configuring virXMLParse. Callers can use virDomainSnapshotDefParse
instead.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: storage: Provide only virStorageVolDefParse
Peter Krempa [Thu, 22 Sep 2022 15:22:55 +0000 (17:22 +0200)]
conf: storage: Provide only virStorageVolDefParse

Remove the virStorageVolDefParseFile/String shim functions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: storage: Remove virStorageVolDefParseNode
Peter Krempa [Thu, 22 Sep 2022 15:17:21 +0000 (17:17 +0200)]
conf: storage: Remove virStorageVolDefParseNode

Proper use of virXMLParse replaces everything the function provides.
Callers can use virStorageVolDefParseXML instead.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: storage: Provide only virStoragePoolDefParse
Peter Krempa [Thu, 22 Sep 2022 15:08:16 +0000 (17:08 +0200)]
conf: storage: Provide only virStoragePoolDefParse

Replace the virStoragePoolDefParseString/File thin wrappers by
virStoragePoolDefParse.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: storage: Remove virStoragePoolDefParseNode
Peter Krempa [Thu, 22 Sep 2022 15:00:25 +0000 (17:00 +0200)]
conf: storage: Remove virStoragePoolDefParseNode

Replace it by proper use of virXMLParse to validate the root node and
allocate the context. The use in the test driver can be directly
replaced by virStoragePoolDefParseXML as both are validated.

The change to the storage driver isn't trivial though as it requires
careful xpath context juggling to parse the nested volumes properly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>