]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
5 years agodocs: drvqemu: remove relative time reference
Ján Tomko [Wed, 17 Jul 2019 11:56:13 +0000 (13:56 +0200)]
docs: drvqemu: remove relative time reference

It has not aged well.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
5 years agodocs: drvqemu: fix a typo
Ján Tomko [Wed, 17 Jul 2019 11:46:37 +0000 (13:46 +0200)]
docs: drvqemu: fix a typo

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
5 years agodocs: link to networkportformat.html in format.html
Ján Tomko [Tue, 16 Jul 2019 15:39:30 +0000 (17:39 +0200)]
docs: link to networkportformat.html in format.html

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
5 years agoqemu: command: remove qemuDomainFSDriver
Ján Tomko [Tue, 16 Jul 2019 10:31:03 +0000 (12:31 +0200)]
qemu: command: remove qemuDomainFSDriver

Having a translation enum full of empty strings seems excessive.
Now that the validiation is performed in qemuDomainDeviceDefValidateFS,
remove it completely and open-code the two allowed cases.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
5 years agoqemu: command: use VIR_AUTOCLEAN in qemuBuildFS*
Ján Tomko [Tue, 16 Jul 2019 10:25:31 +0000 (12:25 +0200)]
qemu: command: use VIR_AUTOCLEAN in qemuBuildFS*

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
5 years agoqemu: introduce qemuDomainDeviceDefValidateFS
Ján Tomko [Tue, 16 Jul 2019 10:05:19 +0000 (12:05 +0200)]
qemu: introduce qemuDomainDeviceDefValidateFS

Move validation of the filesystem device out of qemu_command.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
5 years agoqemu: command: use VIR_AUTOFREE in qemuBuildFSDevCommandLine
Ján Tomko [Tue, 16 Jul 2019 08:37:03 +0000 (10:37 +0200)]
qemu: command: use VIR_AUTOFREE in qemuBuildFSDevCommandLine

Introduce two separate variables instead of reusing the same one
for clarity.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
5 years agoqemu: command: re-introduce qemuBuildFSDevCommandLine
Ján Tomko [Tue, 16 Jul 2019 08:35:44 +0000 (10:35 +0200)]
qemu: command: re-introduce qemuBuildFSDevCommandLine

This time it only builds one device.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
5 years agoqemu: command: rename qemuBuildFSDevCommandLine
Ján Tomko [Tue, 16 Jul 2019 08:30:51 +0000 (10:30 +0200)]
qemu: command: rename qemuBuildFSDevCommandLine

This function iterates over all filesystems, not just -fsdevs.

Rename it to free the name for a function that actually builds fsdevs.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
5 years agoqemu: address: remove useless comment
Ján Tomko [Tue, 16 Jul 2019 06:30:31 +0000 (08:30 +0200)]
qemu: address: remove useless comment

Commit b27375a9b86f010a9a9fc0323be3f204b62195f4 omitted one zero.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
5 years agoqemu: add CAPS_LATEST tests for 9pfs
Ján Tomko [Tue, 16 Jul 2019 10:49:32 +0000 (12:49 +0200)]
qemu: add CAPS_LATEST tests for 9pfs

Use the existing fs9p.xml and fs9p-ccw.xml to run the tests
with latest caps on x86_64 and s390x.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
5 years agotests: qemu: minimize fs9p.xml
Ján Tomko [Tue, 16 Jul 2019 10:50:44 +0000 (12:50 +0200)]
tests: qemu: minimize fs9p.xml

Remove the hard drive, USB controller and memballoon.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
5 years agovirCommand: use procfs to learn opened FDs
Michal Privoznik [Tue, 2 Jul 2019 17:49:51 +0000 (19:49 +0200)]
virCommand: use procfs to learn opened FDs

When spawning a child process, between fork() and exec() we close
all file descriptors and keep only those the caller wants us to
pass onto the child. The problem is how we do that. Currently, we
get the limit of opened files and then iterate through each one
of them and either close() it or make it survive exec(). This
approach is suboptimal (although, not that much in default
configurations where the limit is pretty low - 1024). We have
/proc where we can learn what FDs we hold open and thus we can
selectively close only those.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovircommand: Separate mass FD closing into a function
Michal Privoznik [Tue, 2 Jul 2019 06:27:25 +0000 (08:27 +0200)]
vircommand: Separate mass FD closing into a function

I will optimize this code a bit in the next commit. But for that
it is better if the code lives in a separate function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotest: Introduce virnetdevopenvswitchtest
Michal Privoznik [Tue, 16 Jul 2019 07:33:38 +0000 (09:33 +0200)]
test: Introduce virnetdevopenvswitchtest

Test if our parsing of interface stats as returned by ovs-vsctl
works as expected. To achieve this without having to mock
virCommand* I'm separating parsing of stats into a separate
function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirNetDevOpenvswitchInterfaceStats: Optimize for speed
Michal Privoznik [Fri, 28 Jun 2019 08:33:09 +0000 (10:33 +0200)]
virNetDevOpenvswitchInterfaceStats: Optimize for speed

We run 'ovs-vsctl' nine times (first to find if interface is
there and then eight times = for each stats member separately).
This is very inefficient. I've found a way to run it once and
with a bit of help from virJSON module we can parse out stats
we need.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: don't assume "localhost" only resolves to 1/2 IPs
Daniel P. Berrangé [Mon, 15 Jul 2019 15:58:02 +0000 (16:58 +0100)]
tests: don't assume "localhost" only resolves to 1/2 IPs

On Debian derived distros "localhost" can resolve to the normal
"127.0.0.1" and "::1", but it can also resolve to "127.0.1.1"

Rewrite the code so that it doesn't assume a fixed number of IPs.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotest_driver: implement virDomainSetMemoryParameters
Ilias Stamatis [Thu, 4 Jul 2019 21:36:35 +0000 (23:36 +0200)]
test_driver: implement virDomainSetMemoryParameters

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agointerface: fix driver name in state directory path
Daniel P. Berrangé [Thu, 11 Jul 2019 15:22:03 +0000 (16:22 +0100)]
interface: fix driver name in state directory path

Typo meant we use 'nodedev' instead of 'interface'. This doesn't hurt
libvirtd because if a process tries to acquire a lock it already holds
it will succeed. It fails when nodedev & interface drivers are in
separate daemons though.

Reviewed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoall: don't wait for driver lock during startup
Daniel P. Berrangé [Thu, 11 Jul 2019 14:57:34 +0000 (15:57 +0100)]
all: don't wait for driver lock during startup

When the drivers acquire their pidfile lock we don't want to wait if the
lock is already held. We need the driver to immediately report error,
causing the daemon to exit.

Reviewed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotest_driver: implement virDomainSetUserPassword
Ilias Stamatis [Tue, 9 Jul 2019 16:13:44 +0000 (18:13 +0200)]
test_driver: implement virDomainSetUserPassword

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agolibvirt_nss: Report newer addresses first
Michal Privoznik [Wed, 10 Jul 2019 12:30:11 +0000 (14:30 +0200)]
libvirt_nss: Report newer addresses first

Ideally, a software that's translating domain names would iterate
over all addresses the NSS returned, but some software does not
bother (e.g. ping). What happens is that for instance when
installing a guest, it's assigned one IP address but once it's
installed and rebooted it gets a different IP address (because
client ID used for the first DHCP traffic when installing the
guest was generated dynamically and never saved so after reboot
the guest generated new ID which resulted in different IP address
to be assigned). This results in 'ping $domain' not working
properly as it still pings the old IP address. Well, it might -
NSS plugin does not guarantee any order of addresses.

To resolve this problem, we can sort the array just before
returning it to the caller (ping) so that the newer IP addresses
come before older ones.

Reported-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agolibvirt_nss: Pass @name to appendAddr()
Michal Privoznik [Wed, 10 Jul 2019 08:34:53 +0000 (10:34 +0200)]
libvirt_nss: Pass @name to appendAddr()

In the nss plugin we have ERROR() macro which by default does
nothing. However, at compile time it can be made to report errors
(this is useful for debugging because by nature of NSS debugging
is hard). Anyway, the appendAddr() function uses @name (which
contains name the caller wants us to resolve) for error
reporting. But the caller findLeaseInJSON() is not passing it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agolibvirt_nss: Drop some needless cleanup labels
Michal Privoznik [Wed, 10 Jul 2019 08:09:46 +0000 (10:09 +0200)]
libvirt_nss: Drop some needless cleanup labels

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agolibvirt_nss: Use VIR_AUTOPTR and VIR_AUTOFREE
Michal Privoznik [Wed, 10 Jul 2019 08:03:49 +0000 (10:03 +0200)]
libvirt_nss: Use VIR_AUTOPTR and VIR_AUTOFREE

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agolibvirt_nss: Use VIR_STEAL_PTR() in findLease()
Michal Privoznik [Wed, 10 Jul 2019 08:01:56 +0000 (10:01 +0200)]
libvirt_nss: Use VIR_STEAL_PTR() in findLease()

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agosecurity: aa-helper: allow virt-aa-helper to read .vhd images
Christian Ehrhardt [Wed, 3 Jul 2019 10:44:31 +0000 (12:44 +0200)]
security: aa-helper: allow virt-aa-helper to read .vhd images

VHD images can be used as any other, so we should add them to the list
of types that virt-aa-helper can read when creating the per-guest rules
for backing files.

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: Jamie Strandboge <jamie@canonical.com>
5 years agoqemu: Relax os.loader->type check when validating domain
Michal Privoznik [Sat, 13 Jul 2019 07:17:06 +0000 (09:17 +0200)]
qemu: Relax os.loader->type check when validating domain

When validating a domain among all the checks there are two that
concern VIR_DOMAIN_LOADER_TYPE_PFLASH specifically. The first
check ensures that on x86 ACPI is enabled when UEFI is requested,
the second ensures that UEFI is used when ACPI is requested on
aarch64. However, check for UEFI is done by plain comparison of
def->os.loader->type which is insufficient because we have
def->os.firmware too.

NB, this wouldn't be a problem for active domain, because on
startup process def->os.loader->type gets filled by
qemuFirmwareEnableFeatures(), but that's not the case for
inactive domains.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1729604
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agoqemu: block: Split up qemuBlockStorageSourceAttachApply
Peter Krempa [Mon, 27 May 2019 15:30:12 +0000 (17:30 +0200)]
qemu: block: Split up qemuBlockStorageSourceAttachApply

Split up the addition of a storage source into the following sub-steps:
1) storage access dependencies (TLS transport, persistent reservation)
2) storage acccess node (file/gluster/nbd...)
3) format driver dependencies (encryption secret)
4) format driver node (qcow2, raw, ...)

The functions split out will be later reused when implementing support
for 'blockdev-create' as we'll need the dependencies plugged in first,
then blockdev-create will be called and after that successfully finishes
blockdev-add will be added.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Refactor variables for extracting flags in qemuDomainBlockCopyCommon
Peter Krempa [Tue, 21 May 2019 11:51:27 +0000 (13:51 +0200)]
qemu: Refactor variables for extracting flags in qemuDomainBlockCopyCommon

Add separate booleans for extracting VIR_DOMAIN_BLOCK_COPY_REUSE_EXT and
VIR_DOMAIN_BLOCK_COPY_SHALLOW from '@flags' and also change 'reuse' into
'existing'.

qemuMonitorDriveMirror requires the unmodified state of the flags to
pass to qemu and also we use the value a few times internally. Extract
it separately now.

The 'reuse' flag did not indicate reusing of the file as much as the
fact that the storage is existing and thus should not be created, so
modify the name to reflect this.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: blockjob: Don't emit traditional disk events for jobs without disk
Peter Krempa [Tue, 23 Apr 2019 08:47:01 +0000 (10:47 +0200)]
qemu: blockjob: Don't emit traditional disk events for jobs without disk

With -blockdev it will be possible that a block job loses the disk that
was used to start it to a guest-initiated hot-unplug. Don't emit the
block job events in that case as we can't report the top level source or
disk target for an unplugged (and potentially replugged with different
source) disk.

Eventually when we add machinery for tracking jobs globally for a VM the
event will be reinstated via the domain job event.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: blockjob: Don't reset state when entering sync blockjob
Peter Krempa [Mon, 27 May 2019 13:20:21 +0000 (15:20 +0200)]
qemu: blockjob: Don't reset state when entering sync blockjob

job->newstate is now used internally all the time so there's no need to
clear it as it already has correct value.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: add 'bochs' video display type
Jonathon Jongsma [Fri, 12 Jul 2019 20:12:16 +0000 (15:12 -0500)]
qemu: add 'bochs' video display type

Update schema and configuration to allow specifying new video type of
'bochs'. Add implementation and tests for qemu.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Add bochs-display capability
Jonathon Jongsma [Fri, 12 Jul 2019 20:12:15 +0000 (15:12 -0500)]
qemu: Add bochs-display capability

Check whether qemu supports the bochs-display device and set a
capability. Update tests.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agostorage: Add iscsi-direct pool list type flag
Han Han [Thu, 11 Jul 2019 07:23:05 +0000 (15:23 +0800)]
storage: Add iscsi-direct pool list type flag

Add pool list type flag VIR_CONNECT_LIST_STORAGE_POOLS_ISCSI_DIRECT,
which was forgotten when introducing iscsi-direct pool at f0bf1be3.

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

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agovirsh.pod: Add zfs and vstorage pool types
Han Han [Thu, 11 Jul 2019 07:23:07 +0000 (15:23 +0800)]
virsh.pod: Add zfs and vstorage pool types

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agostorage: Add missing pool type flags in comment
Han Han [Thu, 11 Jul 2019 07:23:06 +0000 (15:23 +0800)]
storage: Add missing pool type flags in comment

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agomaint: RNG comment fix
Eric Blake [Fri, 12 Jul 2019 21:25:00 +0000 (16:25 -0500)]
maint: RNG comment fix

Typo'd at file creation in commit 0c97dc41.

Signed-off-by: Eric Blake <eblake@redhat.com>
5 years agosnapshot: Factor out redefine cycle validation
Eric Blake [Sat, 6 Jul 2019 02:07:43 +0000 (21:07 -0500)]
snapshot: Factor out redefine cycle validation

The code to check whether a redefined snapshot/checkpoint XML is
attempting to create a cycle in the list of moments is lengthy, and
common between the two types of list. Therefore, it belongs in the
shared base file.

Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
5 years agotests: skip systemd activation test if FDs 3/4/5 are open
Daniel P. Berrangé [Fri, 12 Jul 2019 16:55:13 +0000 (17:55 +0100)]
tests: skip systemd activation test if FDs 3/4/5 are open

With systemd activation the passed in file descriptors are required to
be numbered from STDERR_FILENO + 1 onwards. The unit tests thus require
FDs 3, 4 and 5 to be available.

This may not be the case in all environments in which the tests run. For
example on RHEL7 it was seen that a library constructor (gcrypt probably)
opens /dev/urandom and leaves the file handle open. This means FD 3 is
not available and the activation tests fail.

The best way to deal with this would be to create a standalone helper
program for the tests, but that's much more work than just skipping the
tests if we notice we have the problem.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agorpc: remove unused typedef for auto shutdown function callback
Daniel P. Berrangé [Mon, 1 Jul 2019 14:16:48 +0000 (15:16 +0100)]
rpc: remove unused typedef for auto shutdown function callback

The use of the virNetServerAutoShutdownFunc typedef was removed in

  commit 79b8a56995e6d9ce47e0b44512f7be440df9ff7d
  Author: Daniel P. Berrange <berrange@redhat.com>
  Date:   Wed Oct 31 19:03:55 2012 +0000

    Replace polling for active VMs with signalling by drivers

This unused typedef was then copied into the virNetDaemon object
when that was split off from virNetServer, resulting in a typedef
virNetDaemonAutoShutdownFunc that has never been needed.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoutil: remove unused helper for getting UNIX socket path
Daniel P. Berrangé [Tue, 25 Jun 2019 17:36:36 +0000 (18:36 +0100)]
util: remove unused helper for getting UNIX socket path

The new systemd activation APIs mean there is no longer a need to get
the UNIX socket path associated with a plain FD.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoutil: move code for getting listen FDs into systemd module
Daniel P. Berrangé [Tue, 25 Jun 2019 17:35:11 +0000 (18:35 +0100)]
util: move code for getting listen FDs into systemd module

The virGetListenFDs method no longer needs to be called directly, so it
can be a static function internal to the systemd code.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agologging: convert log daemon to use systemd activation APIs
Daniel P. Berrangé [Tue, 25 Jun 2019 17:29:43 +0000 (18:29 +0100)]
logging: convert log daemon to use systemd activation APIs

Using the new system activation APIs allows for simpler code setting up
the network services.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agolocking: convert lock daemon to use systemd activation APIs
Daniel P. Berrangé [Tue, 25 Jun 2019 17:29:43 +0000 (18:29 +0100)]
locking: convert lock daemon to use systemd activation APIs

Using the new system activation APIs allows for simpler code setting up
the network services.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoutil: remove code spawning with systemd activation env vars
Daniel P. Berrangé [Tue, 25 Jun 2019 17:09:31 +0000 (18:09 +0100)]
util: remove code spawning with systemd activation env vars

The only use of this code was removed by:

  commit be78814ae07f092d9c4e71fd82dd1947aba2f029
  Author: Michal Privoznik <mprivozn@redhat.com>
  Date:   Thu Apr 2 14:41:17 2015 +0200

    virNetSocketNewConnectUNIX: Use flocks when spawning a daemon

less than a year after it was first introduced in

  commit 1b807f92dbb617db5b9d551777d3026d8ff0903f
  Author: Martin Kletzander <mkletzan@redhat.com>
  Date:   Wed Jul 16 08:00:19 2014 +0200

    rpc: pass listen FD to the daemon being started

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoremote: update config files to note usage wrt systemd socket activation
Daniel P. Berrangé [Mon, 24 Jun 2019 11:00:37 +0000 (12:00 +0100)]
remote: update config files to note usage wrt systemd socket activation

Certain libvirtd.conf settings are not honoured when using systemd
socket activation.

Certain systemd unit file settings must match those defined in
libvirtd.conf for systemd socket activation to work with systemd
version < 227, otherwise libvirtd cannot determine which inherited
FD to use for which service.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoremote: make system libvirtd exit when idle via timeout
Daniel P. Berrangé [Tue, 30 Apr 2019 15:44:15 +0000 (16:44 +0100)]
remote: make system libvirtd exit when idle via timeout

Since we have socket activation available now, we can let the system
libvirtd exit when it is idle. This allows it to still do autostart
when the host boots up, but when nothing was started it will quickly
exit again until some mgmt app connects to the socket.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoremote: add systemd socket units for UNIX/TCP sockets
Daniel P. Berrangé [Tue, 30 Apr 2019 15:41:10 +0000 (16:41 +0100)]
remote: add systemd socket units for UNIX/TCP sockets

We don't do socket activation of libvirtd, since we need to
unconditionally start libvirtd in order to perform autostart. This
doesn't mean we can't have systemd socket units. Some use cases will
not need libvirt's autostart & are thus free to use activation.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agorpc: remove unused API for creating services from FDs
Daniel P. Berrangé [Mon, 24 Jun 2019 10:52:40 +0000 (11:52 +0100)]
rpc: remove unused API for creating services from FDs

The virNetServerServiceNewFDOrUNIX method cannot be correctly used when
dealing with systemd activation of a service which can receive more than
one socket FD as there is not guaranteed ordering of FDs.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoremote: fix handling of systemd activation wrt socket ordering
Daniel P. Berrangé [Tue, 25 Jun 2019 16:27:04 +0000 (17:27 +0100)]
remote: fix handling of systemd activation wrt socket ordering

The current libvirtd code for systemd socket activation assumes socket
FDs are passed in the order unix-rw, unix-ro, unix-admin.  There is in
fact no ordering guarantee made by systemd. Applications are expected
to check the address or name associated with each FD to figure out its
identity.

This rewrites libvirtd to make use of the new systemd activation APIs
to make it robust wrt socket ordering changes.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoremote: simplify libvirtd code for deciding if SASL auth is needed
Daniel P. Berrangé [Tue, 25 Jun 2019 16:32:29 +0000 (17:32 +0100)]
remote: simplify libvirtd code for deciding if SASL auth is needed

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agorpc: add API for checking whether an auth scheme is in use on a server
Daniel P. Berrangé [Tue, 25 Jun 2019 16:04:47 +0000 (17:04 +0100)]
rpc: add API for checking whether an auth scheme is in use on a server

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agorpc: add helper APIs for adding services with systemd activation
Daniel P. Berrangé [Tue, 25 Jun 2019 15:33:36 +0000 (16:33 +0100)]
rpc: add helper APIs for adding services with systemd activation

Currently code has to first create the service and then separately
register it with the server. If the socket associated with a particular
service is not passed from systemd we want to skip creating the service
altogether. This means we can't put the systemd activation logic into
the constructors for virNetServerService.

This patch thus creates some helper methods against virNetServer which
combine systemd activation, service creation and service registration
into one single operation. This operation is automatically a no-op if
systemd activation is present and no sockets were passed in.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agorpc: avoid unlinking sockets passed in from systemd
Daniel P. Berrangé [Tue, 25 Jun 2019 19:17:27 +0000 (20:17 +0100)]
rpc: avoid unlinking sockets passed in from systemd

Currently the socket code will unlink any UNIX socket path which is
associated with a server socket. This is not fine grained enough, as we
need to avoid unlinking server sockets we were passed by systemd.

To deal with this we must explicitly track whether each socket needs to
be unlinked when closed, separately of the client vs server state.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agorpc: allow creating RPC service from an array of FDs
Daniel P. Berrangé [Tue, 25 Jun 2019 14:54:48 +0000 (15:54 +0100)]
rpc: allow creating RPC service from an array of FDs

The virNetServerServiceNewFD API only accepts a single FD, but it is
easily changed to allow for an array of FDs to be passed in.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agorpc: refactor RPC service constructors to share more code
Daniel P. Berrangé [Mon, 24 Jun 2019 10:48:38 +0000 (11:48 +0100)]
rpc: refactor RPC service constructors to share more code

Introduce a virNetServerServiceNewSocket API that allows the various
constructors to share more code.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoutil: add APIs for facilitating use of systemd activation FDs
Daniel P. Berrangé [Tue, 25 Jun 2019 12:03:56 +0000 (13:03 +0100)]
util: add APIs for facilitating use of systemd activation FDs

When receiving multiple FDs from systemd during service activation it is
neccessary to identify which purpose each FD is used for. While this
could be inferred by looking for the specific IP ports or UNIX socket
paths, this requires the systemd config to always match what is expected
by the code. Using systemd FD names we can remove this restriction and
simply identify FDs based on an arbitrary name.

The FD names are passed by systemd in the LISTEN_FDNAMES env variable
which is populated with the socket unit file names, unless overriden
by using the FileDescriptorName setting.

This is supported since the system 227 release and unfortunately RHEL7
lacks this version. Thus the code has some back compat support whereby
we look at the TCP ports or the UNIX socket paths to identify what
socket maps to which name. This back compat code is written such that
is it easly deleted when we are able to mandate newer systemd.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agorpc: ensure all sockets bind to same port when service is NULL
Daniel P. Berrangé [Wed, 26 Jun 2019 11:22:29 +0000 (12:22 +0100)]
rpc: ensure all sockets bind to same port when service is NULL

When the service passed to getaddrinfo is NULL the kernel will choose a
free port to bind to. In a dual stack though we will get separate
sockets for IPv4 and IPv6 and we need them to bind to the same port
number. Thus once the kerel has auto-selected a port for the first
socket, we must disable auto-select for subsequent IP sockets and force
reuse of the first port.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agostorage: rbd: do not attempt to dereference a non-pointer
Ján Tomko [Fri, 12 Jul 2019 15:47:11 +0000 (17:47 +0200)]
storage: rbd: do not attempt to dereference a non-pointer

My commit 9b7c4048fa0559fd81d57b7f7d13b1dccd6a99b2 was too blind
and my librbd was not new enough to actually compile this part.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agodocs: RBD pool only supports raw volumes
Ján Tomko [Fri, 12 Jul 2019 14:23:54 +0000 (16:23 +0200)]
docs: RBD pool only supports raw volumes

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoRevert "conf: Remove volOptions for VIR_STORAGE_POOL_RBD"
Ján Tomko [Fri, 12 Jul 2019 14:13:17 +0000 (16:13 +0200)]
Revert "conf: Remove volOptions for VIR_STORAGE_POOL_RBD"

This reverts commit 035db37394ad11a39d47f8bd2b6a8a2734283cbf

Even though we only allow using RBD with raw volumes,
removing the options and the default format causes our
parser not to fill out the volume format and the backend code
rejects creating a non-raw volume.

Re-introduce the volume options to fix volume creation while
erroring out on requests to use non-raw formats.

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agostorage: rbd: actually index the array when iterating over it
Ján Tomko [Fri, 12 Jul 2019 14:11:16 +0000 (16:11 +0200)]
storage: rbd: actually index the array when iterating over it

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

Fixes: 3aa190f2a43a632b542a6ba751a6c3ab4d51f1dd
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agostorage: rbd: use VIR_REALLOC in the loop
Ján Tomko [Fri, 12 Jul 2019 14:09:32 +0000 (16:09 +0200)]
storage: rbd: use VIR_REALLOC in the loop

If there are more than 16 images, the memory allocated in images
might be leaked on subsequent execution(s).

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: minor refactor of video device string handling
Jonathon Jongsma [Thu, 11 Jul 2019 21:05:32 +0000 (16:05 -0500)]
qemu: minor refactor of video device string handling

In preparation for adding the bochs display device, refactor the logic
so that each branch handles a single device type and checks its
parameters within that branch. In this case VGA and VMVGA are still
grouped into the same branch since they share device-specific parameter
names.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agovirnetworkobj: Drop needless cleanup label in virNetworkObjDeletePort
Michal Privoznik [Tue, 9 Jul 2019 14:57:44 +0000 (16:57 +0200)]
virnetworkobj: Drop needless cleanup label in virNetworkObjDeletePort

The cleanup label in virNetworkObjDeletePort() function serves no
purpose. Drop it and thus simplify the function a bit.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agovirnetworkobj: Drop needless cleanup label in virNetworkObjAddPort
Michal Privoznik [Tue, 9 Jul 2019 14:51:43 +0000 (16:51 +0200)]
virnetworkobj: Drop needless cleanup label in virNetworkObjAddPort

The cleanup label in virNetworkObjAddPort() function serves no
purpose. Drop it and thus simplify the function a bit.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agovirnetworkobj: Free retval of virNetworkObjGetPortStatusDir()
Michal Privoznik [Tue, 9 Jul 2019 14:46:31 +0000 (16:46 +0200)]
virnetworkobj: Free retval of virNetworkObjGetPortStatusDir()

The virNetworkObjGetPortStatusDir() function allocates a memory
to construct a path. None of the callers free it leading to a
memleak.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agologging: ensure virtlogd rollover takes priority over logrotate
Daniel P. Berrangé [Fri, 5 Jul 2019 09:32:53 +0000 (10:32 +0100)]
logging: ensure virtlogd rollover takes priority over logrotate

The virtlogd config is set to rollover logs every 2 MB.

Normally a logrotate config file is also installed to handle cases where
virtlogd is disabled. This is set to rollover weekly with no size
constraint.

As a result logrotate can interfere with virtlogd's, rolling over files
that virtlogd has already taken care of.

This changes logrotate configs to rollover based on a max size
constraint of 2 MB + 1 byte. When virtlogd is running the log files will
never get this large, making logrotate a no-op.

If the user changes the size in virtlogd's config to something larger,
they are responsible for also changing the logrotate config suitably.

The LXC/libxl drivers don't use virtlogd, but there logrotate config is
altered to match the QEMU driver config, for the sake of consistency.

Reviewed-by: Jim Fehlig <jfehlig@suse.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agorpc: always pass "-T -e none" args to ssh
Daniel P. Berrangé [Tue, 9 Jul 2019 17:02:38 +0000 (18:02 +0100)]
rpc: always pass "-T -e none" args to ssh

Way back in the past, the "no_tty=1" option was added for the remote
driver to disable local password prompting by disabling use of the local
tty:

  commit b32f42984994a397441a1c48f1a002e906624c51
  Author: Daniel P. Berrange <berrange@redhat.com>
  Date:   Fri Sep 21 20:17:09 2007 +0000

    Added a no_tty param to remote URIs to stop SSH prompting for password

This was done by adding "-T -o BatchMode=yes -e none" args to ssh. This
achieved the desired results but is none the less semantically flawed
because it is mixing up config parameters for the local tty vs the
remote tty.

The "-T" arg stops allocation of a TTY on the remote host. This is good
for all libvirt SSH tunnels as we never require a TTY for our usage
model, so we should have just passed this unconditionally.

The "-e none" option disables the escape character for sessions with a
TTY. If we pass "-T" this is not required, but it also not harmful to
add it, so we should just pass it unconditionally too.

Only the "-o BatchMode=yes" option is related to disabling local
password prompts and thus needs control via the no_tty URI param.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: stop formatting json='1' in status XML
Ján Tomko [Fri, 14 Jun 2019 19:14:48 +0000 (21:14 +0200)]
qemu: stop formatting json='1' in status XML

For quite some time now it is impossible to connect to a domain
using a HMP monitor, so there is no point in formatting it in the status
XML.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
5 years agonodedev: add missing include for virFileMakePathWithMode
Daniel P. Berrangé [Thu, 11 Jul 2019 13:19:03 +0000 (14:19 +0100)]
nodedev: add missing include for virFileMakePathWithMode

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoutil: add API for resolving socket service names
Daniel P. Berrangé [Mon, 24 Jun 2019 10:26:28 +0000 (11:26 +0100)]
util: add API for resolving socket service names

The getservent() APIs are not re-entrant safe so cannot be used in any
threaded program. Add a wrapper around getaddrinfo() for resolving the
service names to a port number.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agorpc: add helper API for getting UNIX path from socket object
Daniel P. Berrangé [Mon, 24 Jun 2019 10:48:12 +0000 (11:48 +0100)]
rpc: add helper API for getting UNIX path from socket object

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoutil: add helper API for getting UNIX path from socket address
Daniel P. Berrangé [Mon, 24 Jun 2019 10:25:48 +0000 (11:25 +0100)]
util: add helper API for getting UNIX path from socket address

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agolocking,logging: put a strong dep from admin socket to main socket
Daniel P. Berrangé [Wed, 26 Jun 2019 16:17:51 +0000 (17:17 +0100)]
locking,logging: put a strong dep from admin socket to main socket

It doesn't make sense to have the admin socket active if the main
socket is not running, so bind their lifecycle together.

This ensures that if primary socket is stopped, the corresponding
admin socket is also stopped.

In the reverse, starting the admin socket will also automatically
start the primary socket.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agogitlab: Perform some builds on Debian 10
Andrea Bolognani [Thu, 11 Jul 2019 10:34:50 +0000 (12:34 +0200)]
gitlab: Perform some builds on Debian 10

The split is mostly arbitrary, but we purposefully moved
the mips64el builds off sid since currently that container
is failing to build and is thus unavailable.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoci: Update image list
Andrea Bolognani [Thu, 11 Jul 2019 10:32:07 +0000 (12:32 +0200)]
ci: Update image list

We really need to change this so that it fetches the image
list dynamically from Quay, but for the time being at least
make sure the static list is accurate.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoci: Use default image tag "latest"
Andrea Bolognani [Thu, 11 Jul 2019 10:30:04 +0000 (12:30 +0200)]
ci: Use default image tag "latest"

Up until now, our images have been tagged as "master" instead
of the default "latest" due to the way the build process
worked, but we're using the default now.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobhyve: acquire a pidfile in the driver root directory
Daniel P. Berrangé [Thu, 23 May 2019 10:34:08 +0000 (11:34 +0100)]
bhyve: acquire a pidfile in the driver root directory

When we allow multiple instances of the driver for the same user
account, using a separate root directory, we need to ensure mutual
exclusion. Use a pidfile to guarantee this.

In privileged libvirtd this ends up locking

   /var/run/libvirt/bhyve/driver.pid

In unprivileged libvirtd this ends up locking

  /run/user/$UID/libvirt/bhyve/run/driver.pid

NB, the latter can vary depending on $XDG_RUNTIME_DIR

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovz: acquire a pidfile in the driver root directory
Daniel P. Berrangé [Thu, 23 May 2019 10:34:08 +0000 (11:34 +0100)]
vz: acquire a pidfile in the driver root directory

When we allow multiple instances of the driver for the same user
account, using a separate root directory, we need to ensure mutual
exclusion. Use a pidfile to guarantee this.

In privileged libvirtd this ends up locking

   /var/run/libvirt/vz/driver.pid

In unprivileged libvirtd this ends up locking

  /run/user/$UID/libvirt/vz/run/driver.pid

NB, the latter can vary depending on $XDG_RUNTIME_DIR

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agolxc: acquire a pidfile in the driver root directory
Daniel P. Berrangé [Thu, 23 May 2019 10:34:08 +0000 (11:34 +0100)]
lxc: acquire a pidfile in the driver root directory

When we allow multiple instances of the driver for the same user
account, using a separate root directory, we need to ensure mutual
exclusion. Use a pidfile to guarantee this.

In privileged libvirtd this ends up locking

   /var/run/libvirt/lxc/driver.pid

In unprivileged libvirtd this ends up locking

  /run/user/$UID/libvirt/lxc/run/driver.pid

NB, the latter can vary depending on $XDG_RUNTIME_DIR

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agolibxl: acquire a pidfile in the driver root directory
Daniel P. Berrangé [Thu, 23 May 2019 10:34:08 +0000 (11:34 +0100)]
libxl: acquire a pidfile in the driver root directory

When we allow multiple instances of the driver for the same user
account, using a separate root directory, we need to ensure mutual
exclusion. Use a pidfile to guarantee this.

In privileged libvirtd this ends up locking

   /var/run/libvirt/libxl/driver.pid

In unprivileged libvirtd this ends up locking

  /run/user/$UID/libvirt/libxl/run/driver.pid

NB, the latter can vary depending on $XDG_RUNTIME_DIR

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agolibxl: remove obsolete check for xend during driver startup
Daniel P. Berrangé [Wed, 10 Jul 2019 10:43:04 +0000 (11:43 +0100)]
libxl: remove obsolete check for xend during driver startup

No supported build targets for libvirt still ship xend, so there is no
need for the libxl driver to check for it anymore.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agonwfilter: acquire a pidfile in the driver root directory
Daniel P. Berrangé [Thu, 23 May 2019 10:34:08 +0000 (11:34 +0100)]
nwfilter: acquire a pidfile in the driver root directory

When we allow multiple instances of the driver for the same user
account, using a separate root directory, we need to ensure mutual
exclusion. Use a pidfile to guarantee this.

In privileged libvirtd this ends up locking

   /var/run/libvirt/nwfilter/driver.pid

In unprivileged libvirtd this ends up locking

  /run/user/$UID/libvirt/nwfilter/run/driver.pid

NB, the latter can vary depending on $XDG_RUNTIME_DIR

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agointerface: acquire a pidfile in the driver root directory
Daniel P. Berrangé [Thu, 23 May 2019 10:34:08 +0000 (11:34 +0100)]
interface: acquire a pidfile in the driver root directory

When we allow multiple instances of the driver for the same user
account, using a separate root directory, we need to ensure mutual
exclusion. Use a pidfile to guarantee this.

In privileged libvirtd this ends up locking

   /var/run/libvirt/interface/driver.pid

In unprivileged libvirtd this ends up locking

  /run/user/$UID/libvirt/interface/run/driver.pid

NB, the latter can vary depending on $XDG_RUNTIME_DIR

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agonodedev: acquire a pidfile in the driver root directory
Daniel P. Berrangé [Thu, 23 May 2019 10:34:08 +0000 (11:34 +0100)]
nodedev: acquire a pidfile in the driver root directory

When we allow multiple instances of the driver for the same user
account, using a separate root directory, we need to ensure mutual
exclusion. Use a pidfile to guarantee this.

In privileged libvirtd this ends up locking

   /var/run/libvirt/nodedev/driver.pid

In unprivileged libvirtd this ends up locking

  /run/user/$UID/libvirt/nodedev/run/driver.pid

NB, the latter can vary depending on $XDG_RUNTIME_DIR

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agostorage: acquire a pidfile in the driver root directory
Daniel P. Berrangé [Thu, 23 May 2019 10:34:08 +0000 (11:34 +0100)]
storage: acquire a pidfile in the driver root directory

When we allow multiple instances of the driver for the same user
account, using a separate root directory, we need to ensure mutual
exclusion. Use a pidfile to guarantee this.

In privileged libvirtd this ends up locking

   /var/run/libvirt/storage/driver.pid

In unprivileged libvirtd this ends up locking

  /run/user/$UID/libvirt/storage/run/driver.pid

NB, the latter can vary depending on $XDG_RUNTIME_DIR

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agonetwork: acquire a pidfile in the driver root directory
Daniel P. Berrangé [Thu, 23 May 2019 10:34:08 +0000 (11:34 +0100)]
network: acquire a pidfile in the driver root directory

When we allow multiple instances of the driver for the same user
account, using a separate root directory, we need to ensure mutual
exclusion. Use a pidfile to guarantee this.

In privileged libvirtd this ends up locking

   /var/run/libvirt/network/driver.pid

In unprivileged libvirtd this ends up locking

  /run/user/$UID/libvirt/network/run/driver.pid

NB, the latter can vary depending on $XDG_RUNTIME_DIR

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosecrets: acquire a pidfile in the driver root directory
Daniel P. Berrangé [Thu, 23 May 2019 10:34:08 +0000 (11:34 +0100)]
secrets: acquire a pidfile in the driver root directory

When we allow multiple instances of the driver for the same user
account, using a separate root directory, we need to ensure mutual
exclusion. Use a pidfile to guarantee this.

In privileged libvirtd this ends up locking

   /var/run/libvirt/secrets/driver.pid

In unprivileged libvirtd this ends up locking

  /run/user/$UID/libvirt/secrets/run/driver.pid

NB, the latter can vary depending on $XDG_RUNTIME_DIR

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: acquire a pidfile in the driver root directory
Daniel P. Berrangé [Thu, 23 May 2019 10:34:08 +0000 (11:34 +0100)]
qemu: acquire a pidfile in the driver root directory

When we allow multiple instances of the driver for the same user
account, using a separate root directory, we need to ensure mutual
exclusion. Use a pidfile to guarantee this.

In privileged libvirtd this ends up locking

   /var/run/libvirt/qemu/driver.pid

In unprivileged libvirtd this ends up locking

  /run/user/$UID/libvirt/qemu/run/driver.pid

NB, the latter can vary depending on $XDG_RUNTIME_DIR

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosnapshot: Add VIR_DOMAIN_SNAPSHOT_CREATE_VALIDATE flag
Eric Blake [Sat, 6 Jul 2019 03:05:37 +0000 (22:05 -0500)]
snapshot: Add VIR_DOMAIN_SNAPSHOT_CREATE_VALIDATE flag

We've been doing a terrible job of performing XML validation in our
various API that parse XML with a corresponding schema (we started
with domains back in commit dd69a14f, v1.2.12, but didn't catch all
domain-related APIs, didn't document the use of the flag, and didn't
cover other XML). New APIs (like checkpoints) should do the validation
unconditionally, but it doesn't hurt to continue retrofitting existing
APIs to at least allow the option.

While there are many APIs that could be improved, this patch focuses
on wiring up a new snapshot XML creation flag through all the
hypervisors that support snapshots, as well as exposing it in 'virsh
snapshot-create'.  For 'virsh snapshot-create-as', we blindly set the
flag without a command-line option, since the XML we create from the
command line should generally always comply (note that validation
might cause failures where it used to succeed, such as if we tighten
the RNG to reject a name of '../\n'); but blindly passing the flag
means we also have to add in fallback code to disable validation if
the server is too old to understand the flag.

Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
5 years agosnapshot: Add internal option to validate XML against schema
Eric Blake [Sat, 6 Jul 2019 03:02:03 +0000 (22:02 -0500)]
snapshot: Add internal option to validate XML against schema

Similar to VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA; the next patch will
put it to use with a counterpart public API flag.

No need to change qemudomainsnapshotxml2xmltest to use the flag, since
the testsuite already has a separate virschematest that does the same.

Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
5 years agomaint: Drop dead code in check-driverimpls.pl
Eric Blake [Tue, 9 Jul 2019 14:02:35 +0000 (09:02 -0500)]
maint: Drop dead code in check-driverimpls.pl

We no longer need to special-case xenUnified, since 1dac5fbbbb0
dropped support for that naming scheme.

Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
5 years agovz: fix typo that lost the '#' in '#define'
Daniel P. Berrangé [Wed, 10 Jul 2019 14:35:29 +0000 (15:35 +0100)]
vz: fix typo that lost the '#' in '#define'

Previous commit:

  commit faceedaf7170903065807e2c37dd0d1bd06a6ef5
  Author: Jonathon Jongsma <jjongsma@redhat.com>
  Date:   Tue Jun 18 11:13:12 2019 -0500

    src/vz: use #pragma once in headers

accidentally chomped the "#" in a "#define" when re-indenting

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoutil: assume modern CPU_ALLOC macros always exist
Daniel P. Berrangé [Tue, 9 Jul 2019 11:30:50 +0000 (12:30 +0100)]
util: assume modern CPU_ALLOC macros always exist

Support for the modern CPU_ALLOC macros was added 10 years ago in

  commit a73cd93b2428adbbc62bb919b6cf5ffd27728040
  Author: Daniel P. Berrange <berrange@redhat.com>
  Date:   Mon Nov 16 16:08:29 2009 +0000

    Alternate CPU affinity impl to cope with NR_CPUS > 1024

This is long enough that we can assume it always exists and drop the
back compat code.

Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agodocs: introduce a "knowledge base" for task oriented guides
Daniel P. Berrangé [Mon, 8 Jul 2019 12:58:56 +0000 (13:58 +0100)]
docs: introduce a "knowledge base" for task oriented guides

The previously added AMD SEV doc was not linked from anywhere on the
website. Address this by introducing a new "Knowledge base" section
that can hold task oriented guide to various features. Moving the SEV,
disk locking and secure usage guides under this section.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agomaint: Typo fix for whether
Eric Blake [Tue, 9 Jul 2019 13:53:31 +0000 (08:53 -0500)]
maint: Typo fix for whether

Signed-off-by: Eric Blake <eblake@redhat.com>
5 years agobhyve: Fix build
Eric Blake [Tue, 9 Jul 2019 15:36:31 +0000 (10:36 -0500)]
bhyve: Fix build

Continuous integration caught that although 'make syntax-check' was
sufficient to let me be aware that I had to change bhyve to use
s/virDomainShutdownEnsureACL/virDomainShutdownFlagsEnsureACL/, it was
not sufficient to note which ACL functions require 2 vs. 3 arguments
for flag validation.

Fixes: eded8aad
Signed-off-by: Eric Blake <eblake@redhat.com>
5 years agolibxl_driver: Drop needless variable
Michal Privoznik [Tue, 28 May 2019 16:02:23 +0000 (18:02 +0200)]
libxl_driver: Drop needless variable

The @oldDef variable in libxlAddDom0() is not used really. Drop
it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>