summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* conf: numa: Allow formatting 'none' values for 'associativity' and 'policy' ↵Peter Krempa2023-05-171-9/+4
| | | | | | | | | | | | | of cache The parser makes the values mandatory and also the qemu code implements actions for those values. The formatter skips them though. Since format+parse is used to copy the XML at startup a definition with those values can't be started. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2203709 Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
* virDomainNumaDefNodeCacheParseXML: Refactor parsing of cache XMLPeter Krempa2023-05-171-46/+14
| | | | | | | Use virXMLProp* helpers to simplify the code. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
* qemu: Generate command line for MTE featureMichal Privoznik2023-05-161-0/+6
| | | | | | | | This is pretty trivial, just append "mte=on/off" to -machine arguments. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
* qemu: Validate MTE featureMichal Privoznik2023-05-161-8/+17
| | | | | | | | The MTE feature is not supported by all QEMUs, only those with QEMU_CAPS_MACHINE_VIRT_MTE capability. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
* qemu:: Introduce QEMU_CAPS_MACHINE_VIRT_MTE capabilityMichal Privoznik2023-05-162-0/+3
| | | | | | | | The MTE feature (introduced in QEMU commit of v5.1.0-rc1~8^2~11) is detectable via 'qom-list-properties' for 'virt' machine type. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
* conf: Introduce MTE domain featureMichal Privoznik2023-05-164-1/+12
| | | | | | | | | | The Memory Tagging Extensions are hardware acceleration present in some ARM processors that allow memory error detection [1]. Introduce a domain XML knob that turns them on or off. 1: https://www.arm.com/blogs/blueprint/memory-safety-arm-memory-tagging-extension Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
* qemu: Drop @forceVFIO argument of qemuDomainGetMemLockLimitBytes()Michal Privoznik2023-05-163-21/+14
| | | | | | | | | | | After previous cleanup, there's not a single caller that would call qemuDomainGetMemLockLimitBytes() with @forceVFIO set. All callers pass false. Drop the unneeded argument from the function. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
* qemu: Drop @forceVFIO argument of qemuDomainAdjustMaxMemLock()Michal Privoznik2023-05-163-20/+15
| | | | | | | | | | | After previous cleanup, there's not a single caller that would call qemuDomainAdjustMaxMemLock() with @forceVFIO set. All callers pass false. Drop the unneeded argument from the function. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
* qemu_domin: Account for NVMe disks when calculating memlock limit on hotplugMichal Privoznik2023-05-162-1/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | During hotplug of a NVMe disk we need to adjust the memlock limit. The computation of the limit is handled by qemuDomainGetMemLockLimitBytes() which looks at given domain definition and accounts for various device types (as different types require different amounts). But during disk hotplug the disk is not added to domain definition until the very last moment. Therefore, qemuDomainGetMemLockLimitBytes() has this @forceVFIO argument which tells it to assume VFIO even if there are no signs of VFIO in domain definition. And this kind of works, until the amount needed for NVMe disks changed (in v9.3.0-rc1~52). What's missing in the commit is making @forceVFIO behave the same as if there was an NVMe disk present in the domain definition. But, we can do even better - just mimic whatever we're doing for hostdevs. IOW - introduce qemuDomainAdjustMaxMemLockNVMe() that behaves the same as qemuDomainAdjustMaxMemLockHostdev(). There are subtle differences though: 1) qemuDomainAdjustMaxMemLockHostdev() can afford placing hostdev right at the end of vm->def->hostdevs, because the array was already reallocated (at the beginning of qemuDomainAttachHostPCIDevice()). But qemuDomainAdjustMaxMemLockNVMe() doesn't have that luxury. 2) qemuDomainAdjustMaxMemLockHostdev() places a virDomainHostdevDef pointer into domain definition, while qemuDomainStorageSourceAccessModifyNVMe() (which calls qemuDomainAdjustMaxMemLock()) sees a virStorageSource pointer but domain definition contains virDomainDiskDef. But that's okay, we can create a dummy disk definition and append it into the domain definition. After this, qemuDomainAdjustMaxMemLock() can be called with @forceVFIO = false, as the disk is now part of domain definition (when computing the new limit). Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2014030#c28 Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
* schemas: backup: Allow missing 'type' attribute for backup diskPeter Krempa2023-05-161-0/+4
| | | | | | | | | | | | | One of our examples in the 'formatbackup.rst' page shows following config: <disk name='vda' backup='yes'/> The schema didn't allow it though. Fix the schema as the internals were supposed to support it (except for the bug fixed in previous patches). Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* conf: backup: Fix logic for generating default backup filenamesPeter Krempa2023-05-161-2/+5
| | | | | | | | | | | | | If the 'disk->store' property is already allocated which happens e.g. when the disk is described by the backup XML but the optional filename is not filled in 'virDomainBackupDefAssignStore' would not fill in the default location. Fix the logic to do it also if a 'virStorageSource' categorizes as empty. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* virDomainBackupDefAssignStore: Restructure control flowPeter Krempa2023-05-161-6/+8
| | | | | | | Return early for errors instead of using 'else' branches. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* qemu: Update documentation for dbus_daemon qemu.conf keyAndrea Bolognani2023-05-112-2/+4
| | | | | | | | Reflect the new default value, and explain that a runtime lookup will be performed if the value is not an absolute path. Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
* meson: Stop looking for dbus-daemonAndrea Bolognani2023-05-111-0/+1
| | | | | | | | Now that we're performing the lookup at runtime, doing it at build time is no longer necessary. Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
* qemu: Find dbus-daemon at runtimeAndrea Bolognani2023-05-111-5/+9
| | | | | | | | | | | | Don't bother looking at /usr/libexec, since every distro ships dbus-daemon in $PATH. Note that it's still possible for the administrator to prevent this lookup and use an arbitrary binary by setting the appropriate key in qemu.conf. Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
* qemu: Update documentation for qemu.conf keysAndrea Bolognani2023-05-102-4/+8
| | | | | | | | Reflect the new default value, and explain that a runtime lookup will be performed if the value is not an absolute path. Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
* meson: Stop looking for QEMU helpersAndrea Bolognani2023-05-101-0/+4
| | | | | | | | Now that we're performing the lookup at runtime, doing it at build time is no longer necessary. Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
* qemu: Find helpers at runtimeAndrea Bolognani2023-05-102-6/+26
| | | | | | | | | | | | | | | Use the recently introduced virFindFileInPathFull() function to discover the path for qemu-bridge-helper and qemu-pr-helper at runtime. Note that it's still possible for the administrator to prevent this lookup and use arbitrary binaries by setting the appropriate keys in qemu.conf: this simply removes the need to perform the lookup at build time, and thus to have the helpers installed in the build environment. Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
* util: Introduce virFileFindInPathFull()Andrea Bolognani2023-05-103-0/+37
| | | | | Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
* util: Small refactorAndrea Bolognani2023-05-101-6/+8
| | | | | | | Prepare for further changes. Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
* util: include virfirewall.h in virfirewalld.hMichal Privoznik2023-05-101-0/+2
| | | | | | | | | | The virfirewalld.h file provides a declaration for virFirewallDApplyRule() which accepts an argument of type virFirewallLayer. But the typedef lives in virfirewall.h and thus including just virfirewalld.h is not sufficient. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
* conf: qemu: Add support for multi-channel mode for 'usb' sound cardsPeter Krempa2023-05-094-0/+35
| | | | | | | | | | Allow users controlling the multi-channel mode by adding a 'multichannel' property parsed for USB audio devices and wire up the support in the qemu driver. Closes: https://gitlab.com/libvirt/libvirt/-/issues/472 Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* conf: Register autoptr cleanup for 'virDomainSoundDef' and refactor ↵Peter Krempa2023-05-092-12/+8
| | | | | | | | | virDomainSoundDefParseXML Use our modern cleanup path pattern. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* qemu: Report domain name in unexpectedly closed monitor messageMichal Privoznik2023-05-091-3/+6
| | | | | | | | | | | | | | When QEMU closes the monitor suddenly, the following error message is reported: internal error: qemu unexpectedly closed the monitor: ... And this works. But other error messages produced in the same function include domain name too. Do that for the unexpectedly closed monitor message too. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
* logging: Provide empty VIRTLOGD_ARGS in the unit fileMichal Privoznik2023-05-091-0/+1
| | | | | | | | | | | | | | | | | | | For all our daemons, we provide VIRXXXD_ARGS env var in the unit file. The variable can then be overridden in corresponding file: EnvironmentFile=-@initconfdir@/virtxxxd The daemon is then executed as: ExecStart=@sbindir@/virtxxxd $VIRTXXXD_ARGS But virtlogd is exception, for no good reason. And while there are probably no arguments we want to pass to virtlogd by default, just mimic what we do for say virtlockd, where we also don't pass any default argument. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* qemu: hotplug: Reorder setup of disk backend metadataPeter Krempa2023-05-051-3/+3
| | | | | | | | | | | | | | The regular VM startup code first calls the setup of the disk backing chain as defined in the XML and then calls the function to load the rest of the backing chain from the image metadata. The hotplug code did it the other way around, thus causing a failure when attempting to attach a QCOW2 image via FD passing. Reorder the hotplug code to have the same order. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2193315 Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* meson: Use initconfdirAndrea Bolognani2023-05-0517-16/+17
| | | | | Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
* util: Improve comment for workaroundAndrea Bolognani2023-05-041-2/+1
| | | | | | | | | Now that a version of GLib that contains the fix has been released, it's more useful to record that information. Adding a TODO annotation makes the whole thing easily greppable. Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* qemu: Fix error messageAndrea Bolognani2023-05-041-1/+1
| | | | | | | The spelling is slightly different from another otherwise identical error message in the same file. Signed-off-by: Andrea Bolognani <abologna@redhat.com>
* cpu_riscv64.c: add update() implementationDaniel Henrique Barboza2023-05-041-1/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | At this moment it is not possible to launch a 'riscv64' domain if a CPU definition is presented in the domain. For example, adding this CPU definition: <cpu mode='custom' match='exact' check='none'> <model fallback='forbid'>rv64</model> </cpu> Will trigger the following error: $ sudo ./run tools/virsh start riscv-virt1 error: Failed to start domain 'riscv-virt1' error: this function is not supported by the connection driver: cannot update guest CPU for riscv64 architecture The error comes from virCPUUpdate(), via qemuProcessUpdateGuestCPU(), and it's caused by the absence of the 'update' API in the existing RISC-V driver. Add an 'update' API impl to the RISC-V driver to allow for CPU definitions to be declared in RISC-V domains. This API was copied from the ARM driver (virCPUarmUpdate()) since it's a good enough implementation to get us going. Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> Reviewed-by: Andrea Bolognani <abologna@redhat.com>
* qemu: Use configured iothread poll parameters on startupPeter Krempa2023-05-022-14/+34
| | | | | | | | Implement the support for the persisted poll parameters and remove restrictions on saving config when modifying them during runtime. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* conf: Store the iothread 'poll' settings in the XMLPeter Krempa2023-05-023-1/+66
| | | | | | | | | Currently we allow configuring the 'poll-max-ns', 'poll-grow', and 'poll-shrink' parameters of qemu iothreads only during runtime and they are not persisted. Add XML machinery to persist them. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* qemu: Store all iothread's 'poll*' attributes as unsigned long longPeter Krempa2023-05-024-36/+51
| | | | | | | | | | | | | | | | | | | | Convert the internal types to unsigned long long. Luckily we can also covert the external types too: - 'qemuDomainSetIOThreadParams' can accept both _UINT and _ULLONG by converting to 'virTypedParamsGetUnsigned' - querying is handled via the bulk stats API which is flexible: - we use virTypedParamListAddUnsigned to use the bigger type only if necessary - most users don't even notice because the bindings abstract the data types Apart from the code modifications we also improve the documentation which was missing for the setters. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* qemu: Remove iothread 'poll-' value validationPeter Krempa2023-05-022-28/+0
| | | | | | | | | | | | QEMU accepts even values bigger than INT_MAX. The reasoning for these checks was that the QAPI definition declares them as 'int', but in QAPI terms that's any number as it's JSON. Remove the validation as well as the comment misinterpreting the QAPI definiton. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* virTypedParamsValidate: Allow typed params to be both _UINT and _ULLONGPeter Krempa2023-05-022-5/+23
| | | | | | | | | | | | | | | For certain typed parameters we want to extend the supproted range by switching to VIR_TYPED_PARAM_ULLONG. To preserve compatibility we've added APIs such as 'virTypedParamsGetUnsigned' and 'virTypedParamListAddUnsigned' which automatically select the bigger type if necessary. This patch adds a new internal macro VIR_TYPED_PARAM_UNSIGNED which is used with virTypedParamsValidate to allow both types and adjusts the code to handle it properly. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* virTypedParamsValidate: Refactor variable declaration and cleanupPeter Krempa2023-05-021-15/+16
| | | | | | | | | Use automatic memory cleanup for the 'keys' and 'sorted' helpers and remove the 'cleanup' label. Since this patch is modifying variable declarations ensure that all declarations conform with our coding style. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* util: virtypedparam: Introduce virTypedParamsGetUnsignedPeter Krempa2023-05-023-0/+57
| | | | | | | | | | | | Add an internal helper for fetching a typed parameter which can be either of the '_UINT' or '_ULONG' type and store it in a unsigned long long variable. Since this is an internal helper it offers less protections against invalid use compared to those we expose as public API. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* util: typedparam: Introduce virTypedParamListAddUnsignedPeter Krempa2023-05-023-0/+43
| | | | | | | | | | | The new helper adds a unsigned value, stored as _UINT if it fits into the type and stored as _ULLONG otherwise. This is useful for the statistics code which is quite tolerant to changes in type in cases when we'll need more range for the value. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* util: virtypedparam: Remove return values from virTypedParamListAdd* APIsPeter Krempa2023-05-026-394/+173
| | | | | | | | The function now return always 0. Refactor the code and remove return values. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* util: virtypedparam: Store errors inside virTypedParamListPeter Krempa2023-05-021-28/+34
| | | | | | | | | | The only non-abort()-ing error which can happen is if the field name is too long. Store the overly long name in the virTypedParamList container so that in upcoming patches the helpers adding to the list can be refactored to not have a return value. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* util: virtypedparam: Refactor return value of virTypedParamListStealParamsPeter Krempa2023-05-027-16/+35
| | | | | | | | | | | | Return the number of parameters via pointer passed as argument to free up possibility to report errors. Strangely all callers actually use 'int' as type for storing the count of elements, thus this function will use the same. The function is also renamed to virTypedParamListSteal. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* util: virtypedparam: Privatize definition of struct _virTypedParamListPeter Krempa2023-05-022-5/+7
| | | | | | | Ensure that all callers access it via the APIs. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* Use 'virTypedParamListFetch' for extracting identity parameters listPeter Krempa2023-05-022-2/+13
| | | | | Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* util: virtypedparam: Introduce 'virTypedParamListFetch'Peter Krempa2023-05-023-0/+33
| | | | | | | | | | | Introduce a helper that fetches the typed parameters from the list while still preserving ownership of the pointer by the list. In the future this will be also able to report errors stored in the list. Signed-off-by: Peter Krempa <pkrempa@redhat.com Reviewed-by: Ján Tomko <jtomko@redhat.com>
* qemuDomainGetStatsBlock: Don't directly access virTypedParamListPeter Krempa2023-05-021-10/+6
| | | | | | | | | | The struct will be made private in upcoming patches. Construct the list of block entries into a separate list and append them rather than remember the index of the count element. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
* util: typedparam: Introduce 'virTypedParamListConcat'Peter Krempa2023-05-023-0/+28
| | | | | | | | | | Introduce a helper function to concatenate two virTypedParamLists. This will allow us to refactor qemuDomainGetStatsBlock to not access the list directly. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
* util: virtypedparam: Introduce virTypedParamListNew()Peter Krempa2023-05-027-7/+16
| | | | | | | | | Add an allocator function and refactor all allocations to use it. In upcoming patches 'struct _virTypedParamList' will be made private. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
* virtypedparam.h: Consistently use contemporary header stylePeter Krempa2023-05-021-60/+80
| | | | | | | | | The header uses both styles randomly, switch it to the contemporary style. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
* util: virtypedparam: Simplify error handling in virTypedParamListAdd*Peter Krempa2023-05-021-31/+15
| | | | | | | | | | Don't check the return value of 'virTypedParamListExtend' which will always be a valid pointer and 'virTypedParameterAssignValue' always returns 0. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
* virTypedParameterAssignValueVArgs: Ensure proper typed param type in callerPeter Krempa2023-05-021-15/+14
| | | | | | | | | | | | | | | | There are two callers of virTypedParameterAssignValueVArgs. - 'virTypedParameterAssignValue' always uses the correct type, thus doesn't need to be modified. Just use the proper type in the function declaration - 'virTypedParameterAssign' can get improper type, but we can move the validation into it decreasing the scope in which failures need to be propagated. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>