Commit Graph

41941 Commits

Author SHA1 Message Date
Tim Wiederhake
7ae08ef3a2 virDomainGraphicsDefParseXMLSDL: Use virXMLProp*
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-04-26 13:43:32 +02:00
Daniel P. Berrangé
3c3c55be66 meson: don't probe for -Werror if --werror is enabled
Meson has its own mechanism to turn on -Werror with the --werror option.
If this is set, then there is no reason for libvirt to check for -Werror
itself.

We remove the summary line output because it is potentially misleading
when libvirt hasn't enabled -Werror, but meson has.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-04-23 16:13:56 +01:00
Daniel P. Berrangé
a9461d456c meson: honour meson warning_level option
Meson defines a warning_level option which has the following behaviour
with C code

 0:  no warning flags
 1: -Wall
 2: -Wall -Wextra
 3: -Wall -Wextra -Wpedantic

Currently we add our extra warning flags unconditionally if the compiler
supports them, regardless of the meson warning_level setting. This has
effectively nullified the warning_level setting in meson, and also
results in meson printing these messages:

  meson.build:498: WARNING: Consider using the built-in warning_level option instead of using "-Wall".
  meson.build:498: WARNING: Consider using the built-in warning_level option instead of using "-Wextra".

Semantically we can think of our huge list of flags as being an "extra"
set of warnings, and thus we ought to only add them when meson would
itself use -Wextra. aka warning_level == 2 or 3.

In practice libvirt code can't be built with -Wpedantic so we can ignore
meson warning_level 3, and only add our flags when warning_level==2.

In doing this change, we no longer have to check -Wall/-Wextra ourselves
as we can assume meson already set them.

-W is an alias of -Wextra so it is removed too.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-04-23 16:12:53 +01:00
Daniel P. Berrangé
8f28944fd5 meson: avoid checking compiler flags twice
In several cases we check if a compiler flag is supported, and then add
it to the 'cc_flags' array. The entire 'cc_flags' array is then later
tested to see if each flag is supported, which duplicates the check in
some cases.

Move the check of cc_flags earlier, and for the extra flags append
directly to supported_cc_flags to avoid the duplicate check

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-04-23 16:12:53 +01:00
Daniel P. Berrangé
8394f08e9d 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>
2021-04-23 16:12:53 +01:00
Daniel P. Berrangé
2e85a83abe 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>
2021-04-23 16:12:53 +01:00
Daniel P. Berrangé
36489081b0 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>
2021-04-23 16:12:52 +01:00
Daniel P. Berrangé
a0e5aca072 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>
2021-04-23 16:12:52 +01:00
Tim Wiederhake
ee387289dd 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>
2021-04-23 16:36:50 +02:00
Tim Wiederhake
65789be8e4 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>
2021-04-23 16:36:49 +02:00
Tim Wiederhake
0b20fd3754 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>
2021-04-23 16:36:49 +02:00
Tim Wiederhake
b45ba35e35 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>
2021-04-23 16:36:49 +02:00
Tim Wiederhake
3d2c54b062 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>
2021-04-23 16:36:49 +02:00
Tim Wiederhake
376bb1ebb3 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>
2021-04-23 16:36:49 +02:00
Tim Wiederhake
8395c909a6 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>
2021-04-23 16:36:49 +02:00
Tim Wiederhake
c02c301130 virXMLPropEnum: Fix return value
Function incorrectly returns 0 when property was successfully read.

Fixes: ab5d2776c9
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>
2021-04-23 16:36:49 +02:00
Michal Privoznik
310b37e486 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: 2d37d8dbc9
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-04-23 11:02:21 +02:00
Bastian Germann
509d9b5b9f 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>
2021-04-22 16:35:57 +02:00
Tim Wiederhake
9ac2ca799a 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>
2021-04-22 15:49:06 +02:00
Tim Wiederhake
fa48004af5 virDomainChrSourceDefParseTCP: Use virXMLProp*
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-04-22 15:31:10 +02:00
Tim Wiederhake
47d810c4f2 domain_conf: Remove function virDomainChrSourceDefParseMode
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-04-22 15:31:07 +02:00
Tim Wiederhake
170288c408 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>
2021-04-22 15:31:01 +02:00
Tim Wiederhake
45abc1a5db virDomainDiskDefDriverParseXML: Use virXMLProp*
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-04-22 15:30:59 +02:00
Tim Wiederhake
eec82ea2d9 virDomainDiskDef: Change type of detect_zeroes to virDomainDiskDetectZeroes
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-04-22 15:30:58 +02:00
Tim Wiederhake
ea7d0071d5 virDomainDiskDef: Change type of discard to virDomainDiskDiscard
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-04-22 15:30:56 +02:00
Tim Wiederhake
de472f7248 virDomainDiskDef: Change type of iomode to virDomainDiskInfo
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-04-22 15:30:54 +02:00
Tim Wiederhake
7a3bf2589d virDomainDiskDef: Change type of rerror_policy to virDomainDiskErrorPolicy
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-04-22 15:30:52 +02:00
Tim Wiederhake
90a50b98f6 virDomainDiskDef: Change type of error_policy to virDomainDiskErrorPolicy
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-04-22 15:30:50 +02:00
Tim Wiederhake
f86e0b4cbc virDomainDiskDef: Change type of cachemode to virDomainDiskCache
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-04-22 15:30:46 +02:00
Michal Privoznik
1051c23b51 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>
2021-04-22 14:10:47 +02:00
Michal Privoznik
5aba8d5438 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>
2021-04-22 13:57:46 +02:00
Michal Privoznik
bfe2d857f2 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>
2021-04-22 13:53:05 +02:00
Michal Privoznik
da61e92739 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>
2021-04-22 13:52:21 +02:00
Lin Ma
093eed7360 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>
2021-04-22 13:46:48 +02:00
Lin Ma
14c36b107d virsh: Add mountpoint completion to domfsfreeze/domfsthaw command
Signed-off-by: Lin Ma <lma@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-04-22 13:46:44 +02:00
Tim Wiederhake
c226ae47fc virDomainMemorytuneDefParseMemory: Use virXMLProp*
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-04-22 11:24:53 +02:00
Tim Wiederhake
38dc25989c virDomainDiskSourceNetworkParse: Use virXMLProp*
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-04-22 11:24:53 +02:00
Tim Wiederhake
dfff3db776 virDomainDeviceInfoParseXML: Use virXMLProp*
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-04-22 11:24:53 +02:00
Tim Wiederhake
ad1d37876d virStorageEncryptionInfoParseCipher: Use virXMLProp*
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-04-22 11:24:53 +02:00
Tim Wiederhake
88cc6a1f9f virDomainHostdevSubsysSCSIHostDefParseXML: Use virXMLProp*
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-04-22 11:24:53 +02:00
Tim Wiederhake
d19af62435 virDomainDeviceDimmAddressParseXML: Use virXMLProp*
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-04-22 11:24:53 +02:00
Tim Wiederhake
3d69665959 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>
2021-04-22 11:24:53 +02:00
Tim Wiederhake
13f617a119 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>
2021-04-22 11:24:53 +02:00
Tim Wiederhake
df91deb7a9 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>
2021-04-22 11:24:53 +02:00
Tim Wiederhake
931afa7d99 virDomainKeyWrapCipherDefParseXML: Use virXMLProp*
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-04-22 11:24:53 +02:00
Andrea Bolognani
73a3ac414f 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>
2021-04-22 11:01:27 +02:00
Andrea Bolognani
cf66ee8ddc 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>
2021-04-22 11:01:27 +02:00
Andrea Bolognani
c813acc0df 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>
2021-04-22 11:01:27 +02:00
Andrea Bolognani
d800c50349 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>
2021-04-22 11:01:27 +02:00
Andrea Bolognani
2244ac168d 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>
2021-04-22 11:01:27 +02:00