Commit Graph

34733 Commits

Author SHA1 Message Date
Andrea Bolognani
167138a525 Revert "qemu: Generate command line for MTE feature"
The QEMU interface is still in a state of flux, and KVM support
has been pulled shortly after having been merged. Let's not
commit to a stable interface in libvirt just yet.

Reverts: b10bc8f7ab
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
2023-05-22 15:12:51 +02:00
Michal Privoznik
17c8a173b6 numa_conf: Deny other memory modes than 'restrictive' if a memnode is 'restrictive'
We already do check that if there's <memory mode='restrictive'/>
then all <memnode/> have to be of 'restrictive' mode too. But
what we are missing the reverse: if there is <memnode/> with
'restrictive' mode, then the <memory/> has to be of the same mode
too.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2208946
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-05-22 13:58:03 +02:00
Michal Privoznik
f6ba9fc12a numa_conf: Move memnode mode validation into virDomainNumaDefValidate()
When parsing a <memnode/> we also check whether the @mode
argument fulfills some requirements wrt 'restrictive' mode. This
is not the right place though. There's virDomainNumaDefValidate()
which contains other checks.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-05-22 13:57:44 +02:00
Michal Privoznik
a152d856c3 virDomainNumatuneNodeSpecified: Fix const correctness
The virDomainNumatuneNodeSpecified() function does not write into
passed @numatune pointer, it just reads from it. Therefore, the
argument should be const, which allows this function to be called
from places where virDomainNuma is already const (e.g. domain
validation code).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-05-22 13:49:34 +02:00
Jiang Jiacheng
ffa258a39d qemu: support set parallel migration compression method
Add new compress methods zlib and zstd for parallel migration,
these method should be used with migration option --comp-methods
and will be processed in 'qemuMigrationParamsSetCompression'.
Note that only one compress method could be chosen for parallel
migration and they cann't be used in compress migration.

Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2023-05-18 15:47:30 +02:00
Peter Krempa
af621caa6b conf: numa: Allow formatting 'none' values for 'associativity' and 'policy' 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>
2023-05-17 10:07:18 +02:00
Peter Krempa
0d5fc7219a virDomainNumaDefNodeCacheParseXML: Refactor parsing of cache XML
Use virXMLProp* helpers to simplify the code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-05-17 10:07:18 +02:00
Michal Privoznik
b10bc8f7ab qemu: Generate command line for MTE feature
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>
2023-05-16 17:43:05 +02:00
Michal Privoznik
c6c9b5d251 qemu: Validate MTE feature
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>
2023-05-16 17:43:03 +02:00
Michal Privoznik
1347a19f75 qemu:: Introduce QEMU_CAPS_MACHINE_VIRT_MTE capability
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>
2023-05-16 17:43:00 +02:00
Michal Privoznik
720e8f13ff conf: Introduce MTE domain feature
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>
2023-05-16 17:42:58 +02:00
Michal Privoznik
37e41b7f16 qemu: Drop @forceVFIO argument of qemuDomainGetMemLockLimitBytes()
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>
2023-05-16 14:43:43 +02:00
Michal Privoznik
4f355fa5b7 qemu: Drop @forceVFIO argument of qemuDomainAdjustMaxMemLock()
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>
2023-05-16 14:43:43 +02:00
Michal Privoznik
c925bb9273 qemu_domin: Account for NVMe disks when calculating memlock limit on hotplug
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>
2023-05-16 14:43:42 +02:00
Peter Krempa
9884e89236 schemas: backup: Allow missing 'type' attribute for backup disk
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>
2023-05-16 10:26:33 +02:00
Peter Krempa
1222ada2af conf: backup: Fix logic for generating default backup filenames
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>
2023-05-16 10:26:33 +02:00
Peter Krempa
de48ade195 virDomainBackupDefAssignStore: Restructure control flow
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>
2023-05-16 10:26:33 +02:00
Andrea Bolognani
517d76466b qemu: Update documentation for dbus_daemon qemu.conf key
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>
2023-05-11 15:04:56 +02:00
Andrea Bolognani
4400f63636 meson: Stop looking for dbus-daemon
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>
2023-05-11 15:04:54 +02:00
Andrea Bolognani
769de39f50 qemu: Find dbus-daemon at runtime
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>
2023-05-11 15:04:50 +02:00
Andrea Bolognani
db91bf2ba3 qemu: Update documentation for qemu.conf keys
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>
2023-05-10 18:54:15 +02:00
Andrea Bolognani
b134a9bd2a meson: Stop looking for QEMU helpers
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>
2023-05-10 18:54:12 +02:00
Andrea Bolognani
934113d376 qemu: Find helpers at runtime
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>
2023-05-10 18:54:09 +02:00
Andrea Bolognani
ef91f9e52a util: Introduce virFileFindInPathFull()
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-05-10 18:54:08 +02:00
Andrea Bolognani
d92054c867 util: Small refactor
Prepare for further changes.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-05-10 18:54:04 +02:00
Michal Privoznik
c033377a17 util: include virfirewall.h in virfirewalld.h
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>
2023-05-10 14:41:53 +02:00
Peter Krempa
3d6bc5c611 conf: qemu: Add support for multi-channel mode for 'usb' sound cards
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>
2023-05-09 15:12:03 +02:00
Peter Krempa
783c6bc2f0 conf: Register autoptr cleanup for 'virDomainSoundDef' and refactor virDomainSoundDefParseXML
Use our modern cleanup path pattern.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-05-09 15:12:03 +02:00
Michal Privoznik
30a1ceb67c qemu: Report domain name in unexpectedly closed monitor message
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>
2023-05-09 14:57:28 +03:00
Michal Privoznik
25ce34998b logging: Provide empty VIRTLOGD_ARGS in the unit file
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>
2023-05-09 14:27:52 +03:00
Peter Krempa
9b8bb536ff qemu: hotplug: Reorder setup of disk backend metadata
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>
2023-05-05 16:32:29 +02:00
Andrea Bolognani
32f772e986 meson: Use initconfdir
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-05-05 15:08:25 +02:00
Andrea Bolognani
4419e74117 util: Improve comment for workaround
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>
2023-05-04 18:30:25 +02:00
Andrea Bolognani
e533074983 qemu: Fix error message
The spelling is slightly different from another otherwise
identical error message in the same file.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2023-05-04 18:03:56 +02:00
Daniel Henrique Barboza
d4c39bad85 cpu_riscv64.c: add update() implementation
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>
2023-05-04 14:15:15 +02:00
Peter Krempa
4b5a9e34ad qemu: Use configured iothread poll parameters on startup
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>
2023-05-02 14:32:47 +02:00
Peter Krempa
83eee66f81 conf: Store the iothread 'poll' settings in the XML
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>
2023-05-02 14:32:47 +02:00
Peter Krempa
6f9d66c828 qemu: Store all iothread's 'poll*' attributes as unsigned long long
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>
2023-05-02 14:32:47 +02:00
Peter Krempa
6d8dcc644c qemu: Remove iothread 'poll-' value validation
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>
2023-05-02 14:32:47 +02:00
Peter Krempa
07652410a7 virTypedParamsValidate: Allow typed params to be both _UINT and _ULLONG
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>
2023-05-02 14:32:47 +02:00
Peter Krempa
b5ee977d17 virTypedParamsValidate: Refactor variable declaration and cleanup
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>
2023-05-02 14:32:46 +02:00
Peter Krempa
111eeba7a7 util: virtypedparam: Introduce virTypedParamsGetUnsigned
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>
2023-05-02 14:32:46 +02:00
Peter Krempa
e280e83bff util: typedparam: Introduce virTypedParamListAddUnsigned
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>
2023-05-02 14:32:46 +02:00
Peter Krempa
f9f40a6d4b util: virtypedparam: Remove return values from virTypedParamListAdd* APIs
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>
2023-05-02 14:32:46 +02:00
Peter Krempa
29dd390ea6 util: virtypedparam: Store errors inside virTypedParamList
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>
2023-05-02 14:32:46 +02:00
Peter Krempa
ec3a076c9e util: virtypedparam: Refactor return value of virTypedParamListStealParams
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>
2023-05-02 14:32:46 +02:00
Peter Krempa
88925728f6 util: virtypedparam: Privatize definition of struct _virTypedParamList
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>
2023-05-02 14:32:46 +02:00
Peter Krempa
50be70ded3 Use 'virTypedParamListFetch' for extracting identity parameters list
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-05-02 14:32:46 +02:00
Peter Krempa
0fac024958 util: virtypedparam: Introduce 'virTypedParamListFetch'
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>
2023-05-02 14:32:46 +02:00
Peter Krempa
8ea33c8c18 qemuDomainGetStatsBlock: Don't directly access virTypedParamList
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>
2023-05-02 14:32:46 +02:00
Peter Krempa
e3dff704bf util: typedparam: Introduce 'virTypedParamListConcat'
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>
2023-05-02 14:32:46 +02:00
Peter Krempa
0d09e79b42 util: virtypedparam: Introduce virTypedParamListNew()
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>
2023-05-02 14:32:46 +02:00
Peter Krempa
2e18d84746 virtypedparam.h: Consistently use contemporary header style
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>
2023-05-02 14:32:46 +02:00
Peter Krempa
6813a46db5 util: virtypedparam: Simplify error handling in virTypedParamListAdd*
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>
2023-05-02 14:32:46 +02:00
Peter Krempa
ff8a626c58 virTypedParameterAssignValueVArgs: Ensure proper typed param type in caller
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>
2023-05-02 14:32:46 +02:00
Peter Krempa
81391c0e1d virTypedParamsDeserialize: Remove unnecessary line breaks
All changed lines even fit into 80 columns.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-05-02 14:32:46 +02:00
Peter Krempa
49dc447d31 util: virtypedparam: Use proper enum type for all switch() statements
Ensure that all switch statements in this module use the proper type in
switch() statements to ensure complier protections.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-05-02 14:32:46 +02:00
Peter Krempa
d9ed32bb27 virTypedParameterAssignValue: Drop 'copystr' parameter
All callers pass 'true'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-05-02 14:32:46 +02:00
Tim Shearer
6425a311b8 virpci: Resolve leak in virPCIVirtualFunctionList cleanup
Repeatedly querying an SR-IOV PCI device's capabilities exposes a
memory leak caused by a failure to free the virPCIVirtualFunction
array within the parent struct's g_autoptr cleanup.

Valgrind output after getting a single interface's XML description
1000 times:

==325982== 256,000 bytes in 1,000 blocks are definitely lost in loss record 2,634 of 2,635
==325982==    at 0x4C3C096: realloc (vg_replace_malloc.c:1437)
==325982==    by 0x59D952D: g_realloc (in /usr/lib64/libglib-2.0.so.0.5600.4)
==325982==    by 0x4EE1F52: virReallocN (viralloc.c:52)
==325982==    by 0x4EE1FB7: virExpandN (viralloc.c:78)
==325982==    by 0x4EE219A: virInsertElementInternal (viralloc.c:183)
==325982==    by 0x4EE23B2: virAppendElement (viralloc.c:288)
==325982==    by 0x4F65D85: virPCIGetVirtualFunctionsFull (virpci.c:2389)
==325982==    by 0x4F65753: virPCIGetVirtualFunctions (virpci.c:2256)
==325982==    by 0x505CB75: virNodeDeviceGetPCISRIOVCaps (node_device_conf.c:2969)
==325982==    by 0x505D181: virNodeDeviceGetPCIDynamicCaps (node_device_conf.c:3099)
==325982==    by 0x505BC4E: virNodeDeviceUpdateCaps (node_device_conf.c:2677)
==325982==    by 0x260FCBB2: nodeDeviceGetXMLDesc (node_device_driver.c:355)

Signed-off-by: Tim Shearer <tshearer@adva.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-05-02 06:49:33 +02:00
Michal Privoznik
4644aba0b0 qemu: Stop virQEMUCaps propagation into qemuHostdevPreparePCIDevices()
After previous cleanups, qemuHostdevPreparePCIDevices() no longer
needs virQEMUCaps. Drop its passing from callers.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-04-25 12:36:31 +02:00
Michal Privoznik
430fc2ec26 qemu: Remove empty functions
After previous cleanup, there are some functions that do nothing:

  qemuConnectDomainXMLToNativePrepareHostHostdev()
  qemuConnectDomainXMLToNativePrepareHost()
  qemuProcessPrepareHostHostdev()
  qemuProcessPrepareHostHostdevs()

Remove them.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-04-25 12:36:31 +02:00
Michal Privoznik
fea0d8c40d qemu: Move <hostdev> SCSI path generation into qemuDomainPrepareHostdev()
When preparing a SCSI <hostdev/> with passthrough of a host SCSI
adapter (i.e. no protocol), a virStorageSource structure is
initialized and stored inside virDomainHostdevDef. But the source
structure is filled in many places, with almost the same code.

Firstly, qemuProcessPrepareHostHostdev() and
qemuConnectDomainXMLToNativePrepareHostHostdev() are the same.

Secondly, qemuDomainPrepareHostdev() allocates the src structure,
only to let qemuProcessPrepareHostHostdev() fill src->path later.

Well, src->path can be filled at the same place where the src
structure is allocated (qemuDomainPrepareHostdev()) which renders
the other two functions needless.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-04-25 12:36:30 +02:00
Michal Privoznik
57e4e9791a qemu_hotplug: Drop PCI backend check in qemuDomainAttachHostPCIDevice()
There is no way the qemuDomainAttachHostPCIDevice() function can
be called over a hostdev with PCI backend other than VFIO. And
even if it were, then the check is written so poorly that it lets
some types through (e.g. KVM) only to let
qemuBuildPCIHostdevDevProps() called afterwards fail properly.

Drop this check and rely on qemuDomainPrepareHostdevPCI() (and
worst case scenario even qemuBuildPCIHostdevDevProps()) to report
the proper error.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-04-25 12:36:30 +02:00
Michal Privoznik
59962b69b5 qemu: Deny all but VFIO PCI backends in hostdev prepare phase
We used to support KVM and VFIO style of PCI assignment. The
former was dropped in v5.7.0-rc1~103 and thus we only support
VFIO. All other backends lead to an error (see
qemuBuildPCIHostdevDevProps(), or qemuBuildPCIHostdevDevStr() as
it used to be called in the era of aforementioned commit).

Might as well report the error in prepare phase and save hassle
of proceeding with device preparation (e.g. in case of hotplug
overriding the device's driver, setting seclabels, etc.).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-04-25 12:36:30 +02:00
Michal Privoznik
3b87709c76 qemu: Move <hostdev/> PCI backend setting into qemuDomainPrepareHostdev()
virsh command domxml-to-native failed with below error but start
command succeed for same domain xml.

  "internal error: invalid PCI passthrough type 'default'"

If a <hostdev> PCI backend is not set in the XML, the supported
one is then chosen in qemuHostdevPreparePCIDevicesCheckSupport().
But this function is not called anywhere from
qemuConnectDomainXMLToNative(). But qemuDomainPrepareHostdev()
is. And it is also called from domain startup/hotplug code.
Therefore, move the backend setting to the common path and drop
qemuHostdevPreparePCIDevicesCheckSupport().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-04-25 12:36:30 +02:00
Michal Privoznik
6e60e8cb9f qemu_domain: Move internals of qemuDomainPrepareHostdev() into a separate function
So far, qemuDomainPrepareHostdev() is a NOP for anything but a
SCSI hostdev. This will change soon. Therefore, move the SCSI
hostdev preparation into a separate function
(qemuDomainPrepareHostdevSCSI()) and make
qemuDomainPrepareHostdev() call function corresponding to the
hostdev type (or nothing if the type doesn't need any
preparation).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-04-25 12:36:30 +02:00
Michal Privoznik
3f7039f9e8 qemuDomainAttachHostDevice: Prepare device early and for all types
When attaching a hostdev of a SCSI subsys,
qemuDomainPrepareHostdev() is called. This makes sense because
the function prepares just SCSI hostdevs ignoring others. But
this will soon change. Thefore, move the function call out of
qemuDomainAttachHostSCSIDevice() and into
qemuDomainAttachHostDevice().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-04-25 12:36:30 +02:00
Ján Tomko
03ca889b15 qemu: allow forcing emulated maxphysaddr
Treat:
  <maxphysaddr mode="emulate"/>
as a request not to take the maximum address size from the host.
This is useful if QEMU changes the default.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-04-25 11:19:37 +02:00
Ján Tomko
e3d95a1eba qemu: add support for setting host-phys-bits-limit
Translate <maxphysaddr limit='39'/> to:
host-phys-bits-limit=39

https://gitlab.com/libvirt/libvirt/-/issues/450
https://bugzilla.redhat.com/show_bug.cgi?id=2171860

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-04-25 11:19:37 +02:00
Ján Tomko
d6fbb21210 conf: cpu: add limit for maxphysaddr
Add a limit attribute to restrict the maximum physical address bits
that would be used for the guest CPU:

   <cpu mode='host-passthrough'>
     <maxphysaddr mode='passthrough' limit='39'/>
   </cpu>

https://gitlab.com/libvirt/libvirt/-/issues/450
https://bugzilla.redhat.com/show_bug.cgi?id=2171860

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-04-25 11:19:37 +02:00
Michal Privoznik
46410c2be8 lxc: Fix access to hostdev capabilities
In a few places, where a capabilities <hostdev/> is processed, a
wrong union member is access: def->source.subsys.type instead of
def->source.caps.type. Fortunately, both union members have .type
as the very first member so no real harm is done. Nevertheless,
we should access the correct union member.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-25 11:00:57 +02:00
Michal Privoznik
537d90437c lxc: Make lxcCreateHostdevDef() less versatile
Usually, we want a function to be as reusable as possible. But in
this specific case, when it's used just once we don't need that.
The lxcCreateHostdevDef() function is meant to create a hostdev.
The first argument selects the hostdev mode (caps/subsys) and the
second argument selects the type of hostdev (NET/STORAGE/MISC).
But because of how the function is written, it's impossible to
create a subsys hostdev as the function sets
hostdev->source.caps.type, regardless of mode. So the @mode
argument can be dropped.

Then, the function is called from one place and one place only.
And in there, VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET is passed for
@type so we can drop that argument too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-25 11:00:57 +02:00
Michal Privoznik
541582a91b qemu_hotplug.h: Expose less functions
After previous cleanups a lot of functions from qemu_hotplug.c
are called only within the file. Make them static and drop their
declarations from the header file.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2023-04-25 08:46:27 +02:00
Michal Privoznik
132b483006 qemu: Move qemuDomainUpdateDeviceLive() into qemu_hotplug.c
There is no good reason for qemuDomainUpdateDeviceLive() to live
in (ever growing) qemu_driver.c while we have qemu_hotplug.c
which already contains the rest of hotplug code. Move the
function to its new home.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
2023-04-25 08:46:27 +02:00
Michal Privoznik
f5d6290bfe qemu: Move qemuDomainAttachDeviceLive() into qemu_hotplug.c
There is no good reason for qemuDomainAttachDeviceLive() to live
in (ever growing) qemu_driver.c while we have qemu_hotplug.c
which already contains the rest of hotplug code. Move the
function to its new home.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
2023-04-25 08:46:27 +02:00
Michal Privoznik
c8b286935d qemu: Replace @dom argument with @driver in qemuDomainUpdateDeviceLive()
The qemuDomainUpdateDeviceLive() accepts virDomainPtr as one of
its arguments, but use it only to get QEMU driver out of it.
Well, the only caller already does that and thus can pass it
instead of virDomainPtr.

This also makes it look like the rest of device hot(un-)plug
functions: qemuDomainAttachDeviceLive() and
qemuDomainUpdateDeviceLive().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
2023-04-25 08:46:27 +02:00
K Shiva
c4bc4d3b82 Move default Input bus logic to PostParse handling
A new enum type "Default" has been added for Input bus.
The logic that handled default input bus types in
virDomainInputParseXML() has been moved to a new function
virDomainInputDefPostParse() in domain_postparse.c
Link to Issue: https://gitlab.com/libvirt/libvirt/-/issues/8

Signed-off-by: K Shiva <shiva_kr@riseup.net>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-04-24 15:23:50 +02:00
Peter Krempa
fb1bfad7ad qemu: hotplug: Update disk private data after hotplug
The disk private data contain information about the tray and
removability of the disk. Until recently we didn't support hotplug of
removable disks thus it wasn't a problem but now when you can hotplug a
CDROM you would not be able to open its tray.

Fix it by updating the hotplugged disk the same way we do at startup.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2160435
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-24 12:57:56 +02:00
Peter Krempa
b60efa9a39 qemuProcessRefreshDisks: Extract update of a single disk
Extract the logic to update one single disk (without emitting any
events) so that it can be reused when updating the state after a disk
hotplug.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-24 12:57:56 +02:00
Peter Krempa
c8e7ed7f7b qemuProcessRefreshDisks: Properly compare tray status
The code compares the 'tray_open' boolean from 'struct
qemuDomainDiskInfo' directly against 'disk->tray_status' which is
declared as virDomainDiskTray (enum). Now the logic works correctly
because the _OPEN enum has value '1'.

Separate the event emission code from the update code and remember the
old tray state in a separate variable rather than having the sneaky
logic we have today.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-24 12:57:56 +02:00
Ján Tomko
d063389f10 conf: storage: remove redundant condition
We exit early if poolOptions->formatToString is false.

Fixes: 9dadc73029
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2023-04-20 17:28:34 +02:00
Ján Tomko
6e48e02475 ch: pinVcpuLive: remove unused variable
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2023-04-20 17:28:34 +02:00
Ján Tomko
53d43bf23f qemu: command: join two adjacent conditions
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2023-04-20 17:28:33 +02:00
Ján Tomko
34c1715ed1 conf: domain: remove unreachable break
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2023-04-20 17:28:33 +02:00
Michal Privoznik
ac7f3667f2 meson: Work around configure_file(copy:true) deprecation
In our meson scripts, we use configure_file(copy:true) to copy
files from srcdir into builddir. However, as of meson-0.64.0,
this is deprecated [1] in favor of using:

  fs = import('fs')
  fs.copyfile(in, out)

Except, the submodule's new method wasn't introduced until
0.64.0. And since we can't bump the minimal meson version we
require, we have to work with both: new and old versions.

Now, the fun part: fs.copyfile() is not a drop in replacement as
it returns different type (a custom_target object). This is
incompatible with places where we store the configure_file()
retval in a variable to process it further.

While we could just replace 'copy:true' with a dummy
'configuration:...' (say 'configuration: configmake_conf') we
can't do that for binary files (like src/fonts/ or src/images/).

Therefore, places where we are not interested in the retval can
be switched to fs.copyfile() and places where we are interested
in the retval will just use a dummy 'configuration:'.

Except, src/network/meson.build. In here we not just copy the
file but also specify alternative install dir and that's not
something that fs.copyfile() can handle. Yet, using 'copy: true'
is viewed wrong [2].

1: https://mesonbuild.com/Release-notes-for-0-64-0.html#fscopyfile-to-replace-configure_filecopy-true
2: https://github.com/mesonbuild/meson/pull/10042

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-04-20 15:30:18 +02:00
Martin Kletzander
383caddea1 qemu, ch: Move threads to cgroup dir before changing parameters
With cgroupv2 this has better effect on the resource allocation.  An
excerpt from Documentation/admin-guide/cgroup-v2.rst explains is this
way:

  Migrating a process across cgroups is a relatively expensive operation
  and stateful resources such as memory are not moved together with the
  process.  This is an explicit design decision as there often exist
  inherent trade-offs between migration and various hot paths in terms
  of synchronization cost.

  [...]

  Setting a non-empty value to "cpuset.mems" causes memory of
  tasks within the cgroup to be migrated to the designated nodes if
  they are currently using memory outside of the designated nodes.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-04-20 12:39:49 +02:00
Martin Kletzander
d2af152d1f qemu: Forbid most duplicated watchdogs
Most of them are platform devices and only i6300esb can be plugged
multiple times into different PCI slots.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-04-20 10:17:35 +02:00
Martin Kletzander
865b071ae8 qemu: Validate watchdog action compatibility per-device
This makes it also work during attach.  Also add a test for attaching a
watchdog with incompatible action.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2187278
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-04-20 10:17:35 +02:00
Martin Kletzander
d56ddd0d19 qemu: Check all watchdogs for iTCO duplicates
The loop initially skipped the first one because it was mainly checking
the incompatible actions, but was then modified to also check the
duplicity of iTCO watchdogs.

While at it change the type of the iteration variable to the usual size_t.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2187133
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-04-20 10:17:35 +02:00
Martin Kletzander
2669b442f9 qemu: Forbid ib700 watchdogs for non-i440fx machine types
We can launch qemu with it, but it will not work since it's not even
probed by the kernel at the mapped address with different machine types
since they are expected to be connected to ISA and not even its newer
LPC counterpart found on q35.  And it does not exist on non-x86
architectures.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-04-20 10:17:35 +02:00
Martin Kletzander
18f7dd6f1f qemu: Forbid device attach of existing platform watchdog
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-04-20 10:17:35 +02:00
Martin Kletzander
623d074e44 qemu: Fix grammar and quoting in watchdog error message on hotplug
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-04-20 10:17:35 +02:00
Martin Kletzander
687d7fba4c conf: Add missing empty lines before virDomainWatchdogDefParseXML
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-04-20 10:17:35 +02:00
Michal Privoznik
5670c50ffb qemu_domain: Increase memlock limit for NVMe disks
When starting QEMU, or when hotplugging a PCI device QEMU might
lock some memory. How much? Well, that's an undecidable problem.

But despite that, we try to guess. And it more or less works,
until there's a counter example. This time, it's a guest with
both <hostdev/> and an NVMe <disk/>. I've started a simple guest
with 4GiB of memory:

  # virsh dominfo fedora
  Max memory:     4194304 KiB
  Used memory:    4194304 KiB

And here are the amounts of memory that QEMU tried to lock,
obtained via:

  grep VmLck /proc/$(pgrep qemu-kvm)/status

  1) with just one <hostdev/>
     VmLck:   4194308 kB

  2) with just one NVMe <disk/>
     VmLck:   4328544 kB

  3) with one <hostdev/> and one NVMe <disk/>
     VmLck:   8522852 kB

Now, what's surprising is case 2) where the locked memory exceeds
the VM memory. It almost resembles VDPA. Therefore, treat is as
such.

Unfortunately, I don't have a box with two or more spare NVMe-s
so I can't tell for sure. But setting limit too tight means QEMU
refuses to start.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2014030
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-04-20 08:37:22 +02:00
Michal Privoznik
0d0604a51a networkRefreshDhcpDaemon: Get dnsmasq's PID once
This is a relic of commit v3.7.0-rc1~132 when getter/setter APIs
for dnsmasq's PID were introduced. Previously, obj->dnsmasqPid
was accessed directly. But the aforementioned commit introduced
two calls to virNetworkObjGetDnsmasqPid() even though the result
of the first call is stored in a variable.

Remove the second call as it's unnecessary.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-19 15:00:51 +02:00
Michal Privoznik
004d5141c5 conf: Initialize _virNetworkObj::dnsmasqPid to -1 in virNetworkObjNew()
Throughout all of our network driver code we assume that
dnsmasqPid of value -1 means the network has no dnsmasq process
running. There are plenty of calls to:

  virNetworkObjSetDnsmasqPid(obj, -1);

or:

  pid_t dnsmasqPid = virNetworkObjGetDnsmasqPid(obj);
  if (dnsmasqPid > 0) ...;

Now, a virNetworkObj is created via virNetworkObjNew() which
might as well set this de-facto default value.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-19 15:00:24 +02:00
Michal Privoznik
212dfa94ee networkUpdateState: do not assume dnsmasq_caps
Assume there's a dnsmasq running (because there's an active
virtual network that spawned it). Now, shut down the daemon,
remove the dnsmasq binary and start the daemon again. At this
point, networkUpdateState() is called, but dnsmasq_caps is NULL
(because networkStateInitialize() called earlier failed to set
them, rightfully though).

Now, the networkUpdateState() tries to read the dnsmasq's PID
file using virPidFileReadIfAlive() which takes a path to the
corresponding binary as one of its arguments. To provide that
path, dnsmasqCapsGetBinaryPath() is called, but since
dnsmasq_caps is NULL, it dereferences it and thus causes a crash.

It's true that virPidFileReadIfAlive() can deal with a removed
binary (well virPidFileReadPathIfAlive() which it calls can), but
iff the binary path is provided in its absolute form. Otherwise,
virFileResolveAllLinks() fails to canonicalize the path
(expected, the path doesn't exist anyway).

Therefore, reading dnsmasq's PID file didn't work before
v8.1.0-rc1~401 which introduced this crash. It was always set to
-1. But passing NULL as binary path instead, makes
virPidFileReadIfAlive() return early, right after the PID file is
read and it's confirmed the PID exists.

Yes, this may yield wrong results, as the PID might be of a
completely different binary. But this problem is preexistent and
until we start locking PID files, there's nothing we can do about
it. IOW, it would require rework of dnsmasq PID file handling.

Fixes: 4b68c982e2
Resolves: https://gitlab.com/libvirt/libvirt/-/issues/456
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-19 14:58:33 +02:00
Jim Fehlig
b9236758c7 qemu: Change default machine type for RISC-V
It's quite difficult, if not impossible, to create a working RISC-V VMs
using the current default machine type of 'spike_v1.10'. Change the
default to the more appropriate and virtualization friendly 'virt'
machine type.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2023-04-18 08:55:25 -06:00
Jim Fehlig
cb8e3ab3f9 qemu: Change default machine type for ARM
It's quite difficult, if not impossible, to create a usable ARM VMs
using the current default machine type of 'integratorcp'. Change the
default to the more appropriate and virtualization friendly 'virt'
machine type.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2023-04-18 08:54:49 -06:00
Michal Privoznik
8de96e270a qemu_hotplug: Deny live detach of <console/>
I've tried, then I've tried even harder, but still wasn't able to
make sense of our console backcompat code in all its fine
details. Since I value my sanity, let's just forbid hotunplug of
<console/>, especially since detaching of corresponding <serial/>
works.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-18 16:02:35 +02:00
Michal Privoznik
b5a591f73b qemuDomainRemoveChrDevice: Deal with qemuDomainChrRemove() failure
When cleaning up after removed device, qemuDomainChrRemove() is
called. But this may fail, in which case we successfully ignore
the failure and virDomainChrDefFree() the device anyway. While it
decreases our memory consumption, it's a bit too far, especially
if the next step is 'virsh dumpxml'. Then our memory consumption
decreases all the way down to zero as we crash.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-18 16:02:35 +02:00
Michal Privoznik
fc8320faef qemuAssignDeviceChrAlias: Fix a crasher during <console/> hotplug
For a running guest, a <serial/> device can be hotunplugged. This
will then remove also aliased <console/>. Trying to hotplug a
<console/> device then, libvirtd crashed because it dereferences
def->consoles while there's none.

Fixes: 42d53ac799
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-18 16:02:35 +02:00
Michal Privoznik
e99072731c qemuDomainChrRemove: Don't leak vmdef->consoles[0]
When removing the compat console from domain defintion, removing
it from the vmdef->consoles array is good, but not sufficient.
The console definition might have been fully allocated (after
daemon restarted and reloaded the status XML). Use
virDomainChrDefFree() to free also the definition.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-18 16:02:35 +02:00
Michal Privoznik
9129643d26 qemuDomainChrInsertPreAlloced: Fix adding implicit console
When hotpluging a <serial/> device, we might need to add a
<console/> device with it (because of some crazy backcompat).
Now, hotplugging is done in several phases. In one of them,
qemuDomainChrPreInsert() allocates space for both devices, and
then qemuDomainChrInsertPreAlloced() actually inserts the device
into domain definition and sets up the <console/> device with it.
Except, the condition that checks whether to create the aliased
<console/> is wrong as it compares nconsoles against 0.
Surprisingly, qemuDomainChrInsertPreAllocCleanup() doesn't suffer
from the same error.

Fixes: daf51be5f1
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-18 16:02:35 +02:00
Andrea Bolognani
985f78e804 conf: Restrict use of <portForward> to the passt backend
That's already the case in practice, but it's a better
experience for the user if we reject this configuration
outright instead of silently ignoring part of it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-18 15:52:30 +02:00
Marc-André Lureau
883b427acf Move src/keycodemapdb -> subprojects/keycodemapdb
Follow better meson build system conventions. This allows to find
keymap-gen or CSV without explicitly setting the paths.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-04-17 15:02:38 +02:00
Marc-André Lureau
c4ec51edd6 rpc/ssh: ssh_userauth_agent() is not supported on win32
The function does not exist on win32.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-04-17 15:02:37 +02:00
Marc-André Lureau
e06beacec2 meson: drop explicit python interpreter
meson wraps python scripts already on win32, so we end up with these
failing commands:

[1/359] "C:/msys64/ucrt64/bin/meson" "--internal" "exe" "--capture" "src/util/virkeycodetable_atset1.h" "--" "sh" "C:/msys64/home/marca/src/libvirt/scripts/meson-python.sh" "C:/msys64/ucrt64/bin/python3.EXE" "python" "C:/msys64/home/marca/src/libvirt/src/keycodemapdb/tools/keymap-gen" "code-table" "--lang" "stdc" "--varname" "virKeyCodeTable_atset1" "C:/msys64/home/marca/src/libvirt/src/keycodemapdb/data/keymaps.csv" "atset1"
FAILED: src/util/virkeycodetable_atset1.h
"C:/msys64/ucrt64/bin/meson" "--internal" "exe" "--capture" "src/util/virkeycodetable_atset1.h" "--" "sh" "C:/msys64/home/marca/src/libvirt/scripts/meson-python.sh" "C:/msys64/ucrt64/bin/python3.EXE" "python" "C:/msys64/home/marca/src/libvirt/src/keycodemapdb/tools/keymap-gen" "code-table" "--lang" "stdc" "--varname" "virKeyCodeTable_atset1" "C:/msys64/home/marca/src/libvirt/src/keycodemapdb/data/keymaps.csv" "atset1"

If LC_ALL, LANG and LC_CTYPE need to be set, it would probably be better
to use a meson environment() instead.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-04-17 15:02:35 +02:00
Marc-André Lureau
785dfe58fa meson: don't hard code find_program() location
Use 'dirs' argument to locate the program.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-04-17 15:02:31 +02:00
Marc-André Lureau
6d78280bb4 keycodemapdb: update submodule for build fixes
A number of changes, but notably python script shebang fixing build
issues in CI:

Daniel P. Berrangé (1):
      Revert "Add local argparse for compat with python 2.6"

Dawid Dziurla (1):
      Don't hardcode python3 path in shebang

Eli Schwartz (1):
      make the meson.build stub a bit more well-rounded by exporting files

Pierre Ossman (1):
      Fix macOS "ISO" key

Ross Lagerwall (2):
      Use python3 binary rather than unversioned python
      Fix Hangeul/Hanja scancodes

William (1):
      Add Qemu qcode support for F13 to F24

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-04-17 15:02:26 +02:00
Peter Krempa
2fbb8e9a7b Don't translate strings used with VIR_DEBUG
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-14 15:21:59 +02:00
Peter Krempa
b108a73a7b virCgroupV1GetBlkioIo(Device)Serviced: Refactor extraction of cgroup data
Rewrite the code to improve maintainability and also re-do construction
of error messages which are assembled from non-translatable parts.

Closes: https://gitlab.com/libvirt/libvirt/-/issues/455
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-04-14 15:20:14 +02:00
Andrea Bolognani
194cfb44e7 qemu: Fix incorrect command name in error messages
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2023-04-14 10:38:47 +02:00
Eric Farman
ebd004a03d security: do not remember/recall labels for VFIO MDEVs
Commit dbf1f68410 ("security: do not remember/recall labels for VFIO")
rightly changed the DAC and SELinux labeling parameters to fix a problem
with "VFIO hostdevs" but really only addressed the PCI codepaths.
As a result, we can still encounter this with VFIO MDEVs such as
vfio-ccw and vfio-ap, which can fail on a hotplug:

  [test@host ~]# mdevctl stop -u 11f2d2bc-4083-431d-a023-eff72715c4f0
  [test@host ~]# mdevctl start -u 11f2d2bc-4083-431d-a023-eff72715c4f0
  [test@host ~]# cat disk.xml
    <hostdev mode='subsystem' type='mdev' model='vfio-ccw'>
      <source>
        <address uuid='11f2d2bc-4083-431d-a023-eff72715c4f0'/>
      </source>
      <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x3c51'/>
    </hostdev>
  [test@host ~]# virsh attach-device guest ~/disk.xml
  error: Failed to attach device from /home/test/disk.xml
  error: Requested operation is not valid: Setting different SELinux label on /dev/vfio/3 which is already in use

Make the same changes as reported in commit dbf1f68410, for the mdev paths.

Reported-by: Matthew Rosato <mjrosato@linux.ibm.com>
Signed-off-by: Eric Farman <farman@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-04-13 16:34:13 +02:00
Akihiko Odaki
4497c1ac40 conf: Introduce igb model for <interface>
igb is a new network device which will be introduced with QEMU 8.0.0.
It is a successor of e1000e so it has PCIe interface and is understands
virtio-net headers as e1000e does.

Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-04-13 09:28:47 +02:00
Jim Fehlig
1527703334 qemu: Fix potential crash during driver cleanup
During qemu driver shutdown, objects are freed in qemuStateCleanup that
could still be used by active worker threads, resulting in crashes. E.g.
a worker thread could be processing a monitor EOF event after the
security manager is already disposed

Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007fd9a9a1e1fe in virSecurityManagerMoveImageMetadata (mgr=0x7fd948012160, pid=-1, src=src@entry=0x7fd98c072c90, dst=dst@entry=0x0)
    at ../../src/security/security_manager.c:468
#1  0x00007fd9646ff0f0 in qemuSecurityMoveImageMetadata (driver=driver@entry=0x7fd948043830, vm=vm@entry=0x7fd98c066db0, src=src@entry=0x7fd98c072c90,
    dst=dst@entry=0x0) at ../../src/qemu/qemu_security.c:182
#2  0x00007fd96462c7b0 in qemuBlockRemoveImageMetadata (driver=driver@entry=0x7fd948043830, vm=vm@entry=0x7fd98c066db0, diskTarget=0x7fd98c072530 "vda",
    src=<optimized out>) at ../../src/qemu/qemu_block.c:2628
#3  0x00007fd9646929d6 in qemuProcessStop (driver=driver@entry=0x7fd948043830, vm=vm@entry=0x7fd98c066db0, reason=reason@entry=VIR_DOMAIN_SHUTOFF_SHUTDOWN,
    asyncJob=asyncJob@entry=QEMU_ASYNC_JOB_NONE, flags=<optimized out>) at ../../src/qemu/qemu_process.c:7585
#4  0x00007fd9646fc842 in processMonitorEOFEvent (vm=0x7fd98c066db0, driver=0x7fd948043830) at ../../src/qemu/qemu_driver.c:4794
#5  qemuProcessEventHandler (data=0x561a93febb60, opaque=0x7fd948043830) at ../../src/qemu/qemu_driver.c:4900
#6  0x00007fd9a9971a31 in virThreadPoolWorker (opaque=opaque@entry=0x561a93fb58e0) at ../../src/util/virthreadpool.c:163
(gdb) p mgr->drv
$2 = (virSecurityDriverPtr) 0x0

Prior to commit 7cf76d4e3a, the worker thread pool was freed before
disposing any driver objects. Let's return to that pattern, but leave
the other changes made by 7cf76d4e3a.

Signed-off-by: Tamara Schmitz <tamara.schmitz@suse.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-04-12 11:26:22 -06:00
Andrea Bolognani
f9ad302335 conf: Fix migration in some firmware autoselection scenarios
Introduce a small kludge in the parser to avoid unnecessarily
blocking incoming migration from a range of recent libvirt
releases.

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-12 18:03:21 +02:00
K Shiva Kiran
62f29b9f98 conf: Move validation of virDomainGraphicsListenDef out of parser
In an effort to separate the validation steps from the Parse stage,
a few validation checks of virDomainGraphicsListenDef have been moved from
virDomainGraphicsListenDefParseXML() in domain_conf.c to
virDomainGraphicsDefListensValidate() in domain_validate.c

Signed-off-by: K Shiva <shiva_kr@riseup.net>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-04-12 17:41:56 +02:00
Peter Krempa
7e1b4cc19c qemu: snapshot: Allow inactive internal snapshots with uefi
Historically the snapshot code attempted to forbid internal snapshots
with UEFI both in active and inactive case. Unfortunately due to the
intricacies of UEFI probing this didn't really work for inactive VMs
which made users rely on the feature.

Now with the changes to store detected UEFI environment also in the
inactive definition this broke the feature for those users.

Since the varstore doesn't really change that much in the lifecycle of a
VM it usually is okay to simply leave it as is.

Restore the functionality for inactive snapshots by disabling the check.

In the future when uefi snapshotting will be added the rest of the
condition will also be removed.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/460
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-11 10:09:05 +02:00
Peter Krempa
dd1987268b virDomainPCIAddressSetExtensionAlloc: Remove return value
The function always returns 0. Remove the return value and refactor
caller.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-11 10:08:31 +02:00
Ján Tomko
7eead248c6 util: acpi: include unistd.h
For lseek.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2023-04-06 15:39:37 +02:00
Michal Privoznik
ab6e04d7ce viracpi: Fir error format string in virAcpiParseIORTNodeHeader()
Inside of virAcpiParseIORTNodeHeader() there's an
virReportError() which reports size of a structure using sizeof()
operator. Well, it's not well documented but the returned type of
sizeof() is apparently size_t but the format string uses %lu.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2023-04-06 14:27:00 +02:00
Michal Privoznik
1a5c864e9f util: Introduce virAcpi module
The aim of this new module is to contain code that's parsing ACPI
tables. For now, only parsing of IORT table is implemented (it's
ARM specific table). And since we only need to check whether the
table contains SMMU record, the code is very simplified.
I've followed the specification published here:

  https://developer.arm.com/documentation/den0049/latest/

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2023-04-06 12:48:22 +02:00
Pavel Hrdina
d292ddf1cc qemu_snapshot: external: don't error out when updating metadata
Attaching disk into running VM the offline definition may not be
updated and we will end up with that disk existing only in live
definition. Creating snapshot with this state saves both live and
offline definition into snapshot metadata.

When we are deleting an external snapshot we are updating these
definitions in the snapshot metadata so we should just skip over
non-existing disks instead of reporting error.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 14:32:40 +02:00
Peter Krempa
723a3e74ab qemuValidateDomainDefPSeriesFeature: Simplify feature validation
Unify validation of VIR_DOMAIN_FEATURE_HTM, VIR_DOMAIN_FEATURE_NESTED_HV,
VIR_DOMAIN_FEATURE_CCF_ASSIST and remove temporary string.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
f13a45d8a9 qemuValidateDomainDefPSeriesFeature: Simplify machine validation logic
Return early and reformat the error message.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
518d8d1de1 qemu: capabilities: Retire obsolete 'pseries' capabilities
Retire:

    QEMU_CAPS_MACHINE_PSERIES_CAP_HPT_MAX_PAGE_SIZE
    QEMU_CAPS_MACHINE_PSERIES_CAP_HTM
    QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV
    QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST
    QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC
    QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC
    QEMU_CAPS_MACHINE_PSERIES_CAP_IBS

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
d2bca62e8a qemuValidateDomainDefPSeriesFeature: Remove obsolete checks
The features:

QEMU_CAPS_MACHINE_PSERIES_CAP_HPT_MAX_PAGE_SIZE
QEMU_CAPS_MACHINE_PSERIES_CAP_HTM
QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV
QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST
QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC
QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC
QEMU_CAPS_MACHINE_PSERIES_CAP_IBS

are supported by all qemu versions that libvirt supports. Drop the
obsolete checks.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
b4cd07cc70 virCapabilitiesFreeMachines: Remove unused function
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
74998ed662 virQEMUCapsInitGuest: Refactor cleanup and remove return value
Use automatic pointer freeing, remove 'ret' variable and also remove
return value completely.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
a4c03bdd59 virQEMUCapsInitGuestFromBinary: Remove return value
The function always returns 0.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
6481b06a19 virQEMUCapsInitGuestFromBinary: Refactor cleanup
Remove useless call to virCapabilitiesFreeMachines as the pointers were
cleared and the unneeded 'ret' variable. Since we don't need to clear
the 'machines' pointer now, remove that as well.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
58e1b19aef virQEMUCapsGetMachineTypesCaps: Remove return value
The function always returns 0.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
ccee1ee088 virCapabilitiesAllocMachines: Use NULL-terminated list as argument and return count
Simplify use of the function by determining the number of elements
inside the function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
dca563b296 libxlCapsInitGuests: Rework insane use of ternary operators
Get rid of nested ternaries by adding a few helper variables and more
explicit if conditions to fill them appropriately.

Note that 'virCapabilitiesAllocMachines' doesn't require return value
check any more as it can't fail.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
6861964704 qemu: capabilities: Drop 'kvmVersion' field
It's never set to any real value. Remove it along with the caching code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
1485f9c17d virDomainHostdevDefClear: Fix and shorten comment
There's more stuff than device info to clear nowadays. Drop the
misleading comment. Shorten the comment saying that device info is freed
elsewhere when 'parentnet' is present.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
cab9e1884d conf: Unexport virDomainHostdevDefClear
Move it before its first usage and make it static.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
6af47df5ac virQEMUCapsProbeHVF: Factor out setting of the capability
Separate the architecture specific code to probe the support for HVF
from the actual setting of the capability.

In upcoming patches 'virQEMUCapsProbeHVF' will be mocked in the
testsuite to provide testing for the HVF hypervisor.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:06 +02:00
Peter Krempa
111cfc5532 qemu: capabilities: Fix testing of 'TCG' capabilities probing
The logic in 'virQEMUCapsInitQMP' invokes a second probe of qemu in case
when acceleration is used and TCG is supported to specifically probe the
CPU and features of non-accelerated guests.

The same logic must then be used in 'qemucapabilitiestest' when
replaying the data for testing otherwise the test would fail.

Export 'virQEMUCapsHaveAccel' for test usage and use the same logic
in 'testQemuCaps'.

Fix the comment in 'virQEMUCapsInitQMP' to outline what's happening.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:06 +02:00
Peter Krempa
ed93c15f82 schema: capabilities: Add 'hvf' virt type into list of allowed types
The capabilities generated on OSX hosts with 'hvf' accelerator will not
pass schema testing as the 'hvf' type was not allowed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:06 +02:00
Peter Krempa
5b738195a2 virStringParseVersion: Parse into 'unsigned long long'
Phase out 'unsigned long'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-04-03 09:19:06 +02:00
Peter Krempa
85a4f035f6 Use 'libvirt.org' instead of 'www.libvirt.org'
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-03 09:19:05 +02:00
Ján Tomko
c9a1f11afd Remove trailing spaces from translatable strings
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2023-04-03 08:55:27 +02:00
Michal Privoznik
58b7cafc28 virauth: Report error on empty auth result
When opening a connection, it may be necessary to provide user
credentials, or some additional info (e.g. whether to trust an
ssh key). We have a special API for that: virConnectOpenAuth()
where and additional callback can be passed. This callback is
then called with _virConnectCredential struct filled partially
and it's callback's responsibility to get desired data (e.g. by
prompting user) and store it into .result member of the struct.

But we document the callback behaviour as:

  When authentication requires one or more interactions, this callback
  is invoked. For each interaction supplied, data must be gathered
  from the user and filled in to the 'result' and 'resultlen' fields.
  If an interaction cannot be filled, fill in NULL and 0.

  Returns 0 if all interactions were filled, or -1 upon error

But there are some buggy callbacks out there, which set:

  .result = NULL;
  .resultlen = 0;

and return 0. Report an error when such buggy callback is met.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2181235
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-04-03 08:34:53 +02:00
Jiri Denemark
90d8652438 src: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:35 +02:00
Jiri Denemark
72bcbcfef9 vz: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:35 +02:00
Jiri Denemark
c7dbe9c93d vmx: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:35 +02:00
Jiri Denemark
9d10e31258 vmware: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:35 +02:00
Jiri Denemark
7d2d1cc705 vbox: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:35 +02:00
Jiri Denemark
b32bbe1e60 util: Update format strings in translated messages (part 3)
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:35 +02:00
Jiri Denemark
f0ed4de9ec util: Update format strings in translated messages (part 2)
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:35 +02:00
Jiri Denemark
e349cdc54b util: Update format strings in translated messages (part 1)
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:35 +02:00
Jiri Denemark
b3a5d1f1dc test: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:35 +02:00
Jiri Denemark
74f4547c47 storage_file: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:35 +02:00
Jiri Denemark
ce0c2010a8 storage: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:35 +02:00
Jiri Denemark
181d61fd5c secret: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:34 +02:00
Jiri Denemark
798bf7588c security: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:34 +02:00
Jiri Denemark
88af62f6a0 rpc: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:34 +02:00
Jiri Denemark
732ff069ad remote: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:34 +02:00
Jiri Denemark
71b19c4f08 qemu: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:34 +02:00
Jiri Denemark
21833b5564 qemu/qemu_validate: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:34 +02:00
Jiri Denemark
49f2835ee3 qemu/qemu_process: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:34 +02:00
Jiri Denemark
6d6f072e4b qemu/qemu_monitor_json: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:34 +02:00
Jiri Denemark
d5abf94073 qemu/qemu_migration: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:34 +02:00
Jiri Denemark
030a14679b qemu/qemu_hotplug: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:34 +02:00
Jiri Denemark
042c94220c qemu/qemu_driver: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:34 +02:00
Jiri Denemark
27ed822d30 qemu/qemu_domain: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:33 +02:00
Jiri Denemark
9c6fc8b555 qemu/qemu_command: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:33 +02:00
Jiri Denemark
1d4a4f21ce openvz: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:33 +02:00
Jiri Denemark
04df8f474b nwfilter: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:33 +02:00
Jiri Denemark
6b8763675d node_device: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:33 +02:00
Jiri Denemark
0f96ac3d2c network: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:33 +02:00
Jiri Denemark
322dd93901 lxc: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:33 +02:00
Jiri Denemark
0121243d67 logging: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:33 +02:00
Jiri Denemark
3d61757c3b locking: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:33 +02:00
Jiri Denemark
8875aee4eb libxl: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:33 +02:00
Jiri Denemark
be664663fa interface: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:33 +02:00
Jiri Denemark
1d279b0abd hypervisor: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:33 +02:00
Jiri Denemark
7d8f371801 hyperv: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:32 +02:00
Jiri Denemark
e9616d9786 esx: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:32 +02:00
Jiri Denemark
e0fd806363 cpu: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:32 +02:00
Jiri Denemark
5f354d5cc0 conf: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:32 +02:00
Jiri Denemark
0df355c6ba conf/node_device_conf: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:32 +02:00
Jiri Denemark
772316c8df conf/network_conf: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:32 +02:00
Jiri Denemark
b908a3b0bb conf/domain_validate: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:32 +02:00
Jiri Denemark
d4d01dcb92 conf/domain_conf: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:32 +02:00
Jiri Denemark
187a94b97b ch: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:32 +02:00
Jiri Denemark
4cae4cd40e bhyve: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:32 +02:00
Jiri Denemark
044ec5f7d2 admin: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:32 +02:00
Jiri Denemark
a1f8154b3d access: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:31 +02:00
Jiri Denemark
6ad1f3c701 Do not use VIR_PCI_DEVICE_ADDRESS_FMT in translations
xgettext cannot handle strings concatenated with cpp macros.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-01 09:58:17 +02:00
Jiri Denemark
dc65e253fe Drop excess whitespace from error messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-01 09:58:17 +02:00
Peter Krempa
0bfd11dd85 conf: Clear pointer to freed bitmap holding hostdev's 'origstates'
'virDomainHostdevDefClear' must clear the pointers too as it can be
invoked multiple times on the same object e.g. inside
qemuDomainRemoveHostDevice once via virDomainHostdevDefFree which skips
freeing the object if it's used via <interface> and thus has a 'net'
definition corresponding to it, and then subsequently via
virDomainNetDefFree.

Fix it by clearing the pointer along with freeing it.

Fixes: d9e4075d4e
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2182961
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-03-30 15:17:08 +02:00
Anastasia Belova
2c6b5a8425 storage_file_probe: change maximum len value in vmdk4GetBackingStore
desc length should be always less than VIR_STORAGE_MAX_HEADER.
If len = VIR_STORAGE_MAX_HEADER, desc may be out of bounds.

Fixes: 296032bfb2 ("util: extract storage file probe code into virtstoragefileprobe.c")
Signed-off-by: Anastasia Belova <abelova@astralinux.ru>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-03-29 13:02:01 +02:00
Andrea Bolognani
420a7a2550 qemu: Default to raw firmware for existing domains
The changes to the output files are the exact opposite of
those from commit 22207713cf: this is proof that the fix is
working as intended, and that existing domains will keep using
raw firmware images regardless of whether or not qcow2 images
are available on the system and have higher priority.

New domains will keep picking whatever firmware is considered
the preferred one according to the order of descriptors, as
evidenced by the fact that the recently introduced
firmware-auto-efi-abi-update-aarch64 test case is unaffected.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-03-28 14:22:34 +02:00
Michal Privoznik
d05ad0f15e esx: Change the default username when connecting to VCenter
While it's true that the default username is:

  administrator@${SSO-Domain}

in majority of cases the ${SSO-Domain} is "vsphere.local". But
our code (and what virsh displays then) says it's just
"administrator".

This is wrong also from a different POV: the username must
contain the suffix no matter what and our default suggests
otherwise.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2181234
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-03-24 14:44:54 +01:00
Michal Privoznik
b407897ea9 qemu_shim: Require absolute path for root directory
The virConnectOpen(), well virConnectOpenInternal() reports an
error if embed root is not an absolute path. This is a fair
requirement, but our qemu_shim doesn't check this requirement and
passes the path to mkdir(), only to fail later on, leaving the
empty directory behind:

  $ ls -d asd
  ls: cannot access 'asd': No such file or directory

  $ virt-qemu-run -r asd whatever.xml
  virt-qemu-run: cannot open qemu:///embed?root=asd: unsupported configuration: root path must be absolute

  $ ls -d asd
  asd

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
2023-03-22 15:53:33 +01:00
Michal Privoznik
94862a77be qemu_domain: Drop ATTRIBUTE_NONNULL() for non-existent arguments
After cleanup done in v8.2.0-rc1~47 the
qemuDomainObjExitMonitor() and after v8.7.0-rc1~176 the
qemuDomainObjEnterMonitor() lost the @driver argument. But
corresponding ATTRIBUTE_NONNULL() annotation was not removed and
both functions are still annotated as ATTRIBUTE_NONNULL(2) even
though they accept just one argument (@obj).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
2023-03-22 15:53:33 +01:00
Ján Tomko
8c8cda2c9a qemu_shim: set system identity
Otherwise looking up a secret fails when we try to elevate the identity
in qemuDomainSecretInfoSetupFromSecret.

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-03-22 14:41:28 +01:00
Andrea Bolognani
f099d3fe10 qemu: Move validation check out of postparse
Suggested-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-03-22 13:49:53 +01:00
Andrea Bolognani
e493a2ed73 conf: Move validation check out of postparse
The reason why it was in postparse in the first place was so
that we could could automatically enable the secure-boot feature
in some cases, but that no longer happens so we can finally move
it to the proper location.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-03-22 13:49:53 +01:00
Andrea Bolognani
6d0d416f41 conf: Don't explicitly set the secure-boot feature
Now that we're adding information obtained from the firmware
descriptor to the domain XML, this will happen automatically
whenever a firmware that has the enrolled-keys feature ends up
being selected.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-03-22 13:49:53 +01:00
Andrea Bolognani
24ad99d76d qemu: Automatically add firmware type/features information
Even when the user is not taking advantage of firmware
autoselection and instead manually providing all the necessary
information, in most cases they're still going to use firmware
builds that are provided by the OS vendor, are installed in
standard paths and come with a corresponding firmware
descriptor.

Similarly, even when the user is not guiding the autoselection
process by specifying the desired status of certain features
and instead is relying on the system-level descriptor priority
being set up correctly, libvirt will still ultimately decide to
use a specific descriptor, which includes information about the
firmware's features.

In both these cases, take the additional information that were
obtained from the firmware descriptor and reflect them back into
the domain XML, where they can be conveniently inspected by the
user and management applications alike.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-03-22 13:49:53 +01:00
Andrea Bolognani
50d68c1d10 qemu: Don't drop firmware type/features information
Now that we no longer reject configurations that include both
this information and explicit firmware details, as long of
course as everything is internally consistent, and that we've
ensured that we produce maximally compatible XML on migration,
we can stop stripping this information at the end of the
firmware selection process.

There are several advantages to keeping this information around:

  * if the user wants to change the firmware configuration for
    an existing VM, they can simply drop the <loader> and
    <nvram> elements, tweak the firmware autoselection parameters
    and let libvirt pick a firmware that matches on the new
    requirements;

  * management applications can inspect the XML and easily
    figure out firmware-related information without having to
    reverse-engineer them based on some opaque paths.

Overall, this change makes things more transparent and easier to
understand. The improvement is so significant that, in a
follow-up commit, we're going to ensure that this information is
available in even more cases.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-03-22 13:49:53 +01:00
Andrea Bolognani
a0065f9728 conf: Don't format firmware type/features when migrating
The combination of explicit firmware paths, which we now
produce in all cases, and firmware autoselection knobs is
explicitly rejected by libvirt 8.6.0 and newer.

Right now we produce inherently migratable XML in all cases,
since we always strip those bits, but that's going to change
soon. To prepare for that, make sure that we always skip the
problematic elements and attributes when preparing a
migratable XML.

The destination will simply receive a fully specified firmware
configuration, which is indistinguishable from one that was
manually provided by the user and is thus accepted by any old
version of libvirt, regardless of whether or not firmware
autoselection was used on the source host.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-03-22 13:49:53 +01:00
Andrea Bolognani
ccf4aa37a0 conf: Remove some firmware validation checks
libvirt 8.6.0 introduced these checks and very clearly delineated
two possible firmware selection scenarios: manual firmware
selection, where the user is responsible for providing all
information, and firmware autoselection, where a list of desired
features is provided and everything else is handled by libvirt.

In the interest of maintaining the clear separation between these
two scenarios, setting most attributes when firmware autoselection
is active will result in the configuration being rejected.

This works fine, but is unnecessarily restrictive: in most cases,
the additional information that the user has provided matches
the information that libvirt would have discovered on its own by
looking at firmware descriptors, and asking the user to scrub it
from the XML only result in pointless friction.

Remove these checks entirely.

Unsurprisingly, this results in a few test cases that were
rejected until now to suddenly start working and producing
sensible results.

The firmware-auto-efi-loader-path-nonstandard test case is
notable: while we can now enable the xml2xml part of the test,
the xml2argv part is still failing, although in a slightly
different way. This is expected: since the firmware binary is a
non-standard one, libvirt is unable to figure out the missing
information from a firmware descriptor, and the configuration
is still ultimately an invalid one. However, if we were to find
such a configuration on disk at daemon startup, we would not
ignore it completely and instead would offer the user a chance
to fix it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-03-22 13:49:53 +01:00
Andrea Bolognani
04568019c6 qemu: Always go through firmware autoselection
Right now there are a few scenarios in which we skip ahead, and
removing these exceptions will make for more consistent and
predictable behavior.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-03-22 13:49:53 +01:00
Andrea Bolognani
63859189e6 qemu: Discard requires-smm firmware when loader.secure=no
The requires-smm feature being present in a firmware descriptor
causes loader.secure=yes to be automatically chosen for the
domain, so we have to avoid this situation or the user's choice
will be silently subverted.

Note that we can't actually encounter loader.secure=no in this
function at the moment because of earlier checks, but that's
going to change soon.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-03-22 13:49:53 +01:00
Andrea Bolognani
8b96a17019 qemu: Introduce qemuFirmwareMatchesPaths()
Right now we have checks in place that ensure that explicit
paths are not provided when firmware autoselection has been
enabled, but that's going to change soon.

To prepare for that, take into account user-provided paths
during firmware autoselection if present, and discard all
firmware descriptors that don't contain matching information.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-03-22 13:49:53 +01:00
Andrea Bolognani
b62d1b30ae qemu: Fix memory leaks in firmware selection code
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2023-03-22 13:49:50 +01:00
Ján Tomko
4be3ba0226 vbox: unify "unable to get hard disk id" message
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2023-03-20 14:32:41 +01:00
Ján Tomko
3811027318 Unify error message when namespaces are unsupported
Some helpers used a period at the end, others did not.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2023-03-20 14:32:40 +01:00
Ján Tomko
0526a6024b util: xml: remove function names from error messages
The function name is already logged, and these can happen only as a
result of a programmer error.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2023-03-20 14:32:40 +01:00
Ján Tomko
161e21018a vbox: remove unreachable error in virVBoxSnapshotConfSaveVboxFile
Both callers in the VirtualBox driver handle the error and only
call this function with a non-NULL argument.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2023-03-20 14:32:40 +01:00
Ján Tomko
d2a430f90a vbox: remove unreachable error in virVBoxSnapshotConfLoadVboxFile
Both callers in the VirtualBox driver error out if the path
can't be fetched via VirtualBox APIs and abort on conversion error
from UTF-16 to UTF-8.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2023-03-20 14:32:40 +01:00
Ján Tomko
6c41f2e076 bhyve: unify error message for UUID generation
All the other places spell UUID in all caps.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2023-03-20 14:32:40 +01:00
Ján Tomko
6e23112304 src: unify symlink creation error message
In some places, one quote got dropped by accident.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2023-03-20 14:32:40 +01:00
Ján Tomko
9fc3c2524c bhyve: fix typo in error message
Use the same string as in qemu_process.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2023-03-20 14:32:40 +01:00
Shaleen Bathla
9a3bccf695 capabilities: reduce scope in virCapabilitiesInitCaches()
over-writing a variable in inner while-loop without freeing previous memory
leaks it over time.
To fix this, we can just change scope of bank variable to the inner loop.

Signed-off-by: Shaleen Bathla <shaleen.bathla@oracle.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Fixes: 5c84485439
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2023-03-20 14:29:38 +01:00
Ján Tomko
50f0e8e7aa rpc: fix typo in admin code generation
An extra '&' introduced a crash.

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

Fixes: 778c300460
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2023-03-17 16:42:55 +01:00
Ján Tomko
9dab836721 qemu: use correct formatting string for size_t
Otherwise the build on armv7l breaks:
error: format ‘%lu’ expects argument of type
‘long unsigned int’, but argument 4 has type
‘size_t’ {aka ‘unsigned int’} [-Werror=format=]

Fixes: 1992ae40fa
Fixes: e239f7d0a8

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2023-03-17 15:36:48 +01:00
Or Ozeri
5589a3e1f3 qemu: add luks-any encryption support for RBD images
The newly added luks-any rbd encryption format in qemu
allows for opening both LUKS and LUKS2 encryption formats.
This commit enables libvirt uses to use this wildcard format.

Signed-off-by: Or Ozeri <oro@il.ibm.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2023-03-16 15:19:36 +01:00
Or Ozeri
5a42a8c38c qemu: capabilities: Introduce QEMU_CAPS_RBD_ENCRYPTION_LUKS_ANY capability
This capability represents that qemu supports the "luks-any" encryption
format for RBD images.
Both LUKS and LUKS2 formats can be parsed using this wildcard format.

Signed-off-by: Or Ozeri <oro@il.ibm.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2023-03-16 15:19:36 +01:00
Or Ozeri
77c9663d72 qemu: add support for librbd layered encryption
This commit enables libvirt users to use layered encryption
of RBD images, using the librbd encryption engine.
This allows opening of an encrypted cloned image
whose parent is encrypted with a possibly different encryption key.
To open such images, multiple encryption secrets are expected
to be defined under the encryption XML tag.

Signed-off-by: Or Ozeri <oro@il.ibm.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2023-03-16 15:19:36 +01:00
Or Ozeri
1992ae40fa qemu: add multi-secret support in _qemuDomainStorageSourcePrivate
This commit changes the _qemuDomainStorageSourcePrivate struct
to support multiple secrets (instead of a single one before this commit).
This will useful for storage encryption requiring more than a single secret.

Signed-off-by: Or Ozeri <oro@il.ibm.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2023-03-16 15:19:36 +01:00
Or Ozeri
5c84e6fcdd qemu: add multi-secret support in qemuBlockStorageSourceAttachData
This commit changes the qemuBlockStorageSourceAttachData struct
to support multiple secrets (instead of a single one before this commit).
This will useful for storage encryption requiring more than a single secret.

Signed-off-by: Or Ozeri <oro@il.ibm.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2023-03-16 15:19:36 +01:00
Or Ozeri
e239f7d0a8 qemu: add support for multiple secret aliases
Change secret aliases from %s-%s-secret0 to %s-%s-secret%lu,
which will later be used for storage encryption requiring more
than a single secret.

Signed-off-by: Or Ozeri <oro@il.ibm.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2023-03-16 15:19:35 +01:00
Or Ozeri
6c34f19334 qemu: capabilities: Introduce QEMU_CAPS_RBD_ENCRYPTION_LAYERING capability
This capability represents that qemu supports the layered encryption
of RBD images, where a cloned image is encrypted with a possible
different encryption than its parent image.

Signed-off-by: Or Ozeri <oro@il.ibm.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2023-03-16 15:19:35 +01:00
Ján Tomko
c92e5bbdad util: virXMLValidatorInit: improve translatable errors
In some translations, the RNG initials were mistranslated
as a random number generator.

Spell it out as RelaxNG to make it clearer.
Include the word 'schema' and quotes around the filename.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2023-03-15 17:12:46 +01:00
Tim Wiederhake
62dd68ef18 cpu_map: Add missing feature "fsrc"
Introduced in qemu 58794f644e.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-03-15 14:46:12 +01:00
Tim Wiederhake
4bf853cac2 cpu_map: Add missing feature "fsrs"
Introduced in qemu 58794f644e.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-03-15 14:46:12 +01:00
Tim Wiederhake
43869b9178 cpu_map: Add missing feature "fzrm"
Introduced in qemu 58794f644e.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-03-15 14:46:12 +01:00
Tim Wiederhake
71d11166a9 cpu_map: Add missing feature "sgx-aex-notify"
Introduced in qemu d45f24fe75.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-03-15 14:46:12 +01:00
Tim Wiederhake
d8db5d2af6 cpu_map: Add missing feature "sgx-edeccssa"
Introduced in qemu d45f24fe75.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-03-15 14:46:12 +01:00
Tim Wiederhake
cd143c5deb sync_qemu_features_i386: Ignore xen-vapic
Not a cpu-feature.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-03-15 14:46:12 +01:00
Tim Wiederhake
7c671dc6e3 sync_qemu_models_i386.py: Add missing features
This brings the tool's list of features in sync with qemu
commit 9832009d9dd2386664c15cc70f6e6bfe062be8bd.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-03-15 14:46:12 +01:00
Tim Wiederhake
2360ec34ba sync_qemu_models_i386.py: Sort features
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-03-15 14:46:12 +01:00
Michal Privoznik
df2ef2e706 qemuBuildThreadContextProps: Prune .node-affinity wrt <emulatorpin/>
When a thread-context object is specified on the cmd line, then
QEMU spawns a thread and sets its affinity to the list of NUMA
nodes specified in .node-affinity attribute. And this works just
fine, until the main QEMU thread itself is not restricted.

Because of v5.3.0-rc1~18 we restrict the main emulator thread
even before QEMU is executed and thus then it tries to set
affinity of a thread-context thread, it inevitably fails with:

  Setting CPU affinity failed: Invalid argument

Now, we could lift the pinning temporarily, let QEMU spawn all
thread-context threads, and enforce pinning again, but that would
require some form of communication with QEMU (maybe -preconfig?).
But that would still be wrong, because it would circumvent
<emulatorpin/>.

Technically speaking, thread-context is an internal
implementation detail of QEMU, and if it weren't for it, the main
emulator thread would be doing the allocation. Therefore, we
should honor the pinning and prune the list of node so that
inaccessible ones are dropped.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2154750
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2023-03-15 12:46:55 +01:00
Michal Privoznik
45222a83b7 qemu: Add @nodemask argument to qemuBuildThreadContextProps()
When building a thread-context object (inside of
qemuBuildThreadContextProps()) we look at given memory-backend-*
object and look for .host-nodes attribute. This works, as long as
we need to just copy the attribute value into another
thread-context attribute. But soon we will need to adjust it.
That's the point where having the value in virBitmap comes handy.
Utilize the previous commit, which made
qemuBuildMemoryBackendProps() set the argument and pass it into
qemuBuildThreadContextProps().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2023-03-15 12:46:52 +01:00
Michal Privoznik
9f26f6cc4b qemu: Add @nodemaskRet argument to qemuBuildMemoryBackendProps()
While it's true that anybody who's interested in getting
.host-nodes attribute value can just use
virJSONValueObjectGetArray() (and that's exactly what
qemuBuildThreadContextProps() is doing, btw), if somebody is
interested in getting the actual virBitmap, they would have to
parse the JSON array.

Instead, introduce an argument to qemuBuildMemoryBackendProps()
which is set to corresponding value used when formatting the
attribute.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2023-03-15 12:46:49 +01:00
Michal Privoznik
450d932cd9 qemuBuildMemoryBackendProps: Join two conditions
There are two compound conditions in
qemuBuildMemoryBackendProps() and each one checks for nodemask
for NULL first. Join them into one bigger block.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2023-03-15 12:46:46 +01:00
Michal Privoznik
7feed1613d qemu: Fix qemuDomainGetEmulatorPinInfo()
The order of pinning priority (at least for emulator thread) was
set by v1.2.15-rc1~58 (for cgroup code). But later, when
automatic placement was implemented into
qemuDomainGetEmulatorPinInfo(), the priority was not honored.

Now that we have this priority code in a separate function, we
can just call that and avoid this type of error.

Fixes: 776924e376
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2023-03-15 12:46:43 +01:00
Michal Privoznik
b4ccb0dc41 qemu: Move cpuset preference evaluation into a separate function
The set of if()-s that determines the preference in cpumask used
for setting things like emulatorpin, vcpupin, etc. is going to be
re-used. Separate it out into a function.

You may think that this changes behaviour, but
qemuProcessPrepareDomainNUMAPlacement() ensures that
priv->autoCpuset is set for VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2023-03-15 12:46:40 +01:00
Michal Privoznik
95ae91fdd4 qemuxml2argvmock: Drop virNuma* mocks
Since qemuxml2argvtest is now using virnumamock, there's no need
for qemuxml2argvmock to offer reimplementation of virNuma*()
functions. Also, the comment about CLang and FreeBSD (introduced
in v4.3.0-40-g77ac204d14) is no longer true. Looks like noinline
attribute was the missing culprit.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2023-03-15 12:46:36 +01:00
Michal Privoznik
213b6822a8 virnumamock: Introduce virNumaGetNodeOfCPU() mock
Introduce a mock of virNumaGetNodeOfCPU() because soon we will
need virNumaCPUSetToNodeset() to return predictable results.
Also, fill in missing symlinks in vircaps2xmldata/.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2023-03-15 12:46:21 +01:00
Michal Privoznik
b6cfd348e9 virnuma: Introduce virNumaCPUSetToNodeset()
So far, we have a function that expands given list of NUMA nodes
into list of CPUs. But soon, we are going to need the inverse -
expand list of CPUs into list of NUMA nodes. Introduce
virNumaCPUSetToNodeset() for that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2023-03-15 12:46:16 +01:00
Michal Privoznik
01e5111c3c virnuma: Move virNumaNodesetToCPUset() out of WITH_NUMACTL
Technically, there's nothing libnuma specific about
virNumaNodesetToCPUset(). It just implements a generic algorithm
over virNumaGetNodeCPUs() (which is then libnuma dependant).
Nevertheless, there's no need to have this function living inside
WITH_NUMACTL block. Any error returned from virNumaGetNodeCPUs()
(including the one that !WITH_NUMACTL stub returns) is propagated
properly.

Move the function out of the block into a generic one and drop
the !WITH_NUMACTL stub.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2023-03-15 12:46:11 +01:00
Michal Privoznik
42d53ac799 qemu_alias: Fix backcompat console alias generation
We have this crazy backwards compatibility when it comes to
serial and console devices. Basically, in same cases the very
first <console/> is just an alias to the very first <serial/>
device. This is to be seen at various places:

1) virDomainDefFormatInternalSetRootName() - when generating
   domain XML, the <console/> configuration is basically ignored
   and corresponding <serial/> config is formatted,

2) virDomainDefAddConsoleCompat() - which adds a copy of
   <serial/> or <console/> into virDomainDef in post parse.

And when talking to QEMU we need a special handling too, because
while <serial/> is generated on the cmd line, the <console/> is
not. And in a lot of place we get it right. Except for generating
device aliases. On domain startup the 'expected' happens and
devices get "serial0" and "console0" aliases, correspondingly.
This ends up in the status XML too. But due to aforementioned
trick when formatting domain XML, "serial0" ends up in both
'virsh dumpxml' and the status XML. But internally, both devices
have different alias. Therefore, detaching the device using
<console/> fails as qemuDomainDetachDeviceChr() tries to detach
"console0".

After the daemon is restarted and status XML is parsed, then
everything works suddenly. This is because in the status XML both
devices have the same alias.

Let's generate correct alias from the beginning.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2156300
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2023-03-15 12:35:27 +01:00
Jiri Denemark
a9a36fb9e1 qemu_migration: Use VIR_DOMAIN_PAUSED_API_ERROR
Other APIs that internally use QEMU migration and need to temporarily
suspend a domain already report failure to resume vCPUs by setting
VIR_DOMAIN_PAUSED_API_ERROR state reason and emitting
VIR_DOMAIN_EVENT_SUSPENDED event with
VIR_DOMAIN_EVENT_SUSPENDED_API_ERROR.

Let's do the same in qemuMigrationSrcRestoreDomainState for consistent
behavior.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-03-15 10:52:14 +01:00