]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
2 years agoqemu_process: Produce better debug message wrt domain namespaces
Michal Privoznik [Tue, 7 Feb 2023 09:34:40 +0000 (10:34 +0100)]
qemu_process: Produce better debug message wrt domain namespaces

When going through debug log of a domain startup process, one can
meet the following line:

  debug : qemuProcessLaunch:7668 : Building mount namespace

But this is in fact wrong. Firstly, domain namespaces are just
enabled in domain's privateData. Secondly, the debug message says
nothing about actual state of namespace - whether it was enabled
or not.

Therefore, move the debug printing into
qemuProcessEnableDomainNamespaces() and tweak it so that the
actual value is reflected.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2 years agoqemu: Jump to cleanup label on umount failure
Jim Fehlig [Mon, 6 Feb 2023 17:40:12 +0000 (10:40 -0700)]
qemu: Jump to cleanup label on umount failure

Similar to other error paths in qemuDomainUnshareNamespace(), jump to
the cleanup label on umount error instead of directly returning -1.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemuProcessLaunch: Tighten rules for external devices wrt incoming migration
Michal Privoznik [Fri, 27 Jan 2023 12:59:08 +0000 (13:59 +0100)]
qemuProcessLaunch: Tighten rules for external devices wrt incoming migration

When starting a guest, helper processes are started first. But
they need a bit of special handling. Just consider a regular cold
boot and an incoming migration. For instance, in case of swtpm
with its state on a shared volume, we want to set label on the
state for the cold boot case, but don't want to touch the label
in case of incoming migration (because the source very
specifically did not restore it either).

Until now, these two cases were differentiated by testing
@incoming against NULL. And while that makes sense for other
aspects of domain startup, for external devices we need a bit
more, because a restore from a save file is also 'incoming
migration'.

Now, there is a difference between regular migration and restore
from a save file. In the former case we do not want to set
seclabels in the save state. BUT, in the latter case we do need
to set them, because the code that saves the machine restored
seclabels.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2161557
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemuExtTPMStop: Restore TPM state label more often
Michal Privoznik [Fri, 27 Jan 2023 09:46:55 +0000 (10:46 +0100)]
qemuExtTPMStop: Restore TPM state label more often

When stopping swtpm we can restore the label either on just the
swtpm's domain specific logfile (/var/log/swtpm/libvirt/qemu/...),
or on the logfile and the state too (/var/lib/libvirt/swtpm/...).

The deciding factor is whether the guest is stopped because of
outgoing migration OR the state is on a shared filesystem.

But this is not correct condition, because for instance saving the
guest into a file (virsh save) is also an outgoing migration.
Alternatively, when the swtpm state is stored on a shared
filesystem, but the guest is destroyed (virsh destroy), i.e.
stopped because of different reason than migration, we want to
restore the seclabels.

The correct condition is: skip restoring the state on outgoing
migration AND shared filesystem.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2161557
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemuProcessStop: Fix detection of outgoing migration for external devices
Michal Privoznik [Fri, 27 Jan 2023 09:45:50 +0000 (10:45 +0100)]
qemuProcessStop: Fix detection of outgoing migration for external devices

When cleaning up host in qemuProcessStop(), our external helper
processes (e.g. swtpm) want to know whether the domain is being
migrated out or not (so that they restore seclabels on a device
state that's on a shared storage).

This fact is reflected in the @outgoingMigration variable which
is set to true if asyncJob is anything but
VIR_ASYNC_JOB_MIGRATION_IN. Well, we have a specific job for
outgoing migration (VIR_ASYNC_JOB_MIGRATION_OUT) and thus we
should check for that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirhostdevtest: Decrease possibility of uninitialized @subsys
Michal Privoznik [Mon, 6 Feb 2023 15:03:44 +0000 (16:03 +0100)]
virhostdevtest: Decrease possibility of uninitialized @subsys

With the current way the myInit() is written, it's fairly easy to
miss initialization of @subsys variable as the variable is
allocated firstly on the stack and then it's assigned to
hostdev[i] which was allocated using g_new0() (this it is
containing nothing but all zeroes).

Make the subsys point to the corresponding member in hostdev[i]
from the start. This way only the important bits are overwritten
and the rest stays initialized to zero.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agovirhostdevtest: Initialize hostdev @subsys
Michal Privoznik [Mon, 6 Feb 2023 14:55:31 +0000 (15:55 +0100)]
virhostdevtest: Initialize hostdev @subsys

With recent work on storing original PCI stats in
_virDomainHostdevSubsysPCI struct, the virhostdevtest can across
a latent bug we had. Only some parts of the
virDomainHostdevSubsys structure are initialized. Incidentally,
subsys->u.pci.origstates is not one of them. This lead to
unexpected crashes at runtime.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agologging: use the log cleaner
Oleg Vasilev [Mon, 30 Jan 2023 15:00:02 +0000 (21:00 +0600)]
logging: use the log cleaner

Actually use the log cleaner introduced by previous commit.

Signed-off-by: Oleg Vasilev <oleg.vasilev@virtuozzo.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agologging: add log cleanup for obsolete domains
Oleg Vasilev [Mon, 30 Jan 2023 15:00:01 +0000 (21:00 +0600)]
logging: add log cleanup for obsolete domains

Before, logs from deleted machines have been piling up, since there were
no garbage collection mechanism. Now, virtlogd can be configured to
periodically scan the log folder for orphan logs with no recent modifications
and delete it.

A single chain of recent and rotated logs is deleted in a single transaction.

Signed-off-by: Oleg Vasilev <oleg.vasilev@virtuozzo.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agologging: add configuration for future log cleaner
Oleg Vasilev [Mon, 30 Jan 2023 15:00:00 +0000 (21:00 +0600)]
logging: add configuration for future log cleaner

We want to specify the folder to clean and how much time can a log
chain live.

Signed-off-by: Oleg Vasilev <oleg.vasilev@virtuozzo.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agologging: move virLogHandler to header
Oleg Vasilev [Mon, 30 Jan 2023 14:59:59 +0000 (20:59 +0600)]
logging: move virLogHandler to header

Signed-off-by: Oleg Vasilev <oleg.vasilev@virtuozzo.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agologging: refactor to store config inside log handler
Oleg Vasilev [Mon, 30 Jan 2023 14:59:58 +0000 (20:59 +0600)]
logging: refactor to store config inside log handler

Signed-off-by: Oleg Vasilev <oleg.vasilev@virtuozzo.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agoconf: Use proper type for 'type' field of struct _virDomainDeviceDef
Peter Krempa [Fri, 2 Dec 2022 13:55:02 +0000 (14:55 +0100)]
conf: Use proper type for 'type' field of struct _virDomainDeviceDef

Use virDomainDeviceType as type and update all switch statements which
didn't mention all possible values.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirDomainDeviceDefParse: Separate code for parsing type
Peter Krempa [Fri, 2 Dec 2022 13:46:42 +0000 (14:46 +0100)]
virDomainDeviceDefParse: Separate code for parsing type

Move the code into a new function named virDomainDeviceDefParseType. The
separation will make it easier to change the type of the 'type' field in
side of virDomainDeviceDef.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemuDomainGetStatsVcpu: Refactor cleanup
Peter Krempa [Thu, 2 Feb 2023 15:46:19 +0000 (16:46 +0100)]
qemuDomainGetStatsVcpu: Refactor cleanup

Automatically free 'cpuinfo' and remove the cleanup label and ret
variable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: agent: Use virJSONValueObjectGetArray
Peter Krempa [Thu, 2 Feb 2023 15:43:30 +0000 (16:43 +0100)]
qemu: agent: Use virJSONValueObjectGetArray

Replace virJSONValueObjectGet + virJSONValueIsArray by the single API
which returns only an array.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu_monitor_json: Replace simplify fetching Array from JSON object
Peter Krempa [Tue, 6 Dec 2022 14:29:28 +0000 (15:29 +0100)]
qemu_monitor_json: Replace simplify fetching Array from JSON object

Replace instances of virJSONValueObjectGet + virJSONValueIsArray by
virJSONValueObjectGetArray.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemuMonitorJSONQueryStats: Simplify logic to construct 'provider_list'
Peter Krempa [Wed, 9 Nov 2022 15:59:25 +0000 (16:59 +0100)]
qemuMonitorJSONQueryStats: Simplify logic to construct 'provider_list'

Simplify construction of a single provider by using
virJSONValueObjectAdd and restructuring the code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agovirbitmap: Allow NULL bitmap in functions returning index of a set/clear bit
Peter Krempa [Wed, 9 Nov 2022 15:54:56 +0000 (16:54 +0100)]
virbitmap: Allow NULL bitmap in functions returning index of a set/clear bit

virBitmapNextSetBit/virBitmapLastSetBit/virBitmapNextClearBit can be
used for iteration of a bitmap. Allow NULL bitmap so that iteration of a
bitmap can be simplified in certain cases.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoconf: Store 'origstates' of PCI hostdevs in a bitmap
Peter Krempa [Thu, 6 Oct 2022 11:17:00 +0000 (13:17 +0200)]
conf: Store 'origstates' of PCI hostdevs in a bitmap

Refactor the code to use a bitmap with an enum.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agoqemustatusxml2xmltest: Add test data for testing '<origstates>' of PCI hostdev
Peter Krempa [Thu, 2 Feb 2023 14:54:09 +0000 (15:54 +0100)]
qemustatusxml2xmltest: Add test data for testing '<origstates>' of PCI hostdev

The <origstates> XML element captures private data of a PCI device
needed to restore it after a VM is started. Unfortunately at the point
when it was added we didn't yet have the existing private data
infrastructure.

Since the element is parsed only in cases similar to the status XML we
need to test it there.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agovirBitmapIsBitSet: Allow NULL bitmap
Peter Krempa [Wed, 9 Nov 2022 15:54:56 +0000 (16:54 +0100)]
virBitmapIsBitSet: Allow NULL bitmap

The virBitmapIsBitSet API is a permissive one which returns false when
the bit is not set or is out of range. We can do the same if the bitmap
is NULL to aid certain situations when this can happen, but we don't
want to add extra checks.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agovirNetworkDHCPHostDefParseXML: Use virXMLNodeGetSubelement to find 'lease'
Peter Krempa [Fri, 2 Dec 2022 10:02:58 +0000 (11:02 +0100)]
virNetworkDHCPHostDefParseXML: Use virXMLNodeGetSubelement to find 'lease'

This also prevents a potential memleak when multiple elements would be
present.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agovirNetworkDHCPRangeDefParseXML: Use virXMLNodeGetSubelement to find 'lease'
Peter Krempa [Fri, 2 Dec 2022 10:02:58 +0000 (11:02 +0100)]
virNetworkDHCPRangeDefParseXML: Use virXMLNodeGetSubelement to find 'lease'

This also prevents a potential memleak when multiple elements would be
present.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agovirNetDevVPortProfileParse: Use virXMLNodeGetSubelement to find '<parameters>'
Peter Krempa [Fri, 2 Dec 2022 10:01:06 +0000 (11:01 +0100)]
virNetDevVPortProfileParse: Use virXMLNodeGetSubelement to find '<parameters>'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agovirPCIDeviceAddressParseXML: Use virXMLNodeGetSubelement to find 'zpci'
Peter Krempa [Thu, 1 Dec 2022 10:02:05 +0000 (11:02 +0100)]
virPCIDeviceAddressParseXML: Use virXMLNodeGetSubelement to find 'zpci'

Use the helper designed to find the subelement. A slight semantic
difference after this patch is that the first <zpci> element will be
considered instead of the last, but only one is expected in a valid XML.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agotools: Fix detection of remote libvirt access in virt-qemu-sev-validate
Jim Fehlig [Thu, 2 Feb 2023 18:04:20 +0000 (11:04 -0700)]
tools: Fix detection of remote libvirt access in virt-qemu-sev-validate

The VM's firmware path is not extracted from the XML when invoking
virt-qemu-sev-validate in insecure mode and connecting to the local libvirt

virt-qemu-sev-validate --insecure --tk tek-tik.bin --domain test-sev-es
ERROR: Cannot access firmware path remotely

The test for remote access compares the return value from socket.gethostname()
to the return value from conn.getHostname(). The former doesn't always return
the fqdn, whereas the latter does. Use socket.getfqdn() instead.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agodocs: Fix examples in virt-qemu-sev-validate man page
Jim Fehlig [Thu, 2 Feb 2023 18:00:18 +0000 (11:00 -0700)]
docs: Fix examples in virt-qemu-sev-validate man page

Some of the examples refer to virt-dom-sev-validate. Replace them with
the proper name.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2 years ago.gitignore: Ignore cscope and other *tags files
Martin Kletzander [Thu, 2 Feb 2023 14:47:43 +0000 (15:47 +0100)]
.gitignore: Ignore cscope and other *tags files

Commit f7114e61dbc2 cleaned up way too much and now that I have cscope
working again I noticed there are some files that ought to stay ignored.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agotools: use g_autofree more
Ján Tomko [Wed, 1 Feb 2023 15:08:22 +0000 (16:08 +0100)]
tools: use g_autofree more

Remove some obvious uses of VIR_FREE in favor of automatic cleanup.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoschema: storage: Allow interleaving of 'cipher' and 'ivgen' elements
Peter Krempa [Thu, 13 Oct 2022 16:46:24 +0000 (18:46 +0200)]
schema: storage: Allow interleaving of 'cipher' and 'ivgen' elements

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoschema: nodedev: Allow interleaving sub-elements of 'css' address type
Peter Krempa [Thu, 13 Oct 2022 16:29:55 +0000 (18:29 +0200)]
schema: nodedev: Allow interleaving sub-elements of 'css' address type

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoschema: nodedev: Allow interleaving of sub-elements of 'device'
Peter Krempa [Thu, 13 Oct 2022 16:29:49 +0000 (18:29 +0200)]
schema: nodedev: Allow interleaving of sub-elements of 'device'

Note that the schema doesn't allow us to represent the two branches of
optional <devnode type='dev'> and zero or more <devnode type='link'>
definitions, so I've merged them under the <zeroOrMore> case.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoschema: domain: Allow interleaving of 'inituser/initgroup' in 'osexe' definition
Peter Krempa [Thu, 13 Oct 2022 16:16:19 +0000 (18:16 +0200)]
schema: domain: Allow interleaving of 'inituser/initgroup' in 'osexe' definition

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoschema: domain: Allow interleaving of elements in 'osxen' definition
Peter Krempa [Thu, 13 Oct 2022 15:40:18 +0000 (17:40 +0200)]
schema: domain: Allow interleaving of elements in 'osxen' definition

The 'osxen' RNG type defines options for the <os> element in certain
modes. Allow interleaving of subelements recursively.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoschema: domain: Allow interleave of 'smartcard' subelements
Peter Krempa [Thu, 13 Oct 2022 14:22:22 +0000 (16:22 +0200)]
schema: domain: Allow interleave of 'smartcard' subelements

Allow interleave of the top level sub-elements as well as the
subelements in the 'host-certificates' mode. Note that '<interleave>'
doesn't work properly if there's multiple definitions of the same
sub-element in the interleave so for this patch I chose to '<group>' the
'certificate' subelements. Another options would require us to stop
enforcing that there's exactly 3 of them.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: Don't remove macvtaps on failed start
Michal Privoznik [Tue, 31 Jan 2023 09:24:01 +0000 (10:24 +0100)]
qemu: Don't remove macvtaps on failed start

If a domain is configured to create a macvtap/macvlan but the
target link already exists, startup fails (as expected) with:

  error: error creating macvtap interface test@eth0 (52:54:00:d9:0b:db): File exists

Okay, we could make that error message better, but that's not the
point. Since this error originated while generating cmd line
(the caller is qemuProcessStart(), transitively), the cleanup
after failed start is performed (qemuProcessStop()). Here,
virNetDevMacVLanDeleteWithVPortProfile() is called which removes
the macvtap interface we did not create (as it made us fail in
the first place).

Therefore, we need to track which macvtap/macvlan interface was
created successfully and remove only those.

You'll notice that only qemuProcessStop() has the new check. For
the (failed) hotplug case (qemuDomainAttachNetDevice()) this
function is already in place (the @iface_connected variable), or
not needed (qemuDomainRemoveNetDevice() - we're removing an
interface that was already attached to QEMU).

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2166235
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: Format and parse private data for virDomainNetDef
Michal Privoznik [Wed, 1 Feb 2023 08:02:19 +0000 (09:02 +0100)]
conf: Format and parse private data for virDomainNetDef

The virDomainNetDef struct has privateData (which is currently
used by QEMU driver to store FDs opened during cmd line building
phase and pass them onto cmd line).

Soon, we will need to store additional information that needs to
survive daemon restart. Let's introduce machinery for parsing and
formatting privateData.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirnetdevmacvlan: Drop G_GNUC_WARN_UNUSED_RESULT annotation for virNetDevMacVLanDelet...
Michal Privoznik [Wed, 1 Feb 2023 12:29:37 +0000 (13:29 +0100)]
virnetdevmacvlan: Drop G_GNUC_WARN_UNUSED_RESULT annotation for virNetDevMacVLanDeleteWithVPortProfile()

Every single caller of the
virNetDevMacVLanDeleteWithVPortProfile() function is calling it
wrapped inside of ignore_value() macro. This is because the
function is annotated as G_GNUC_WARN_UNUSED_RESULT. This makes no
sense. Drop the annotation and the macro envelope.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agodomain_conf: Rewrite virDomainChrSourceModeTypeFromString() using VIR_ENUM_IMPL()
Michal Privoznik [Wed, 1 Feb 2023 08:24:55 +0000 (09:24 +0100)]
domain_conf: Rewrite virDomainChrSourceModeTypeFromString() using VIR_ENUM_IMPL()

In domain_conf.c there's virDomainChrSourceModeTypeFromString()
which is open coded. Let's rewrite it using VIR_ENUM_DECL() +
VIR_ENUM_IMPL() combo.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agodomain_conf: Move virDomainNetVhostuserMode enum declaration
Michal Privoznik [Wed, 1 Feb 2023 08:24:27 +0000 (09:24 +0100)]
domain_conf: Move virDomainNetVhostuserMode enum declaration

While it's true that the virDomainNetVhostuserMode enum is used
solely in virDomainNetDefParseXML(), its placement just above the
function is rather unfortunate. Let's put it at the beginning of
the file with the rest of the enum declarations/implementations.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: fix a typo
Ján Tomko [Wed, 1 Feb 2023 12:12:20 +0000 (13:12 +0100)]
qemu: fix a typo

s/usw/use/

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: block: Properly handle FD-passed disk hot-(un-)plug
Peter Krempa [Tue, 31 Jan 2023 14:35:05 +0000 (15:35 +0100)]
qemu: block: Properly handle FD-passed disk hot-(un-)plug

The hotplug code paths need to be able to pass the FDs to the monitor to
ensure that hotplug works.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agoqemu: domain: Store fdset ID for disks passed to qemu via FD
Peter Krempa [Tue, 31 Jan 2023 14:30:51 +0000 (15:30 +0100)]
qemu: domain: Store fdset ID for disks passed to qemu via FD

To ensure that we can hot-unplug the disk including the associated fdset
we need to store the fdset ID in the status XML.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agoqemu: fd: Add helpers allowing storing FD set data in status XML
Peter Krempa [Tue, 31 Jan 2023 14:25:57 +0000 (15:25 +0100)]
qemu: fd: Add helpers allowing storing FD set data in status XML

Rollback of FD sets passed to qemu is also needed after possible restart
of libvirtd when we need to serialize the data into status XML. For this
purpose we need to access the fdset ID once it was passed to qemu and
potentially re-create a 'qemuFDPass' struct in passed state.

Introduce 'qemuFDPassNewPassed' and 'qemuFDPassIsPassed'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agoqemuFDPassTransferCommand: Mark that FD was passed
Peter Krempa [Tue, 31 Jan 2023 16:26:43 +0000 (17:26 +0100)]
qemuFDPassTransferCommand: Mark that FD was passed

Until now the code didn't expect that we'd want to rollback/detach a FD
passed on the commandline, but whith disk backend FD passing this can
happen.

Properly mark the 'qemuFDPass' object as passed to qemu even when it was
done on the commandline.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agoqemu: command: Handle FD passing commandline via qemuBuildBlockStorageSourceAttachDat...
Peter Krempa [Tue, 31 Jan 2023 13:37:40 +0000 (14:37 +0100)]
qemu: command: Handle FD passing commandline via qemuBuildBlockStorageSourceAttachDataCommandline

Copy the pointer to qemuFDPass into struct qemuBlockStorageSourceAttachData
so that it can be used from qemuBuildBlockStorageSourceAttachDataCommandline
rather than looping again in qemuBuildDiskSourceCommandLineFDs.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agoqemuStorageSourcePrivateDataFormat: Rename 'tmp' to 'objectsChildBuf'
Peter Krempa [Tue, 31 Jan 2023 14:19:58 +0000 (15:19 +0100)]
qemuStorageSourcePrivateDataFormat: Rename 'tmp' to 'objectsChildBuf'

Be consistent with other children buffer variable naming scheme.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agoqemu_fd: Remove declaration for 'qemuFDPassNewDirect'
Peter Krempa [Tue, 31 Jan 2023 14:23:54 +0000 (15:23 +0100)]
qemu_fd: Remove declaration for 'qemuFDPassNewDirect'

The function doesn't exist any more.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agostorageBackendCreateQemuImgSecretPath: Refactor cleanup
Peter Krempa [Thu, 8 Dec 2022 15:39:50 +0000 (16:39 +0100)]
storageBackendCreateQemuImgSecretPath: Refactor cleanup

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agolibxlMakeNetworkDiskSrc: Refactor cleanup
Peter Krempa [Thu, 8 Dec 2022 11:24:30 +0000 (12:24 +0100)]
libxlMakeNetworkDiskSrc: Refactor cleanup

Automatically unref the 'conn' object and remove the 'cleanup' section
and 'ret' variable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agovirStorageBackendISCSIDirectSetAuth: Use 'g_strndup' to '\0' terminate data
Peter Krempa [Thu, 8 Dec 2022 10:12:54 +0000 (11:12 +0100)]
virStorageBackendISCSIDirectSetAuth: Use 'g_strndup' to '\0' terminate data

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agovirStorageBackendISCSIDirectSetAuth: Refactor cleanup
Peter Krempa [Thu, 8 Dec 2022 10:13:53 +0000 (11:13 +0100)]
virStorageBackendISCSIDirectSetAuth: Refactor cleanup

Use automatic pointer for 'conn' and remove the 'cleanup' label and
'ret' variable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agovirStorageBackendISCSISetAuth: Use g_strndup to '\0' terminate data
Peter Krempa [Thu, 8 Dec 2022 10:18:34 +0000 (11:18 +0100)]
virStorageBackendISCSISetAuth: Use g_strndup to '\0' terminate data

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agovirStorageBackendISCSISetAuth: Refactor cleanup
Peter Krempa [Thu, 8 Dec 2022 10:19:23 +0000 (11:19 +0100)]
virStorageBackendISCSISetAuth: Refactor cleanup

Automatically free 'conn' and remove the 'cleanup' section and 'ret'
variable. 'datatypes.h' contains the declaration of the autoptr cleanup
function for virConnect.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agovirCryptoEncryptDataAESgnutls: Restructure control flow
Peter Krempa [Thu, 8 Dec 2022 11:44:27 +0000 (12:44 +0100)]
virCryptoEncryptDataAESgnutls: Restructure control flow

Prepare the buffer for encryption only after initializing the cipher, so
that there's just one failure point. This allows to remove the 'error'
label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agovirDomainNetDefFormat: Modernize <mac/> formatting
Michal Privoznik [Tue, 31 Jan 2023 15:45:07 +0000 (16:45 +0100)]
virDomainNetDefFormat: Modernize <mac/> formatting

The <source/> child element of <mac/> is formatted the old way.
Switch to virXMLFormatElement().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agovirDomainNetDefFormat: Simplify @sourceAttrBuf handling for some types of VIR_DOMAIN_NET
Michal Privoznik [Tue, 31 Jan 2023 16:35:55 +0000 (17:35 +0100)]
virDomainNetDefFormat: Simplify @sourceAttrBuf handling for some types of VIR_DOMAIN_NET

For VIR_DOMAIN_NET_TYPE_{SERVER,CLIENT,MCAST,UDP} we need to put
(optionally) 'address' attribute and 'port' attributes of
<source/> element. But the way we currently do that is
particularly verbose. It can be shortened using
virBufferEscapeString().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agovirDomainNetDefFormat: Modernize <source/> formatting
Michal Privoznik [Tue, 31 Jan 2023 15:41:19 +0000 (16:41 +0100)]
virDomainNetDefFormat: Modernize <source/> formatting

The <source/> child element of <interface/> is formatted the old
way. Switch to virXMLFormatElement().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agovirDomainNetDefFormat: Modernize <guest/> formatting
Michal Privoznik [Tue, 31 Jan 2023 12:42:13 +0000 (13:42 +0100)]
virDomainNetDefFormat: Modernize <guest/> formatting

The <guest/> child element of <interface/> is formatted the old
way. Switch to virXMLFormatElement(). Since this element is used
in LXC driver, this part of the function is tested by
lxcxml2xmltest (specifically lxc-ethernet* test cases).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agovirDomainNetDefFormat: Modernize <tune/> formatting
Michal Privoznik [Tue, 31 Jan 2023 09:46:59 +0000 (10:46 +0100)]
virDomainNetDefFormat: Modernize <tune/> formatting

The <tune/> child element of <interface/> is formatted the old
way. Switch to virXMLFormatElement().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agovirDomainNetDefFormat: Rename @attrBuf to @targetAttrBuf
Michal Privoznik [Tue, 31 Jan 2023 15:23:58 +0000 (16:23 +0100)]
virDomainNetDefFormat: Rename @attrBuf to @targetAttrBuf

The @attrBuf variable in virDomainNetDefFormat() is named too
broadly. It holds attribute buffer to the <target/> element.
Rename it to @targetAttrBuf then.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemuxml2xmloutdata: Turn net-mtu.xml into a symlink
Michal Privoznik [Tue, 31 Jan 2023 09:57:21 +0000 (10:57 +0100)]
qemuxml2xmloutdata: Turn net-mtu.xml into a symlink

There's nothing specific about net-mtu test. In fact, if device
addresses are filled in (and some elements reordered), we get the
same XML. Make those changes to the input XML and turn the output
XML to be a symlink.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoremote: Fix memory leak in remoteDomainMigrateFinish3*
Jiri Denemark [Thu, 26 Jan 2023 15:54:06 +0000 (16:54 +0100)]
remote: Fix memory leak in remoteDomainMigrateFinish3*

Theoretically, when remoteDomainMigrateFinish3* is called without a
pointer for storing migration cookie or its length (i.e., either
cookieout == NULL or cookieoutlen == NULL), we would leak the freshly
created virDomain object referenced by rv.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2 years agovirsh: Make domif-setlink work more than once
Michal Privoznik [Mon, 30 Jan 2023 09:55:22 +0000 (10:55 +0100)]
virsh: Make domif-setlink work more than once

In virsh, we have this convenient domif-setlink command, which is
just a wrapper over virDomainUpdateDeviceFlags() and which allows
setting link state of given guest NIC. It does so by fetching
corresponding <interface/> XML snippet and either putting <link
state=''/> into it, OR if the element already exists setting the
attribute to desired value. The XML is then fed into the update
API.

There's, however, a small bug in detecting the pre-existence of
the element and its attribute. The code looks at "link"
attribute, while in fact, the attribute is called "state".

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/426
Fixes: e575bf082ed4889280be07c986375f1ca15bb7ee
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoremote: Fix version annotation for remoteDomainFDAssociate
Jiri Denemark [Thu, 26 Jan 2023 15:12:00 +0000 (16:12 +0100)]
remote: Fix version annotation for remoteDomainFDAssociate

The API was added in libvirt 9.0.0.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agorpc: Use struct zero initializer for args
Michal Privoznik [Thu, 26 Jan 2023 15:48:50 +0000 (16:48 +0100)]
rpc: Use struct zero initializer for args

In a recent commit of v9.0.0-104-g0211e430a8 I've turned all args
vars in src/remote/remote_driver.c to be initialized wit {0}.
What I've missed was the generated code.

Do what we've done in v9.0.0-13-g1c656836e3 and init also args,
not just ret.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agoqemuxml2argvdata: Fix missing device in crypto-builtin XML
Martin Kletzander [Thu, 26 Jan 2023 15:57:20 +0000 (16:57 +0100)]
qemuxml2argvdata: Fix missing device in crypto-builtin XML

Another forgotten fix after a post-review rebase.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2 years agoqemuxml2argvdata: Fix watchdog parameters in crypto-builtin
Martin Kletzander [Thu, 26 Jan 2023 15:57:20 +0000 (16:57 +0100)]
qemuxml2argvdata: Fix watchdog parameters in crypto-builtin

Forgotten fix after a post-review rebase.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2 years agonews: Add information about iTCO watchdog changes
Martin Kletzander [Fri, 20 Jan 2023 17:22:34 +0000 (18:22 +0100)]
news: Add information about iTCO watchdog changes

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoDocument change to multiple watchdogs
Martin Kletzander [Fri, 20 Jan 2023 17:22:30 +0000 (18:22 +0100)]
Document change to multiple watchdogs

With the reasoning behind it.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: Add implicit watchdog for q35 machine types
Martin Kletzander [Fri, 20 Jan 2023 10:22:22 +0000 (11:22 +0100)]
qemu: Add implicit watchdog for q35 machine types

The iTCO watchdog is part of the q35 machine type since its inception,
we just did not add it implicitly.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: Enable iTCO watchdog by disabling its noreboot pin strap
Martin Kletzander [Fri, 20 Jan 2023 13:15:06 +0000 (14:15 +0100)]
qemu: Enable iTCO watchdog by disabling its noreboot pin strap

In order for the iTCO watchdog to be operational we must disable the
noreboot pin strap in qemu.  This is the default starting from 8.0
machine types, but desirable for older ones as well.  And we can safely
do that since that is not guest-visible.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoAdd iTCO watchdog support
Martin Kletzander [Fri, 20 Jan 2023 09:26:21 +0000 (10:26 +0100)]
Add iTCO watchdog support

Supported only with q35 machine types.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoSupport multiple watchdog devices
Martin Kletzander [Tue, 8 Nov 2022 08:10:57 +0000 (09:10 +0100)]
Support multiple watchdog devices

This is already possible with qemu, and actually already happening with
q35 machines and a specified watchdog since q35 already includes a
watchdog we do not include in the XML.  In order to express such
posibility multiple watchdogs need to be supported.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemuDomainAttachWatchdog: Avoid unnecessary nesting
Martin Kletzander [Fri, 20 Jan 2023 09:28:52 +0000 (10:28 +0100)]
qemuDomainAttachWatchdog: Avoid unnecessary nesting

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoremote: Drop useless cleanup in remoteDispatchNodeGet{CPU,Memory}Stats
Jiri Denemark [Wed, 25 Jan 2023 14:25:06 +0000 (15:25 +0100)]
remote: Drop useless cleanup in remoteDispatchNodeGet{CPU,Memory}Stats

The function cannot fail once it starts populating
ret->params.params_val[i].field.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoremote: Avoid leaking uri_out
Jiri Denemark [Wed, 25 Jan 2023 14:06:33 +0000 (15:06 +0100)]
remote: Avoid leaking uri_out

In case the API returned success and a NULL pointer in uri_out, we would
leak the preallocated buffer used for storing the uri_out pointer.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoremote: Propagate error from virDomainGetSecurityLabelList via RPC
Jiri Denemark [Wed, 25 Jan 2023 10:56:28 +0000 (11:56 +0100)]
remote: Propagate error from virDomainGetSecurityLabelList via RPC

The daemon side of this API has been broken ever since the API was
introduced in 2012. Instead of sending the error from
virDomainGetSecurityLabelList via RPC so that the client can see it, the
dispatcher would just send a successful reply with return value set to
-1 (and an empty array of labels). The client side would propagate this
return value so the client can see the API failed, but the original
error would be lost.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoremote: Initialize args variable
Michal Privoznik [Thu, 26 Jan 2023 12:19:31 +0000 (13:19 +0100)]
remote: Initialize args variable

Recently, in v9.0.0-7-gb2034bb04c we've dropped initialization of
@args variable. The reasoning was that eventually, all members of
the variable will be set. Well, this is not correct. For
instance, in remoteConnectGetAllDomainStats() the
args.doms.doms_val pointer is set iff @ndoms != 0. However,
regardless of that, the pointer is then passed to VIR_FREE().

Worse, the whole args is passed to
xdr_remote_connect_get_all_domain_stats_args() which then calls
xdr_array, which tests the (uninitialized) pointer against NULL.

This effectively reverts b2034bb04c61c75ddbfbed46879d641b6f8ca8dc.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agoqemu_domain: Don't unref NULL hash table in qemuDomainRefreshStatsSchema()
Michal Privoznik [Thu, 26 Jan 2023 10:56:10 +0000 (11:56 +0100)]
qemu_domain: Don't unref NULL hash table in qemuDomainRefreshStatsSchema()

The g_hash_table_unref() function does not accept NULL. Passing
NULL results in a glib warning being triggered. Check whether the
hash table is not NULL and unref it only then.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoNEWS: Document 'crypto' device
zhenwei pi [Tue, 17 Jan 2023 01:46:54 +0000 (09:46 +0800)]
NEWS: Document 'crypto' device

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: command: support crypto device
zhenwei pi [Tue, 17 Jan 2023 01:46:53 +0000 (09:46 +0800)]
qemu: command: support crypto device

Support virtio-crypto device, also support cryptodev types:
- builtin
- lkcf

Finally, we can launch a VM(QEMU) with one or more crypto devices by
libvirt.

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: alias: support crypto device
zhenwei pi [Tue, 17 Jan 2023 01:46:52 +0000 (09:46 +0800)]
qemu: alias: support crypto device

Support 'cryptoX' alias for a crypto device.

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agocapabilities: introduce crypto device
zhenwei pi [Tue, 17 Jan 2023 01:46:51 +0000 (09:46 +0800)]
capabilities: introduce crypto device

Changes in this commit:
- docs: formatdomaincaps.rst
- conf: crypto related domain caps
- qemu: crypto related
- tests: crypto related test

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoconf: introduce crypto device
zhenwei pi [Tue, 17 Jan 2023 01:46:50 +0000 (09:46 +0800)]
conf: introduce crypto device

Introduce crypto device like:

  <crypto model='virtio' type='qemu'>
    <backend model='builtin' queues='1'/>
    <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
  </crypto>

  <crypto model='virtio' type='qemu'>
    <backend model='lkcf'/>
    <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/>
  </crypto>

Currently, crypto model supports virtio only, type supports qemu only
(vhost-user in the plan). For the qemu type, backend supports modle
builtin/lkcf, and the queues is optional.

Changes in this commit:
- docs: formatdomain.rst
- schemas: domaincommon.rng
- conf: crypto related domain conf
- qemu: crypto related
- tests: crypto related test

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agotests: add QEMU RISC-V "virt" machine in domaincapstest
Daniel Henrique Barboza [Wed, 4 Jan 2023 18:39:59 +0000 (15:39 -0300)]
tests: add QEMU RISC-V "virt" machine in domaincapstest

'domaincapstest' is currently skipping RISC-V tests. Let's enable it.

The decision of enabling the "virt" machine is based on the idea that
this is the most used QEMU RISC-V machine in the community and it's the
most likely to be widely supported in the long run.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
2 years agotests: update RISC-V QEMU caps for QEMU 8.0.0
Daniel Henrique Barboza [Wed, 4 Jan 2023 18:23:38 +0000 (18:23 +0000)]
tests: update RISC-V QEMU caps for QEMU 8.0.0

Update RISC-V capabilities for the QEMU 8.0.0 cycle. Changes made are
based on the JSONification of device parameters.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
2 years agosrc/cpu: add a basic RiscV64 cpu driver
Daniel Henrique Barboza [Fri, 6 Jan 2023 16:49:56 +0000 (13:49 -0300)]
src/cpu: add a basic RiscV64 cpu driver

There are tests in qemuxml2argvtest that will fail if we enable RISC-V
testing, with an error like the following:

"cpuGetSubDriver:64 : this function is not supported by the connection
driver: 'riscv64' architecture is not supp orted by CPU driver"

This happens because we don't have a RISC-V driver yet.

Add a barebone RISC-V driver to allow tests to be executed. The only 2
callbacks implemented here are 'compare' and 'validateFeatures', both
acting as a no-op. More callbacks and features will be added in the
future.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
2 years agorpc: Fix error message in virNetServerSetClientLimits
Martin Kletzander [Tue, 24 Jan 2023 12:45:09 +0000 (13:45 +0100)]
rpc: Fix error message in virNetServerSetClientLimits

Commit f007940cb25a tried to change the error message so that it is unified
later in 35afa1d2d6c1, but various rewrites missed this particular error message
which does not make sense.  Fix it so that it is the same as the other two
messages checking the same thing in this file.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: Remove 'memAliasOrderMismatch' field from VM private data
Peter Krempa [Thu, 19 Jan 2023 14:18:45 +0000 (15:18 +0100)]
qemu: Remove 'memAliasOrderMismatch' field from VM private data

The field is no longer used so we can remove it and the code filling it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agoqemu: alias: Remove 'oldAlias' argument of qemuAssignDeviceMemoryAlias
Peter Krempa [Thu, 19 Jan 2023 14:16:58 +0000 (15:16 +0100)]
qemu: alias: Remove 'oldAlias' argument of qemuAssignDeviceMemoryAlias

All callers pass 'false' so we no longer need it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agoqemu: hotplug: Remove legacy quirk for 'dimm' address generation
Peter Krempa [Thu, 19 Jan 2023 14:06:11 +0000 (15:06 +0100)]
qemu: hotplug: Remove legacy quirk for 'dimm' address generation

Commit b7798a07f93 (in fall of 2016) changed the way we generate aliases
for 'dimm' memory devices as the alias itself is part of the migration
stream section naming and thus must be treated as ABI.

The code added compatibility layer for VMs with memory hotplug started
with the old scheme to prevent from generating wrong aliases. The
compatibility layer broke though later when 'nvdimm' and 'pmem' devices
were introduced as it wrongly detected them as old configuration.

Now rather than attempting to fix the legacy compat layer to treat other
devices properly we'll be better off simply removing it as it's
extremely unlikely that somebody has a VM started in 2016 running with
today's libvirt and attempts to hotplug more memory.

This fixes a corner case when a user hot-adds a 'dimm' into a VM with a
'dimm' and a 'nvdimm' after restart of libvirtd and then attempts to
migrate the VM.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2158701
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agovirnetlibsshsession: Don't check return value of 'virNetLibsshSessionAuthMethodNew'
Peter Krempa [Mon, 23 Jan 2023 15:41:55 +0000 (16:41 +0100)]
virnetlibsshsession: Don't check return value of 'virNetLibsshSessionAuthMethodNew'

The function can't return NULL to the callers so it doesn't make sense
to check it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirNetLibsshSessionAuthAddPasswordAuth: Don't access unlocked 'sess'
Peter Krempa [Mon, 23 Jan 2023 15:48:19 +0000 (16:48 +0100)]
virNetLibsshSessionAuthAddPasswordAuth: Don't access unlocked 'sess'

'sess->authPath' is modified before locking the 'sess' object.
Additionally on failure of 'virAuthGetConfigFilePathURI' 'sess' would be
unlocked even when it was not yet locked.

Fixes: 6917467c2b0e8f655999f3e568708c4651811689
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirnetsshsession: Don't check return value of 'virNetSSHSessionAuthMethodNew'
Peter Krempa [Mon, 23 Jan 2023 15:41:55 +0000 (16:41 +0100)]
virnetsshsession: Don't check return value of 'virNetSSHSessionAuthMethodNew'

The function can't return NULL to the callers so it doesn't make sense
to check it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirNetSSHSessionAuthAddPasswordAuth: Don't access unlocked 'sess'
Peter Krempa [Mon, 23 Jan 2023 15:40:00 +0000 (16:40 +0100)]
virNetSSHSessionAuthAddPasswordAuth: Don't access unlocked 'sess'

'sess->authPath' is modified before locking the 'sess' object.
Additionally on failure of 'virAuthGetConfigFilePathURI' 'sess' would be
unlocked even when it was not yet locked.

Fixes: 273745b43122a77adf8c73b2e0a852ac42387349
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoutil: authconfig: Don't check return value of 'g_key_file_new()'
Peter Krempa [Mon, 23 Jan 2023 15:36:43 +0000 (16:36 +0100)]
util: authconfig: Don't check return value of 'g_key_file_new()'

The function can't fail so it's pointless to check its return value.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovbox: Stop reporting RC in error messages
Michal Privoznik [Sat, 21 Jan 2023 11:11:08 +0000 (12:11 +0100)]
vbox: Stop reporting RC in error messages

As shown in the commit that introduced vboxReportError(), we are
appending the retval of a failed VirtualBox API onto our error
messages. Well, this is no longer needed because
vboxReportError() already appends the VirtualBox error in plain
text.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agovbox: Move error messages onto a single line
Michal Privoznik [Sat, 21 Jan 2023 10:07:31 +0000 (11:07 +0100)]
vbox: Move error messages onto a single line

Our coding style suggests error messages to be on a single line
for easier git grep. Since I'm touching them anyways, let's make
them follow our own suggestion.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>