Commit Graph

44877 Commits

Author SHA1 Message Date
Michal Privoznik
96d72b461f conf: Fix @tickpolicy member of _virDomainTimerDef struct
The @tickpolicy member of the _virDomainTimerDef struct stores
values of the virDomainTimerTickpolicyType enum, or -1 for the
default value (when user provided no value in XML).

This is needlessly complicated. Introduce new value to the enum
which reflects the default state.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-26 10:49:20 +01:00
Michal Privoznik
754a7f6c94 conf: Fix type of @present in _virDomainTimerDef struct
In the _virDomainTimerDef structure we have @present member which
is like virTristateBool, except it's an integer and has values
shifted by one. This is harder to read. Retype the member to
virTristateBool which we are familiar with.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-26 10:49:18 +01:00
Michal Privoznik
9198b7090b virDomainChrSourceDefCopy: return void
This function never returns an error, make it void then. And
while at it, make the @src argument const to make it obvious it's
never changed inside the function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-26 10:49:17 +01:00
Michal Privoznik
7e57285eec virDomainChrSourceDefCopy: Don't check arguments against NULL
The only caller of this function
(qemuProcessFindCharDevicePTYsMonitor()) doesn't pass NULL.
Remove corresponding check from virDomainChrSourceDefCopy().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-26 10:49:14 +01:00
Michal Privoznik
8af76c3764 virDomainChrSourceDefCopy: Copy more struct members
The aim of virDomainChrSourceDefCopy() is to make a deep copy of
given virDomainChrSourceDef. However, some types were not copied
at all (VIR_DOMAIN_CHR_TYPE_SPICEVMC and
VIR_DOMAIN_CHR_TYPE_SPICEPORT) and some members weren't copied
either (@logfile, @logappend).

After this, there are still some members that are not copied
(seclabels and private data), but the sole caller
qemuProcessFindCharDevicePTYsMonitor() doesn't seem to care.
Therefore, just document this behavior so that future user is
aware.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-26 10:49:11 +01:00
Michal Privoznik
3de95c3d51 virDomainInputDefParseXML: Move validation into validator
There is some code that validates whether parsed @bus <input/>
makes sense (e.g. some hypervisors have their own type of bus).
But this code should not live in the parser, but validator
rather. That way, we can also validate that the value we compute
(if user didn't provide any) is valid.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-26 10:49:03 +01:00
Peter Krempa
ddb2384f0c qemuDomainSetupDisk: Initialize 'targetPaths'
Compiler isn't able to see that 'virDevMapperGetTargets' in cases e.g.
when the devmapper isn't available may not initialize the value in the
pointer passed as the second argument.

The usage 'qemuDomainSetupDisk' lead to an accidental infinite loop as
previous calls apparently doctored the stack to a point where
'g_slist_concat' would end up in an infinite loop trying to find the end
of the list.

Fixes: 6c49c2ee9f
Closes: https://gitlab.com/libvirt/libvirt/-/issues/268
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-01-26 09:24:59 +01:00
Olaf Hering
7d54a29138 meson: recognize sles when guessing default_qemu_user
NAME="SLES"
VERSION="15-SP3"
VERSION_ID="15.3"
PRETTY_NAME="SUSE Linux Enterprise Server 15 SP3"
ID="sles"
ID_LIKE="suse"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:suse:sles:15:sp3"
DOCUMENTATION_URL="https://documentation.suse.com/"

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-01-25 18:09:09 +01:00
Roman Bolshakov
5f27793b28 news: Mention hvf domain type
Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Brad Laue <brad@brad-x.com>
Tested-by: Christophe Fergeau <cfergeau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2022-01-25 16:54:44 +01:00
Roman Bolshakov
3ff4ff4831 docs: Add support page for libvirt on macOS
Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Brad Laue <brad@brad-x.com>
Tested-by: Christophe Fergeau <cfergeau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2022-01-25 16:54:44 +01:00
Roman Bolshakov
9a5306ba2f docs: Note hvf support for domain elements
Many domain elements have "QEMU and KVM only" or "QEMU/KVM since x.y.z"
remarks. Most of the elements work for HVF domain, so it makes sense to
add respective notices for HVF domain.

All the elements have been manually tested.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Brad Laue <brad@brad-x.com>
Tested-by: Christophe Fergeau <cfergeau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2022-01-25 16:54:44 +01:00
Roman Bolshakov
44863b37c1 docs: Add hvf on QEMU driver page
It's worth to make the domain type a little bit more visible than a row
in news. An example of hvf domain is available on QEMU driver page.

While at it, mention Hypervisor.framework on index page.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Brad Laue <brad@brad-x.com>
Tested-by: Christophe Fergeau <cfergeau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2022-01-25 16:54:44 +01:00
Andrea Bolognani
299d48d574 tests: Add HVF test cases
We need to use a hardcoded list of capabilities because we don't
yet have proper replies files obtained from QEMU running on actual
macOS machines.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Brad Laue <brad@brad-x.com>
Tested-by: Christophe Fergeau <cfergeau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2022-01-25 16:54:44 +01:00
Andrea Bolognani
ebb921cb37 tests: Add macOS support to qemuxml2*test
The new DO_TEST_MACOS() macro makes it possible to create test
cases that verify the behavior of libvirt on a macOS machine
with HVF support available.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Brad Laue <brad@brad-x.com>
Tested-by: Christophe Fergeau <cfergeau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2022-01-25 16:54:44 +01:00
Andrea Bolognani
5fd9ddfa1f tests: Add macOS support to testutilsqemu
This exposes a couple of macOS-specific variants of existing
APIs, which can be used when implementing test programs and
result in HVF support being advertised.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Brad Laue <brad@brad-x.com>
Tested-by: Christophe Fergeau <cfergeau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2022-01-25 16:54:44 +01:00
Andrea Bolognani
f16626ccd7 tests: Introduce testQemuHostOS
This new enumeration provides a way to specify the host OS
that a specific test case expects. The default is Linux, which
has been the implicit host OS until now; when Linux is selected
as the host OS, KVM support is advertised in capabilies data
exposed to test cases.

This commit doesn't result in any functional change, and simply
sets the stage for introducing macOS host OS support later.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Brad Laue <brad@brad-x.com>
Tested-by: Christophe Fergeau <cfergeau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2022-01-25 16:54:44 +01:00
Roman Bolshakov
244542f3bf qemu: Correct CPU capabilities probing for hvf
With this change virsh domcapabilites shows:

  <mode name='host-passthrough' supported='yes'/>

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

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Brad Laue <brad@brad-x.com>
Tested-by: Christophe Fergeau <cfergeau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2022-01-25 16:54:44 +01:00
Roman Bolshakov
6b94f4d1b1 qemu: Introduce virQEMUCapsHaveAccel
The function should be used to check if qemu capabilities include a
hardware acceleration, i.e. accel is not TCG.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Brad Laue <brad@brad-x.com>
Tested-by: Christophe Fergeau <cfergeau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2022-01-25 16:54:43 +01:00
Roman Bolshakov
a8643c53fb qemu: Introduce virQEMUCapsTypeIsAccelerated
It replaces hardcoded checks for KVM. It'll be cleaner to use
the function once multiple accelerators are supported in the
QEMU driver.

Explicit KVM domain checks should be done only when a feature is
available only for KVM.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Brad Laue <brad@brad-x.com>
Tested-by: Christophe Fergeau <cfergeau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2022-01-25 16:54:40 +01:00
Roman Bolshakov
9c56dae1cb qemu: Introduce virQEMUCapsAccelStr
This makes possible to add more accelerators by touching less code and
reduces code duplication.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Brad Laue <brad@brad-x.com>
Tested-by: Christophe Fergeau <cfergeau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2022-01-25 16:54:27 +01:00
Roman Bolshakov
c6bf66e1ee qemu: Expose hvf domain type if hvf is supported
Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Brad Laue <brad@brad-x.com>
Tested-by: Christophe Fergeau <cfergeau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2022-01-25 16:53:39 +01:00
Roman Bolshakov
a339c27b15 qemu: Query hvf capability on macOS
There's no QMP command for querying if hvf is supported, therefore we
use sysctl interface that tells if Hypervisor.framework works/available
on the host.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Brad Laue <brad@brad-x.com>
Tested-by: Christophe Fergeau <cfergeau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2022-01-25 16:53:39 +01:00
Roman Bolshakov
171b5ee844 qemu: Define hvf capability
Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Brad Laue <brad@brad-x.com>
Tested-by: Christophe Fergeau <cfergeau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2022-01-25 16:53:39 +01:00
Roman Bolshakov
bb9373d096 conf: Add hvf domain type
QEMU supports Hypervisor.framework since 2.12 as hvf accel.
Hypervisor.framework provides a lightweight interface to run a virtual
cpu on macOS without the need to install third-party kernel
extensions (KEXTs).

It's supported since macOS 10.10 on machines with Intel VT-x feature
set that includes Extended Page Tables (EPT) and Unrestricted Mode.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Brad Laue <brad@brad-x.com>
Tested-by: Christophe Fergeau <cfergeau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2022-01-25 16:53:39 +01:00
Roman Bolshakov
4794458c8d qemu: Add KVM CPUs into cache only if KVM is present
virQEMUCapsFormatCache/virQEMUCapsLoadCache adds/reads KVM CPUs to/from
capabilities cache regardless of QEMU_CAPS_KVM. That can cause undesired
side-effects when KVM CPUs are present in the cache on a platform that
doesn't support it, e.g. macOS or Linux without KVM support.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Brad Laue <brad@brad-x.com>
Tested-by: Christophe Fergeau <cfergeau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2022-01-25 16:53:39 +01:00
Andrea Bolognani
8885cd9a76 qemu: Only probe KVM on Linux
We already know it's not going to be available on other
platforms.

Suggested-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Brad Laue <brad@brad-x.com>
Tested-by: Christophe Fergeau <cfergeau@redhat.com>
Reviewed-by: Ani Sinha <ani@anisinha.ca>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2022-01-25 16:53:39 +01:00
Jim Fehlig
31e937fb3b libxl: Add lock process indicator to saved VM state
Commit fa58f571ee added a lock processes indicator to the
libxlDomainObjPrivate struct to note that a lock process was
successfully started for the VM. However, the commit neglected to
add the indicator to the VM's saved state file. As a result, the
indicator is lost on libvirtd restart, along with the knowledge of
whether a lock process was started for the VM.

This change adds support for the indicator in the domainObjPrivate
data parse and format callbacks, ensuring its value survives libvirtd
restarts.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-01-25 08:50:19 -07:00
Nicolas Lécureuil
673b74be5f conf: network: Allow hostnames to start with a number
RFC952 mandated that hostnames would start with an alpha character.
This requirement was later relaxed by RFC1123 which allowed hostnames to
start with a number as well.

https://datatracker.ietf.org/doc/html/rfc952
https://datatracker.ietf.org/doc/html/rfc1123#page-13

Signed-off-by: Nicolas Lécureuil <nicolas.lecureuil@siveo.net>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-01-25 15:47:05 +01:00
Michal Privoznik
e185f03f39 qemuDomainAttachHostPCIDevice: Fix coding style
Our coding style requires that a body of an if() longer than two
lines is wrapped in a curly braces. There's one offender in
qemuDomainAttachHostPCIDevice(). Fortunately, there was no
functional problem because one of the lines is a comment.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2022-01-25 12:38:40 +01:00
Han Han
fa6e29f978 docs: Mention the types of params in event callbacks
Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-01-24 15:21:54 +01:00
Han Han
d29d153fd9 docs: Fix typos in the code comment
1. s/LifeCycle/Lifecycle/
2. s/virConnectDomainEventTrayChangeReason/virDomainEventTrayChangeReason/

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-01-24 15:21:49 +01:00
Göran Uddeborg
d1f89a9d28 Translated using Weblate (Swedish)
Currently translated at 31.9% (3336 of 10455 strings)

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

Co-authored-by: Göran Uddeborg <goeran@uddeborg.se>
Signed-off-by: Göran Uddeborg <goeran@uddeborg.se>
2022-01-24 10:21:35 +01:00
shenjiatong
7bc7304ca5 qemu: Remove scsi parameter for vhost-user-blk for qemu < 4.2
When trying to attach vhost-user-blk device to virtual machine using
qemu < 4.2 libvirt would mistakenly add a scsi=off parameter, which is
not supported by qemu.

Fixes: https://gitlab.com/libvirt/libvirt/-/issues/265
Signed-off-by: shenjiatong <yshxxsjt715@gmail.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-01-24 10:17:00 +01:00
Peter Krempa
5e645b80f4 qemuxml2argvtest: disk-vhostuser: Add invocation for qemu-4.2
With qemu versions prior to qemu-5.0 we'll format 'scsi=off' for
virtio-blk disks, but also for vhost-user-blk. This is a bug as it's not
supported.

Add a test case to show that wrong configuration is generated by adding
running 'disk-vhostuser' test case on capabilities from qemu-4.2.

For this to be possible it's required to enable shared memory via NUMA
configuration as old QEMU's don't allow configuration of the default
memory backend. This is achieved by adding a copy of the
'disk-vhostuser' XML with NUMA enabled.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2022-01-24 10:17:00 +01:00
Martin Kletzander
4c69d64efa meson: Explicitly specify run_command's check parameter
An update to meson 0.61.1 meant that it started showing warnings due to the fact
that the default for run_command's 'check' parameter is going to change.  It
unveiled the fact that we were even missing that parameter in some calls where
we expected different outcome.  To make sure the behaviour does not change
specify the parameter explicitly.  In places where we check for the return code
the parameter should be 'false' so that meson does not fail.  In all other cases
the parameter should be set to 'true' to make sure possible failure also stops
meson.

The warning in meson was added in https://github.com/mesonbuild/meson/pull/9304

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
2022-01-24 09:54:35 +01:00
Martin Kletzander
2e2c9797c5 esx: Do not return root objects in a lookup
The lookups in esx_vi work a bit differently that we are used to.  The filters
(travelsalSpec and selectSet) choose how to look up the objects, but given a
root object the lookup lists all the objects of a requested type inside it as
well as the root object itself.  We then go through the results and find the one
which has the same name as was requested.  However in a case with nested folders
of a same name this could break when the first returned object in the list is
the parent folder as we'd select it only based on the name.  To avoid this also
add a check that the candidate we are trying to pick is not exactly the same
object (reference) as the root object.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
2022-01-24 09:54:24 +01:00
Tim Wiederhake
088bb9cebe docs: Fix spelling
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
2022-01-24 09:41:44 +01:00
Ján Tomko
eee062d7a2 bhyve: handle all enum values in switches
Recent commits switched some variables to enums but did not
fix the warnings in the bhyve driver.

Fixes: 0eb42087c7
Fixes: a1ce98061c
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2022-01-21 18:20:58 +01:00
Michal Privoznik
bdb95b520c conf: Convert virDomainHostdevDefParseXMLSubsys() to virXMLProp*()
After previous cleanups, the virDomainHostdevDefParseXMLSubsys()
function uses a mixture of virXMLProp*() and the old
virXMLPropString() + virXXXTypeFromString() patterns. Rework it
so that virXMLProp*() is used.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-21 16:42:14 +01:00
Michal Privoznik
af5a7dba78 conf: Convert virNetworkPortDefParseXML() to virXMLProp*()
After previous cleanups, the virNetworkPortDefParseXML() function
uses a mixture of virXMLProp*() and the old virXMLPropString() +
virXXXTypeFromString() patterns. Rework it so that virXMLProp*()
is used.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-21 16:42:14 +01:00
Michal Privoznik
97129ed43a conf: Convert virDomainNetDefParseXML() to virXMLProp*()
After previous cleanups, the virDomainNetDefParseXML() function
uses a mixture of virXMLProp*() and the old virXMLPropString() +
virXXXTypeFromString() patterns. Rework it so that virXMLProp*()
is used.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-21 16:42:14 +01:00
Michal Privoznik
a1ce98061c conf: Convert virDomainFSDefParseXML() to virXMLProp*()
After previous cleanups, the virDomainFSDefParseXML() function
uses a mixture of virXMLProp*() and the old virXMLPropString() +
virXXXTypeFromString() patterns. Rework it so that virXMLProp*()
is used.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-21 16:42:14 +01:00
Michal Privoznik
0eb42087c7 conf: Convert virDomainDefParseBootXML() to virXMLProp*()
After previous cleanups, the virDomainDefParseBootXML() function
uses a mixture of virXMLProp*() and the old virXMLPropString() +
virXXXTypeFromString() patterns. Rework it so that virXMLProp*()
is used.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-21 16:42:14 +01:00
Michal Privoznik
0aaf410262 conf: Convert virCPUDefParseXML() to virXMLProp*()
After previous cleanups, the virCPUDefParseXML() function uses a
mixture of virXMLProp*() and the old virXMLPropString() +
virXXXTypeFromString() patterns. Rework it so that virXMLProp*()
is used.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-21 16:42:14 +01:00
Michal Privoznik
0fe2d8dd33 lib: Almost eliminate use of virTristateBoolTypeFromString()
There are couple of places where virTristateBoolTypeFromString()
is called. Well, the same result can be achieved by
virXMLPropTristateBool() and on fewer lines.

Note there are couple of places left untouched because those
don't care about error reporting and thus are shorter they way
they are now.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-21 16:42:13 +01:00
Michal Privoznik
9086ae4fac lib: Eliminate use of virTristateSwitchTypeFromString()
There are couple of places (all of them in XML parsing) where
virTristateSwitchTypeFromString() is called. Well, the same
result can be achieved by virXMLPropTristateSwitch() and on fewer
lines.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-21 16:42:13 +01:00
Michal Privoznik
5a33dd25c1 qemu: Use virTristateBool instead of virTristateSwitch in a few places
Both @accel2d and @accel3d are parsed as virTristateBool, but in
a few places (qemuDeviceVideoGetModel() and
qemuValidateDomainDeviceDefVideo()) they are compared to
virTristateSwitch enum either directly or via a variable of that
type. Clear this confusion by using the correct enum.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-21 16:42:13 +01:00
Michal Privoznik
2ab0a346bf qemuValidateDomainDeviceDefFS: Use correct enum for fs->multidevs comparison
During validation of a virDomainFSDef QEMU capabilities are check
for multidevs support if the FS definition has it enabled.
However, the fs->multidevs is really type of virDomainFSMultidevs
but is compared against virDomainFSModel enum. Fortunately, both
values are the same so no user visible harm done here.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-21 16:42:13 +01:00
Michal Privoznik
6690a97b06 virNetworkPortDefParseXML: Fix a typo in an error message
There's a typo in error message that's printed when parsing of
<plug type=''/> fails: "prt" is reported instead of "port".

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-21 16:42:13 +01:00
Michal Privoznik
7b64a83ae2 virxml: Extend virXMLPropU{Int,LongLong}() error message
In case virXMLPropUInt() or virXMLPropULongLong() meets an
attribute with a negative integer the following error message is
printed:

  Invalid value ...: Expected integer value

This message is not as good as it could be. Let users know it's a
non-negative integer we are expecting.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-21 16:42:13 +01:00