Commit Graph

41876 Commits

Author SHA1 Message Date
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
Andrea Bolognani
63d11538b5 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>
2021-04-22 11:01:27 +02:00
Andrea Bolognani
3e14f008dc 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>
2021-04-22 11:01:27 +02:00
Michal Privoznik
7657804df7 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: b889594a70
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2021-04-22 10:14:38 +02:00
Cole Robinson
f0e5100f00 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>
2021-04-21 11:51:31 -04:00
Cole Robinson
f4c97327fb 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>
2021-04-21 11:51:31 -04:00
Pavel Hrdina
9c81d1ec11 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: 16c69e7aae
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-04-21 17:26:12 +02:00
Tim Wiederhake
a85d553d76 virDomainLoaderDefParseXML: Use virXMLProp*
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-04-21 17:11:05 +02:00
Tim Wiederhake
2beae8273b virDomainVsockDefParseXML: Use virXMLProp*
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-04-21 17:11:05 +02:00
Tim Wiederhake
f16e3e8b79 virDomainVideoResolutionDefParseXML: Use virXMLProp*
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-04-21 17:11:05 +02:00
Tim Wiederhake
e2a38216d2 virDomainAudioJackParse: Use virXMLProp*
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-04-21 17:11:05 +02:00
Tim Wiederhake
97cdb5be1e virDomainChrSourceDefParseLog: Use virXMLProp*
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-04-21 17:11:05 +02:00
Tim Wiederhake
fcc563a29b virDomainChrSourceDefParseFile: Use virXMLProp*
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-04-21 17:11:04 +02:00
Tim Wiederhake
c348da7c4c virDomainDiskSourceNVMeParse: Use virXMLProp*
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-04-21 17:11:04 +02:00
Tim Wiederhake
7d397e0418 virDomainDeviceISAAddressParseXML: Use virXMLProp*
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-04-21 17:11:04 +02:00
Tim Wiederhake
f0e1cc7083 virDomainDeviceBootParseXML: Use virXMLProp*
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-04-21 17:11:04 +02:00