]> git.ipfire.org Git - thirdparty/libvirt.git/log
thirdparty/libvirt.git
3 years agovirJSONValueObjectAddVArgs: Add check for presence of the ':' separator
Peter Krempa [Wed, 6 Oct 2021 11:11:10 +0000 (13:11 +0200)] 
virJSONValueObjectAddVArgs: Add check for presence of the ':' separator

Enforce that the ':' separator between the key and value is always
present.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirJSONValueObjectAddVArgs: Add 'k' convertor for formatting non-negative integers
Peter Krempa [Tue, 5 Oct 2021 12:07:31 +0000 (14:07 +0200)] 
virJSONValueObjectAddVArgs: Add 'k' convertor for formatting non-negative integers

In many cases we use a signed value, but use the sign to note that it
was not assigned. For converting to JSON objects it will be handy to
have possibility to do this automatically.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: capabilities: Remove QEMU_CAPS_PIIX4_ACPI_HOTPLUG_BRIDGE
Peter Krempa [Mon, 11 Oct 2021 07:17:54 +0000 (09:17 +0200)] 
qemu: capabilities: Remove QEMU_CAPS_PIIX4_ACPI_HOTPLUG_BRIDGE

Commit 58ba0f6a3d7342fba29edbbf2bb9cb5497c870e5 added a capability which
is supported by all qemu versions we support. Remove it and the
associated dead code. Since the capability isn't present in any upstream
release we can delete it completely.

Specifically the commit itself states that it was introduced "around
(qemu) 2.1". The rest of the code handles properly that the feature is
used only on x86 with the i440fx machine so the capability is pointless.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuxml2xmltest: Convert all acpi-hotplug control related tests to DO_TEST_CAPS_LATEST
Peter Krempa [Mon, 11 Oct 2021 12:46:46 +0000 (14:46 +0200)] 
qemuxml2xmltest: Convert all acpi-hotplug control related tests to DO_TEST_CAPS_LATEST

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuxml2argvtest: Add '-enable' variants for ACPI-hotplug related cases
Peter Krempa [Mon, 11 Oct 2021 12:55:42 +0000 (14:55 +0200)] 
qemuxml2argvtest: Add '-enable' variants for ACPI-hotplug related cases

We have input files for those, provide also xml2argv testing since we
have them.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuxml2argvtest: Use real-caps testing for 'acpi-hotplug-bridge-disable'
Peter Krempa [Mon, 11 Oct 2021 12:30:58 +0000 (14:30 +0200)] 
qemuxml2argvtest: Use real-caps testing for 'acpi-hotplug-bridge-disable'

We can use real example configs to prove the support without the
need for using fake capabilities. Fix the recently added test cases.

The negative case for 'pc-i440fx-acpi-hotplug-bridge-disable' is removed
completely as there is no real qemu libvirt supports which wouldn't
have the capability.

The input file for the negative test on aarch64 is modified so that it's
actually a reasonably valid VM config.

Fixes: bef0f0d8be6
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuxml2argvtest: Use real-caps testing for 'pc-i440fx-acpi-root-hotplug-disable'
Peter Krempa [Mon, 11 Oct 2021 12:30:58 +0000 (14:30 +0200)] 
qemuxml2argvtest: Use real-caps testing for 'pc-i440fx-acpi-root-hotplug-disable'

We can use two real example configs to prove the support without the
need for using fake capabilities. Fix the recently added test cases.

Fixes: 133d7983d6c
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuValidateDomainDefPCIFeature: Fix validation logic
Peter Krempa [Mon, 11 Oct 2021 12:15:14 +0000 (14:15 +0200)] 
qemuValidateDomainDefPCIFeature: Fix validation logic

The error that "acpi-bridge-hotplug" is not supported would be triggered
only if both the ICH9 and PIIX don't support the capability and the
machine is q35. This makes no sense.

We want to check that the appropriate platform supports the appropriate
feature.

Fixes: 7300ccc9b3e
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuValidateDomainDefPCIFeature: un-break error messages
Peter Krempa [Mon, 11 Oct 2021 12:11:06 +0000 (14:11 +0200)] 
qemuValidateDomainDefPCIFeature: un-break error messages

https://www.libvirt.org/coding-style.html#error-message-format

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoapparmor: ceph config file names
Christian Ehrhardt [Thu, 7 Oct 2021 11:27:35 +0000 (13:27 +0200)] 
apparmor: ceph config file names

If running multiple [1] clusters (uncommon) the ceph config file will be
derived from the cluster name. Therefore the rule to allow to read ceph
config files need to be opened up slightly to allow for that condition.

[1]: https://docs.ceph.com/en/mimic/rados/configuration/common/#running-multiple-clusters

Fixes: https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1588576
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoNEWS: document new acpi pci hotplug config option
Ani Sinha [Fri, 8 Oct 2021 06:42:15 +0000 (12:12 +0530)] 
NEWS: document new acpi pci hotplug config option

Added the following new libvirt conf option to the release note to
indicate their availability with the next release:

<feature>
  <pci>
    <acpi-bridge-hotplug state='off|on'/>
  </pci>
</feature>

Signed-off-by: Ani Sinha <ani@anisinha.ca>
Reviewed-by: Laine Stump <laine@redhat.com>
3 years agoqemu: command: add support for acpi-bridge-hotplug feature
Ani Sinha [Fri, 8 Oct 2021 06:42:14 +0000 (12:12 +0530)] 
qemu: command: add support for acpi-bridge-hotplug feature

This change adds backend qemu command line support for new libvirt
global feature 'acpi-bridge-hotplug'. This option can be used as
following:

<feature>
  <pci>
    <acpi-bridge-hotplug state='off|on'/>
  </pci>
</feature>

The '<pci>' sub-element under '<feature>' is also newly introduced.

'acpi-bridge-hotplug' turns on the following command line option to
qemu for x86 guests:

(pc): -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=<off|on>

(q35): -global ICH9-LPC.acpi-pci-hotplug-with-bridge-support=<off|on>

This change also adds the required qemuxml2argv unit tests in order to
test correct qemu arguments. Unit tests have also been added to test
qemu capability validation checks as well as checks for using this
option with the right architecture.

Signed-off-by: Ani Sinha <ani@anisinha.ca>
Reviewed-by: Laine Stump <laine@redhat.com>
3 years agoconf: introduce support for acpi-bridge-hotplug feature
Ani Sinha [Fri, 8 Oct 2021 06:42:13 +0000 (12:12 +0530)] 
conf: introduce support for acpi-bridge-hotplug feature

This change introduces a new libvirt sub-element <pci> under
<features> that can be used to configure all pci related features.
Currently the only sub-sub element supported by this sub-element is
'acpi-bridge-hotplug' as shown below:

<features>
  <pci>
    <acpi-bridge-hotplug state='on|off'/>
  </pci>
</features>

The above option is only available for the QEMU driver, for x86 guests
only. It is a global option, affecting all PCI bridge controllers on
the guest.

The 'acpi-bridge-hotplug' option enables or disables ACPI hotplug
support for cold-plugged pci bridges. Examples of bridges include the
PCI-PCI bridge (pci-bridge controller) for pc (i440fx) machinetypes,
or PCIe-PCI bridges and pcie-root-port controllers for q35
machinetypes.

For pc machinetypes in x86, this option has been available in QEMU
since version 2.1. Please see the following changes in qemu repo:

9e047b982452c6 ("piix4: add acpi pci hotplug support")
133a2da488062e ("pc: acpi: generate AML only for PCI0 devices if PCI
               bridge hotplug is disabled")

For q35 machinetypes, this was introduced in QEMU 6.1 with the
following changes in qemu repo:

(a) c0e427d6eb5fef ("hw/acpi/ich9: Enable ACPI PCI hot-plug")
(b) 17858a16950860 ("hw/acpi/ich9: Set ACPI PCI hot-plug as default on
                   Q35")

The reasons for enabling ACPI based hotplug for PCIe (q35) based
machines (as opposed to native hotplug) are outlined in (b). There are
use cases where users would still want to use native
hotplug. Therefore, this config option enables users to choose either
ACPI based hotplug or native hotplug for bridges (for example for pcie
root port controller in q35 machines).

Qemu capability validation checks have also been added along with
related unit tests to exercise the new conf option.

Signed-off-by: Ani Sinha <ani@anisinha.ca>
Reviewed-by: Laine Stump <laine@redhat.com>
3 years agoqemu: capablities: detect acpi-pci-hotplug-with-bridge-support
Ani Sinha [Fri, 8 Oct 2021 06:42:12 +0000 (12:12 +0530)] 
qemu: capablities: detect acpi-pci-hotplug-with-bridge-support

qemu added support for i440fx specific global boolean flag

PIIX4_PM.acpi-pci-hotplug-with-bridge-support

around version 2.1. This flag is enabled by default. When disabled, it
turns off acpi pci hotplug for cold plugged pci bridges in i440fx
machine types.

Very recently, in qemu version 6.1, the same global option was also
added for q35 machine types as well.

ICH9-LPC.acpi-pci-hotplug-with-bridge-support

This option turns on or off acpi based hotplug for cold plugged pcie
bridges like pcie root ports. This flag is also enabled by
default. Please refer to the following qemu changes:

c0e427d6eb5fef ("hw/acpi/ich9: Enable ACPI PCI hot-plug")
17858a16950860 ("hw/acpi/ich9: Set ACPI PCI hot-plug as default on Q35")

This patch adds the corresponding qemu capabilities in libvirt. For
i440fx, the capability is detected as
QEMU_CAPS_PIIX_ACPI_HOTPLUG_BRIDGE. For q35, the capability is
detected as QEMU_CAPS_ICH9_ACPI_HOTPLUG_BRIDGE.

Please note that the test specific qemu capabilities .replies files
has already been updated as a part of regular refreshing them when a
new qemu version is released. Hence, no updates to those files are
required.

Signed-off-by: Ani Sinha <ani@anisinha.ca>
Reviewed-by: Laine Stump <laine@redhat.com>
3 years agovireventglib: Remove handles with the highest priority
Michal Privoznik [Thu, 7 Oct 2021 11:46:43 +0000 (13:46 +0200)] 
vireventglib: Remove handles with the highest priority

When a server decides to close a client, the
virNetServerClientCloseLocked() is called. In here various
cleanup steps are taken, but the most important part (from this
commit's POV at least) is the way that the socket is closed.
Firstly, removal of the socket associated with the client from
the event loop is signalized and then the socket is unrefed. The
socket is not closed just yet though, because the event loop
holds a reference to it. This reference will be freed as soon as
the event loop wakes up and starts issuing callbacks (in this
case virNetSocketEventFree()).

So far, this is how things usually work. But if the daemon
reaches the number of opened files limit, things start to work
differently.

If the RLIMIT_NOFILE limit is reached and there's a client that
wants to connect then the event loop wakes up, sees POLLIN on the
socket and calls virNetServerServiceAccept() which in turn calls
virNetSocketAccept(). But because of the limit, accept() fails
with EMFILE leaving the POLLIN event unhandled. The dispatch then
continues to next FDs with events on them. BUT, it will NOT call
the socket removal callback (virNetSocketEventFree()) because it
has low priority (G_PRIORITY_DEFAULT_IDLE). Per glib's
documentation:

 * Each event source is assigned a priority. The default priority,
 * %G_PRIORITY_DEFAULT, is 0. Values less than 0 denote higher priorities.
 * Values greater than 0 denote lower priorities. Events from high priority
 * sources are always processed before events from lower priority sources.

and per g_idle_add() documentation:

 * Adds a function to be called whenever there are no higher priority
 * events pending to the default main loop. The function is given the
 * default idle priority, %G_PRIORITY_DEFAULT_IDLE.

Now, because we did not accept() the client we are constantly
seeing POLLIN on the main socket and thus the removal of the
client socket won't ever happen.

The fix is to set at least the same priority as other sources,
but since we want to just close an FD, let's give it the highest
priority and call it before handling other events.

This issue can be easily reproduced, for instance:

 # ulimit -S -n 40 (tweak this number if needed)
 # ./src/libvirtd

from another terminal:

 # for ((i=0; i<100; i++)); do virsh list & done; virsh list

The last `virsh list` must not get stuck.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2007168
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agolxc: controller: Fix container launch on cgroup v1
Cole Robinson [Tue, 5 Oct 2021 13:42:12 +0000 (09:42 -0400)] 
lxc: controller: Fix container launch on cgroup v1

With cgroup v1 I'm seeing LXC container startup failures:

$ sudo virt-install --connect lxc:/// --name test-container --memory 128
--boot init=/bin/sh

Starting install...
ERROR    error from service:
GDBus.Error:org.freedesktop.machine1.NoMachineForPID: PID 2145047 does
not belong to any known machine

libvirt 7.0.0 works but 7.1.0+ does not. The root error seems to predate
that, showing up in syslog, but commit 9c1693eff made it fatal:

commit 9c1693eff427661616ce1bd2795688f87288a412
Author: Pavel Hrdina <phrdina@redhat.com>
Date:   Fri Feb 5 16:17:35 2021 +0100

     vircgroup: use DBus call to systemd for some APIs

The error comes from virSystemdGetMachineByPID. The PID that shows up in
the above error message does not match the leader PID as reported by
machinectl.

This change fixes the error. Things seem to continue to work with
cgroupsv2 after this change.

https://gitlab.com/libvirt/libvirt/-/issues/182

Tested-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
3 years agotools: Fix virt-host-validate SEV detection
Jim Fehlig [Wed, 6 Oct 2021 04:34:57 +0000 (22:34 -0600)] 
tools: Fix virt-host-validate SEV detection

virt-host-validate checks if AMD SEV is enabled by verifying
/sys/module/kvm_amd/parameters/sev is set to '1'. On a system
running kernel 5.13, the parameter is reported as 'Y'. To be
extra paranoid, add a check for 'y' along with 'Y' to complement
the existing check for '1'.

Fixes: https://bugzilla.opensuse.org/show_bug.cgi?id=1188715
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agoqemu: export vhost-user-fs-related functions
Ján Tomko [Tue, 5 Oct 2021 14:20:36 +0000 (16:20 +0200)] 
qemu: export vhost-user-fs-related functions

Prepare for hotplug support.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoqemu: vhost-user-fs: build extdevice for zpci
Ján Tomko [Tue, 17 Aug 2021 15:34:51 +0000 (17:34 +0200)] 
qemu: vhost-user-fs: build extdevice for zpci

Other devices (includes 9p-based fsdev) call this wrapper
before formatting the device.

Add it here too.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoqemu: alias: prepare qemuAssignDeviceFSAlias for disjunct ranges
Ján Tomko [Tue, 17 Aug 2021 15:24:08 +0000 (17:24 +0200)] 
qemu: alias: prepare qemuAssignDeviceFSAlias for disjunct ranges

Iterate through the array to find the first free index.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoqemu: remove private data from virDomainFSDef
Ján Tomko [Wed, 18 Aug 2021 12:10:57 +0000 (14:10 +0200)] 
qemu: remove private data from virDomainFSDef

This reverts commit 801e6da29c0202946d44b42136cc4ee229932a29

They are not needed anymore.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoqemu: do not put virtiofs socket in private data
Ján Tomko [Wed, 18 Aug 2021 12:05:46 +0000 (14:05 +0200)] 
qemu: do not put virtiofs socket in private data

Reconstruct the socket path from priv->libDir in every user.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoqemu: vhost-user-fs: separate building of device string
Ján Tomko [Tue, 17 Aug 2021 14:29:28 +0000 (16:29 +0200)] 
qemu: vhost-user-fs: separate building of device string

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoqemu: vhost-user-fs: separate building of chardev string
Ján Tomko [Tue, 17 Aug 2021 14:12:50 +0000 (16:12 +0200)] 
qemu: vhost-user-fs: separate building of chardev string

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agotests: qemuxml2argvtest: fix path to virtiofs socket
Ján Tomko [Wed, 18 Aug 2021 10:34:06 +0000 (12:34 +0200)] 
tests: qemuxml2argvtest: fix path to virtiofs socket

The mocked path in the test suite is not in sync with what libvirtd
generates.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoqemu: domain: introduce qemuDomainGetVHostUserFSSocketPath
Ján Tomko [Wed, 18 Aug 2021 08:24:36 +0000 (10:24 +0200)] 
qemu: domain: introduce qemuDomainGetVHostUserFSSocketPath

Intended as a replacement for qemuVirtioFSCreateSocketFilename,
to be used outside of qemu_virtiofs.c

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoconf: define cleanup func for virDomainChrSourceDef
Ján Tomko [Wed, 18 Aug 2021 08:46:13 +0000 (10:46 +0200)] 
conf: define cleanup func for virDomainChrSourceDef

It's defined also for 'virDomainChrDef'

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoqemu: vhost-user-fs: format alias on the command line
Ján Tomko [Tue, 5 Oct 2021 11:18:52 +0000 (13:18 +0200)] 
qemu: vhost-user-fs: format alias on the command line

The commit adding the vhost-user-fs device forgot to format
the device's alias on the command line.

Thankfully it was not needed yet because virtiofs migration
is not yet supported, but it will be needed in the future
to allow hot(un)plug.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agotools: Fix typo firemare -> firmware
Andrea Bolognani [Wed, 6 Oct 2021 09:14:07 +0000 (11:14 +0200)] 
tools: Fix typo firemare -> firmware

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
3 years agovirsh: Use VIR_AUTOCLOSE more
Michal Privoznik [Sun, 26 Sep 2021 10:54:10 +0000 (12:54 +0200)] 
virsh: Use VIR_AUTOCLOSE more

There are few places where we can replace explicit
VIR_FORCE_CLOSE() with VIR_AUTOCLOSE annotation.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
3 years agovirsh: Add wrapper for virStreamFree
Michal Privoznik [Sun, 26 Sep 2021 11:27:26 +0000 (13:27 +0200)] 
virsh: Add wrapper for virStreamFree

Similarly to virshDomainFree add a wrapper for the snapshot object
freeing function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
3 years agovirsh: Add wrapper for virNWFilterFree
Michal Privoznik [Sun, 26 Sep 2021 11:18:17 +0000 (13:18 +0200)] 
virsh: Add wrapper for virNWFilterFree

Similarly to virshDomainFree add a wrapper for the snapshot object
freeing function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
3 years agovirsh: Add wrapper for virNodeDeviceFree
Michal Privoznik [Sun, 26 Sep 2021 09:44:30 +0000 (11:44 +0200)] 
virsh: Add wrapper for virNodeDeviceFree

Similarly to virshDomainFree add a wrapper for the snapshot object
freeing function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
3 years agovirsh: Add wrapper for virNetworkFree
Michal Privoznik [Sun, 26 Sep 2021 08:57:38 +0000 (10:57 +0200)] 
virsh: Add wrapper for virNetworkFree

Similarly to virshDomainFree add a wrapper for the snapshot object
freeing function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
3 years agovirsh: Add wrapper for virStorageVolFree
Michal Privoznik [Sun, 26 Sep 2021 08:28:06 +0000 (10:28 +0200)] 
virsh: Add wrapper for virStorageVolFree

Similarly to virshDomainFree add a wrapper for the snapshot object
freeing function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
3 years agovirsh: Add wrapper for virStoragePoolFree
Michal Privoznik [Sun, 26 Sep 2021 07:25:41 +0000 (09:25 +0200)] 
virsh: Add wrapper for virStoragePoolFree

Similarly to virshDomainFree add a wrapper for the snapshot object
freeing function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
3 years agovirsh: Add wrapper for virInterfaceFree
Michal Privoznik [Sun, 26 Sep 2021 06:20:54 +0000 (08:20 +0200)] 
virsh: Add wrapper for virInterfaceFree

Similarly to virshDomainFree add a wrapper for the snapshot object
freeing function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
3 years agovirsh-util.h: Fix ordering of virshXXXFree functions
Michal Privoznik [Sun, 26 Sep 2021 06:23:32 +0000 (08:23 +0200)] 
virsh-util.h: Fix ordering of virshXXXFree functions

Currently the order of virshXXXFree functions in the header file
does not correspond to the order in the corresponding .c file.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
3 years agoqemu: Check if unpriv_sgio is already set before trying to set it
Michal Privoznik [Tue, 5 Oct 2021 12:37:12 +0000 (14:37 +0200)] 
qemu: Check if unpriv_sgio is already set before trying to set it

In case when libvirt runs inside a restricted container it may
not have enough permissions to modify unpriv_sgio. However, it
may have been set beforehand by sysadmin or an orchestration
tool. Therefore, let's check whether the currently set value is
the one we want and if it is refrain from writing to the file.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2010306
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirsh: Fix --nvram and --keep-nvram help strings
Michal Privoznik [Thu, 30 Sep 2021 14:32:19 +0000 (16:32 +0200)] 
virsh: Fix --nvram and --keep-nvram help strings

The --nvram and --keep-nvram options of the undefine command can
be used regardless of the domain status (the only consumer so far
- qemuDomainUndefineFlags() doesn't care about the domain
status). Yet, their corresponding help strings say something
about inactive domains while manpage says nothing. Remove the
reference to domain state.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2007659
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agoqemu: capabilities: remove -en from piix4-acpi-root-hotplug-en
Ani Sinha [Mon, 4 Oct 2021 17:26:13 +0000 (22:56 +0530)] 
qemu: capabilities: remove -en from piix4-acpi-root-hotplug-en

The capability name piix4-acpi-root-hotplug-en is not conventional and
appreared to be confusing to some. "en" suffix is also incorrect as the
capability in qemu is used to both enable and disable hotplug on the pci root
bus on the i440fx. Hence, rename it to piix4.acpi-root-pci-hotplug so that it
is clearer, less confusing and more accurate.

Signed-off-by: Ani Sinha <ani@anisinha.ca>
Reviewed-by: Laine Stump <laine@redhat.com>
3 years agoch: use g_auto in virCHMonitorNew
William Douglas [Fri, 1 Oct 2021 18:12:37 +0000 (11:12 -0700)] 
ch: use g_auto in virCHMonitorNew

Also introduces a G_DEFINE_AUTOPTR_CLEANUP_FUNC for virCHMonitor.

Signed-off-by: William Douglas <william.douglas@intel.com>
Reviewed-by: Laine Stump <laine@redhat.com>
3 years agoch: use g_auto in virCHMonitorBuildKernelRelatedJson
William Douglas [Fri, 1 Oct 2021 18:12:36 +0000 (11:12 -0700)] 
ch: use g_auto in virCHMonitorBuildKernelRelatedJson

Signed-off-by: William Douglas <william.douglas@intel.com>
Reviewed-by: Laine Stump <laine@redhat.com>
3 years agoch: use g_auto in virCHMonitorBuildMemoryJson
William Douglas [Fri, 1 Oct 2021 18:12:35 +0000 (11:12 -0700)] 
ch: use g_auto in virCHMonitorBuildMemoryJson

Signed-off-by: William Douglas <william.douglas@intel.com>
Reviewed-by: Laine Stump <laine@redhat.com>
3 years agoch: remove extra unref of domain object during virCHMonitorClose()
William Douglas [Sun, 3 Oct 2021 20:08:18 +0000 (16:08 -0400)] 
ch: remove extra unref of domain object during virCHMonitorClose()

It is already being unrefed in virCHMonitorDispose().

Signed-off-by: William Douglas <william.douglas@intel.com>
Reviewed-by: Laine Stump <laine@redhat.com>
3 years agoch: Correctly ref and close the virCHMonitor in virCHMonitorNew
William Douglas [Fri, 1 Oct 2021 18:12:34 +0000 (11:12 -0700)] 
ch: Correctly ref and close the virCHMonitor in virCHMonitorNew

In virCHMontiorNew the monitor object was referenced an additional
time incorrectly preventing it from being disposed of, and wasn't
always closed properly on failure.

Signed-off-by: William Douglas <william.douglas@intel.com>
Reviewed-by: Laine Stump <laine@redhat.com>
3 years agoch_monitor: Stop leaking json value objects
William Douglas [Fri, 1 Oct 2021 18:12:33 +0000 (11:12 -0700)] 
ch_monitor: Stop leaking json value objects

In virCHMonitorBuildKernelRelatedJson there are two cases of json
value objects being lost after the pointer being redefined. This
change removes the needless redefinition.

Signed-off-by: William Douglas <william.douglas@intel.com>
Reviewed-by: Laine Stump <laine@redhat.com>
3 years agoNEWS: cosmetic - fix indentation
Ani Sinha [Sat, 2 Oct 2021 16:07:13 +0000 (21:37 +0530)] 
NEWS: cosmetic - fix indentation

The indentation of the first item under the categoty "new features" for the
future release v7.9.0 is not right. Fix it.

Signed-off-by: Ani Sinha <ani@anisinha.ca>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agodocs: describe flag VIR_STORAGE_POOL_CREATE_NORMAL to correct the HTML doc
Robin Lee [Fri, 1 Oct 2021 17:34:25 +0000 (01:34 +0800)] 
docs: describe flag VIR_STORAGE_POOL_CREATE_NORMAL to correct the HTML doc

This patch makes the descriptions of virStoragePoolCreateFlags annotate to the
correct flag in the generated HTML file.

Signed-off-by: Robin Lee <cheeselee@fedoraproject.org>
3 years agoTranslated using Weblate (Korean)
simmon [Fri, 1 Oct 2021 15:05:10 +0000 (17:05 +0200)] 
Translated using Weblate (Korean)

Currently translated at 100.0% (10374 of 10374 strings)

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

Co-authored-by: simmon <simmon@nplob.com>
Signed-off-by: simmon <simmon@nplob.com>
3 years agoTranslated using Weblate (Finnish)
Jan Kuparinen [Fri, 1 Oct 2021 15:05:10 +0000 (17:05 +0200)] 
Translated using Weblate (Finnish)

Currently translated at 23.0% (2387 of 10374 strings)

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

Co-authored-by: Jan Kuparinen <copper_fin@hotmail.com>
Signed-off-by: Jan Kuparinen <copper_fin@hotmail.com>
3 years agoNEWS: document new hotplug enable/disable option on pci-root controller
Ani Sinha [Fri, 1 Oct 2021 09:29:48 +0000 (14:59 +0530)] 
NEWS: document new hotplug enable/disable option on pci-root controller

A new 'target' subelement of the pci-root controller has been
introduced having a 'hotplug' property. This property can be used to
turn off or turn on the ability to hotplug/unplug devices to the slots
of the pci-root.

The new element can be used like this:

<controller type='pci' model='pci-root'>
   <target hotplug='off'/>
</controller>

This will turn off hotplug capability on the pci-root ports. To turn
the capability on, we set hotplug='on' above (which is also the
default).

Signed-off-by: Ani Sinha <ani@anisinha.ca>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
3 years agoqemu: command: add support to enable/disable hotplug on pci-root controller
Ani Sinha [Fri, 1 Oct 2021 09:29:47 +0000 (14:59 +0530)] 
qemu: command: add support to enable/disable hotplug on pci-root controller

This change adds qemu backend command line support for enabling or disabling
hotplug on the pci-root controller using the 'target' sub-element of the
pci-root controller as shown below:

<controller type='pci' model='pci-root'>
  <target hotplug='off'/>
</controller>

'<target hotplug='off/on'/>' is only valid for pc (i440fx-based x86)
machinetypes and turns on the following command line option that is passed
to qemu for x86 guests:

-global PIIX4_PM.acpi-root-pci-hotplug=<off/on>

Before introduction of this attribute, hotplug was always enabled for
pci-root of an i440fx-based machinetype, and since its introduction
the default setting has always been "on" for those machinetypes.

This change also adds the required qemuxml2argv unit tests in order to test
correct qemu arguments. Unit tests have also been added to test qemu capability
validation checks.

Signed-off-by: Ani Sinha <ani@anisinha.ca>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
3 years agoconf: introduce option to enable/disable pci hotplug on pci-root controller
Ani Sinha [Fri, 1 Oct 2021 09:29:46 +0000 (14:59 +0530)] 
conf: introduce option to enable/disable pci hotplug on pci-root controller

This change introduces libvirt xml support to enable/disable hotplug on the
pci-root controller. It adds a 'target' subelement for the pci-root controller
with a 'hotplug' property. This property can be used to enable or disable
hotplug for the pci-root controller. For example, in order to disable hotplug
on the pci-root controller, one has to use set '<target hotplug='off'>' as
shown below:

<controller type='pci' model='pci-root'>
  <target hotplug='off'/>
</controller>

'<target hotplug='on'>' option would enable hotplug for pci-root controller.
This is also the default value. This option is only available for pc machine
types and is applicable for qemu/kvm accelerator only.This feature was
introduced from qemu version 5.2 with the following change in qemu repository:

3d7e78aa7777f ("Introduce a new flag for i440fx to disable PCI hotplug on the root bus")

The above qemu commit describes some reasons why users might to disable hotplug
on PCI root buses.

Related unit tests to exercise the new conf option has also been added.

Signed-off-by: Ani Sinha <ani@anisinha.ca>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
3 years agoqemu: capablities: detect presence of acpi-root-pci-hotplug for i440fx machines
Ani Sinha [Fri, 1 Oct 2021 09:29:45 +0000 (14:59 +0530)] 
qemu: capablities: detect presence of acpi-root-pci-hotplug for i440fx machines

The following change in qemu added support for a global boolean flag specific
to i440fx machines that would turn off or on acpi based hotplug for pci root
bus:

3d7e78aa7777f ("Introduce a new flag for i440fx to disable PCI hotplug on the root bus")

The option is passed as "-global PIIX4_PM.acpi-root-pci-hotplug=on" etc in qemu
commandline. It is enabled by default. This patch adds the corresponding qemu
capabilities in libvirt as QEMU_CAPS_PIIX_ACPI_ROOT_PCI_HOTPLUG.

Please note that the test specific qemu capabilities .replies files has already
been updated as a part of regular refreshing them when a new qemu version is
released. Hence, no updates to those files are required.

Signed-off-by: Ani Sinha <ani@anisinha.ca>
Reviewed-by: Laine Stump <laine@redhat.com>
3 years agovshCmddefCheckInternals: Fix typo
Tim Wiederhake [Wed, 22 Sep 2021 12:37:49 +0000 (14:37 +0200)] 
vshCmddefCheckInternals: Fix typo

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agokbase: Document virtio-mem
Michal Privoznik [Sun, 7 Feb 2021 19:52:08 +0000 (20:52 +0100)] 
kbase: Document virtio-mem

This commit adds new memorydevices.rst page which should serve
all models of memory devices. Yet, I'm documenting virtio-mem
quirks only.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agonews: document recent virtio memory addition
Michal Privoznik [Thu, 3 Dec 2020 08:55:35 +0000 (09:55 +0100)] 
news: document recent virtio memory addition

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirsh: Introduce update-memory-device command
Michal Privoznik [Thu, 21 Jan 2021 16:51:31 +0000 (17:51 +0100)] 
virsh: Introduce update-memory-device command

New 'update-memory-device' command is introduced which aims on
making it user friendly to change <memory/> device. So far I just
need to change <requested/> so I'm introducing --requested-size
only; but the idea is that this is extensible for other cases
too. For instance, want to change <myElement/>? A new
--my-element argument can be easily introduced.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuDomainSetMemoryFlags: Take virtio-mem into consideration
Michal Privoznik [Tue, 16 Mar 2021 18:09:27 +0000 (19:09 +0100)] 
qemuDomainSetMemoryFlags: Take virtio-mem into consideration

The qemuDomainSetMemoryFlags() allows for memballoon
(<currentMemory/>) changes for both active and inactive guests.
And just before doing any change, we have to make sure that the
new size is not greater than the total memory (<memory/>).

However, the total memory includes not only the regular guest
memory, but also sum of maximum sizes of all virtio-mems (in fact
all memory devices for that matter). But virtio-mem devices are
modified differently (via virDomainUpdateDevice()) and thus the
upper limit for new balloon size has to be lowered.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: Account for both memballoon and virtio-mem
Michal Privoznik [Mon, 15 Mar 2021 16:18:56 +0000 (17:18 +0100)] 
qemu: Account for both memballoon and virtio-mem

Reporting how much memory is exposed to the guest happens under
<currentMemory/> which is taken from def->mem.cur_balloon. The
reported amount should account for both balloon size and the sum
of @currentsize of all virtio-mems. For instance, if domain has
4GiB via balloon and additional 2GiB via virtio-mem, then the
domain XML should report 6GiB. The same applies for domain
statistics.

The way to achieve this is to account for either balloon or
virtio-mem when the size of the other is changed, e.g. on balloon
change we have to add all @currentsize (for non virtio-mem these
will be zero, so the check for memory model is needless, but
makes it more obvious what's happening), and vice versa.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: Refresh the current size of virtio-mem on monitor reconnect
Michal Privoznik [Wed, 25 Nov 2020 10:35:00 +0000 (11:35 +0100)] 
qemu: Refresh the current size of virtio-mem on monitor reconnect

If the QEMU driver restarts it loses the track of the current size
of virtio-mem (because it's runtime type of information and thus
not stored in XML) and therefore, we have to refresh it when
reconnecting to the domain monitor.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: Wire up MEMORY_DEVICE_SIZE_CHANGE event
Michal Privoznik [Thu, 21 Jan 2021 13:16:44 +0000 (14:16 +0100)] 
qemu: Wire up MEMORY_DEVICE_SIZE_CHANGE event

As advertised in previous commit, this event is delivered to us
when virtio-mem module changes the allocation inside the guest.
It comes with one attribute - size - which holds the new size of
the virtio-mem (well, allocated size), in bytes.
Mind you, this is not necessarily the same number as 'requested
size'. It almost certainly will be when sizing the memory up, but
it might not be when sizing the memory down - the guest kernel
might be unable to free some blocks.

This current size is reported in the domain XML as an output
element only.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoconf: Introduce virDomainMemoryFindByDeviceAlias()
Michal Privoznik [Mon, 21 Jun 2021 09:58:37 +0000 (11:58 +0200)] 
conf: Introduce virDomainMemoryFindByDeviceAlias()

This function will be needed in the next commit where we will
want to find virtio-mem given its alias by QEMU on the monitor.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoIntroduce <current/> property to virtio-mem
Michal Privoznik [Mon, 21 Jun 2021 09:56:07 +0000 (11:56 +0200)] 
Introduce <current/> property to virtio-mem

The virtio-mem has another property that isn't exposed yet:
current size exposed to the guest. Please note, that this is
different to <requested/> because esp. on sizing the memory
down guest may refuse to release some blocks. Therefore, let's
have another size to report in the XML. But because of its
nature, the <current/> won't be parsed and is report only (for
live XMLs).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: Wire up <memory/> offline update
Michal Privoznik [Fri, 10 Sep 2021 14:41:43 +0000 (16:41 +0200)] 
qemu: Wire up <memory/> offline update

Updating offline XML of <memory/> devices might come handy when
dealing with virtio-mem devices. But it's implemented to just
replace one virDomainMemoryDef with another so it can be used to
change almost anything.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: Wire up <memory/> live update
Michal Privoznik [Mon, 23 Nov 2020 16:29:00 +0000 (17:29 +0100)] 
qemu: Wire up <memory/> live update

As advertised in one of previous commits, we want to be able to
change 'requested-size' attribute of virtio-mem on the fly. This
commit does exactly that. Changing anything else is checked for
and forbidden.

Once guest has changed the allocation, QEMU emits an event which
we will use to track the allocation. In the next commit.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: Build command line for virtio-mem
Michal Privoznik [Tue, 19 Jan 2021 09:16:55 +0000 (10:16 +0100)] 
qemu: Build command line for virtio-mem

Nothing special is happening here. All important changes were
done when for 'virtio-pmem' (adjusting the code to put virtio
memory on PCI bus, generating alias using
qemuDomainDeviceAliasIndex(). The only bit that might look
suspicious is no prealloc for virtio-mem. But if you think about
it, the whole purpose of this device is to change amount of
memory exposed to guest on the fly. There is no point in locking
the whole backend in memory.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoconf: Introduce virtio-mem <memory/> model
Michal Privoznik [Mon, 18 Jan 2021 15:13:12 +0000 (16:13 +0100)] 
conf: Introduce virtio-mem <memory/> model

The virtio-mem is paravirtualized mechanism of adding/removing
memory to/from a VM. A virtio-mem-pci device is split into blocks
of equal size which are then exposed (all or only a requested
portion of them) to the guest kernel to use as regular memory.
Therefore, the device has two important attributes:

  1) block-size, which defines the size of a block
  2) requested-size, which defines how much memory (in bytes)
     is the device requested to expose to the guest.

The 'block-size' is configured on command line and immutable
throughout device's lifetime. The 'requested-size' can be set on
the command line too, but also is adjustable via monitor. In
fact, that is how management software places its requests to
change the memory allocation. If it wants to give more memory to
the guest it changes 'requested-size' to a bigger value, and if it
wants to shrink guest memory it changes the 'requested-size' to a
smaller value. Note, value of zero means that guest should
release all memory offered by the device. Of course, guest has to
cooperate. Therefore, there is a third attribute 'size' which is
read only and reflects how much memory the guest still has. This
can be different to 'requested-size', obviously. Because of name
clash, I've named it 'current' and it is dealt with in future
commits (it is a runtime information anyway).

In the backend, memory for virtio-mem is backed by usual objects:
memory-backend-{ram,file,memfd} and their size puts the cap on
the amount of memory that a virtio-mem device can offer to a
guest. But we are already able to express this info using <size/>
under <target/>.

Therefore, we need only two more elements to cover 'block-size'
and 'requested-size' attributes. This is the XML I've came up
with:

  <memory model='virtio-mem'>
    <source>
      <nodemask>1-3</nodemask>
      <pagesize unit='KiB'>2048</pagesize>
    </source>
    <target>
      <size unit='KiB'>2097152</size>
      <node>0</node>
      <block unit='KiB'>2048</block>
      <requested unit='KiB'>1048576</requested>
    </target>
    <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
  </memory>

I hope by now it is obvious that:

  1) 'requested-size' must be an integer multiple of
     'block-size', and
  2) virtio-mem-pci device goes onto PCI bus and thus needs PCI
     address.

Then there is a limitation that the minimal 'block-size' is
transparent huge page size (I'll leave this without explanation).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu_capabilities: Introduce QEMU_CAPS_MEMORY_BACKEND_RESERVE
Michal Privoznik [Mon, 13 Sep 2021 07:44:42 +0000 (09:44 +0200)] 
qemu_capabilities: Introduce QEMU_CAPS_MEMORY_BACKEND_RESERVE

This capability tracks whether memory-backend-* supports .reserve
attribute which is going to be important for backends associated
with virtio-mem devices.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu_capabilities: Introduce QEMU_CAPS_DEVICE_VIRTIO_MEM_PCI
Michal Privoznik [Mon, 2 Nov 2020 11:43:39 +0000 (12:43 +0100)] 
qemu_capabilities: Introduce QEMU_CAPS_DEVICE_VIRTIO_MEM_PCI

This commit introduces a new capability that reflects virtio-mem-pci
device support in QEMU:

  QEMU_CAPS_DEVICE_VIRTIO_MEM_PCI, /* -device virtio-mem-pci */

The virtio-mem-pci device was introduced in QEMU 5.1.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirhostmem: Introduce virHostMemGetTHPSize()
Michal Privoznik [Wed, 20 Jan 2021 10:30:34 +0000 (11:30 +0100)] 
virhostmem: Introduce virHostMemGetTHPSize()

New virHostMemGetTHPSize() is introduced which allows caller to
obtain THP PMD (Page Middle Directory) size, which is equal to
the minimal size that THP can use, taken from kernel doc
(Documentation/admin-guide/mm/transhuge.rst):

  Some userspace (such as a test program, or an optimized memory allocation
  library) may want to know the size (in bytes) of a transparent hugepage::

    cat /sys/kernel/mm/transparent_hugepage/hpage_pmd_size

Since this size depends on the host architecture and the kernel
it won't change whilst libvirtd is running. Therefore, we can use
virOnce() and cache the value. Of course, we can be running under
kernel that has THP disabled or has no notion of THP at all. In
that case a negative value is returned to signal error.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildNumaCommandLine: Separate out building of CPU list
Michal Privoznik [Wed, 20 May 2020 10:00:23 +0000 (12:00 +0200)] 
qemuBuildNumaCommandLine: Separate out building of CPU list

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoqemuBuildNumaCommandLine: Move vars into loops
Michal Privoznik [Wed, 20 May 2020 09:32:14 +0000 (11:32 +0200)] 
qemuBuildNumaCommandLine: Move vars into loops

There are two variables that are used only in a single
loop. Move their definitions into their respective blocks.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agovirCPUDefParseXML: Prefer virXMLPropUInt over virXPathUInt
Michal Privoznik [Tue, 21 Sep 2021 14:26:48 +0000 (16:26 +0200)] 
virCPUDefParseXML: Prefer virXMLPropUInt over virXPathUInt

When parsing CPU topology, which is described in <topology/>
attributes we can use virXMLPropUInt() instead of virXPathUInt()
as the former results in shorter code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agovirCPUDefParseXML: Parse uint using virXPathUInt()
Michal Privoznik [Wed, 20 May 2020 13:36:17 +0000 (15:36 +0200)] 
virCPUDefParseXML: Parse uint using virXPathUInt()

There is no need to use virXPathULong() and a temporary UL
variable if we can use virXPathUInt() directly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoPost-release version bump to 7.9.0
Jiri Denemark [Fri, 1 Oct 2021 08:38:45 +0000 (10:38 +0200)] 
Post-release version bump to 7.9.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3 years agoRelease of libvirt-7.8.0 v7.8.0
Jiri Denemark [Fri, 1 Oct 2021 08:34:54 +0000 (10:34 +0200)] 
Release of libvirt-7.8.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3 years agoTranslated using Weblate (Ukrainian) v7.8.0-rc2
Yuri Chornoivan [Wed, 29 Sep 2021 08:05:11 +0000 (10:05 +0200)] 
Translated using Weblate (Ukrainian)

Currently translated at 100.0% (10374 of 10374 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>
3 years agoTranslated using Weblate (Polish)
Piotr Drąg [Wed, 29 Sep 2021 08:05:10 +0000 (10:05 +0200)] 
Translated using Weblate (Polish)

Currently translated at 22.6% (2345 of 10374 strings)

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

Co-authored-by: Piotr Drąg <piotrdrag@gmail.com>
Signed-off-by: Piotr Drąg <piotrdrag@gmail.com>
3 years agoTranslated using Weblate (Korean)
simmon [Wed, 29 Sep 2021 08:05:10 +0000 (10:05 +0200)] 
Translated using Weblate (Korean)

Currently translated at 99.7% (10345 of 10374 strings)

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

Co-authored-by: simmon <simmon@nplob.com>
Signed-off-by: simmon <simmon@nplob.com>
3 years agoUpdate translation files
Weblate [Wed, 29 Sep 2021 08:05:07 +0000 (10:05 +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>
3 years agopo: Refresh potfile for v7.8.0 v7.8.0-rc1
Jiri Denemark [Mon, 27 Sep 2021 09:38:35 +0000 (11:38 +0200)] 
po: Refresh potfile for v7.8.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3 years agoTranslated using Weblate (Korean)
simmon [Mon, 27 Sep 2021 07:55:01 +0000 (09:55 +0200)] 
Translated using Weblate (Korean)

Currently translated at 100.0% (10353 of 10353 strings)

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

Co-authored-by: simmon <simmon@nplob.com>
Signed-off-by: simmon <simmon@nplob.com>
3 years agoTranslated using Weblate (Korean)
jason lee [Mon, 27 Sep 2021 07:55:00 +0000 (09:55 +0200)] 
Translated using Weblate (Korean)

Currently translated at 100.0% (10353 of 10353 strings)

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

Co-authored-by: jason lee <ppark5237@gmail.com>
Signed-off-by: jason lee <ppark5237@gmail.com>
3 years agoTranslated using Weblate (Korean)
simmon [Mon, 27 Sep 2021 07:54:59 +0000 (09:54 +0200)] 
Translated using Weblate (Korean)

Currently translated at 100.0% (10353 of 10353 strings)

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

Translated using Weblate (Korean)

Currently translated at 92.4% (9576 of 10353 strings)

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

Co-authored-by: simmon <simmon@nplob.com>
Signed-off-by: simmon <simmon@nplob.com>
3 years agoTranslated using Weblate (Korean)
jason lee [Mon, 27 Sep 2021 07:54:58 +0000 (09:54 +0200)] 
Translated using Weblate (Korean)

Currently translated at 92.4% (9576 of 10353 strings)

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

Translated using Weblate (Korean)

Currently translated at 91.6% (9484 of 10353 strings)

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

Co-authored-by: jason lee <ppark5237@gmail.com>
Signed-off-by: jason lee <ppark5237@gmail.com>
3 years agoqemu: deprecate QEMU_CAPS_FSDEV_CREATEMODE
Ján Tomko [Fri, 24 Sep 2021 15:23:33 +0000 (17:23 +0200)] 
qemu: deprecate QEMU_CAPS_FSDEV_CREATEMODE

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu: assume QEMU_CAPS_FSDEV_CREATEMODE
Ján Tomko [Fri, 24 Sep 2021 15:20:37 +0000 (17:20 +0200)] 
qemu: assume QEMU_CAPS_FSDEV_CREATEMODE

Added by QEMU commit:
b96feb2cb9 "9pfs: local: Add support for custom fmode/dmode in 9ps
mapped security modes"
in 2.10.0

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu: Deprecate QEMU_CAPS_MACHINE_KERNEL_IRQCHIP
Ján Tomko [Fri, 24 Sep 2021 15:09:56 +0000 (17:09 +0200)] 
qemu: Deprecate QEMU_CAPS_MACHINE_KERNEL_IRQCHIP

Now that it's no longer used, remove probing for it
and mark it as deprecated.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu: assume QEMU_CAPS_MACHINE_KERNEL_IRQCHIP
Ján Tomko [Fri, 24 Sep 2021 15:07:06 +0000 (17:07 +0200)] 
qemu: assume QEMU_CAPS_MACHINE_KERNEL_IRQCHIP

Even though we only allow this option on x86,
all QEMUs report the command line option.

Added in QEMU v1.1:
6a48ffaaa7 "kvm: Activate in-kernel irqchip support"

Remove the pointless capability.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu: capabilities: do not look at parameters for sandbox
Ján Tomko [Fri, 24 Sep 2021 14:23:32 +0000 (16:23 +0200)] 
qemu: capabilities: do not look at parameters for sandbox

Assume the presence of the 'sandbox' option is enough,
no need to look at the parameters.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu: capabilities: deprecate QEMU_CAPS_SECCOMP_BLACKLIST
Ján Tomko [Fri, 24 Sep 2021 14:22:06 +0000 (16:22 +0200)] 
qemu: capabilities: deprecate QEMU_CAPS_SECCOMP_BLACKLIST

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu: seccomp: remove dead code
Ján Tomko [Fri, 24 Sep 2021 14:20:01 +0000 (16:20 +0200)] 
qemu: seccomp: remove dead code

There is no QEMU we support that would need the old syntax
for -sandbox on.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu: conf: simplify seccomp_sandbox comment
Ján Tomko [Fri, 24 Sep 2021 14:15:30 +0000 (16:15 +0200)] 
qemu: conf: simplify seccomp_sandbox comment

It contains too many negations and conditions that are
no longer relevant now that we only support QEMU >= 2.11.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu: always assume QEMU_CAPS_SECCOMP_BLACKLIST
Ján Tomko [Fri, 24 Sep 2021 14:04:30 +0000 (16:04 +0200)] 
qemu: always assume QEMU_CAPS_SECCOMP_BLACKLIST

elevateprivileges was introduced by QEMU commit:
73a1e64725 "seccomp: add elevateprivileges argument to command line"
released in 2.11.0
and later made conditional on SECCOMP support by:
9d0fdecbad sandbox: disable -sandbox if CONFIG_SECCOMP undefined

Use the existence of the sandbox option as a witness for its support.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu: ingore the transient domain state in fake reboot
Zhenzhong Duan [Sun, 26 Sep 2021 09:06:38 +0000 (17:06 +0800)] 
qemu: ingore the transient domain state in fake reboot

When action for 'on_poweroff' is set to 'restart', 'fake reboot'
is triggered and qemu shutdown state is transient. Domain state
need not to be changed and events not sent in this case.

Fixes: 4ffc807214cb80086d57e1d3e7b60959a41d2874
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agovirsh: domain: remove else branch
Kristina Hanicova [Fri, 24 Sep 2021 15:17:50 +0000 (17:17 +0200)] 
virsh: domain: remove else branch

I removed else branches after return/break as they are not
necessary and the code looks cleaner without them.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agovirsh: domain: remove 'ret' variable and use 'count' instead
Kristina Hanicova [Fri, 24 Sep 2021 15:17:49 +0000 (17:17 +0200)] 
virsh: domain: remove 'ret' variable and use 'count' instead

This patch also includes use of an early return in case of an
error. I think the changes make the functions more readable.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agovirsh: domain: use early return when possible
Kristina Hanicova [Fri, 24 Sep 2021 15:17:48 +0000 (17:17 +0200)] 
virsh: domain: use early return when possible

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>