]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
4 years agomeson: merge all cc_flags arrays into one
Daniel P. Berrangé [Thu, 8 Apr 2021 10:23:03 +0000 (11:23 +0100)]
meson: merge all cc_flags arrays into one

The split of arrays is fairly arbitrary and a hang over from the way we
had to structure lists of flags when we used GNULIB's compiler flag
checking m4 logic.

The separate lists leads to cases where we enable a flag in one list and
have contradictory setting in another list, which leads to confusion.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agomeson: remove obsolete comment about stack frame size
Daniel P. Berrangé [Thu, 8 Apr 2021 12:57:55 +0000 (13:57 +0100)]
meson: remove obsolete comment about stack frame size

The virStrerror function no longer exists in libvirt so is not a
constraint. At the current stack limit of 4k, and default Linux
stack size of 8 MB, we have a recursion limit of 2048 in the
absolute worst case, and much higher in common case. Even with
smaller stack sizes, we're going to be fine as we don't deeply
recurse in code.

Thus it is not worth spending effort to optimize below our current
4k worst case limit. Removing the comment will stop encouraging
people to spend time on this in future.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agomeson: actually check for -Wframe-larger-than
Daniel P. Berrangé [Wed, 7 Apr 2021 17:19:32 +0000 (18:19 +0100)]
meson: actually check for -Wframe-larger-than

All other warning flags are checked for compiler support, so we
shouldn't blindly assume this one always exists.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agomeson: get rid of list of unused warning flags
Daniel P. Berrangé [Wed, 7 Apr 2021 17:16:50 +0000 (18:16 +0100)]
meson: get rid of list of unused warning flags

We're not using these warning flags with libvirt, and it is not worth
keeping them just to issue a warning if someone tries to enable them.
If someone does try to enable them, either libvirt will build cleanly
or it won't.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirDomainGraphicsDefParseXMLVNC: Use virXMLProp*
Tim Wiederhake [Fri, 23 Apr 2021 10:37:41 +0000 (12:37 +0200)]
virDomainGraphicsDefParseXMLVNC: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agovirDomainGraphicsDef: Change type of sharePolicy to virDomainGraphicsVNCSharePolicy
Tim Wiederhake [Fri, 23 Apr 2021 10:37:40 +0000 (12:37 +0200)]
virDomainGraphicsDef: Change type of sharePolicy to virDomainGraphicsVNCSharePolicy

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agovirDomainGraphicsListenDefParseXML: Use virXMLProp*
Tim Wiederhake [Fri, 23 Apr 2021 10:37:39 +0000 (12:37 +0200)]
virDomainGraphicsListenDefParseXML: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agovirDomainNetDefParseXML: Use virXMLProp*
Tim Wiederhake [Fri, 23 Apr 2021 10:37:38 +0000 (12:37 +0200)]
virDomainNetDefParseXML: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agovirDomainActualNetDef: Change type of type to virDomainNetType
Tim Wiederhake [Fri, 23 Apr 2021 10:37:36 +0000 (12:37 +0200)]
virDomainActualNetDef: Change type of type to virDomainNetType

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agovirDomainPCIControllerOpts: Change type of modelName to virDomainControllerPCIModelName
Tim Wiederhake [Fri, 23 Apr 2021 10:37:34 +0000 (12:37 +0200)]
virDomainPCIControllerOpts: Change type of modelName to virDomainControllerPCIModelName

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agovirDomainControllerDef: Change type of ioeventfd to virTristateSwitch
Tim Wiederhake [Fri, 23 Apr 2021 10:37:33 +0000 (12:37 +0200)]
virDomainControllerDef: Change type of ioeventfd to virTristateSwitch

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agovirXMLPropEnum: Fix return value
Tim Wiederhake [Fri, 23 Apr 2021 10:37:32 +0000 (12:37 +0200)]
virXMLPropEnum: Fix return value

Function incorrectly returns 0 when property was successfully read.

Fixes: ab5d2776c925ec45eb54ec5432f5645cebb80c85
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Don't double free @node_cpus in qemuProcessSetupPid()
Michal Privoznik [Fri, 23 Apr 2021 08:05:50 +0000 (10:05 +0200)]
qemu: Don't double free @node_cpus in qemuProcessSetupPid()

When placing vCPUs into CGroups the qemuProcessSetupPid() is
called which then enters a for() loop (around its middle) where
it calls virDomainNumaGetNodeCpumask() for each guest NUMA node.
But the latter returns only a pointer not new reference/copy and
thus the caller must not free it. But the variable is decorated
with g_autoptr() which leads to a double free.

Fixes: 2d37d8dbc987d1998b4ad8029ba324b6bfe49799
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agorpc: libssh2: Enable EC host keys
Bastian Germann [Sun, 28 Mar 2021 21:10:21 +0000 (23:10 +0200)]
rpc: libssh2: Enable EC host keys

libssh2 has ECDSA and ED25519 support beginning with v1.9.0. libvirt cannot
make use of those because it will handle them as unknown key types.

Add support for those host key types.

Signed-off-by: Bastian Germann <bastiangermann@fishpost.de>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovahDeinit: Fix memory leak
Tim Wiederhake [Thu, 22 Apr 2021 13:07:33 +0000 (15:07 +0200)]
vahDeinit: Fix memory leak

Calling VIR_FREE on a virDomainDef* does not free its various contained
pointers.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agovirDomainChrSourceDefParseTCP: Use virXMLProp*
Tim Wiederhake [Thu, 22 Apr 2021 10:32:57 +0000 (12:32 +0200)]
virDomainChrSourceDefParseTCP: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agodomain_conf: Remove function virDomainChrSourceDefParseMode
Tim Wiederhake [Thu, 22 Apr 2021 10:32:56 +0000 (12:32 +0200)]
domain_conf: Remove function virDomainChrSourceDefParseMode

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agodomain_conf: Introduce function virDomainChrSouceModeTypeFromString
Tim Wiederhake [Thu, 22 Apr 2021 10:32:55 +0000 (12:32 +0200)]
domain_conf: Introduce function virDomainChrSouceModeTypeFromString

Preparatory step to remove virDomainChrSourceDefParseMode.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirDomainDiskDefDriverParseXML: Use virXMLProp*
Tim Wiederhake [Thu, 22 Apr 2021 10:32:54 +0000 (12:32 +0200)]
virDomainDiskDefDriverParseXML: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirDomainDiskDef: Change type of detect_zeroes to virDomainDiskDetectZeroes
Tim Wiederhake [Thu, 22 Apr 2021 10:32:53 +0000 (12:32 +0200)]
virDomainDiskDef: Change type of detect_zeroes to virDomainDiskDetectZeroes

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirDomainDiskDef: Change type of discard to virDomainDiskDiscard
Tim Wiederhake [Thu, 22 Apr 2021 10:32:52 +0000 (12:32 +0200)]
virDomainDiskDef: Change type of discard to virDomainDiskDiscard

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirDomainDiskDef: Change type of iomode to virDomainDiskInfo
Tim Wiederhake [Thu, 22 Apr 2021 10:32:51 +0000 (12:32 +0200)]
virDomainDiskDef: Change type of iomode to virDomainDiskInfo

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirDomainDiskDef: Change type of rerror_policy to virDomainDiskErrorPolicy
Tim Wiederhake [Thu, 22 Apr 2021 10:32:50 +0000 (12:32 +0200)]
virDomainDiskDef: Change type of rerror_policy to virDomainDiskErrorPolicy

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirDomainDiskDef: Change type of error_policy to virDomainDiskErrorPolicy
Tim Wiederhake [Thu, 22 Apr 2021 10:32:49 +0000 (12:32 +0200)]
virDomainDiskDef: Change type of error_policy to virDomainDiskErrorPolicy

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirDomainDiskDef: Change type of cachemode to virDomainDiskCache
Tim Wiederhake [Thu, 22 Apr 2021 10:32:48 +0000 (12:32 +0200)]
virDomainDiskDef: Change type of cachemode to virDomainDiskCache

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agolxc: Let the driver detect CGroups earlier
Michal Privoznik [Tue, 20 Apr 2021 08:33:03 +0000 (10:33 +0200)]
lxc: Let the driver detect CGroups earlier

This is the bug I'm facing. I deliberately configured a container
so that the source of a <filesystem/> to passthrough doesn't
exist. The start fails with:

  lxcContainerPivotRoot:669 : Failed to create /non-existent/path/.oldroot: Permission denied

which is expected. But what is NOT expected is that CGroup
hierarchy is left behind. This is because the controller sets up
the CGroup hierarchy, user namespace, moves interfaces, etc. and
finally checks whether container setup (done in a separate
process) succeeded. Only after all this the error is propagated
to the LXC driver. The driver aborts the startup and tries to
perform the cleanup, but this is missing CGroups because those
weren't detected yet.

Ideally, whenever a function fails, it tries to unroll back so
that is has no artifacts left behind (look at all those frees/FD
closes/etc. at end of functions). But with CGroups it is
different - the controller process can't clean up after itself,
because it is still running inside that CGroup.

Therefore, what we have to do is to let the driver detect CGroups
as soon as they are created, and proceed with controller
execution only after that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
4 years agolxc: Pass another pipe to lxc_controller
Michal Privoznik [Tue, 20 Apr 2021 11:28:20 +0000 (13:28 +0200)]
lxc: Pass another pipe to lxc_controller

Currently, there is only a single pipe passed to lxc_controller
and it is used by lxc_controller to signal to the LXC driver that
the container is set up and ready to run. However, in the next
commit we will need to signal that the LXC driver has done its
part of startup process and thus the controller can proceed.
Unfortunately, virCommand handshake can't be used for this,
because it's already used to read controller's PID.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
4 years agolxc_controller: Move closing of handshakeFd out of virLXCControllerDaemonHandshake()
Michal Privoznik [Tue, 20 Apr 2021 11:34:55 +0000 (13:34 +0200)]
lxc_controller: Move closing of handshakeFd out of virLXCControllerDaemonHandshake()

Future commits will want to reuse the handshakeFd and thus it
mustn't be closed in virLXCControllerDaemonHandshake(). Do the
closing explicitly afterwards.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
4 years agolxc_controller: Initialize ctrl->handshakeFd properly
Michal Privoznik [Tue, 20 Apr 2021 08:36:09 +0000 (10:36 +0200)]
lxc_controller: Initialize ctrl->handshakeFd properly

The lxc_controller has a structure that's keeping its internal
state, including so called handshakeFd which is the write end of
a pipe that's used to signal to the LXC driver that the container
is set up and ready to run. However, the struct member is not
initialized to -1, so if anything fails before it is set then the
virLXCControllerFree() function tries to close FD 0 (stdin).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
4 years agovirsh: Fix completion logic to guestvcpus command
Lin Ma [Thu, 22 Apr 2021 10:38:19 +0000 (18:38 +0800)]
virsh: Fix completion logic to guestvcpus command

In case of non-continuous vCPU topology, We can't infer the bitmap size
from the combination of onlineVcpuStr and nvcpus.
We should use virBitmapParseUnlimited here instead of virBitmapParse due
to the bitmap size is unknown.

e.g.:

  <vcpus>
    <vcpu id='0' enabled='yes' hotpluggable='no' order='1'/>
    <vcpu id='1' enabled='yes' hotpluggable='yes' order='2'/>
    <vcpu id='2' enabled='yes' hotpluggable='yes' order='3'/>
    <vcpu id='3' enabled='yes' hotpluggable='yes' order='4'/>
    <vcpu id='4' enabled='yes' hotpluggable='yes' order='5'/>
    <vcpu id='5' enabled='yes' hotpluggable='yes' order='6'/>
    <vcpu id='6' enabled='no' hotpluggable='yes'/>
    <vcpu id='7' enabled='no' hotpluggable='yes'/>
  </vcpus>

 # virsh guestvcpus --domain VM
vcpus          : 0-5
online         : 0-5
offlinable     : 1-5

 # virsh setvcpu --domain VM --disable --vcpulist 2

 # virsh guestvcpus --domain VM --disable --cpulist 4,5

 # virsh guestvcpus --domain VM
vcpus          : 0-1,3-5
online         : 0-1,3
offlinable     : 1,3-5

Before:
 # virsh guestvcpus --domain VM --enable --cpulist <TAB><TAB>
2  4

After:
 # virsh guestvcpus --domain VM --enable --cpulist <TAB><TAB>
4  5

Signed-off-by: Lin Ma <lma@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirsh: Add mountpoint completion to domfsfreeze/domfsthaw command
Lin Ma [Thu, 22 Apr 2021 10:38:18 +0000 (18:38 +0800)]
virsh: Add mountpoint completion to domfsfreeze/domfsthaw command

Signed-off-by: Lin Ma <lma@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirDomainMemorytuneDefParseMemory: Use virXMLProp*
Tim Wiederhake [Wed, 21 Apr 2021 15:51:33 +0000 (17:51 +0200)]
virDomainMemorytuneDefParseMemory: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirDomainDiskSourceNetworkParse: Use virXMLProp*
Tim Wiederhake [Wed, 21 Apr 2021 15:51:32 +0000 (17:51 +0200)]
virDomainDiskSourceNetworkParse: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirDomainDeviceInfoParseXML: Use virXMLProp*
Tim Wiederhake [Wed, 21 Apr 2021 15:51:31 +0000 (17:51 +0200)]
virDomainDeviceInfoParseXML: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirStorageEncryptionInfoParseCipher: Use virXMLProp*
Tim Wiederhake [Wed, 21 Apr 2021 15:51:30 +0000 (17:51 +0200)]
virStorageEncryptionInfoParseCipher: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirDomainHostdevSubsysSCSIHostDefParseXML: Use virXMLProp*
Tim Wiederhake [Wed, 21 Apr 2021 15:51:29 +0000 (17:51 +0200)]
virDomainHostdevSubsysSCSIHostDefParseXML: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirDomainDeviceDimmAddressParseXML: Use virXMLProp*
Tim Wiederhake [Wed, 21 Apr 2021 15:51:28 +0000 (17:51 +0200)]
virDomainDeviceDimmAddressParseXML: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirxml: Add virXMLPropULongLong
Tim Wiederhake [Wed, 21 Apr 2021 15:51:27 +0000 (17:51 +0200)]
virxml: Add virXMLPropULongLong

Convenience function to return the value of an unsigned long long XML
attribute.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuAppendKeyWrapMachineParm: Stricten parameter types
Tim Wiederhake [Wed, 21 Apr 2021 15:51:26 +0000 (17:51 +0200)]
qemuAppendKeyWrapMachineParm: Stricten parameter types

Follow up to the last patch.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirDomainKeyWrapDef: Make members virTristateSwitch
Tim Wiederhake [Wed, 21 Apr 2021 15:51:25 +0000 (17:51 +0200)]
virDomainKeyWrapDef: Make members virTristateSwitch

With the last usage of `aes` and `dea` as int gone, these two can
become virTristateSwitch.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirDomainKeyWrapCipherDefParseXML: Use virXMLProp*
Tim Wiederhake [Wed, 21 Apr 2021 15:51:24 +0000 (17:51 +0200)]
virDomainKeyWrapCipherDefParseXML: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agospec: Drop -bash-completion package
Andrea Bolognani [Tue, 20 Apr 2021 16:54:58 +0000 (18:54 +0200)]
spec: Drop -bash-completion package

It's now empty, so no point in keeping it around.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agotools: Generate per-command bash completion script
Andrea Bolognani [Mon, 19 Apr 2021 16:40:14 +0000 (18:40 +0200)]
tools: Generate per-command bash completion script

The current setup uses a single script that is symlinked twice
and that tries to configure bash completion for both virsh and
virt-admin, even if only one of them is installed. This also
forces us to have a -bash-completion RPM package that only
contains the tiny shared file.

Rework bash completion support so that two scripts are
generated, each one tailored to a specific command.

Since the shared script no longer exists after this change,
the corresponding RPM package becomes empty.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agospec: Move systemtap probes from -client to -libs
Andrea Bolognani [Mon, 19 Apr 2021 16:31:10 +0000 (18:31 +0200)]
spec: Move systemtap probes from -client to -libs

Any application that uses the libraries can take advantage of
the systemtap probes, so they should be shipped in the -libs
package rather than in -client.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agospec: Move some files from -client to -daemon
Andrea Bolognani [Mon, 19 Apr 2021 16:29:25 +0000 (18:29 +0200)]
spec: Move some files from -client to -daemon

The -client package's purpose is enabling remote machines to
connect to a virtualization host, but the virt-host-validate
and libvirt-guests tools are designed to be run directly on
the virtualization host and as such are a better fit for the
-daemon package.

With this change, installing and removing the -client package
no longer needs to touch the systemd configuration.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agospec: Merge -admin package into -daemon
Andrea Bolognani [Mon, 19 Apr 2021 16:23:12 +0000 (18:23 +0200)]
spec: Merge -admin package into -daemon

It's useful to have virt-admin around when debugging issues
with libvirtd, and since it's a tiny binary we can simply
include it in the -daemon package to ensure it's always going
to be available when needed.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agodocs: Expand upon the contents of the -daemon package
Andrea Bolognani [Tue, 20 Apr 2021 16:00:24 +0000 (18:00 +0200)]
docs: Expand upon the contents of the -daemon package

It doesn't only contain the libvirtd binary.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agodocs: Use consistent vertical spacing
Andrea Bolognani [Tue, 20 Apr 2021 15:54:55 +0000 (17:54 +0200)]
docs: Use consistent vertical spacing

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agobash-completion: Fix argument passing to $1
Michal Privoznik [Tue, 20 Apr 2021 13:03:16 +0000 (15:03 +0200)]
bash-completion: Fix argument passing to $1

Our vsh bash completion string is merely just a wrapper over
virsh/virt-admin complete (cmdComplete) - a hidden command that
uses internal readline completion to generate list of candidates.
But this means that we have to pass some additional arguments to
the helper process: e.g. connection URI and R/O flag.

Candidates are printed on a separate line each (and can contain
space), which means that when bash is reading the helper's output
into an array, it needs to split items on '\n' char - hence the
IFS=$'\n' prefix on the line executing the helper. This was
introduced in b889594a70.

But this introduced a regression - those extra arguments we might
pass are stored in a string and previously were split on a space
character (because $IFS was kept untouched and by default
contains space). But now, after the fix that's no longer the case
and thus virsh/virt-admin sees ' -r -c URI' as one argument.

The solution is to take $IFS out of the picture by storing the
extra arguments in an array instead of string.

Fixes: b889594a7092440dc916e3f43eeeaca2684571ee
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agoqemu: virtiofs: support <sandbox mode='chroot'/>
Cole Robinson [Fri, 26 Mar 2021 16:58:28 +0000 (12:58 -0400)]
qemu: virtiofs: support <sandbox mode='chroot'/>

This maps to `virtiofsd -o sandbox=chroot|namespace`, which was added
in qemu 5.2.0:

https://git.qemu.org/?p=qemu.git;a=commit;h=06844584b62a43384642f7243b0fc01c9fff0fc7

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
4 years agoconf: Introduce <sandbox mode='chroot'/> for <filesystem><binary>
Cole Robinson [Fri, 26 Mar 2021 15:24:37 +0000 (11:24 -0400)]
conf: Introduce <sandbox mode='chroot'/> for <filesystem><binary>

This adds a new XML element

<filesystem>
  <binary>
    <sandbox mode='chroot|namespace'/>
  </binary>
</filesystem>

This will be used by qemu virtiofs

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
4 years agostorage_backend_fs: use MKFS ony if WITH_STORAGE_FS is defined
Pavel Hrdina [Wed, 21 Apr 2021 13:31:12 +0000 (15:31 +0200)]
storage_backend_fs: use MKFS ony if WITH_STORAGE_FS is defined

The code in storage_backend_fs is used for storage_dir and storage_fs
drivers so some parts need to be guarded by checking for
WITH_STORAGE_FS.

Fixes: 16c69e7aaed4cabfd8e8c19cc326854d4c480437
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirDomainLoaderDefParseXML: Use virXMLProp*
Tim Wiederhake [Wed, 21 Apr 2021 13:33:32 +0000 (15:33 +0200)]
virDomainLoaderDefParseXML: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirDomainVsockDefParseXML: Use virXMLProp*
Tim Wiederhake [Wed, 21 Apr 2021 13:33:31 +0000 (15:33 +0200)]
virDomainVsockDefParseXML: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirDomainVideoResolutionDefParseXML: Use virXMLProp*
Tim Wiederhake [Wed, 21 Apr 2021 13:33:30 +0000 (15:33 +0200)]
virDomainVideoResolutionDefParseXML: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirDomainAudioJackParse: Use virXMLProp*
Tim Wiederhake [Wed, 21 Apr 2021 13:33:29 +0000 (15:33 +0200)]
virDomainAudioJackParse: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirDomainChrSourceDefParseLog: Use virXMLProp*
Tim Wiederhake [Wed, 21 Apr 2021 13:33:28 +0000 (15:33 +0200)]
virDomainChrSourceDefParseLog: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirDomainChrSourceDefParseFile: Use virXMLProp*
Tim Wiederhake [Wed, 21 Apr 2021 13:33:27 +0000 (15:33 +0200)]
virDomainChrSourceDefParseFile: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirDomainDiskSourceNVMeParse: Use virXMLProp*
Tim Wiederhake [Wed, 21 Apr 2021 13:33:26 +0000 (15:33 +0200)]
virDomainDiskSourceNVMeParse: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirDomainDeviceISAAddressParseXML: Use virXMLProp*
Tim Wiederhake [Wed, 21 Apr 2021 13:33:25 +0000 (15:33 +0200)]
virDomainDeviceISAAddressParseXML: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirDomainDeviceBootParseXML: Use virXMLProp*
Tim Wiederhake [Wed, 21 Apr 2021 13:33:24 +0000 (15:33 +0200)]
virDomainDeviceBootParseXML: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirDomainVirtioOptionsParseXML: Use virXMLProp*
Tim Wiederhake [Wed, 21 Apr 2021 13:33:23 +0000 (15:33 +0200)]
virDomainVirtioOptionsParseXML: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agospec: Do not build qemu driver for Power on RHEL-9
Jiri Denemark [Wed, 21 Apr 2021 12:55:03 +0000 (14:55 +0200)]
spec: Do not build qemu driver for Power on RHEL-9

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: add socket for virtiofs filesystems
Ján Tomko [Sat, 13 Feb 2021 12:22:56 +0000 (13:22 +0100)]
qemu: add socket for virtiofs filesystems

Copy the socket path in qemuExtDevicesStart, because
for libvirt-managed virtiofsd daemons the path is filled there
in qemuVirtioFSStart.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoconf: add socket for virtiofs filesystems
Ján Tomko [Mon, 7 Sep 2020 20:07:35 +0000 (22:07 +0200)]
conf: add socket for virtiofs filesystems

Allow passing a socket of an externally launched virtiofsd
to the vhost-user-fs device.

<filesystem type='mount'>
  <driver type='virtiofs' queue='1024'/>
  <source socket='/tmp/sock/'/>
</filesystem>

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoconf: fs: allow missing accessmode in the formatter
Ján Tomko [Mon, 7 Sep 2020 15:12:56 +0000 (17:12 +0200)]
conf: fs: allow missing accessmode in the formatter

So far VIR_DOMAIN_FS_ACCESSMODE_PASSTHROUGH is always set
in virDomainFSDefPostParse, but future commits aim to change
that.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoconf: fs: fill out accessmode in post-parse
Ján Tomko [Mon, 7 Sep 2020 15:01:16 +0000 (17:01 +0200)]
conf: fs: fill out accessmode in post-parse

Move the default setting of accessmode to the post-parse phase.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agodocs: formatdomain: Fix quoting of ':since:' argument for <teaming>
Peter Krempa [Wed, 21 Apr 2021 13:33:19 +0000 (15:33 +0200)]
docs: formatdomain: Fix quoting of ':since:' argument for <teaming>

The end quote of the argument of :since: must not have a space in front
of it as it's then not considered as end of the argument.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirInterfaceLinkParseXML: Use virXMLProp*
Tim Wiederhake [Wed, 21 Apr 2021 12:08:08 +0000 (14:08 +0200)]
virInterfaceLinkParseXML: Use virXMLProp*

This strictens the parser to disallow negative values (interpreted as
`UINT_MAX + value + 1`) for attribute `speed`, which does not make sense for
a value measured in Mbits per second.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirDomainDeviceUSBAddressParseXML: Use virXMLProp*
Tim Wiederhake [Wed, 21 Apr 2021 12:08:07 +0000 (14:08 +0200)]
virDomainDeviceUSBAddressParseXML: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirDomainDeviceCcidAddressParseXML: Use virXMLProp*
Tim Wiederhake [Wed, 21 Apr 2021 12:08:06 +0000 (14:08 +0200)]
virDomainDeviceCcidAddressParseXML: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirDomainDeviceVirtioSerialAddressParseXML: Use virXMLProp*
Tim Wiederhake [Wed, 21 Apr 2021 12:08:05 +0000 (14:08 +0200)]
virDomainDeviceVirtioSerialAddressParseXML: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirDomainDeviceDriveAddressParseXML: Use virXMLProp*
Tim Wiederhake [Wed, 21 Apr 2021 12:08:04 +0000 (14:08 +0200)]
virDomainDeviceDriveAddressParseXML: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirDomainDeviceCCWAddressParseXML: Use virXMLProp*
Tim Wiederhake [Wed, 21 Apr 2021 12:08:03 +0000 (14:08 +0200)]
virDomainDeviceCCWAddressParseXML: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirPCIDeviceAddressParseXML: Use virXMLProp*
Tim Wiederhake [Wed, 21 Apr 2021 12:08:02 +0000 (14:08 +0200)]
virPCIDeviceAddressParseXML: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirZPCIDeviceAddressParseXML: Use virXMLProp*
Tim Wiederhake [Wed, 21 Apr 2021 12:08:01 +0000 (14:08 +0200)]
virZPCIDeviceAddressParseXML: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirDomainBackupDefParse: Use virXMLProp*
Tim Wiederhake [Wed, 21 Apr 2021 12:08:00 +0000 (14:08 +0200)]
virDomainBackupDefParse: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirDomainBackupDiskDefParseXML: Use virXMLProp*
Tim Wiederhake [Wed, 21 Apr 2021 12:07:59 +0000 (14:07 +0200)]
virDomainBackupDiskDefParseXML: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemu: blockjob: Transition into 'ready' state only from expected states
Peter Krempa [Tue, 20 Apr 2021 10:58:28 +0000 (12:58 +0200)]
qemu: blockjob: Transition into 'ready' state only from expected states

In certain rare occasions qemu can transition a block job which was
already 'ready' into 'standby' and then back. If this happens in the
following order libvirt will get confused about the actual job state:

1) the block copy job is 'ready' (job->state == QEMU_BLOCKJOB_STATE_READY)

2) user calls qemuDomainBlockJobAbort with VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT
   flag but without VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC

3) the block job is switched to synchronous event handling

4) the block job blips to 'standby' and back to 'ready', the event is
   not processed since the blockjob is in sync mode for now

5) qemuDomainBlockJobPivot is called:
    5.1) 'job-complete' QMP command is issued
    5.2) job->state is set to QEMU_BLOCKJOB_STATE_PIVOTING

6) code for synchronous-wait for the job completion in qemuDomainBlockJobAbort
   is invoked

7) the waiting loop calls qemuBlockJobUpdate:

    7.1) job->newstate is QEMU_BLOCKJOB_STATE_READY due to 4)
    7.2) qemuBlockJobEventProcess is called
    7.3) the handler for QEMU_BLOCKJOB_STATE_READY overwrites
         job->state from QEMU_BLOCKJOB_STATE_PIVOTING to QEMU_BLOCKJOB_STATE_READY

8) qemuDomainBlockJobAbort is looking for a finished job, so waits again

9) qemu finishes the blockjob and transitions it into 'concluded' state

10) qemuBlockJobUpdate is triggered again, this time finalizing the job.
    10.1) job->newstate is = QEMU_BLOCKJOB_STATE_CONCLUDED
          job->state is = QEMU_BLOCKJOB_STATE_READY
    10.2) qemuBlockJobEventProcessConcluded is called, the function
          checks whether there was an error with the blockjob. Since
          there was no error job->newstate becomes
          QEMU_BLOCKJOB_STATE_COMPLETED.
    10.3) qemuBlockJobEventProcessConcludedTransition selects the action
          for the appropriate block job type where we have:

    case QEMU_BLOCKJOB_TYPE_COPY:
        if (job->state == QEMU_BLOCKJOB_STATE_PIVOTING && success)
            qemuBlockJobProcessEventConcludedCopyPivot(driver, vm, job, asyncJob);
        else
            qemuBlockJobProcessEventConcludedCopyAbort(driver, vm, job, asyncJob);
        break;

          Since job->state is QEMU_BLOCKJOB_STATE_READY,
          qemuBlockJobProcessEventConcludedCopyAbort is called.

This patch forbids transitions to QEMU_BLOCKJOB_STATE_READY if the
previous job state isn't QEMU_BLOCKJOB_STATE_RUNNING or
QEMU_BLOCKJOB_STATE_NEW.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1951507
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agostorage: use virFindFileInPath to validate presence of mkfs
Pavel Hrdina [Wed, 14 Apr 2021 23:09:21 +0000 (01:09 +0200)]
storage: use virFindFileInPath to validate presence of mkfs

Future patch will remove MKFS define as we will no longer check it
during compilation.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agobhyvexml2argvtest: use virCommandToStringFull to strip command path
Pavel Hrdina [Fri, 16 Apr 2021 18:32:34 +0000 (20:32 +0200)]
bhyvexml2argvtest: use virCommandToStringFull to strip command path

Currently the tests would fail if the bhyve commands are installed in
different path then /usr/bin. Strip the command path to not depend on
the host environment.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agomeson: don't check collie as program for sheepdog
Pavel Hrdina [Thu, 15 Apr 2021 12:36:32 +0000 (14:36 +0200)]
meson: don't check collie as program for sheepdog

Upstream sheepdog changed collie to dog back in 2013 in version 0.7.0.
Looking into repology that version is no longer used by any distribution
supported by libvirt.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirnetdev: move virNetDevSetRootQDisc to virnetdevbandwidth
Pavel Hrdina [Wed, 14 Apr 2021 22:34:48 +0000 (00:34 +0200)]
virnetdev: move virNetDevSetRootQDisc to virnetdevbandwidth

The function in question uses "tc" binary so virnetdevbandwidth feels
like better place for it.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agotests: use virfirewallmock instead of hasNetfilterTools
Pavel Hrdina [Wed, 14 Apr 2021 21:57:50 +0000 (23:57 +0200)]
tests: use virfirewallmock instead of hasNetfilterTools

Instead of checking for specific error that the binaries are not
available mock the virFindFileInPath function. This way we don't have
to skip these tests on host where the binaries are missing.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agotests: introduce virfirewallmock
Pavel Hrdina [Wed, 14 Apr 2021 21:52:14 +0000 (23:52 +0200)]
tests: introduce virfirewallmock

This will allow us to run tests using firewall on hosts where the mocked
binaries are not available/installed instead of skipping these tests.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirfirewall: use virFindFileInPath instead of virFileIsExecutable
Pavel Hrdina [Thu, 15 Apr 2021 18:46:53 +0000 (20:46 +0200)]
virfirewall: use virFindFileInPath instead of virFileIsExecutable

Following patches will make this change necessary as we will stop
detecting the full path during compile time.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirdnsmasq: remove binaryPath argument from dnsmasqCapsNewFromBinary
Pavel Hrdina [Wed, 14 Apr 2021 15:57:08 +0000 (17:57 +0200)]
virdnsmasq: remove binaryPath argument from dnsmasqCapsNewFromBinary

We always pass DNSMASQ so there is no need for the argument at all.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirdnsmasq: remove binaryPath argument from dnsmasqCapsNewFromBuffer
Pavel Hrdina [Wed, 14 Apr 2021 15:46:47 +0000 (17:46 +0200)]
virdnsmasq: remove binaryPath argument from dnsmasqCapsNewFromBuffer

We always pass DNSMASQ so there is no need for the argument at all.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirdnsmasq: drop unused dnsmasqCapsRefresh function
Pavel Hrdina [Wed, 14 Apr 2021 15:19:11 +0000 (17:19 +0200)]
virdnsmasq: drop unused dnsmasqCapsRefresh function

Instead of removing binaryPath let's drop the function completely as
it is not used anywhere.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirdnsmasq: drop unused dnsmasqCapsNewFromFile function
Pavel Hrdina [Wed, 14 Apr 2021 15:01:43 +0000 (17:01 +0200)]
virdnsmasq: drop unused dnsmasqCapsNewFromFile function

Instead of removing binaryPath let's drop the function completely as
it is not used anywhere.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agobridge_driver: fix comment about dnsmasqCaps
Pavel Hrdina [Wed, 14 Apr 2021 15:17:42 +0000 (17:17 +0200)]
bridge_driver: fix comment about dnsmasqCaps

We will never call dnsmasqCapsRefresh() so reflect what actually
happens.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoutil: xml: Fix confusing semantics of VIR_XML_PROP_OPTIONAL flag
Peter Krempa [Wed, 21 Apr 2021 06:49:51 +0000 (08:49 +0200)]
util: xml: Fix confusing semantics of VIR_XML_PROP_OPTIONAL flag

The new enum helpers use a set of flags to modify their behaviour, but
the declared set of flags is semantically confusing:

 typedef enum {
     VIR_XML_PROP_OPTIONAL = 0, /* Attribute may be absent */
     VIR_XML_PROP_REQUIRED = 1 << 0, /* Attribute may not be absent */

Since VIR_XML_PROP_OPTIONAL is declared as 0 any other flag shadows it
and makes it impossible to detect. The functions are not able to detect
a semantic nonsense of VIR_XML_PROP_OPTIONAL | VIR_XML_PROP_REQUIRED and
it's a perfectly valid statement for the compilers.

In general having two flags to do the same boolean don't make sense and
the implementation doesn't fix any shortcomings either.

To prevent mistakes, rename VIR_XML_PROP_OPTIONAL to VIR_XML_PROP_NONE,
so that there's always an enum value used with the calls but it doesn't
imply that the flag makes the property optional when the actual value is
0.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoutil: xml: Remove VIR_XML_PROP_WRAPNEGATIVE
Peter Krempa [Wed, 21 Apr 2021 06:41:00 +0000 (08:41 +0200)]
util: xml: Remove VIR_XML_PROP_WRAPNEGATIVE

As I've pointed out in my review, the negative number wrapping for
unsigned variables is an anti-feature which should not be promoted in
any way.

Remove VIR_XML_PROP_WRAPNEGATIVE which would make it more accessible.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agotestUpdateQEMUCaps: Fix memory leak
Tim Wiederhake [Tue, 20 Apr 2021 11:27:52 +0000 (13:27 +0200)]
testUpdateQEMUCaps: Fix memory leak

testUpdateQEMUCaps is called multiple times. Use virQEMUCapsUpdateHostCPUModel
instead of virQEMUCapsInitHostCPUModel to not overwrite (and leak) the
pointers in qemuCaps->kvm.hostCPU and qemuCaps->tcg.hostCPU.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu: Introduce virQEMUCapsUpdateHostCPUModel
Tim Wiederhake [Tue, 20 Apr 2021 11:27:51 +0000 (13:27 +0200)]
qemu: Introduce virQEMUCapsUpdateHostCPUModel

Function will be used by next patch.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoxenParseHypervisorFeatures: Remove superfluous VIR_FREE
Tim Wiederhake [Tue, 20 Apr 2021 11:27:50 +0000 (13:27 +0200)]
xenParseHypervisorFeatures: Remove superfluous VIR_FREE

Fixes: 4eb7c621985dad4de911ec394ac628bd1a5b29ab
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirxml: Fix schema validation of individual nodes
Tim Wiederhake [Tue, 20 Apr 2021 11:27:49 +0000 (13:27 +0200)]
virxml: Fix schema validation of individual nodes

xmlDocSetRootElement removes the node from its previous document tree,
effectively removing the "<cpu>" node from "<domain>" in virCPUDefParseXML.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoReplace AbsPath judgement method with g_path_is_absolute()
Luke Yue [Tue, 20 Apr 2021 04:44:12 +0000 (12:44 +0800)]
Replace AbsPath judgement method with g_path_is_absolute()

The g_path_is_absolute() considers more situations
than just a simply "path[0] == '/'".

Related issue: https://gitlab.com/libvirt/libvirt/-/issues/12

Signed-off-by: Luke Yue <lukedyue@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirshCheckpointListCollect: Do not pass NULL to qsort
Tim Wiederhake [Mon, 19 Apr 2021 11:54:15 +0000 (13:54 +0200)]
virshCheckpointListCollect: Do not pass NULL to qsort

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agocmdSnapshotList: Fix memory leak
Tim Wiederhake [Mon, 19 Apr 2021 11:54:14 +0000 (13:54 +0200)]
cmdSnapshotList: Fix memory leak

Fixes: 3caa28dc50df7ec215713075d669b20bef6473a2
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>