]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
5 years agonetwork: delay global firewall setup if no networks are running
Daniel P. Berrangé [Tue, 21 May 2019 11:40:13 +0000 (12:40 +0100)]
network: delay global firewall setup if no networks are running

Creating firewall rules for the virtual networks causes the kernel to
load the conntrack module. This imposes a significant performance
penalty on Linux network traffic. Thus we want to only take that hit if
we actually have virtual networks running.

We need to create global firewall rules during startup in order to
"upgrade" rules for any running networks created by older libvirt.
If no running networks are present though, we can safely delay setup
until the time we actually start a network.

Reviewed-by: Jim Fehlig <jfehlig@suse.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agonetwork: add more debugging of firewall chain creation
Daniel P. Berrangé [Wed, 22 May 2019 12:08:13 +0000 (13:08 +0100)]
network: add more debugging of firewall chain creation

Reviewed-by: Jim Fehlig <jfehlig@suse.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agonetwork: pull global chain init into separate method
Daniel P. Berrangé [Tue, 21 May 2019 10:37:37 +0000 (11:37 +0100)]
network: pull global chain init into separate method

Pull the logic for creating global iptables chains into a separate
method and protect its invocation with virOnce, to make it possible
to reuse it in non-startup paths.

Reviewed-by: Jim Fehlig <jfehlig@suse.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: Tweak Intel IOMMU command line generation
Andrea Bolognani [Mon, 20 May 2019 10:48:01 +0000 (12:48 +0200)]
qemu: Tweak Intel IOMMU command line generation

Mostly add comments explaining why there are two capabilites
for the same feature and how they interact.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Introduce qemuDomainDeviceDefValidateIOMMU()
Andrea Bolognani [Fri, 17 May 2019 11:37:35 +0000 (13:37 +0200)]
qemu: Introduce qemuDomainDeviceDefValidateIOMMU()

Device validation should not have to wait until command line
generation time. Moving the code to a separate function also
allows us to avoid some unnecessary repetition.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoIntroduce DOMAIN_DEVICE_ITERATE_MISSING_INFO
Ján Tomko [Tue, 21 May 2019 13:05:37 +0000 (15:05 +0200)]
Introduce DOMAIN_DEVICE_ITERATE_MISSING_INFO

Rename the DOMAIN_DEVICE_ITERATE_GRAPHICS flag.
It was introduced by commit dd45c2710f6fd2d4f8a47f97960532d0e0091e7d
with the intention to run the Validate callback even on the graphics
device.

However, enumerating every single device in virDomainDeviceIterateFlags
is unsustainable and what really was special about the graphics device
was the lack of DeviceInfo.

Rename the flag and iterate over more info-less devices. (and leases)

Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agodocs: Change the 'Launch Security' section id to "launchSecurity"
Erik Skultety [Thu, 23 May 2019 12:26:40 +0000 (14:26 +0200)]
docs: Change the 'Launch Security' section id to "launchSecurity"

Although there's currently only support for SEV, it's likely other
solutions will appear, so we should not refer to the documentation
section simply with 'sev'.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
5 years agomisc: Drop useless checks from *Dispose() functions
Michal Privoznik [Thu, 23 May 2019 10:10:21 +0000 (12:10 +0200)]
misc: Drop useless checks from *Dispose() functions

Due to the way that our virObjectUnref() is written it's not
possible that a NULL is passed into *Dispose() function. However,
some functions check for that regardless.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agotests: Add negative test for Intel IOMMU
Andrea Bolognani [Fri, 17 May 2019 14:37:56 +0000 (16:37 +0200)]
tests: Add negative test for Intel IOMMU

Make sure validation is working as intended by trying to use
Intel IOMMU with the i440fx machine type, though we know it's
a q35-only feature, and expecting an error to be returned.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: Use DO_TEST_CAPS_*() for Intel IOMMU
Andrea Bolognani [Fri, 17 May 2019 12:45:36 +0000 (14:45 +0200)]
tests: Use DO_TEST_CAPS_*() for Intel IOMMU

We can drop the intel-iommu-machine test case while doing so,
since it is supposed to showcase how we generate different
command lines for older QEMU versions and we can do that
using a single input file now.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: Simplify Intel IOMMU testing
Andrea Bolognani [Fri, 17 May 2019 13:38:40 +0000 (15:38 +0200)]
tests: Simplify Intel IOMMU testing

Remove a bunch of irrelevant devices and make sure all input
files explicitly opt out of USB controllers: the latter change
will help later, when we start using DO_TEST_CAPS_*().

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agodocs: hacking: Discourage use of the ternary operator and ban it's abuse
Peter Krempa [Thu, 9 May 2019 10:27:25 +0000 (12:27 +0200)]
docs: hacking: Discourage use of the ternary operator and ban it's abuse

Forbid breaking lines inside the two branches of the ternary operator
and nesting them. Using it in these instances does not help readability.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
ACKed-by: Eric Blake <eblake@redhat.com>
5 years agodocs: hacking: Add good practices for shortening conditional expressions
Peter Krempa [Thu, 9 May 2019 10:20:42 +0000 (12:20 +0200)]
docs: hacking: Add good practices for shortening conditional expressions

Document that checking if a integer is (non-)zero should (not must)
avoid the shortened form that C allows as it may confuse readers into
overlooking the other possible values which might be interresting to
handle.

While pointers have distinct values from the point of view of the code
we only care whether it's non-NULL and thus it's documented it's okay
to shorten those.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
ACKed-by: Eric Blake <eblake@redhat.com>
5 years agodocs: hacking: Document few practices for creating error messages
Peter Krempa [Tue, 7 May 2019 14:47:00 +0000 (16:47 +0200)]
docs: hacking: Document few practices for creating error messages

State that error messages should not be broken into multiple lines for
programmer friendliness and should not be concatenated on the fly for
translator friendliness and few other details.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
ACKed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: monitor: Use VIR_AUTOPTR in qemuMonitorJSON(Drive/Blockdev)Mirror
Peter Krempa [Fri, 17 May 2019 16:17:26 +0000 (18:17 +0200)]
qemu: monitor: Use VIR_AUTOPTR in qemuMonitorJSON(Drive/Blockdev)Mirror

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: monitor: Don't pass full flags to qemuMonitorJSONDriveMirror
Peter Krempa [Fri, 17 May 2019 16:13:53 +0000 (18:13 +0200)]
qemu: monitor: Don't pass full flags to qemuMonitorJSONDriveMirror

Split out the 'shallow' and 'reuse' flags as booleans rather than passing
in flags and constructing them in irrelevant APIs.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: monitor: Don't pass full flags to qemuMonitorJSONBlockdevMirror
Peter Krempa [Fri, 17 May 2019 16:13:53 +0000 (18:13 +0200)]
qemu: monitor: Don't pass full flags to qemuMonitorJSONBlockdevMirror

Split out the 'shallow' flag as a boolean argument rather than passing
in flags and constructing them in irrelevant APIs.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: migration: Don't pass around flags for different API
Peter Krempa [Mon, 20 May 2019 12:48:22 +0000 (14:48 +0200)]
qemu: migration: Don't pass around flags for different API

The NBD migration code uses drive/blockdev-mirror internally. In those
APIs we pass around flags for the monitor commands which are based on
the flags for the virDomainBlockRebase API. Since there's only one flag
which changes, pass it around explicitly rather than obscuring it in a
bitfield.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: blockcopy: sanitize permission handling for 'mirror'
Peter Krempa [Wed, 15 May 2019 15:19:11 +0000 (17:19 +0200)]
qemu: blockcopy: sanitize permission handling for 'mirror'

At the point when we want to modify the permissions for the 'mirror' we
know whether it is supposed to have a backing chain or no. Given that
mirror->backingStore is populated only when we'd need to touch it ayways
we can use qemuDomainStorageSourceChainAccessAllow even in place of
qemuDomainStorageSourceAccessAllow used for other cases to simplify the
code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Simplify allowing access to storage file for block copy
Peter Krempa [Tue, 14 May 2019 15:35:45 +0000 (17:35 +0200)]
qemu: Simplify allowing access to storage file for block copy

One code path open-coded qemuDomainStorageSourceChainAccessAllow badly
and also did not integrate with the locking code.

Replace the separate calls with qemuDomainStorageSourceChainAccessAllow
which does everything internally.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Validate backing store of 'mirror' for block copy
Peter Krempa [Wed, 15 May 2019 15:12:35 +0000 (17:12 +0200)]
qemu: Validate backing store of 'mirror' for block copy

Since 4e797f1a we parse backingStore of mirror which will later be used
with blockdev. Add some validation for the user passed mirror at the
current point to make sure it's not used improperly.

Validate that it's not used without blockdev and also that it's not
passed when not requesting a shallow copy. Also add a chain terminator
for a deep copy since we know the resulting mirror will not have chain.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Remove unnecessary calls to qemuDomainStorageSourceAccessRevoke
Peter Krempa [Tue, 14 May 2019 12:42:35 +0000 (14:42 +0200)]
qemu: Remove unnecessary calls to qemuDomainStorageSourceAccessRevoke

Since 3decae00e90 qemuDomainStorageSourceAccessAllow revokes the
permissions it granted if it fails halfway, thus we can remove some
calls to qemuDomainStorageSourceAccessRevoke which tried to undo this
situation.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Remove unecessary error keeping in qemuDomainBlockCopyCommon
Peter Krempa [Tue, 14 May 2019 13:01:04 +0000 (15:01 +0200)]
qemu: Remove unecessary error keeping in qemuDomainBlockCopyCommon

Since 3decae00e90 qemuDomainStorageSourceAccessRevoke keeps the libvirt
error which was set prior to the call around even after the call, thus
we don't need to do the same when reverting access in the block copy
code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Modernize memory cleaning in qemuDomainBlockCommit
Peter Krempa [Wed, 15 May 2019 11:41:09 +0000 (13:41 +0200)]
qemu: Modernize memory cleaning in qemuDomainBlockCommit

Use VIR_AUTOFREE and VIR_AUTOUNREF.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Modernize memory cleaning in qemuDomainBlockPullCommon
Peter Krempa [Wed, 15 May 2019 11:41:09 +0000 (13:41 +0200)]
qemu: Modernize memory cleaning in qemuDomainBlockPullCommon

Use VIR_AUTOFREE and VIR_AUTOUNREF.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Modernize memory cleaning in qemuDomainBlockCopyCommon
Peter Krempa [Tue, 14 May 2019 12:30:57 +0000 (14:30 +0200)]
qemu: Modernize memory cleaning in qemuDomainBlockCopyCommon

Use VIR_AUTOFREE, VIR_AUTOUNREF, and VIR_STEAL_PTR.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: driver: Set mirror state after successful command
Peter Krempa [Tue, 12 Feb 2019 12:19:17 +0000 (13:19 +0100)]
qemu: driver: Set mirror state after successful command

When aborting or pivoting a block job we record which operation we do
for the mirror in the virDomainDiskDef structure. As everything is
synchronized by a job it's not necessary to modify the state prior to
calling the monitor and resetting the state on failure.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: driver: Don't try to update blockjob status in qemuDomainGetBlockJobInfo
Peter Krempa [Wed, 15 May 2019 09:10:16 +0000 (11:10 +0200)]
qemu: driver: Don't try to update blockjob status in qemuDomainGetBlockJobInfo

All blockjobs get their status updated by events from qemu, so this code
no longer makes sense.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: blockjob: Fix documentation for 'newstate' of _qemuBlockJobData
Peter Krempa [Tue, 12 Feb 2019 13:02:27 +0000 (14:02 +0100)]
qemu: blockjob: Fix documentation for 'newstate' of _qemuBlockJobData

When used with the new job handler the values will also include some of
the non-public values from qemuBlockjobState. Modify the comment to
clarify this.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: blockjob: Remove 'started' from struct _qemuBlockJobData
Peter Krempa [Mon, 11 Feb 2019 12:33:37 +0000 (13:33 +0100)]
qemu: blockjob: Remove 'started' from struct _qemuBlockJobData

As of commit d1a44634acead75bc48fb9b0f68dc1e this field is unused.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agologging: restrict sockets to mode 0600
Daniel P. Berrangé [Tue, 30 Apr 2019 16:27:41 +0000 (17:27 +0100)]
logging: restrict sockets to mode 0600

The virtlogd daemon's only intended client is the libvirtd daemon. As
such it should never allow clients from other user accounts to connect.
The code already enforces this and drops clients from other UIDs, but
we can get earlier (and thus stronger) protection against DoS by setting
the socket permissions to 0600

Fixes CVE-2019-10132

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agolocking: restrict sockets to mode 0600
Daniel P. Berrangé [Tue, 30 Apr 2019 15:51:37 +0000 (16:51 +0100)]
locking: restrict sockets to mode 0600

The virtlockd daemon's only intended client is the libvirtd daemon. As
such it should never allow clients from other user accounts to connect.
The code already enforces this and drops clients from other UIDs, but
we can get earlier (and thus stronger) protection against DoS by setting
the socket permissions to 0600

Fixes CVE-2019-10132

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoadmin: reject clients unless their UID matches the current UID
Daniel P. Berrangé [Tue, 30 Apr 2019 16:26:13 +0000 (17:26 +0100)]
admin: reject clients unless their UID matches the current UID

The admin protocol RPC messages are only intended for use by the user
running the daemon. As such they should not be allowed for any client
UID that does not match the server UID.

Fixes CVE-2019-10132

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agonetworkStartNetworkVirtual: Dissolve 'err0' label in 'error'
Michal Privoznik [Wed, 24 Apr 2019 07:30:32 +0000 (09:30 +0200)]
networkStartNetworkVirtual: Dissolve 'err0' label in 'error'

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agonetworkStartNetworkVirtual: Dissolve 'err1' label in 'error'
Michal Privoznik [Wed, 24 Apr 2019 07:26:15 +0000 (09:26 +0200)]
networkStartNetworkVirtual: Dissolve 'err1' label in 'error'

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agonetworkStartNetworkVirtual: Dissolve 'err2' label in 'error'
Michal Privoznik [Tue, 23 Apr 2019 14:59:55 +0000 (16:59 +0200)]
networkStartNetworkVirtual: Dissolve 'err2' label in 'error'

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agonetworkStartNetworkVirtual: Dissolve 'err3' label in 'error'
Michal Privoznik [Tue, 23 Apr 2019 14:48:02 +0000 (16:48 +0200)]
networkStartNetworkVirtual: Dissolve 'err3' label in 'error'

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agonetworkStartNetworkVirtual: Dissolve 'err4' label in 'error'
Michal Privoznik [Tue, 23 Apr 2019 14:44:59 +0000 (16:44 +0200)]
networkStartNetworkVirtual: Dissolve 'err4' label in 'error'

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agonetworkStartNetworkVirtual: s/err5/error
Michal Privoznik [Tue, 23 Apr 2019 14:13:06 +0000 (16:13 +0200)]
networkStartNetworkVirtual: s/err5/error

In attempt to getting rid of errN labels let's start with the
most upper one and rename it to 'error'.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agoRevert "qemu: Do not override config XML in case of snapshot revert"
Michal Privoznik [Mon, 20 May 2019 12:18:17 +0000 (14:18 +0200)]
Revert "qemu: Do not override config XML in case of snapshot revert"

This reverts commit dfd70ca1ebc623fcda788c414a472107b37b2bb8.

Pushed by a mistake, sorry. There's still some discussion going
on upstream.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
5 years agorpm: remove dependancy from qemu to network/storage drivers
Daniel P. Berrangé [Tue, 14 May 2019 14:57:05 +0000 (15:57 +0100)]
rpm: remove dependancy from qemu to network/storage drivers

The libvirt-daemon-driver-qemu RPM has historically had a hard
dependency on the libvirt-daemon-driver-network and
libvirt-daemon-driver-storage-core packages. This was because the QEMU
driver would directly call into APIs that were part of these drivers.

The dependency to the storage driver was eliminated in

  commit 064fec69be4a4673e0df17b007bf781026c3b4b2
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   Thu Jan 25 09:35:46 2018 +0000

    storage: move storage file backend framework into util directory

The dependency to the network driver was eliminated in

  commit 5b13570ab8b43ec3c590399ec5a7644d91082149
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   Thu Jan 25 09:35:47 2018 +0000

    conf: introduce callback registration for domain net device allocation

  commit 1438aea4ee4c65be1c7e5096a5549bc0f7581165
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   Thu Jan 25 09:35:48 2018 +0000

    conf: expand network device callbacks to cover bandwidth updates

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: Add entry for balloon stats stat-htlb-pgalloc and stat-htlb-pgfail
Han Han [Sun, 28 Apr 2019 09:18:05 +0000 (17:18 +0800)]
qemu: Add entry for balloon stats stat-htlb-pgalloc and stat-htlb-pgfail

Qemu added reporting of virtio balloon new statistics stat-htlb-pgalloc and
stat-htlb-pgfail since qemu-3.0 commit b7b12644297. The value of
stat-htlb-pgalloc represents the number of successful hugetlb page allocations
while stat-htlb-pgfail represents the number of failed ones. Add this
statistics reporting to libvirt.

To enable this feature for vm, guest kenel >= 4.17 is required because
the exporting hugetlb page allocation for virtio balloon is introduced
since 6c64fe7f.

Signed-off-by: Han Han <hhan@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Do not override config XML in case of snapshot revert
Maxiwell S. Garcia [Tue, 30 Apr 2019 17:54:01 +0000 (14:54 -0300)]
qemu: Do not override config XML in case of snapshot revert

Snapshot create operation saves the live XML and uses it to replace the
domain definition in case of revert. But the VM config XML is not saved
and the revert operation does not address this issue. This commit
prevents the config XML from being overridden by snapshot definition.

An active domain stores both current and new definitions. The current
definition (vm->def) stores the live XML and the new definition
(vm->newDef) stores the config XML. In an inactive domain, only the
config XML is persistent, and it's saved in vm->def.

The revert operation uses the virDomainObjAssignDef() to set the
snapshot definition in vm->newDef, if domain is active, or in vm->def
otherwise. But before that, it saves the old value to return to
caller. This return is used here to restore the config XML after
all snapshot startup process finish.

Signed-off-by: Maxiwell S. Garcia <maxiwell@linux.ibm.com>
5 years agoexamples: Fix installation on Windows
Andrea Bolognani [Mon, 13 May 2019 12:48:45 +0000 (14:48 +0200)]
examples: Fix installation on Windows

We can't rely on $(noinst_PROGRAMS) retaining its original
value, so let's use a separate $(EXAMPLES) variable instead.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agolib: Avoid double close when passing FDs with virCommandPassFD()
Michal Privoznik [Tue, 30 Apr 2019 09:17:22 +0000 (11:17 +0200)]
lib: Avoid double close when passing FDs with virCommandPassFD()

If an FD is passed into a child using:

  virCommandPassFD(cmd, fd, VIR_COMMAND_PASS_FD_CLOSE_PARENT);

then the parent should refrain from touching @fd thereafter. This
is even documented in virCommandPassFD() comment. The reason is
that either at virCommandRun()/virCommandRunAsync() or
virCommandFree() time the @fd will be closed. Closing it earlier,
e.g. right after virCommandPassFD() call might result in
undesired results. Another thread might open a file and receive
the same FD which is then unexpectedly closed by virCommandFree()
or virCommandRun().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agosrc: don't statically link code that's already in libvirt.so
Daniel P. Berrangé [Thu, 16 May 2019 08:27:45 +0000 (09:27 +0100)]
src: don't statically link code that's already in libvirt.so

Various binaries are statically linking to libvirt_util.la and
other intermediate libraries we build. These intermediate libs
all get built into the main libvirt.so shared library eventually,
so we can dynamically link to that instead and reduce the on disk
footprint.

In libvirt-daemon RPM:

            virtlockd: 1.6 MB -> 153 KB
             virtlogd: 1.6 MB -> 157 KB
     libvirt_iohelper: 937 KB -> 23 KB

In libvirt-daemon-driver-network RPM:

 libvirt_leaseshelper: 940 KB -> 26 KB

In libvirt-daemon-driver-storage-core RPM:

   libvirt_parthelper: 926 KB -> 21 KB

IOW, about 5.6 MB total space saving in a build done on Fedora 30
x86_64 architecture.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agom4: Drop needless string checks
Michal Privoznik [Fri, 17 May 2019 09:10:09 +0000 (11:10 +0200)]
m4: Drop needless string checks

We provide default values for both MODPROBE and RMMOD and thus
there is no way that their paths can be empty strings.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agom4: Provide default value fore UDEVADM
Michal Privoznik [Fri, 17 May 2019 09:09:45 +0000 (11:09 +0200)]
m4: Provide default value fore UDEVADM

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

It may happen that the system where libvirt is built at doesn't
have udevadm binary but the one where it runs does have it.
If we change how udevadm is run in virWaitForDevices() then we
can safely pass a default value in m4 macro.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agolib: Drop UDEVSETTLE
Michal Privoznik [Fri, 17 May 2019 09:01:49 +0000 (11:01 +0200)]
lib: Drop UDEVSETTLE

The udevsettle binary is no longer used anywhere as it was
replaced by 'udevadm settle'. There's no reason for us to even
check for it in configure.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirWaitForDevices: Drop confusing part of comment
Michal Privoznik [Fri, 17 May 2019 09:10:27 +0000 (11:10 +0200)]
virWaitForDevices: Drop confusing part of comment

It's not true that there is a backup loop. There isn't. Drop this
part of the comment to not confuse anybody.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Only probe available machine types
Andrea Bolognani [Thu, 16 May 2019 10:04:48 +0000 (12:04 +0200)]
qemu: Only probe available machine types

Since we know the full list of machine types supported
by the QEMU binary when probing machine type properties,
we can save some work (and eventually test suite churn,
as more architecture-specific machine types need to be
probed) by only probing machines that we know exist.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
5 years agotests: Refresh capabilities for QEMU on ppc64
Andrea Bolognani [Thu, 16 May 2019 14:29:53 +0000 (16:29 +0200)]
tests: Refresh capabilities for QEMU on ppc64

Now that we're probing machine type properties using the
latest machine type rather than the "spapr-machine" parent,
we can finally discover properties that are not available
on all machine types.

This commit refreshes replies for QEMU 4.0.0 as well as
3.1.0 to show not only that we're actually discovering new
machine type properties this way, but also that the number
of available machine type properties increases with each
subsequent QEMU release.

If qom-list-properties had been available in QEMU 2.10.0,
we could now drop the explicit version number checks for
the QEMU_CAPS_MACHINE_PSERIES_MAX_CPU_COMPAT and
QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT capabilities, but
unfortunately it wasn't, so we have to keep them around
still.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
5 years agoqemu: Probe canonicalized machine type
Andrea Bolognani [Thu, 16 May 2019 08:34:01 +0000 (10:34 +0200)]
qemu: Probe canonicalized machine type

Now that we have the list of machine types available when
probing machine type properties, we can list properties for
the canonicalized version of the "pseries" machine type
instead of having to go through "spapr-machine", which we
know to be the parent type for all "pseries-*-machine"
types. By doing this, we'll be able to find even properties
that are only available from a certain versioned machine
type forward, and can't thus be obtained when looking at
the parent type only.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
5 years agoqemu: Add -machine suffix automatically
Andrea Bolognani [Thu, 16 May 2019 08:18:58 +0000 (10:18 +0200)]
qemu: Add -machine suffix automatically

The QOM type for machine types is the machine type name
followed by the -machine suffix. Since this is always the
case, we can make virQEMUCapsMachineProps more readable
and avoid repetition by not including the suffix there and
adding it automatically while processing the data; moreover,
when later on we will start figuring out which specific
versioned machine type to probe at runtime instead of doing
so statically, adding the suffix dynamically will become
necessary.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
5 years agoqemu: Move call to virQEMUCapsProbeQMPMachineProps()
Andrea Bolognani [Thu, 16 May 2019 13:46:58 +0000 (15:46 +0200)]
qemu: Move call to virQEMUCapsProbeQMPMachineProps()

We're going to need information about available machine types
when probing machine type properties soon, and that means we
have to change the order we call QMP commands.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
5 years agoqemu: Introduce virQEMUCapsProbeQMPMachineProps()
Andrea Bolognani [Thu, 16 May 2019 13:45:08 +0000 (15:45 +0200)]
qemu: Introduce virQEMUCapsProbeQMPMachineProps()

Up until now we've probed machine type properties, along with
properties for other types, in virQEMUCapsProbeQMPDevices(), but
soon we're going to need some logic that is specific to machine
types and as such wouldn't quite fit into that function.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
5 years agoqemu: blockjob: Fix saving of inactive XML after completed legacy blockjob
Peter Krempa [Fri, 17 May 2019 08:15:53 +0000 (10:15 +0200)]
qemu: blockjob: Fix saving of inactive XML after completed legacy blockjob

Commit c257352797 introduced a logic bug where we will never save the
inactive XML after a blockjob as the variable which was determining
whether to do so is cleared right before. Thus even if we correctly
modify the inactive state it will be rolled back when libvirtd is
restarted.

Reported-by: Thomas Stein <hello@himbee.re>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agobuild: drop check for udev_monitor_set_receive_buffer_size
Ján Tomko [Mon, 13 May 2019 14:22:40 +0000 (16:22 +0200)]
build: drop check for udev_monitor_set_receive_buffer_size

It has been exported by systemd commit
commit a571c23e954cb88cdd5faa28593b19bd7c340130
    libudev: export udev_monitor_set_receive_buffer_size()
released in v183.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
5 years agobuild: bump minimum udev version to 219
Ján Tomko [Mon, 13 May 2019 14:17:46 +0000 (16:17 +0200)]
build: bump minimum udev version to 219

This is the version of systemd RHEL/CentOS 7 uses:
https://repology.org/project/systemd/versions
Oldest tracked openSUSE distros have 228,
Ubuntu 16.04 has 229 and Gentoo's alternative eudev
has bumped the version to 219 back in 2015.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
5 years agovirt-aa-helper: allow sysfs path used for vhost-scsi
Christian Ehrhardt [Wed, 15 May 2019 11:35:32 +0000 (13:35 +0200)]
virt-aa-helper: allow sysfs path used for vhost-scsi

When a vhost scsi device is hotplugged virt-aa-helper is called to
add the respective path.
For example the config:
  <hostdev mode='subsystem' type='scsi_host' managed='no'>
    <source protocol='vhost' wwpn='naa.50014059de6fba4f'/>
  </hostdev>
Will call it to add:
 /sys/kernel/config/target/vhost//naa.50014059de6fba4f

But in general /sys paths are filtered in virt-aa-helper.c:valid_path
To allow the path used for vhost-scsi we need to add it to the list of
known and accepted overrides.

Fixes: https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1829223
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agonode_device_udev: remove deprecated logging function
Pavel Hrdina [Thu, 9 May 2019 13:23:19 +0000 (15:23 +0200)]
node_device_udev: remove deprecated logging function

The function was deprecated in udev 219 and all the supported OSes
don't have older version of udev or systemd.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuxml2argvtest: add test for remove cpu features
Christian Ehrhardt [Thu, 25 Apr 2019 09:51:55 +0000 (11:51 +0200)]
qemuxml2argvtest: add test for remove cpu features

CPU features that always were a no-op in qemu got removed there.
We no more specify them as that would trigger errors and fail to start
qemu. This test ensures that those features really are not rendered into
qemu command line.

Without the related fix this test will trigger and fail like:
 In 'tests/qemuxml2argvdata/cpu-no-removed-features.args':
 Offset 371
 Expect [ ]
 Actual [,-osxsave,-ospke ]

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoqemu: do not define known no-op features
Christian Ehrhardt [Thu, 25 Apr 2019 09:04:29 +0000 (11:04 +0200)]
qemu: do not define known no-op features

Qemu dropped cpu features for osxsave and ospke [1][2].
The reason for the instant removal is that those features were never
configurable as discussed in [3].

Fortunately the use cases adding those flags in the past are rare, but
they exist. One that I identified are e.g. older virt-install when used
with --cpu=host-model and there always could be the case of a user
adding it to the guest xml.

This triggers an issue like:
  qemu-system-x86_64: can't apply global Broadwell-noTSX-x86_64-
  cpu.osxsave=on: Property '.osxsave' not found

Ensure that this does no more break spawning newer qemu versions by
not rendering those features into the qemu command line.

Fixes: https://bugs.launchpad.net/fedora/+source/qemu/+bug/1825195
Resolves: https://bugzilla.redhat.com/1644848

[1]: https://git.qemu.org/?p=qemu.git;a=commit;h=f1a2352
[2]: https://git.qemu.org/?p=qemu.git;a=commit;h=9ccb978
[3]: https://www.mail-archive.com/qemu-devel@nongnu.org/msg561877.html

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agocpu_map: Define md-clear CPUID bit
Jiri Denemark [Fri, 5 Apr 2019 13:11:20 +0000 (15:11 +0200)]
cpu_map: Define md-clear CPUID bit

CVE-2018-12126, CVE-2018-12127, CVE-2018-12130, CVE-2019-11091

The bit is set when microcode provides the mechanism to invoke a flush
of various exploitable CPU buffers by invoking the VERW instruction.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agocputest: Add data for Intel(R) Xeon(R) CPU E3-1225 v5
Jiri Denemark [Fri, 5 Apr 2019 09:19:30 +0000 (11:19 +0200)]
cputest: Add data for Intel(R) Xeon(R) CPU E3-1225 v5

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemuDomainSnapshotCreateXML: Don't leak parsed snapshot definition
Michal Privoznik [Tue, 14 May 2019 13:43:06 +0000 (15:43 +0200)]
qemuDomainSnapshotCreateXML: Don't leak parsed snapshot definition

This function gets snapshot XML (provided by used) as an
argument. It parses it into a local variable @def and then sets
some more members (e.g. it creates a copy of live domain XML).
Then it proceeds to checking if snapshot XML is valid (e.g. it
contains as many disks as currently in the domain). If this fails
then the control jumps to endjob label and subsequently return
from the function. This is where AUTOFREE function for @def is
ran. Well, because the code says to run plain VIR_FREE() we leak
some memory because @def is actually an object and therefore
it should have been declared as AUTOUNREF.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agostoragepoolxml2argvtest: Avoid double free
Michal Privoznik [Tue, 14 May 2019 08:42:42 +0000 (10:42 +0200)]
storagepoolxml2argvtest: Avoid double free

A double free may occur in testCompareXMLToArgvFiles() when @def
is freed right after virStoragePoolObjNew() failed and the second
time at cleanup label.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agovirCommand: Make virCommandPassFDGetFDIndex fail if passed command is in error state
Michal Privoznik [Tue, 14 May 2019 08:40:27 +0000 (10:40 +0200)]
virCommand: Make virCommandPassFDGetFDIndex fail if passed command is in error state

The idea of virCommand* APIs is that a possible error that
occurred while constructing cmd line is kept in virCommand
struct. If that's the case all subsequent calls to virCommand*()
are NO-OPs or they return an error. Well,
virCommandPassFDGetFDIndex() is not honoring that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agovirNetServerPreExecRestart: Check for retval of virJSONValueNewArray()
Michal Privoznik [Tue, 14 May 2019 08:39:27 +0000 (10:39 +0200)]
virNetServerPreExecRestart: Check for retval of virJSONValueNewArray()

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agovirstorageobj: Don't clear vols if they weren't initialized
Michal Privoznik [Tue, 14 May 2019 08:31:52 +0000 (10:31 +0200)]
virstorageobj: Don't clear vols if they weren't initialized

If virStoragePoolObjNew() fails to create new volume object list
then virObjectUnref() is called and since refcounter is 1 then
virStoragePoolObjDispose() is called which in turn calls
virStoragePoolObjClearVols() which in turn dereferences
obj->volumes.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agovirresctrl: Sort resctrl array correctly in virResctrlMonitorGetStats()
Huaqiang [Fri, 10 May 2019 15:21:47 +0000 (23:21 +0800)]
virresctrl: Sort resctrl array correctly in virResctrlMonitorGetStats()

The qsort element is a pointer of virResctrlMonitorStats, and
the comparing function's arguments have a type of pointer of
virResctrlMonitorStatsPtr.

Signed-off-by: Huaqiang <huaqiang.wang@intel.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
5 years agovirsh: Don't leak disk targets in cmdDomBlkError
Michal Privoznik [Mon, 13 May 2019 12:32:06 +0000 (14:32 +0200)]
virsh: Don't leak disk targets in cmdDomBlkError

The virDomainGetDiskErrors() API copies disk targets into @disks
array that we allocate. But we forgot to free it:

==140828== 16 bytes in 4 blocks are definitely lost in loss record 41 of 242
==140828==    at 0x4C2F08F: malloc (vg_replace_malloc.c:299)
==140828==    by 0x8C406D9: strdup (in /lib64/libc-2.28.so)
==140828==    by 0x5377DD3: virStrdup (virstring.c:966)
==140828==    by 0x54C112F: testDomainGetDiskErrors (test_driver.c:3068)
==140828==    by 0x55C863D: virDomainGetDiskErrors (libvirt-domain.c:10988)
==140828==    by 0x15D1FA: cmdDomBlkError (virsh-domain-monitor.c:1215)
==140828==    by 0x17F1A8: vshCommandRun (vsh.c:1335)
==140828==    by 0x13489E: main (virsh.c:920)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotest_driver: implement virDomainGetDiskErrors
Ilias Stamatis [Sun, 12 May 2019 23:26:14 +0000 (01:26 +0200)]
test_driver: implement virDomainGetDiskErrors

Return the number of disks present in the configuration of the test
domain when called with @errors as NULL and @maxerrors as 0.

Otherwise report an error for every second disk, assigning available
error codes in a cyclic order.

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoexamples: Install under $(docdir)
Andrea Bolognani [Fri, 10 May 2019 14:32:22 +0000 (16:32 +0200)]
examples: Install under $(docdir)

Our build system doesn't currently install the various
example programs provided along libvirt; however, both the
upstream .spec file and the Debian packaging go out of
their way to make sure these useful demos are included in
the respective documentation packages.

Moreover, doing so without help from the upstream build
system is easy to get wrong: the libvirt-docs RPM package,
for example, ends up missing one of the examples and
including a bunch of empty .deps/ directories.

Install the examples in $(docdir) as part of our regular
procedure, so that users and downstreams don't have to do
anything special about them.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: Michal Privoznik <mprivozn@redhat.com>
5 years agodocs: Install documentation under $(docdir)
Andrea Bolognani [Fri, 10 May 2019 14:22:11 +0000 (16:22 +0200)]
docs: Install documentation under $(docdir)

At the moment we allow the user to specify exactly where
they want the HTML documentation to be installed with an
extreme level of precision through the --with-html-dir and
--with-html-subdir configure options.

Most of the time, of course, the user will stick with the
default, that is $(datadir)/doc/$(PACKAGE)-$(VERSION)/html.

So close to $(docdir)! Including the version number in
the path, specifically, seems entirely unnecessary since
different releases of libvirt are not going to be able to
coexist on the same system anyway.

Drop all these custom flexibilty for flexibilty's sake
shenaningans in favor of the standard, well understood
$(docdir).

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: Michal Privoznik <mprivozn@redhat.com>
5 years agodocs: Introduce $(devhelphtml_generated)
Andrea Bolognani [Fri, 10 May 2019 12:54:52 +0000 (14:54 +0200)]
docs: Introduce $(devhelphtml_generated)

Our XSLT magic generates one Devhelp-compatible HTML file
per documentation module, but so far we have only shipped
and installed documentation for virterror.

Now that we have $(modules), however, we can generate the
list of files the same way we do for regular documentation
and make sure we always ship and install everything.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: Michal Privoznik <mprivozn@redhat.com>
5 years agodocs: Introduce $(modules)
Andrea Bolognani [Fri, 10 May 2019 12:48:46 +0000 (14:48 +0200)]
docs: Introduce $(modules)

This variable contains a lists of documentation modules,
in a neutral format.

Right now is only used to define $(apihtml_generated), but
later on we're gonna reuse it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Fix regression with undefine --snapshots-metadata
Eric Blake [Fri, 10 May 2019 14:38:31 +0000 (09:38 -0500)]
qemu: Fix regression with undefine --snapshots-metadata

In refactoring the snapshot code to prepare for checkpoints, I changed
qemuDomainMomentDiscardAll to take a callback that would handle the
cleanup of either a snapshot or a checkpoint, but failed to set the
callback on one of the two snapshot callers.  As a result, 'virsh
undefine $dom --snapshots-metadata' crashed on a NULL function
dereference.

Fixes: a487890d371b8cc3662c1717dfe07eea3f1ef1c0
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1707708
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
5 years agoAdd support for podman in Makefile.ci
Martin Kletzander [Tue, 7 May 2019 15:37:39 +0000 (17:37 +0200)]
Add support for podman in Makefile.ci

This way more users can run our CI builds locally.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovirSysinfoParseX86BaseBoard: Free memory upfront if no board detected
Michal Privoznik [Thu, 9 May 2019 13:59:33 +0000 (15:59 +0200)]
virSysinfoParseX86BaseBoard: Free memory upfront if no board detected

If no board was detected then VIR_REALLOC_N() done at the end of
the function will actually free the memory (because nborads ==
0), but @boards will be set to a non-NULL pointer. This makes it
unnecessary harder for a caller to see if any board was detected.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
5 years agovirSysinfoRead: Simplify #ifdef underbush
Michal Privoznik [Tue, 7 May 2019 14:10:21 +0000 (16:10 +0200)]
virSysinfoRead: Simplify #ifdef underbush

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
5 years agobuild: restore support for libyajl 2.0.1
Ján Tomko [Thu, 9 May 2019 11:11:44 +0000 (13:11 +0200)]
build: restore support for libyajl 2.0.1

Commit 105756660f944e7db02de3b55b98bb7c11cd03bf was too eager and did
not consider SLES 12 which still has 2.0.1 that does not ship
a pkg-config file.

Similar to how we check for readline, prefer pkg-config if available
and fall back to the old detection code if not found.

NB: this is not a clean revert because we're not reintroducing support
for YAJL 1.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reported-by: Olaf Hering <olaf@aepfle.de>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agoDon't include Makefile.ci in Makefile.am
Martin Kletzander [Tue, 7 May 2019 15:21:55 +0000 (17:21 +0200)]
Don't include Makefile.ci in Makefile.am

The way it works now the Makefile needs to be both make valid and automake
valid.  That is fine for now, but if we want to use anything more advanced, like
conditionals, we cannot have it like that any more.

So instead forward all ci-* rules to that file.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
5 years agosnapshot: Make virDomainSnapshotDef a virObject
Eric Blake [Thu, 9 May 2019 14:59:06 +0000 (09:59 -0500)]
snapshot: Make virDomainSnapshotDef a virObject

This brings about a couple of benefits:
- use of VIR_AUTOUNREF() simplifies several callers
- Fixes a todo about virDomainMomentObjList not being polymorphic enough

Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
5 years agosnapshot: Add virDomainSnapshotDefNew
Eric Blake [Wed, 8 May 2019 18:30:38 +0000 (13:30 -0500)]
snapshot: Add virDomainSnapshotDefNew

In preparation for making virDomainSnapshotDef a descendant of
virObject, it is time to fix all callers that allocate an object to
use virDomainSnapshotDefNew() instead of VIR_ALLOC().  Fortunately,
there aren't very many :)

Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
5 years agosnapshot: s/current/parent/ as prep for virObject
Eric Blake [Wed, 8 May 2019 22:10:58 +0000 (17:10 -0500)]
snapshot: s/current/parent/ as prep for virObject

VIR_CLASS_NEW insists that descendents of virObject have 'parent' as
the name of their inherited base class member at offset 0. While it
would be possible to write a new class-creation macro that takes the
actual field name 'current', and rewrite VIR_CLASS_NEW to call the new
macro with the hard-coded name 'parent', it seems less confusing if
all object code uses similar naming. Thus, this is a mechanical rename
in preparation of making virDomainSnapshotDef a descendent of
virObject.

Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
5 years agosnapshot: s/parent/parent_name/ as prep for virObject
Eric Blake [Wed, 8 May 2019 16:39:13 +0000 (11:39 -0500)]
snapshot: s/parent/parent_name/ as prep for virObject

VIR_CLASS_NEW insists that descendents of virObject have 'parent' as
the name of their inherited base class member at offset 0. While it
would be possible to write a new class-creation macro that takes the
actual field name, and rewrite VIR_CLASS_NEW to call the new macro
with the hard-coded name 'parent', so that we could make
virDomainMomentDef use a custom name for its base class, it seems less
confusing if all object code uses similar naming. Thus, this is a
mechanical rename in preparation of making virDomainSnapshotDef a
descendent of virObject, when we can no longer use 'parent' for a
different purpose than the base class.

Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
5 years agoqemu: Refactor/simplify qemuDomainStorageSourceAccessAllow
Peter Krempa [Thu, 18 Apr 2019 14:20:35 +0000 (16:20 +0200)]
qemu: Refactor/simplify qemuDomainStorageSourceAccessAllow

Use qemuDomainStorageSourceAccessModify with correct flags to do the
job.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Mark when modifying access to existing source in qemuDomainStorageSourceAccessM...
Peter Krempa [Thu, 18 Apr 2019 14:16:57 +0000 (16:16 +0200)]
qemu: Mark when modifying access to existing source in qemuDomainStorageSourceAccessModify

Some operations e.g. namespace setup are not necessary when modifying
access to a file which the VM can already access. Add a flag which
allows to skip them.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Allow skipping the revoke step in qemuDomainStorageSourceAccessModify
Peter Krempa [Thu, 18 Apr 2019 14:10:52 +0000 (16:10 +0200)]
qemu: Allow skipping the revoke step in qemuDomainStorageSourceAccessModify

In some cases when we need to modify access permissions for a storage
source which is already used by the VM we should not revoke all
permissions on a failure. Allow this in qemuDomainStorageSourceAccessModify
by adding a new flag.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Use bools rather than labels in qemuDomainStorageSourceAccessModify
Peter Krempa [Thu, 18 Apr 2019 14:06:19 +0000 (16:06 +0200)]
qemu: Use bools rather than labels in qemuDomainStorageSourceAccessModify

Rather than jumping to the correct label use a set of booleans to
determine which operation needs to be rolled back. This will allow more
flexibility when e.g. rollback after a failed operation will not be
necessary/desired.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Allow forcing read-only mode in qemuDomainStorageSourceAccessModify
Peter Krempa [Thu, 18 Apr 2019 13:48:39 +0000 (15:48 +0200)]
qemu: Allow forcing read-only mode in qemuDomainStorageSourceAccessModify

Add a new flag which will set the image as read-only even if the image
data allows writing.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Refactor/simplify qemuDomainStorageSourceAccessRevoke
Peter Krempa [Thu, 18 Apr 2019 12:40:27 +0000 (14:40 +0200)]
qemu: Refactor/simplify qemuDomainStorageSourceAccessRevoke

Use qemuDomainStorageSourceAccessModify instead of the individual calls.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Allow using qemuDomainStorageSourceAccessModify on singe images
Peter Krempa [Thu, 18 Apr 2019 12:36:38 +0000 (14:36 +0200)]
qemu: Allow using qemuDomainStorageSourceAccessModify on singe images

Add a new flag QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_CHAIN to select whether
to work on single image or full chain.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Convert boolean flags to enum flags in qemuDomainStorageSourceAccessModify
Peter Krempa [Thu, 18 Apr 2019 11:02:43 +0000 (13:02 +0200)]
qemu: Convert boolean flags to enum flags in qemuDomainStorageSourceAccessModify

Upcoming patches will add a few more flags. Add an enum to collect them
so that we don't end up with multiple bools.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: domain: Rename qemuDomainStorageSourceChainAccessPrepare
Peter Krempa [Thu, 18 Apr 2019 08:36:30 +0000 (10:36 +0200)]
qemu: domain: Rename qemuDomainStorageSourceChainAccessPrepare

The function will be able to deal with non-chains too so drop 'Chain'
and also change the suffix to 'Modify' as it's used both for setup and
teardown.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Split entry points to qemuDomainStorageSourceChainAccessPrepare
Peter Krempa [Thu, 18 Apr 2019 08:18:51 +0000 (10:18 +0200)]
qemu: Split entry points to qemuDomainStorageSourceChainAccessPrepare

Introduce qemuDomainStorageSourceChainAccess(Allow|Revoke) as entry
points to qemuDomainStorageSourceChainAccessPrepare for symmetry with
the functions for single backing chain elements.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Move and rename qemuHotplugPrepareDiskSourceAccess
Peter Krempa [Thu, 18 Apr 2019 08:04:26 +0000 (10:04 +0200)]
qemu: Move and rename qemuHotplugPrepareDiskSourceAccess

Move it to qemu_domain.c and call it
qemuDomainStorageSourceChainAccessPrepare.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Rename qemuDomainDiskChainElement(Revoke|Prepare)
Peter Krempa [Thu, 18 Apr 2019 07:41:38 +0000 (09:41 +0200)]
qemu: Rename qemuDomainDiskChainElement(Revoke|Prepare)

Use qemuDomainStorageSourceAccess(Allow|Revoke) instead.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agospec: Bump minimum supported Fedora version to 29
Andrea Bolognani [Tue, 7 May 2019 10:10:58 +0000 (12:10 +0200)]
spec: Bump minimum supported Fedora version to 29

Fedora 30 is out, which means that Fedora 28 is going to be
EOL very soon. Let's get ahead of the game and drop support
for it right now.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>