]> git.ipfire.org Git - thirdparty/libvirt.git/log
thirdparty/libvirt.git
6 months agobackup: Add support for passing server socket file descriptor to backup NBD server
Peter Krempa [Tue, 25 Mar 2025 16:46:45 +0000 (17:46 +0100)] 
backup: Add support for passing server socket file descriptor to backup NBD server

In deployments where libvirt is containerized together with the VM it
may be hard for the management application to access listening sockets
inside the container from the outside.

This patch implements "transport='fd'" for the NBD server definition for
backups which allows to use the existing "virDomainFDAssociate()" to
pass FD to a pre-opened server socket to qemu instead of trying to
create it by qemu.

Add schema, enable the parser, add formatter and implement the actual
passing for the qemu backup code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Spellchecked-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 months agoqemu: monitor: Support FD passing of sockets to 'qemuMonitorJSONNBDServerStart'
Peter Krempa [Tue, 25 Mar 2025 16:32:23 +0000 (17:32 +0100)] 
qemu: monitor: Support FD passing of sockets to 'qemuMonitorJSONNBDServerStart'

Upcoming patches will extend the FD passing infrastructure to the backup
job so that users can pass an opened socket instead of qemu opening it
themself to bypass difficulities caused by containerizing libvirt.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 months agovirStorageNetHostDefClear: Move into virStorageNetHostDefFree
Peter Krempa [Tue, 25 Mar 2025 16:27:19 +0000 (17:27 +0100)] 
virStorageNetHostDefClear: Move into virStorageNetHostDefFree

There are no other callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 months agoconf: Introduce VIR_STORAGE_NET_HOST_TRANS_FD
Peter Krempa [Tue, 25 Mar 2025 16:17:11 +0000 (17:17 +0100)] 
conf: Introduce VIR_STORAGE_NET_HOST_TRANS_FD

Prepare the parser code and anything using 'virStorageNetHostTransport'
to support passing a FD instead of opening the connection by qemu
itself.

For now this just prepares the parser and data structures, but the code
is dormant.

Only code paths which will actually support FD passing will then enable
it in the future.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Spellchecked-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 months agovirDomainStorageNetworkParseHost: Refactor cleanup
Peter Krempa [Tue, 25 Mar 2025 14:18:40 +0000 (15:18 +0100)] 
virDomainStorageNetworkParseHost: Refactor cleanup

Use a 'switch' statement instead of a bunch of if statements to do
validation and selection what to parse.

Remove the pre-clearing of the struct as we always allocate cleared
memory for it and we can reorder assignments to avoid the need for
cleanup.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 months agovirDomainStorageNetworkParseHost: Remove unpopulated 'transport' variable
Peter Krempa [Tue, 25 Mar 2025 13:51:25 +0000 (14:51 +0100)] 
virDomainStorageNetworkParseHost: Remove unpopulated 'transport' variable

Since the refactor to use proper enum type for the network transport the
'transport' variable is no longer filled. Remove it and fix the error
message which references it without using NULLSTR.

Fixes: 452695926dc
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 months agovirDomainDiskDefValidateSourceChainOne: Fix validation of 'data-file' nesting
Peter Krempa [Fri, 28 Mar 2025 07:26:17 +0000 (08:26 +0100)] 
virDomainDiskDefValidateSourceChainOne: Fix validation of 'data-file' nesting

As the 'dataStore' is internally represented as a virStorageSource
object it has provisions for nesting which is not supported.

When I've reviewed and modified the commit adding data file parsing
support I've added code that was supposed to reject any 'backingStore'
and 'dataStore' structures nested in a source of a 'dataStore'.

Unfortunately the check was broken as one of the terms checked the
presence of parent's 'backingStore' instead of the nesting.

Fix it and add tests.

Fixes: b3171cf8da3
Resolves: https://issues.redhat.com/browse/RHEL-85320
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
6 months agoesxConnectListAllDomains: Don't propagate failure to lookup a single domain
Peter Krempa [Tue, 25 Mar 2025 06:23:01 +0000 (07:23 +0100)] 
esxConnectListAllDomains: Don't propagate failure to lookup a single domain

In esxConnectListAllDomains if the lookup of the VM name and UUID fails
for a single VM (possible e.g. with broken storage) the whole API would
return failure even when there are working VMs.

Rework the lookup so that if a subset fails we ignore the failure on
those. We report an error only if lookup of all of the objects failed.
Failure is reported from the last one.

Resolves: https://issues.redhat.com/browse/RHEL-80606
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 months agonews: document dropping apparmor < 3.0.0
Daniel P. Berrangé [Tue, 1 Apr 2025 11:35:40 +0000 (12:35 +0100)] 
news: document dropping apparmor < 3.0.0

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 months agomeson: drop remaining checks for apparmor version
Daniel P. Berrangé [Mon, 31 Mar 2025 10:43:33 +0000 (11:43 +0100)] 
meson: drop remaining checks for apparmor version

Now that we mandate version 3, any remaining conditional checks
in meson/source code can be removed.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 months agoRevert "apparmor: Allow version-specific bits in profiles"
Daniel P. Berrangé [Mon, 31 Mar 2025 10:42:43 +0000 (11:42 +0100)] 
Revert "apparmor: Allow version-specific bits in profiles"

This reverts commit 19eb8abc9a4d15190852d644b773a2348f11c9da.

There is no longer any need to dynamically generate version specific
rules. This revert can be reverted, if the need ever arises again
in the future.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 months agoRevert "apparmor: Allow version-specific bits in abstractions too"
Daniel P. Berrangé [Mon, 31 Mar 2025 10:53:40 +0000 (11:53 +0100)] 
Revert "apparmor: Allow version-specific bits in abstractions too"

This reverts commit 63a312fa2d3be0e34a8989deddd39792fc9badf6.

There is no longer any need to dynamically generate version specific
rules. This revert can be reverted, if the need ever arises again
in the future.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 months agoapparmor: assume at least apparmor >= 3
Daniel P. Berrangé [Mon, 31 Mar 2025 10:41:10 +0000 (11:41 +0100)] 
apparmor: assume at least apparmor >= 3

By assuming version 3, we can drop all the conditional version
substitutions from the profiles.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 months agomeson: mandate apparmor >= 3.0.0
Daniel P. Berrangé [Mon, 31 Mar 2025 10:43:33 +0000 (11:43 +0100)] 
meson: mandate apparmor >= 3.0.0

We can now assume at least version three:

 * Debian 12: 3.0.8
 * openSUSE Leap 15.5: 3.0.4
 * openSUSE Leap 15.6: 3.1.7
 * Ubuntu 22.04: 3.0.4
 * Ubuntu 24.04: 4.0.0

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 months agoPost-release version bump to 11.3.0
Jiri Denemark [Tue, 1 Apr 2025 10:03:39 +0000 (12:03 +0200)] 
Post-release version bump to 11.3.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
6 months agoRelease of libvirt-11.2.0 v11.2.0
Jiri Denemark [Tue, 1 Apr 2025 09:59:33 +0000 (11:59 +0200)] 
Release of libvirt-11.2.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
6 months agoTranslated using Weblate (Korean)
김인수 [Sun, 30 Mar 2025 07:26:43 +0000 (07:26 +0000)] 
Translated using Weblate (Korean)

Currently translated at 98.6% (10775 of 10917 strings)

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

Signed-off-by: 김인수 <simmon@nplob.com>
6 months agoTranslated using Weblate (English (United Kingdom))
Andi Chandler [Sun, 30 Mar 2025 07:26:42 +0000 (07:26 +0000)] 
Translated using Weblate (English (United Kingdom))

Currently translated at 48.2% (5270 of 10917 strings)

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

Signed-off-by: Andi Chandler <andi@gowling.com>
6 months agoNEWS: qemu: support block disk along with throttle filters
Harikumar Rajkumar [Tue, 25 Mar 2025 10:57:25 +0000 (16:27 +0530)] 
NEWS: qemu: support block disk along with throttle filters

Signed-off-by: Harikumar Rajkumar <harirajkumar230@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
6 months agoNEWS: Document features/improvements/bug fixes I've participated in
Michal Privoznik [Fri, 28 Mar 2025 07:36:07 +0000 (08:36 +0100)] 
NEWS: Document features/improvements/bug fixes I've participated in

There are some features/improvements/bug fixes I've either
contributed or reviewed/merged. Document them for upcoming
release.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
6 months agoNEWS: Mention bump to qemu-6.2, vhost-user shmem check and stats params discoverabilty v11.2.0-rc2
Peter Krempa [Wed, 26 Mar 2025 09:12:06 +0000 (10:12 +0100)] 
NEWS: Mention bump to qemu-6.2, vhost-user shmem check and stats params discoverabilty

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
6 months agodoc: remove wrong comment
Philipp Schuster [Wed, 26 Mar 2025 12:51:41 +0000 (13:51 +0100)] 
doc: remove wrong comment

This comment is wrong as later qemuMigrationSrcRun() is called which
checks if TLS should be used and activated. QEMU has built-in support
for TLS, which this refers to.

The comment originates from a time when tunneled support was the only
way to get encryption.

Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
6 months agolib: virDomain{Save,Restore}Params: Ensure absolute path
Jim Fehlig [Mon, 29 Jul 2024 22:34:48 +0000 (16:34 -0600)] 
lib: virDomain{Save,Restore}Params: Ensure absolute path

When invoking virDomainSaveParams with a relative path, the image is
saved to the daemon's CWD. Similarly, when providing virDomainRestoreParams
with a relative path, it attempts to restore from the daemon's CWD. In most
configurations, the daemon's CWD is set to '/'. Ensure a relative path is
converted to absolute before invoking the driver domain{Save,Restore}Params
functions.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
6 months agoUpdate translation files
Weblate [Tue, 25 Mar 2025 11:29:11 +0000 (11:29 +0000)] 
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/

Signed-off-by: Fedora Weblate Translation <i18n@lists.fedoraproject.org>
6 months agoqemu_driver: Fix virDomainSaveImageDefineXML
Pavel Hrdina [Mon, 24 Mar 2025 19:11:58 +0000 (20:11 +0100)] 
qemu_driver: Fix virDomainSaveImageDefineXML

Commit 28a06215280b99708ed8dc2d183f62ba7b34ccf8 added support to restore
sparse images but changed the boolean that controls if we open the file
as read-only or read-write. Editing XML in the save image resulted in
following error message:

    failed to write header to domain save file '/data/images/fedora40.save': Bad file descriptor

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
6 months agopo: Refresh potfile for v11.2.0 v11.2.0-rc1
Jiri Denemark [Tue, 25 Mar 2025 11:23:31 +0000 (12:23 +0100)] 
po: Refresh potfile for v11.2.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
6 months agoqemu: Emit NIC_MAC_CHANGE event
Michal Privoznik [Tue, 27 Jun 2023 11:32:55 +0000 (13:32 +0200)] 
qemu: Emit NIC_MAC_CHANGE event

So far, we only process NIC_RX_FILTER_CHANGED event when the
corresponding device has 'trustGuestRxFilters' enabled. And the
event is emitted only for virtio model. IOW, this is fairly
limited situation and other scenarios don't emit any event (e.g.
change of MAC address on a PCI passthrough device).

Resolves: https://issues.redhat.com/browse/RHEL-7035
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
6 months agoIntroduce NIC_MAC_CHANGE event
Michal Privoznik [Tue, 27 Jun 2023 08:13:51 +0000 (10:13 +0200)] 
Introduce NIC_MAC_CHANGE event

The aim off this event is to notify management application that
guest changed MAC address on one of its vNICs so the app can
update its internal records, e.g. for finding match between
guest/host view of vNICs.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
6 months agoqemu: Reflect MAC address change in live domain XML
Michal Privoznik [Tue, 27 Jun 2023 15:13:33 +0000 (17:13 +0200)] 
qemu: Reflect MAC address change in live domain XML

If a guest changes MAC address on its vNIC, then QEMU emits
NIC_RX_FILTER_CHANGED event (the event is emitted in other cases
too, but that's not important right now). Now, domain XML allows
users to chose whether to trust these events or not:

  <interface trustGuestRxFilters='yes|no'/>

For the 'no' case no action is performed and the event is
ignored. But for the 'yes' case, some host side features of
corresponding vNIC (well tap/macvtap device) are tweaked to
reflect changed MAC address. But what is missing is reflecting
this new MAC address in domain XML.

Basically, what happens is: the host sees traffic with new MAC
address, all tools inside the guest see the new MAC address
(including 'virsh domifaddr --source agent') which makes it
harder to match device in the guest with the one in the domain
XML.

Therefore, report this new MAC address as another attribute of
the <mac/> element:

  <mac address="52:54:00:a4:6f:91" currentAddress="00:11:22:33:44:55"/>

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
6 months agoNEWS: Mention virsh hypervisor-cpu-models command
Boris Fiuczynski [Tue, 25 Mar 2025 10:29:57 +0000 (11:29 +0100)] 
NEWS: Mention virsh hypervisor-cpu-models command

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
6 months agoTranslated using Weblate (Spanish)
Nicolás Gal [Mon, 24 Mar 2025 16:13:03 +0000 (16:13 +0000)] 
Translated using Weblate (Spanish)

Currently translated at 52.6% (5708 of 10838 strings)

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

Signed-off-by: Nicolás Gal <nialegal@yandex.com>
6 months agoNEWS: Mention guest agent error code improvements
Peter Krempa [Thu, 20 Mar 2025 15:38:41 +0000 (16:38 +0100)] 
NEWS: Mention guest agent error code improvements

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 months agoqemuAgentCheckError: Rewort error if neither return nor error is found
Peter Krempa [Thu, 20 Mar 2025 15:17:54 +0000 (16:17 +0100)] 
qemuAgentCheckError: Rewort error if neither return nor error is found

Disambiguate the case from other types of error.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 months agoqemuAgentCheckError: Use 'VIR_ERR_AGENT_COMMAND_FAILED'
Peter Krempa [Thu, 20 Mar 2025 15:17:23 +0000 (16:17 +0100)] 
qemuAgentCheckError: Use 'VIR_ERR_AGENT_COMMAND_FAILED'

In the two cases when we know that the command returned failure switch
to the new error code so that management applications can
programatically detect failure of the guest agent command.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 months agolib: error: Introduce 'VIR_ERR_AGENT_COMMAND_FAILED'
Peter Krempa [Thu, 20 Mar 2025 15:10:18 +0000 (16:10 +0100)] 
lib: error: Introduce 'VIR_ERR_AGENT_COMMAND_FAILED'

Add a special error code for when the guest agent returned a failure
message.

Allow management applications to deterministically detect failure of the
guest agent command.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 months agodocs: Point to VIR_ERR_AGENT_COMMAND_TIMEOUT when setting timeout
Peter Krempa [Thu, 20 Mar 2025 14:44:35 +0000 (15:44 +0100)] 
docs: Point to VIR_ERR_AGENT_COMMAND_TIMEOUT when setting timeout

In addition to the error constant appearing add docs hinting that this
new error code can be produced on timeouts.

The most relevant place is to do it when setting the timeout.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 months agoqemuAgentCommandFull: Use VIR_ERR_AGENT_COMMAND_TIMEOUT when agent disappears
Peter Krempa [Thu, 20 Mar 2025 15:07:32 +0000 (16:07 +0100)] 
qemuAgentCommandFull: Use VIR_ERR_AGENT_COMMAND_TIMEOUT when agent disappears

When the agent disappears after geting a proper command we ought to
report the same error code as if we timed out as it's uncertain whether
the guest agent did anything.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 months agoqemu: agent: Differentiate timeouts when syncing from command timeout
Peter Krempa [Thu, 20 Mar 2025 14:17:11 +0000 (15:17 +0100)] 
qemu: agent: Differentiate timeouts when syncing from command timeout

As the guest agent code uses timeouts it is possible that we stop
waiting before the guest agent replies. If this happens while syncing
everything is okay because we didn't send any state-changing command.

In case when the timeout happens after a real command was transmitted
it's unknown if the guest-agent processed it or not.

Use the new special error code VIR_ERR_AGENT_COMMAND_TIMEOUT for cases
when we sent non-sync commands, so that the management applications or
users have possibility to react to this situation.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 months agolib: error: Introduce 'VIR_ERR_AGENT_COMMAND_TIMEOUT'
Peter Krempa [Thu, 20 Mar 2025 14:27:13 +0000 (15:27 +0100)] 
lib: error: Introduce 'VIR_ERR_AGENT_COMMAND_TIMEOUT'

Introduce a new special error code for guest agent commands.

The error code will be specifically reported only when an actual command
(not a sync) was issued to the guest agent and the timeout time was
reached.

This will allow users and management applications to differentiate
between the cases when the sync timed out and thus there's no risk in
the agent actually having executed the command and when the actual
command was sent.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 months agoNEWS: fix one more typo
Ján Tomko [Fri, 21 Mar 2025 15:27:58 +0000 (16:27 +0100)] 
NEWS: fix one more typo

s/ an / a /

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reported-by: Jiri Denemark <jdenemar@redhat.com>
6 months agoNEWS: hotplug virtio-mem device
Boris Fiuczynski [Fri, 21 Mar 2025 07:18:31 +0000 (08:18 +0100)] 
NEWS: hotplug virtio-mem device

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
6 months agoTranslated using Weblate (Chinese (Traditional) (zh_TW))
hsu zangmen [Thu, 20 Mar 2025 05:28:24 +0000 (05:28 +0000)] 
Translated using Weblate (Chinese (Traditional) (zh_TW))

Currently translated at 2.4% (264 of 10838 strings)

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

Signed-off-by: hsu zangmen <chzang55@gmail.com>
6 months agoTranslated using Weblate (English (United Kingdom))
Andi Chandler [Thu, 20 Mar 2025 05:28:23 +0000 (05:28 +0000)] 
Translated using Weblate (English (United Kingdom))

Currently translated at 48.5% (5262 of 10838 strings)

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

Signed-off-by: Andi Chandler <andi@gowling.com>
6 months agoTranslated using Weblate (Russian)
Sergey A [Thu, 20 Mar 2025 05:28:23 +0000 (05:28 +0000)] 
Translated using Weblate (Russian)

Currently translated at 83.8% (9086 of 10838 strings)

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

Signed-off-by: "Sergey A." <Ser82-png@yandex.ru>
6 months agoNEWS: Mention support for mapped-ram
Jim Fehlig via Devel [Thu, 20 Mar 2025 23:25:43 +0000 (17:25 -0600)] 
NEWS: Mention support for mapped-ram

Add a 'New features' entry for mapped-ram itself, and another
for the parallel save/restore feature built on top.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
6 months agoqemu: Fix build on 32-bit platforms
Jim Fehlig via Devel [Thu, 20 Mar 2025 22:17:00 +0000 (16:17 -0600)] 
qemu: Fix build on 32-bit platforms

Commits c2518f7bc7 and 28a0621528 introduced build failures on 32-bit
platforms by using incorrect format specifiers with g_strdup_printf.

In one case, an 'unsigned long' format specifier is used with a
'long long int' variable. Fix by changing the format specifier to
'uintmax_t', and casting the variable likewise.

In a second case, an 'unsigned long' format specifier is used with a
'size_t' variable, which is 'unsigned int' on 32-bit systems. Fix by
changing the format specifier to use the 'z' modifier.

Fixes: c2518f7bc7dd4f8ab8655a12ec3a000e1eb5b232
Fixes: 28a06215280b99708ed8dc2d183f62ba7b34ccf8
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
6 months agovirsh: add --image-format option to the save command
Pavel Hrdina [Thu, 20 Mar 2025 22:34:44 +0000 (23:34 +0100)] 
virsh: add --image-format option to the save command

Option --parallel-channels would require changing configuration file to
be used so introduce this option as well to make it convenient for
users.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
6 months agotools: use virDomainSaveParams only when necessary
Pavel Hrdina [Thu, 20 Mar 2025 22:32:17 +0000 (23:32 +0100)] 
tools: use virDomainSaveParams only when necessary

We should use the newest API only when user sets parallel-channels.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
6 months agotools: use virDomainRestoreParams only when necessary
Pavel Hrdina [Thu, 20 Mar 2025 22:43:59 +0000 (23:43 +0100)] 
tools: use virDomainRestoreParams only when necessary

We should use the newest API only when user sets parallel-channels.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
6 months agoqemu: remove VIR_DOMAIN_SAVE_PARALLEL flag
Pavel Hrdina [Thu, 20 Mar 2025 22:42:05 +0000 (23:42 +0100)] 
qemu: remove VIR_DOMAIN_SAVE_PARALLEL flag

There is no need to use extra flag in addition to the new
"parallel.channels" param.

Using the flag without param would result in using uninitialized
variable. Fixing it would result in error that parallel channels cannot
be less then 1 or setting 1 as default.

Using the param without the flag is ignored.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
6 months agotools: remote --parallel from virsh save command
Pavel Hrdina [Thu, 20 Mar 2025 22:17:11 +0000 (23:17 +0100)] 
tools: remote --parallel from virsh save command

There is no need to have --parallel and --parallel-channels especially
when --parallel on its own is the same as not used at all. In both cases
libvirt will default to single channel.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
6 months agotools: remove --parallel from virsh restore command
Pavel Hrdina [Thu, 20 Mar 2025 22:14:06 +0000 (23:14 +0100)] 
tools: remove --parallel from virsh restore command

There is no need to have --parallel and --parallel-channels especially
when --parallel on its own is the same as not used at all. In both cases
libvirt will default to single channel.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
6 months agoNEWS: fix even more typos
Ján Tomko [Fri, 21 Mar 2025 09:49:25 +0000 (10:49 +0100)] 
NEWS: fix even more typos

The 'editting one' was:
Reported-by: Martin Kletzander <mkletzan@redhat.com>
I found the rest myself.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 months agoqemu/dbus: Allow connections from root to the dbus-daemon
Martin Kletzander [Thu, 20 Mar 2025 14:31:44 +0000 (15:31 +0100)] 
qemu/dbus: Allow connections from root to the dbus-daemon

In commit dbfb96d18c04 libvirt started connecting to the daemon to set
RDP credentials, but our configuration file did not allow connections
from the root user, so the connection failed and the VM failed to start.

In order to avoid such issue allow root to connect if the daemon is
running privileged.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 months agoFix typo in NEWS files
Daniel P. Berrangé [Thu, 20 Mar 2025 17:51:05 +0000 (17:51 +0000)] 
Fix typo in NEWS files

Reported-by: Laine Stump <laine@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 months agoAdd NEWS item for auto-shutdown feature
Daniel P. Berrangé [Thu, 20 Mar 2025 14:54:23 +0000 (14:54 +0000)] 
Add NEWS item for auto-shutdown feature

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 months agotools: add parallel parameter to virsh restore command
Claudio Fontana [Mon, 25 Apr 2022 16:32:31 +0000 (10:32 -0600)] 
tools: add parallel parameter to virsh restore command

Signed-off-by: Claudio Fontana <cfontana@suse.de>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 months agotools: add parallel parameter to virsh save command
Claudio Fontana [Thu, 21 Jul 2022 10:45:11 +0000 (12:45 +0200)] 
tools: add parallel parameter to virsh save command

Signed-off-by: Claudio Fontana <cfontana@suse.de>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 months agoqemu: Add support for parallel save and restore
Jim Fehlig [Wed, 24 Jul 2024 21:14:14 +0000 (15:14 -0600)] 
qemu: Add support for parallel save and restore

Add support for parallel save and restore by mapping libvirt's
"parallel-channels" parameter to QEMU's "multifd-channels"
migration parameter.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 months agoinclude: Define constants for parallel save/restore
Claudio Fontana [Fri, 29 Apr 2022 14:40:10 +0000 (08:40 -0600)] 
include: Define constants for parallel save/restore

Add a new VIR_DOMAIN_SAVE_PARALLEL flag to the save and restore APIs,
which can be used to specify the use of multiple, parallel channels
for saving and restoring a domain. The number of parallel channels
can be set using the VIR_DOMAIN_SAVE_PARAM_PARALLEL_CHANNELS
typed parameter.

Signed-off-by: Claudio Fontana <cfontana@suse.de>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 months agoqemu: Support O_DIRECT with mapped-ram on restore
Jim Fehlig [Wed, 24 Jul 2024 17:24:47 +0000 (11:24 -0600)] 
qemu: Support O_DIRECT with mapped-ram on restore

When using the mapped-ram migration capability, direct IO is
enabled by setting the "direct-io" migration parameter to
"true" and passing QEMU an additional fd with O_DIRECT set.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 months agoqemu: Support O_DIRECT with mapped-ram on save
Jim Fehlig [Mon, 22 Jul 2024 17:34:44 +0000 (11:34 -0600)] 
qemu: Support O_DIRECT with mapped-ram on save

When using the mapped-ram migration capability, direct IO is
enabled by setting the "direct-io" migration parameter to
"true" and passing QEMU an additional fd with O_DIRECT set.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 months agoqemu: Add support for mapped-ram on restore
Jim Fehlig [Mon, 22 Jul 2024 22:09:39 +0000 (16:09 -0600)] 
qemu: Add support for mapped-ram on restore

Add support for the mapped-ram migration capability on restore.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 months agoqemu: Apply migration parameters in qemuMigrationDstRun
Jim Fehlig [Tue, 21 Jan 2025 23:39:20 +0000 (16:39 -0700)] 
qemu: Apply migration parameters in qemuMigrationDstRun

Similar to qemuMigrationSrcRun, apply migration parameters in
qemuMigrationDstRun. This allows callers to create customized
migration parameters, but delegates their application to the
function performing the migration.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 months agoqemu: Move creation of qemuProcessIncomingDef struct
Jim Fehlig [Mon, 22 Jul 2024 23:12:21 +0000 (17:12 -0600)] 
qemu: Move creation of qemuProcessIncomingDef struct

qemuProcessStartWithMemoryState() is the only caller of qemuProcessStart()
that uses the qemuProcessIncomingDef struct. Move creation of the struct
to qemuProcessStartWithMemoryState().

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 months agoqemu: Add support for mapped-ram on save
Jim Fehlig [Tue, 14 Jan 2025 23:13:20 +0000 (16:13 -0700)] 
qemu: Add support for mapped-ram on save

Introduce support for QEMU's new mapped-ram stream format [1].
mapped-ram can be enabled by setting the 'save_image_format'
setting in qemu.conf to 'sparse'.

To use mapped-ram with QEMU:
- The 'mapped-ram' migration capability must be set to true
- The 'multifd' migration capability must be set to true and
  the 'multifd-channels' migration parameter must set to 1
- QEMU must be provided an fdset containing the migration fd
- The 'migrate' qmp command is invoked with a URI referencing the
  fdset and an offset where to start reading or writing the data
  stream, e.g.

  {"execute":"migrate",
   "arguments":{"detach":true,"resume":false,
                "uri":"file:/dev/fdset/0,offset=0x11921"}}

The mapped-ram stream, in conjunction with direct IO and multifd
support provided by subsequent patches, can significantly improve
the time required to save VM memory state. The following tables
compare mapped-ram with the existing, sequential save stream. In
all cases, the save and restore operations are to/from a block
device comprised of two NVMe disks in RAID0 configuration with
xfs (~8600MiB/s). The values in the 'save time' and 'restore time'
columns were scraped from the 'real' time reported by time(1). The
'Size' and 'Blocks' columns were provided by the corresponding
outputs of stat(1).

VM: 32G RAM, 1 vcpu, idle (shortly after boot)

                       | save    | restore |
       | time    | time    | Size         | Blocks
-----------------------+---------+---------+--------------+--------
legacy                 | 6.193s  | 4.399s  | 985744812    | 1925288
-----------------------+---------+---------+--------------+--------
mapped-ram             | 5.109s  | 1.176s  | 34368554354  | 1774472
-----------------------+---------+---------+--------------+--------
legacy + direct IO     | 5.725s  | 4.512s  | 985765251    | 1925328
-----------------------+---------+---------+--------------+--------
mapped-ram + direct IO | 4.627s  | 1.490s  | 34368554354  | 1774304
-----------------------+---------+---------+--------------+--------
mapped-ram + direct IO |         |         |              |
 + multifd-channels=8  | 4.421s  | 0.845s  | 34368554318  | 1774312
-------------------------------------------------------------------

VM: 32G RAM, 30G dirty, 1 vcpu in tight loop dirtying memory

                       | save    | restore |
       | time    | time    | Size         | Blocks
-----------------------+---------+---------+--------------+---------
legacy                 | 25.800s | 14.332s | 33154309983  | 64754512
-----------------------+---------+---------+--------------+---------
mapped-ram             | 18.742s | 15.027s | 34368559228  | 64617160
-----------------------+---------+---------+--------------+---------
legacy + direct IO     | 13.115s | 18.050s | 33154310496  | 64754520
-----------------------+---------+---------+--------------+---------
mapped-ram + direct IO | 13.623s | 15.959s | 34368557392  | 64662040
-----------------------+-------- +---------+--------------+---------
mapped-ram + direct IO |         |         |              |
 + multifd-channels=8  | 6.994s  | 6.470s  | 34368554980  | 64665776
--------------------------------------------------------------------

As can be seen from the tables, one caveat of mapped-ram is the logical
file size of a saved image is basically equivalent to the VM memory size.
Note however that mapped-ram typically uses fewer blocks on disk, hence
the name 'sparse' for 'save_image_format'.

Also note the mapped-ram stream is incompatible with the existing stream
format, hence mapped-ram cannot be used to restore an image saved with
the existing format and vice versa.

[1] https://gitlab.com/qemu-project/qemu/-/blob/master/docs/devel/migration/mapped-ram.rst?ref_type=heads

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 months agoqemu: Add helper function for creating save image fd
Jim Fehlig [Wed, 17 Jul 2024 23:04:43 +0000 (17:04 -0600)] 
qemu: Add helper function for creating save image fd

Move the code in qemuSaveImageCreate that opens, labels, and wraps the
save image fd to a helper function, providing more flexibility for
upcoming mapped-ram support.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 months agoqemu_saveimage: add "sparse" to supported save image formats
Jim Fehlig [Mon, 13 Jan 2025 22:57:50 +0000 (15:57 -0700)] 
qemu_saveimage: add "sparse" to supported save image formats

Extend the list of formats to include "sparse", which uses QEMU's mapped-ram
stream format [1] to write guest memory blocks at fixed offsets in the save
image file.

[1] https://gitlab.com/qemu-project/qemu/-/blob/master/docs/devel/migration/mapped-ram.rst?ref_type=heads

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 months agoqemu: Add function to get migration params for save
Jim Fehlig [Wed, 29 May 2024 22:31:05 +0000 (16:31 -0600)] 
qemu: Add function to get migration params for save

Introduce qemuMigrationParamsForSave() to create a
qemuMigrationParams object initialized with appropriate migration
capabilities and parameters for a save operation.

Note that mapped-ram capability also requires the multifd capability.
For now, the number of multifd channels is set to 1. Future work
to support parallel save/restore can set the number of channels to
a user-specified value.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 months agoqemu: Add mapped-ram migration capability
Jim Fehlig [Thu, 4 Apr 2024 22:55:10 +0000 (16:55 -0600)] 
qemu: Add mapped-ram migration capability

Add the mapped-ram migration capability introduced in QEMU 9.0.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 months agoqemu: Add function to get bool value from migration params
Jim Fehlig [Fri, 26 Jul 2024 17:19:31 +0000 (11:19 -0600)] 
qemu: Add function to get bool value from migration params

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 months agoqemu: Add function to check capability in migration params
Jim Fehlig [Fri, 19 Jul 2024 22:31:19 +0000 (16:31 -0600)] 
qemu: Add function to check capability in migration params

Add new function qemuMigrationParamsCapEnabled() to check if a
capability is set in the caller-provided migration parameters.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 months agoqemu: Add function to get FDPass object from monitor
Jim Fehlig [Thu, 6 Feb 2025 22:20:27 +0000 (15:20 -0700)] 
qemu: Add function to get FDPass object from monitor

Add new function qemuFDPassNewFromMonitor to get an fdset previously
passed to qemu, based on the 'prefix' provided when the qemuFDPass
object was initially created.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 months agovirsh: Add option "throttle-groups" to "attach_disk"
Chun Feng Wu [Wed, 19 Feb 2025 16:57:22 +0000 (22:27 +0530)] 
virsh: Add option "throttle-groups" to "attach_disk"

Update "attach_disk" to support new option: throttle-groups to
form filter chain in QEMU for specific disk

Signed-off-by: Chun Feng Wu <danielwuwy@163.com>
* apply suggested coding style changes.

Signed-off-by: Harikumar Rajkumar <harirajkumar230@gmail.com>
* Fixed alignment of child elements in the XML
* Fixed placement of the throttlegroups element
* Removed completer wrapper

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 months agovirsh: Add support for throttle group operations
Chun Feng Wu [Wed, 19 Feb 2025 16:57:21 +0000 (22:27 +0530)] 
virsh: Add support for throttle group operations

Implement new throttle cmds

* Add new virsh cmds: domthrottlegroupset, domthrottlegrouplist,
  domthrottlegroupinfo, domthrottlegroupdel
* Add doc for new cmds at docs/manpages/virsh.rst
* Add cmd helper "virshDomainThrottleGroupCompleter", which is used by
  domthrottlegroupset, domthrottlegroupinfo, domthrottlegroupdel

Signed-off-by: Chun Feng Wu <danielwuwy@163.com>
* Update of code documentation comments.
* Reimplement Get throttle group from XML.

Signed-off-by: Harikumar Rajkumar <harirajkumar230@gmail.com>a
* Fixed memleaks
* Rewrote getter to avoid extra copies
* Simplified name extractor

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 months agovirsh: Refactor iotune options for re-use
Chun Feng Wu [Wed, 19 Feb 2025 16:57:20 +0000 (22:27 +0530)] 
virsh: Refactor iotune options for re-use

Define macro for iotune options, this macro is used by opts_blkdeviotune and
later throttle group opts

Signed-off-by: Chun Feng Wu <danielwuwy@163.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 months agoqemustatusxml2xmldata: Add 'throttlefilter' tests
Harikumar Rajkumar [Wed, 19 Feb 2025 16:57:18 +0000 (22:27 +0530)] 
qemustatusxml2xmldata: Add 'throttlefilter' tests

* Add tests for throttlefilter nodename parse and format for statusxml
(disk/privateData/nodenames/nodename with type='throttle-filter')
* Add iotune limited disk tests to make sure iotune refactory works

Signed-off-by: Chun Feng Wu <danielwuwy@163.com>
* Isolate status xml test

Signed-off-by: Harikumar Rajkumar <harirajkumar230@gmail.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 months agoqemuxmlconftest: Add 'throttlefilter' tests
Chun Feng Wu [Wed, 19 Feb 2025 16:57:17 +0000 (22:27 +0530)] 
qemuxmlconftest: Add 'throttlefilter' tests

* Add tests for throttlegroup domain xml processing, including
groups referenced and not referenced by filters
* Add tests for throttlefilter domain xml processing, including
throttle group referenced by different disks
* Add negative test case to report error when iotune is configured
together with throttle filters

Signed-off-by: Chun Feng Wu <danielwuwy@163.com>
* Isolate domain xml test

Signed-off-by: Harikumar Rajkumar <harirajkumar230@gmail.com>
* Added test case with copy on read

Reviewed-by-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 months agoconfig: validate: Verify iotune, throttle group and filter
Chun Feng Wu [Wed, 19 Feb 2025 16:57:16 +0000 (22:27 +0530)] 
config: validate: Verify iotune, throttle group and filter

Refactor iotune verification, and verify some rules

* Disk iotune validation can be reused for throttle group validation,
  refactor it into common method "virDomainDiskIoTuneValidate"
* Add "virDomainDefValidateThrottleGroups" to validate throttle groups,
  which in turn calls "virDomainDiskIoTuneValidate"
* Make sure referenced throttle group exists
* Use "iotune" and "throttlefilters" exclusively for specific disk
* Throttle filters cannot be used together with CDROM

Signed-off-by: Chun Feng Wu <danielwuwy@163.com>
* Update of code documentation comments.

Signed-off-by: Harikumar Rajkumar <harirajkumar230@gmail.com>
* Moved validation code from parser to validator
* Removed dead checks after validation

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 months agoqemu: block: Support block disk along with throttle filters
Chun Feng Wu [Wed, 19 Feb 2025 16:57:15 +0000 (22:27 +0530)] 
qemu: block: Support block disk along with throttle filters

For hot attaching/detaching
* Leverage qemuBlockThrottleFiltersData to prepare attaching/detaching
  throttle filter data for qemuMonitorBlockdevAdd and qemuMonitorBlockdevDel
* For hot attaching, within qemuDomainAttachDiskGeneric,prepare throttle
  filters json data, and create corresponding blockdev for QMP request
  ("blockdev-add" with "driver":"throttle")
* Each filter has a nodename, and those filters are chained up,
  create them in sequence, and delete them reversely
* Delete filters by "qemuBlockThrottleFiltersDetach"("blockdev-del")
  when detaching device

For throttle group commandline
* Add qemuBuildThrottleGroupCommandLine in qemuBuildCommandLine to add
  "object" of throttle-group
* Verify throttle group definition when lauching vm
* Check QEMU_CAPS_OBJECT_JSON before "qemuBuildObjectCommandlineFromJSON",
  which is to build "-object" option

For throttle filter commandline
* Add qemuBuildDiskThrottleFiltersCommandLine in qemuBuildDiskCommandLine
  to add "blockdev"

Signed-off-by: Chun Feng Wu <danielwuwy@163.com>
* Apply suggested coding style changes.
* Update of code documentation comments.

Signed-off-by: Harikumar Rajkumar <harirajkumar230@gmail.com>
* Removed QEMU_CAPS_OBJECT_JSON_CHECK

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 months agoqemu: helper: throttle filter nodename and preparation processing
Chun Feng Wu [Wed, 19 Feb 2025 16:57:14 +0000 (22:27 +0530)] 
qemu: helper: throttle filter nodename and preparation processing

It contains throttle filter nodename processing(new nodename,
topnodename, parse and format nodename), throttle filter
attaching/detaching preparation and implementation.

* Updated "qemuDomainDiskGetTopNodename", so if throttlefilter is used
  together with copyOnRead, top node is throttle filter node, e.g.
  device -> throttle -> copyOnRead Layer-> image chain
* In qemuBuildThrottleFiltersAttachPrepareBlockdev, if copy_on_read
  is on, build throttle nodename chain on top of copy_on_read nodename
* In status xml, throttle filter nodename(virDomainDiskDef.nodename) is
  saved at disk/privateData/nodenames/nodename(type='throttle-filter'),
  corresponding parse/format sits in qemuDomainDiskPrivateParse and
  qemuDomainDiskPrivateFormat
* If filter nodename hasn't been set by qemuDomainDiskPrivateParse,
  in qemuDomainPrepareThrottleFilterBlockdev, filter nodename index
  can be generated by reusing qemuDomainStorageIDNew and current
  global sequence number is persistented in virDomainObj-
  >privateData(qemuDomainObjPrivate)->nodenameindex.
  qemuDomainPrepareThrottleFilterBlockdev is called by
  qemuDomainPrepareDiskSourceBlockdev, which in turn used by both
  hotplug and qemuProcessStart to prepare throttle filter node name
* Define method qemuBlockThrottleFilterGetProps, which is used by
  both hotplug and command to build throttle object for QEMU
* Define methods for throttle filter attach/detach/rollback

Signed-off-by: Chun Feng Wu <danielwuwy@163.com>
* Apply suggested coding style changes.
* Update of code documentation comments.

Signed-off-by: Harikumar Rajkumar <harirajkumar230@gmail.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 months agoqemu: Implement qemu driver for throttle API
Chun Feng Wu [Wed, 19 Feb 2025 16:57:13 +0000 (22:27 +0530)] 
qemu: Implement qemu driver for throttle API

ThrottleGroup lifecycle implementation, note, in QOM, throttlegroup name is prefixed with
"throttle-" to clearly separate throttle group objects into their own namespace.
* "qemuDomainSetThrottleGroup", this method is to add("object-add") or update("qom-set")
  throttlegroup in QOM and update corresponding objects in DOM
* "qemuDomainGetThrottleGroup", this method queries throttlegroup info by groupname
* "qemuDomainDelThrottleGroup", this method checks if group is referenced by any throttle
  in disks and delete it if it's not used anymore
* Check flag "QEMU_CAPS_OBJECT_JSON" during qemuDomainSetThrottleGroup when vm is active,
  throttle group feature requries such flag
* "objectAddNoWrap"("props") check is done by reusing qemuMonitorAddObject in
  qemuDomainSetThrottleGroup

Signed-off-by: Chun Feng Wu <danielwuwy@163.com>
* Apply suggested coding style changes.
* cleanup qemu Get ThrottleGroup.
* Update the version to 11.1.0.

Signed-off-by: Harikumar Rajkumar <harirajkumar230@gmail.com>
* Removed QEMU_CAPS_OBJECT_JSON check as the flag no longer exists.
* Update the version to 11.2.0.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 months agoqemu: Refactor qemuDomainSetBlockIoTune to extract common methods
Chun Feng Wu [Wed, 19 Feb 2025 16:57:12 +0000 (22:27 +0530)] 
qemu: Refactor qemuDomainSetBlockIoTune to extract common methods

extract common methods from "qemuDomainSetBlockIoTune" to be reused
by throttle handling later, common methods include:
* "qemuDomainValidateBlockIoTune", which is to validate that PARAMS
  contains only recognized parameter names with correct types
* "qemuDomainSetBlockIoTuneFields", which is to load parameters into
  internal object virDomainBlockIoTuneInfo
* "qemuDomainCheckBlockIoTuneMutualExclusion", which is to check rules
  like "total and read/write of bytes_sec cannot be set at the same time"
* "qemuDomainCheckBlockIoTuneMax", which is to check "max" rules within iotune

Signed-off-by: Chun Feng Wu <danielwuwy@163.com>
* Apply suggested coding style changes.

Signed-off-by: Harikumar Rajkumar <harirajkumar230@gmail.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 months agoremote: New APIs for ThrottleGroup lifecycle management
Chun Feng Wu [Wed, 19 Feb 2025 16:57:11 +0000 (22:27 +0530)] 
remote: New APIs for ThrottleGroup lifecycle management

Defined new public APIs:
* virDomainSetThrottleGroup to add or update throttlegroup within specific domain,
  it will be referenced by throttlefilter later in disk to do limits
* virDomainGetThrottleGroup to get throttlegroup info, old-style is discarded
  (APIs to query first for the number of parameters and then give it a
  reasonably-sized pointer), instead, the new approach is adopted that
  API returns allocated array of fields and number of fileds that are in it.
* virDomainDelThrottleGroup to delete throttlegroup, it fails if this throttlegroup
  is still referenced by some throttlefilter

Signed-off-by: Chun Feng Wu <danielwuwy@163.com>
* Reimplement getter API to fetch data from XML.
* Apply suggested coding style changes.
* Update of code documentation comments.
* Update the version to 11.2.0.

Signed-off-by: Harikumar Rajkumar <harirajkumar230@gmail.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 months agotests: Test qemuMonitorJSONGetThrottleGroup and qemuMonitorJSONUpdateThrottleGroup
Chun Feng Wu [Wed, 19 Feb 2025 16:57:10 +0000 (22:27 +0530)] 
tests: Test qemuMonitorJSONGetThrottleGroup and qemuMonitorJSONUpdateThrottleGroup

Within "testQemuMonitorJSONqemuMonitorJSONUpdateThrottleGroup"
* Test qemuMonitorJSONGetThrottleGroup
* Test qemuMonitorJSONUpdateThrottleGroup, which updates limits through "qom-set"

Signed-off-by: Chun Feng Wu <danielwuwy@163.com>
* fix test

Signed-off-by: Harikumar Rajkumar <harirajkumar230@gmail.com>
* Deleted getter-related code.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 months agoqemu: monitor: Add support for ThrottleGroup operations
Chun Feng Wu [Wed, 19 Feb 2025 16:57:09 +0000 (22:27 +0530)] 
qemu: monitor: Add support for ThrottleGroup operations

This change contains QMP requests for ThrottleGroup

* ThrottleGroup is updated through "qemuMonitorJSONUpdateThrottleGroup"
* ThrottleGroup is retrieved through "qemuMonitorJSONGetThrottleGroup"
* ThrottleGroup is deleted by reusing "qemuMonitorDelObject"
* ThrottleGroup is added by reusing "qemuMonitorAddObject"
* "qemuMonitorMakeThrottleGroupLimits" will be used by building qemu cmd as well

Signed-off-by: Chun Feng Wu <danielwuwy@163.com>
* change throttle group config conversions P to U allow zero.
* Apply suggested coding style changes.

Signed-off-by: Harikumar Rajkumar <harirajkumar230@gmail.com>
* Deleted all getter code.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 months agoconfig: Introduce ThrottleFilter and corresponding XML parsing
Chun Feng Wu [Wed, 19 Feb 2025 16:57:08 +0000 (22:27 +0530)] 
config: Introduce ThrottleFilter and corresponding XML parsing

Introduce throttle filter along with corresponding operations.

* Define new struct 'virDomainThrottleFilterDef' and corresponding destructor
* Update _virDomainDiskDef to include virDomainThrottleFilterDef
* Support throttle filter "Parse" and "Format" for operations between DOM XML
  and structs. Note, this commit just contains parse/format of group name for
  throttle filter in domain_conf.c, there is other commit to handle throttle
  filter nodename parse/format between throttlefilter and diskPrivateData for
  statusxml in qemu_domain.c when processing qemuDomainDiskPrivate and
  qemuDomainDiskPrivate

Signed-off-by: Chun Feng Wu <danielwuwy@163.com>
* Error handling for null throttle group.
* Update of code documentation comments.
* Apply suggested coding style changes.

Signed-off-by: Harikumar Rajkumar <harirajkumar230@gmail.com>
* Fixed naming of virDomainThrottleFilterDefClear to ...Free
* Fixed memleak of the throttle filter definitions

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 months agoconfig: Introduce ThrottleGroup and corresponding XML parsing
Chun Feng Wu [Wed, 19 Feb 2025 16:57:07 +0000 (22:27 +0530)] 
config: Introduce ThrottleGroup and corresponding XML parsing

Introduce throttlegroup into domain and provide corresponding methods

* Define new struct 'virDomainThrottleGroupDef' and corresponding destructor
* Add operations(Add, Update, Del, ByName, Copy, Free) for 'virDomainThrottleGroupDef'
* Update _virDomainDef to include virDomainThrottleGroupDef
* Support new resource "Parse" and "Format" for operations between struct and DOM XML
* Make sure "group_name" is defined in xml

Signed-off-by: Chun Feng Wu <danielwuwy@163.com>
* Validation check for zero throttle groups.
* Update of code documentation comments.

Signed-off-by: Harikumar Rajkumar <harirajkumar230@gmail.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 months agoschema: Add new domain elements to support multiple throttle filters
Chun Feng Wu [Wed, 19 Feb 2025 16:57:06 +0000 (22:27 +0530)] 
schema: Add new domain elements to support multiple throttle filters

Introduce schema for defining '<throttlefilters>' element which
references throttling groups to form filter chain in qemu for specific
disk

* Add new elements '<throttlefilters>'
* <ThrottleFilters> can include multiple throttlegroup references to
  form filter chain in qemu
* Chained throttle filters feature in qemu is described at
  https://gitlab.com/qemu-project/qemu/blob/master/docs/throttle.txt

Signed-off-by: Chun Feng Wu <danielwuwy@163.com>
Signed-off-by: Harikumar Rajkumar <harirajkumar230@gmail.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 months agoschema: Add new domain elements to support multiple throttle groups
Chun Feng Wu [Wed, 19 Feb 2025 16:57:05 +0000 (22:27 +0530)] 
schema: Add new domain elements to support multiple throttle groups

Introduce schema for defining '<throttlegroups>' element which
configures throttling groups which can be configured for multiple
disks.

* Refactor "diskIoTune" to extract common schema "iotune"
* Add new elements '<throttlegroups>'
* <ThrottleGroups> contains <ThrottleGroup> defintion, which references
  "iotune"

Signed-off-by: Chun Feng Wu <danielwuwy@163.com>
Signed-off-by: Harikumar Rajkumar <harirajkumar230@gmail.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 months agovirsh: Introduce new hypervisor-cpu-models command
David Judkovics [Thu, 20 Mar 2025 05:28:24 +0000 (01:28 -0400)] 
virsh: Introduce new hypervisor-cpu-models command

Add new virsh command 'hypervisor-cpu-models'.  Command pulls from the
existing domcapabilities XML and uses xpath to parse CPU model strings.
By default, only models reported as usable by the hypervisor on the
host system are printed.  User may specify "--all" to also print
models which are not supported on the host.

Signed-off-by: David Judkovics <djudkovi@linux.ibm.com>
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Signed-off-by: Collin Walling <walling@linux.ibm.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 months agohypervisor: emit systemd status & log messages while saving
Daniel P. Berrangé [Tue, 7 Jan 2025 15:25:33 +0000 (15:25 +0000)] 
hypervisor: emit systemd status & log messages while saving

Since processing running VMs on OS shutdown can take a while, it is
beneficial to send systemd status messages about the progress.

The systemd status is a point-in-time message, with no ability to
look at the history of received messages. So in the systemd status
we include the progress information. For the same reason there is
no benefit in sending failure messages, as they'll disappear as soon
as a status is sent for the subsequent VM to be processed.

The libvirt log statements can be viewed as a complete log record
so don't need progress info, but do include warnings about failures
(present from earlier commits).

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 months agorpc: don't let systemd shutdown daemon while saving VMs
Daniel P. Berrangé [Tue, 7 Jan 2025 15:22:14 +0000 (15:22 +0000)] 
rpc: don't let systemd shutdown daemon while saving VMs

The service unit "TimeoutStopSec" setting controls how long systemd
waits for a service to stop before aggressively killing it, defaulting
to 30 seconds if not set.

When we're processing shutdown of VMs in response to OS shutdown, we
very likely need more than 30 seconds to complete this job, and can
not stop the daemon during this time.

To avoid being prematurely killed, setup a timer that repeatedly
extends the "TimeoutStopSec" value while stop of running VMs is
arranged.

This does mean if libvirt hangs while stoppping VMs, systemd won't
get to kill the libvirt daemon, but this is considered less harmful
that forcefully killing running VMs.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 months agoadmin: add 'daemon-shutdown' command
Daniel P. Berrangé [Tue, 7 Jan 2025 13:25:49 +0000 (13:25 +0000)] 
admin: add 'daemon-shutdown' command

The daemons are wired up to shutdown in responsible to UNIX process
signals, as well as in response to login1 dbus signals, or loss of
desktop session. The latter two options can optionally preserve state
(ie running VMs).

In non-systemd environments, as well as for testing, it would be useful
to have a way to trigger shutdown with state preservation more directly.

Thus a new admin protocol API is introduced

  virAdmConnectDaemonShutdown

which will trigger a daemon shutdown, and preserve running VMs if the
VIR_DAEMON_SHUTDOWN_PRESERVE flag is set.

It has a corresponding 'virt-admin daemon-shutdown [--preserve]' command
binding.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 months agorpc: fix shutdown sequence when preserving state
Daniel P. Berrangé [Tue, 7 Jan 2025 11:05:51 +0000 (11:05 +0000)] 
rpc: fix shutdown sequence when preserving state

The preserving of state (ie running VMs) requires a fully functional
daemon and hypervisor driver. If any part has started shutting down
then saving state may fail, or worse, hang.

The current shutdown sequence does not guarantee safe ordering, as
we synchronize with the state saving thread only after the hypervisor
driver has had its 'shutdownPrepare' callback invoked. In the case of
QEMU this means that worker threads processing monitor events may well
have been stopped.

This implements a full state machine that has a well defined ordering
that an earlier commit documented as the desired semantics.

With this change, nothing will start shutting down if the state saving
thread is still running.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 months agorpc: don't unconditionally quit after preserving state
Daniel P. Berrangé [Tue, 7 Jan 2025 10:27:21 +0000 (10:27 +0000)] 
rpc: don't unconditionally quit after preserving state

The call to preserve state (ie running VMs) is triggered in response to
the desktop session dbus terminating (session daemon), or logind sending
a "PrepareForShutdown" signal. In the case of the latter, daemons
should only save their state, not actually exit yet. Other things on the
system may still expect the daemon to be running at this stage.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 months agorpc: move state stop into virNetDaemon class
Daniel P. Berrangé [Tue, 7 Jan 2025 10:27:01 +0000 (10:27 +0000)] 
rpc: move state stop into virNetDaemon class

Currently the remote daemon code is responsible for calling virStateStop
in a background thread. The virNetDaemon code wants to synchronize with
this during shutdown, however, so the virThreadPtr must be passed over.

Even the limited synchronization done currently, however, is flawed and
to fix this requires the virNetDaemon code to be responsible for calling
virStateStop in a thread more directly.

Thus the logic is moved over into virStateStop via a further callback
to be registered by the remote daemon.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 months agorpc: rename virNetDaemonSetShutdownCallbacks
Daniel P. Berrangé [Tue, 11 Mar 2025 17:44:44 +0000 (17:44 +0000)] 
rpc: rename virNetDaemonSetShutdownCallbacks

The next patch will be introducing a new callback, so rename the method
to virNetDaemonSetLifecycleCallbacks to reflect the more general usage.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 months agosrc: clarify semantics of the various virStateNNN methods
Daniel P. Berrangé [Tue, 11 Mar 2025 17:24:34 +0000 (17:24 +0000)] 
src: clarify semantics of the various virStateNNN methods

It is not documented what the various virStateNNN methods are each
responsible for doing and the names give little guidance either.
Provide some useful documentation comments to explain the intended
usage of each.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 months agoqemu: add config to control if auto-shutdown VMs are restored
Daniel P. Berrangé [Fri, 20 Dec 2024 12:55:49 +0000 (12:55 +0000)] 
qemu: add config to control if auto-shutdown VMs are restored

If shutting down running VMs at host shutdown, it can be useful to
automatically start them again on next boot. This adds a config
parameter 'auto_shutdown_restore', which defaults to enabled, which
leverages the autostart once feature.

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