]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
5 years agoqemu: eliminate ret in qemuExtDevicesStart
Ján Tomko [Fri, 24 Jan 2020 18:43:18 +0000 (19:43 +0100)]
qemu: eliminate ret in qemuExtDevicesStart

All the callees return either 0 or -1 so there is no need
for propagating the value. And we bail on the first error.

Remove the variable to make the function simpler.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agoqemu: use def instead of vm->def in qemuExtDevicesStart
Ján Tomko [Fri, 24 Jan 2020 18:41:45 +0000 (19:41 +0100)]
qemu: use def instead of vm->def in qemuExtDevicesStart

We have a helper variable to make the code more concise,
use it consistently.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agoqemu: eliminate ret variable in qemuExtTPMStart
Ján Tomko [Fri, 24 Jan 2020 18:36:26 +0000 (19:36 +0100)]
qemu: eliminate ret variable in qemuExtTPMStart

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agoqemu: eliminate ret variable in qemuExtTPMStartEmulator
Ján Tomko [Fri, 24 Jan 2020 18:34:07 +0000 (19:34 +0100)]
qemu: eliminate ret variable in qemuExtTPMStartEmulator

Now that the cleanup section is empty, eliminate the cleanup
label as well as the 'ret' variable.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agoqemu: use g_auto in qemuExtTPMStartEmulator
Ján Tomko [Fri, 24 Jan 2020 18:32:21 +0000 (19:32 +0100)]
qemu: use g_auto in qemuExtTPMStartEmulator

Use the g_auto macros wherever possible to eliminate the cleanup
section.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agoconf: use virXMLFormatElement in virDomainFSDefFormat
Ján Tomko [Wed, 15 Jan 2020 14:16:45 +0000 (15:16 +0100)]
conf: use virXMLFormatElement in virDomainFSDefFormat

Use the virXMLFormatElement helper to format the driver element
to simplify adding further sub-elements.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agogitdm: Add missing entries
Andrea Bolognani [Mon, 13 Jan 2020 16:01:26 +0000 (17:01 +0100)]
gitdm: Add missing entries

A few new companies and individuals contributed to libvirt since
the last time the gitdm configuration was updated.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu_shim: Update temporary directory template
Andrea Bolognani [Mon, 27 Jan 2020 16:48:17 +0000 (17:48 +0100)]
qemu_shim: Update temporary directory template

The template still references libvirt-qemu-shim, which was at one
point the name used to refer to what we now know as virt-qemu-run.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
5 years agoqemu_shim: Fix typos
Andrea Bolognani [Mon, 27 Jan 2020 16:45:37 +0000 (17:45 +0100)]
qemu_shim: Fix typos

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
5 years agodocs: Fix link to virt-qemu-run(1)
Andrea Bolognani [Mon, 27 Jan 2020 16:47:02 +0000 (17:47 +0100)]
docs: Fix link to virt-qemu-run(1)

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
5 years agoqemu: snapshot: go through cleanup on error
Ján Tomko [Mon, 27 Jan 2020 15:42:47 +0000 (16:42 +0100)]
qemu: snapshot: go through cleanup on error

A recent commit added an error check for too-nested backing chains
followed by a return, even though errors above jump to cleanup.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: b168fa88b85dec181882816ab65a59a6c4500667
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agoqemu_shim: cosmetic fixes
Ján Tomko [Mon, 27 Jan 2020 15:39:47 +0000 (16:39 +0100)]
qemu_shim: cosmetic fixes

Remove bogus G_GNUC_UNUSED attribute and add a missing space.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: d6006672788ec0f0290d35c76ceb9672476d1ea8
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agodocs: fix since version in driver documentation
Ján Tomko [Mon, 27 Jan 2020 15:38:19 +0000 (16:38 +0100)]
docs: fix since version in driver documentation

Also one stray angle bracket.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: 068efae5b1a9efeea4a9c3bc0ae80747da5024fb
Fixes: 3e9076e777aff2f4b08330ed17e559fcfb6b3529
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agodocs: fix virt-qemu-run man page
Ján Tomko [Mon, 27 Jan 2020 15:35:58 +0000 (16:35 +0100)]
docs: fix virt-qemu-run man page

Fix a documentation generation error:
System Message: WARNING/2 (<stdin>, line 15); backlink
Inline literal start-string without end-string.

As well as the 'independant' typo.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: d6006672788ec0f0290d35c76ceb9672476d1ea8
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agoqemu: checkpoint: Extract calculation of bitmap merging for checkpoint deletion
Peter Krempa [Wed, 8 Jan 2020 09:25:33 +0000 (10:25 +0100)]
qemu: checkpoint: Extract calculation of bitmap merging for checkpoint deletion

This will allow some testing before refactoring.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: checkpoint: Introduce helper to find checkpoint disk definition in parents
Peter Krempa [Wed, 8 Jan 2020 08:55:18 +0000 (09:55 +0100)]
qemu: checkpoint: Introduce helper to find checkpoint disk definition in parents

The algorithm is used in two places to find the parent checkpoint object
which contains given disk and then uses data from the disk. Additionally
the code is written in a very non-obvious way. Factor out the lookup of
the disk into a function which also simplifies the callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: domain: Remove unused qemuDomainDiskNodeFormatLookup
Peter Krempa [Wed, 8 Jan 2020 07:19:42 +0000 (08:19 +0100)]
qemu: domain: Remove unused qemuDomainDiskNodeFormatLookup

The function has no users now and there's no need for it as the common
pattern is to look up the whole disk object anyways.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: checkpoint: tolerate missing disks on checkpoint deletion
Peter Krempa [Wed, 8 Jan 2020 07:18:51 +0000 (08:18 +0100)]
qemu: checkpoint: tolerate missing disks on checkpoint deletion

If a disk is unplugged and then the user tries to delete a checkpoint
the code would try to use NULL node name as it was not checked.

Fix this by fetching the whole disk definition object and verifying it
was found.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: checkpoint: Use disk definition directly when creating checkpoint
Peter Krempa [Wed, 8 Jan 2020 07:10:35 +0000 (08:10 +0100)]
qemu: checkpoint: Use disk definition directly when creating checkpoint

Lookup the whole disk definition rather than just the node name.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: checkpoint: rename disk->chkdisk in qemuCheckpointAddActions
Peter Krempa [Wed, 8 Jan 2020 06:55:18 +0000 (07:55 +0100)]
qemu: checkpoint: rename disk->chkdisk in qemuCheckpointAddActions

Upcoming patches will also use the domain disk definition. Rename disk
to chkdisk for clarity.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: checkpoint: rename disk->chkdisk in qemuCheckpointDiscardBitmaps
Peter Krempa [Wed, 8 Jan 2020 06:55:18 +0000 (07:55 +0100)]
qemu: checkpoint: rename disk->chkdisk in qemuCheckpointDiscardBitmaps

Upcoming patches will also use the domain disk definition. Rename disk
to chkdisk for clarity.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: checkpoint: split out checkpoint deletion bitmaps
Peter Krempa [Tue, 7 Jan 2020 14:15:38 +0000 (15:15 +0100)]
qemu: checkpoint: split out checkpoint deletion bitmaps

qemuCheckpointDiscard is a massive function that can be separated into
smaller bits. Extract the part that actually modifies the disk from the
metadata handling.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: checkpoint: Store whether deleted checkpoint is current in a variable
Peter Krempa [Tue, 7 Jan 2020 14:01:41 +0000 (15:01 +0100)]
qemu: checkpoint: Store whether deleted checkpoint is current in a variable

Avoid two computations by using a boolean.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agotests: qemu: Remove prehistoric machine types from faked data tests
Peter Krempa [Thu, 23 Jan 2020 09:37:08 +0000 (10:37 +0100)]
tests: qemu: Remove prehistoric machine types from faked data tests

qemu-5.0 will drop pre pc-1.0 machine types. Remove them from our
faked capabilities test suite. If a feature depends on a machine type it
shall be tested with real data and not with this hack.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: qemuxml2xml: Remove prehistoric machine types from legacy tests
Peter Krempa [Thu, 23 Jan 2020 09:39:47 +0000 (10:39 +0100)]
tests: qemuxml2xml: Remove prehistoric machine types from legacy tests

None of the tests depend on anything that the machine type would
influence. This will allow us to drop the very old machine type from the
non-real-data tests. If something depends on the machine type it should
be tested with real data rather than this hack.

Note that these tests are run only in the XML->XML suite because the
XML->argv suite doesn't work with the network driver.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: qemuxml: Remove prehistoric machine types from legacy tests
Peter Krempa [Thu, 23 Jan 2020 09:39:47 +0000 (10:39 +0100)]
tests: qemuxml: Remove prehistoric machine types from legacy tests

None of the tests depend on anything that the machine type would
influence. This will allow us to drop the very old machine type from the
non-real-data tests. If something depends on the machine type it should
be tested with real data rather than this hack.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: Add caps for upcoming qemu-5.0
Peter Krempa [Fri, 13 Dec 2019 13:37:25 +0000 (14:37 +0100)]
tests: Add caps for upcoming qemu-5.0

Based on upstream commit 3e08b2b9cb64. This version already dropped the
pre-historic machine types and supports only machine types starting from
'pc-1.0'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: qemuxml: Purge prehistoric machine type 'pc-0.13' from "latest" tests
Peter Krempa [Thu, 23 Jan 2020 09:17:28 +0000 (10:17 +0100)]
tests: qemuxml: Purge prehistoric machine type 'pc-0.13' from "latest" tests

Remove the old machine type which will be dropped in the upcomming
qemu-5.0 release from tests used against the most recent capabilities
data.

None of the modified tests really cares about the actual machine type.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: qemu: Don't add fake machine types when testing with real data
Peter Krempa [Thu, 23 Jan 2020 12:23:35 +0000 (13:23 +0100)]
tests: qemu: Don't add fake machine types when testing with real data

Skip the step of adding all of the fake machine types which are required
for the legacy tests in case when we are testing with real capabilities.

Faking any data in the real capabilities undermines the point of testing
with real capabilities.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: capabilities: Add accessor to qemu caps machine types presence
Peter Krempa [Thu, 23 Jan 2020 12:21:47 +0000 (13:21 +0100)]
qemu: capabilities: Add accessor to qemu caps machine types presence

Test code will need to know whether the virQEMUCaps object contains any
machine types already. Add a helper and expose it via 'qemu_capspriv.h'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: capabilities: Replace aliased machine type by copy of the canonical machine
Peter Krempa [Thu, 23 Jan 2020 12:20:25 +0000 (13:20 +0100)]
qemu: capabilities: Replace aliased machine type by copy of the canonical machine

The previous approac of just purging the alias combined with the fact
that we filled in fake machine types in the test data meant that if a
test case used an alias machine type such as 'pc' or 'q35' it would not
properly resolve to the actual data returned by qemu.

This started to be a problem since the CPU driver now looks at the
default CPU reported with the machine type.

This patch replaces the original approach of just removing the alias by
replacing it with a copy of the machine type data which the type would
alias to. This means that we are using the real data while we don't
modify the test output after every qemu upgrade.

Additionally this change will allow us to drop adding the fake machine
types later.

The test fallout is from actually excercising the CPU driver with
actual data.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: capabilities: Extract code from virQEMUCapsStripMachineAliases
Peter Krempa [Thu, 23 Jan 2020 12:11:08 +0000 (13:11 +0100)]
qemu: capabilities: Extract code from virQEMUCapsStripMachineAliases

Separate out the internals as they will become more complex soon.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: domain: Validate that machine type is supported by qemu
Peter Krempa [Wed, 22 Jan 2020 09:06:53 +0000 (10:06 +0100)]
qemu: domain: Validate that machine type is supported by qemu

Every supported qemu is able to return the list of machine types it
supports so we can start validating it against that list. The advantage
is a better error message, and the change will also prevent having stale
test data.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: qemu: Add machine types used by the test code to fake capabilities
Peter Krempa [Wed, 22 Jan 2020 16:46:57 +0000 (17:46 +0100)]
tests: qemu: Add machine types used by the test code to fake capabilities

Enumerate all missing machine types for all missing architectures for
the fake capabilities used in many existing tests. This will allow
stricter validation whether qemu actually supports given machine type
since we already have some behaviour dependant on the actual machine
type.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: qemuxml: Use existing machine type in 'iothreads-virtio-scsi-ccw' case
Peter Krempa [Thu, 23 Jan 2020 09:11:12 +0000 (10:11 +0100)]
tests: qemuxml: Use existing machine type in 'iothreads-virtio-scsi-ccw' case

Use the 's390-ccw-virtio' machine type which is actually supported by
the qemu we gathered the test data from.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: qemuxml2argv: Use proper replacement for 'pc-i440fx-wily' machine
Peter Krempa [Wed, 22 Jan 2020 16:45:12 +0000 (17:45 +0100)]
tests: qemuxml2argv: Use proper replacement for 'pc-i440fx-wily' machine

This machine type comes from downstream ubuntu 15.10. Replace it with a
somewhat equivalent qemu-2.3 machine type as we do have test data for
that.

The change allows the CPU code to pick a proper default CPU in the
'-latest' cases.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: qemuxml2argv: Use existing non-virt machine in 'aarch64-gic-not-virt'
Peter Krempa [Wed, 22 Jan 2020 16:43:45 +0000 (17:43 +0100)]
tests: qemuxml2argv: Use existing non-virt machine in 'aarch64-gic-not-virt'

Use 'versatilepb' instead of a fake 'non-virt' machine type.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: qemuxml2argv: Remove downstream machine type in 'controller-order' case
Peter Krempa [Wed, 22 Jan 2020 16:42:42 +0000 (17:42 +0100)]
tests: qemuxml2argv: Remove downstream machine type in 'controller-order' case

Use 'pc' instead of ancient 'rhel-6.1'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: qemuxml2argv: Use existing machine type for 'numatune-distances' case
Peter Krempa [Wed, 22 Jan 2020 16:41:15 +0000 (17:41 +0100)]
tests: qemuxml2argv: Use existing machine type for 'numatune-distances' case

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: qemu: Unify fake machine types filled in for KVM and TCG caps of x86_64
Peter Krempa [Wed, 22 Jan 2020 09:28:19 +0000 (10:28 +0100)]
tests: qemu: Unify fake machine types filled in for KVM and TCG caps of x86_64

For testing with synthetic capabilities we pre-fill the qemu
capabilities with some machine types. Historically there were two arrays
for KVM and TCG but that's not necessary. Make both instances of x86_64
data share the same array as the other architectures do.

This will later on simplify filling in all the other machine types which
are required for the test suite.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: qemuxml: Fix and enable default-video-type* tests
Peter Krempa [Wed, 22 Jan 2020 10:56:09 +0000 (11:56 +0100)]
tests: qemuxml: Fix and enable default-video-type* tests

The tests prefixed default-video* were enabled only for the xml2xml
testing and used impossible configurations.

Enable them for xml2argv testing fix them:
1) aarch64: remove pointless cpu mode
2) s390x: remove pointless cpu and use existing machine type
3) riscv: remove pointless cpu
4) x86: remove pointless cpu and use existing machine type
5) ppc65: use correct machine type and enable USB

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: qemuxml2argv: Modernize tpm-passthrough tests
Peter Krempa [Thu, 23 Jan 2020 09:26:12 +0000 (10:26 +0100)]
tests: qemuxml2argv: Modernize tpm-passthrough tests

XML->XML testing uses DO_TEST_CAPS_LATEST so use it also for the
XML->argv testing. Additionally use the same more modern machine type
in both tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: qemuxml2xml: Modernize 'disk-cache' test
Peter Krempa [Wed, 22 Jan 2020 16:15:35 +0000 (17:15 +0100)]
tests: qemuxml2xml: Modernize 'disk-cache' test

Mirror what's done in the xml2argv test and use recent capabilities.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: qemuxml2argv: Use 64 bit qemu binary and 1.5 machine type in 'disk-cache'...
Peter Krempa [Wed, 22 Jan 2020 16:11:52 +0000 (17:11 +0100)]
tests: qemuxml2argv: Use 64 bit qemu binary and 1.5 machine type in 'disk-cache' case

The data is tested against the latest qemu binaries so we should use the
proper architecture. Also the test is used against data from qemu 1.5.3
and thus we should use a machine type that qemu supported.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: fix linking virt-qemu-run on some distros
Daniel P. Berrangé [Mon, 27 Jan 2020 12:42:04 +0000 (12:42 +0000)]
qemu: fix linking virt-qemu-run on some distros

Debian/Ubuntu linkers are more strict that other distros requiring glib
to be linked explicitly.

macOS needs -export-dynamic instead of -Wl,--export-dynamic

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobhyve: add 'root' parameter to driver initializer
Daniel P. Berrangé [Mon, 27 Jan 2020 12:41:48 +0000 (12:41 +0000)]
bhyve: add 'root' parameter to driver initializer

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: snapshot: Prevent too-nested domain XML when doing inactive snapshot
Peter Krempa [Mon, 20 Jan 2020 15:04:56 +0000 (16:04 +0100)]
qemu: snapshot: Prevent too-nested domain XML when doing inactive snapshot

Similarly to 510d154a0b41aa70aadabc0918d16dee22882394 we need to prevent
doing too deeply nested backing chains and reject them with a sane error
message.

Add a loop to go through the snapshots prior to attempting actually
creating them to prevent some possible inconsistent scenarios.

We don't need to do it when reusing backing chains as we'll be
re-detecting the backing chain in that case anyways.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: snapshot: Always rewrite backingStore data when reusing existing images
Peter Krempa [Fri, 24 Jan 2020 13:14:58 +0000 (14:14 +0100)]
qemu: snapshot: Always rewrite backingStore data when reusing existing images

Don't adopt the backing store data when reusing images provided by the
user. This will force a backing chain re-probe as users might have
passed in something unexpected in the overlay where our view of the
backing chain would not correspond.

This is done only for inactive snapshots as there we have way less
verification.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agodocs: add pages to support Go module package resolution
Daniel P. Berrangé [Mon, 16 Dec 2019 10:06:50 +0000 (10:06 +0000)]
docs: add pages to support Go module package resolution

Currently the libvirt Go modules are accessed by applications using
their github repository URLs. This is undesirable as we don't want
applications to have a direct dependancy on a specific source repo
location. We want to enable applications to use the Go packages via
the libvirt.org namespace.

When you do "go get libvirt.org/libvirt-go", the Go client will do an
HTTPS request to that URL, and parse the HTML content to look for a
<meta> tag which tells it where to the find the GIT repository.

   https://golang.org/cmd/go/#hdr-Remote_import_paths

This adds two pages to support this Go module resolution. They are
not linked from anywhere as we don't expect users to actually look
at them. If someone does happen upon them, there's some boilerplate
text to send them off to godoc.org for API documentation.

Since the pages we're adding have a .html extension, we will also
use a small apache config tweak on the server

    RewriteEngine on
    RewriteRule ^/libvirt-go$ /libvirt-go.html [L]
    RewriteRule ^/libvirt-go-xml$ /libvirt-go-xml.html [L]

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: introduce a new "virt-qemu-run" program
Daniel P. Berrangé [Fri, 17 May 2019 12:01:59 +0000 (13:01 +0100)]
qemu: introduce a new "virt-qemu-run" program

The previous "QEMU shim" proof of concept was taking an approach of only
caring about initial spawning of the QEMU process. It was then
registered with the libvirtd daemon who took over management of it. The
intent was that later libvirtd would be refactored so that the shim
retained control over the QEMU monitor and libvirt just forwarded APIs
to each shim as needed. This forwarding of APIs would require quite alot
of significant refactoring of libvirtd to achieve.

This impl thus takes a quite different approach, explicitly deciding to
keep the VMs completely separate from those seen & managed by libvirtd.
Instead it uses the new "qemu:///embed" URI scheme to embed the entire
QEMU driver in the shim, running with a custom root directory.

Once the driver is initialization, the shim starts a VM and then waits
to shutdown automatically when QEMU shuts down, or should kill QEMU if
it is terminated itself. This ought to use the AUTO_DESTROY feature but
that is not yet available in embedded mode, so we rely on installing a
few signal handlers to gracefully kill QEMU. This isn't reliable if
we crash of course, but you can restart with the same root dir.

Note this program does not expose any way to manage the QEMU process,
since there's no RPC interface enabled. It merely starts the VM and
cleans up when the guest shuts down at the end. This program is
installed to /usr/bin/virt-qemu-run enabling direct use by end users.
Most use cases will probably want to integrate the concept directly
into their respective application codebases. This standalone binary
serves as a nice demo though, and also provides a way to measure
performance of the startup process quite simply.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosecrets: add support for running secret driver in embedded mode
Daniel P. Berrangé [Fri, 17 May 2019 11:35:57 +0000 (12:35 +0100)]
secrets: add support for running secret driver in embedded mode

This enables support for running the secret driver embedded to the
calling application process using a URI:

   secret:///embed?root=/some/path

When using the embedded mode with a root=/var/tmp/embed, the
driver will use the following paths:

       configDir: /var/tmp/embed/etc/secrets
        stateDir: /var/tmp/embed/run/secrets

These are identical whether the embedded driver is privileged
or unprivileged.

This compares with the system instance which uses

       configDir: /etc/libvirt/secrets
        stateDir: /var/lib/libvirt/secrets

When an embedded instance of the secret driver is open, any other
embedded drivers will automatically use the embedded secret driver.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: add support for running QEMU driver in embedded mode
Daniel P. Berrangé [Fri, 17 May 2019 11:35:57 +0000 (12:35 +0100)]
qemu: add support for running QEMU driver in embedded mode

This enables support for running QEMU embedded to the calling
application process using a URI:

   qemu:///embed?root=/some/path

Note that it is important to keep the path reasonably short to
avoid risk of hitting the limit on UNIX socket path names
which is 108 characters.

When using the embedded mode with a root=/var/tmp/embed, the
driver will use the following paths:

                logDir: /var/tmp/embed/log/qemu
           swtpmLogDir: /var/tmp/embed/log/swtpm
         configBaseDir: /var/tmp/embed/etc/qemu
              stateDir: /var/tmp/embed/run/qemu
         swtpmStateDir: /var/tmp/embed/run/swtpm
              cacheDir: /var/tmp/embed/cache/qemu
                libDir: /var/tmp/embed/lib/qemu
       swtpmStorageDir: /var/tmp/embed/lib/swtpm
 defaultTLSx509certdir: /var/tmp/embed/etc/pki/qemu

These are identical whether the embedded driver is privileged
or unprivileged.

This compares with the system instance which uses

                logDir: /var/log/libvirt/qemu
           swtpmLogDir: /var/log/swtpm/libvirt/qemu
         configBaseDir: /etc/libvirt/qemu
              stateDir: /run/libvirt/qemu
         swtpmStateDir: /run/libvirt/qemu/swtpm
              cacheDir: /var/cache/libvirt/qemu
                libDir: /var/lib/libvirt/qemu
       swtpmStorageDir: /var/lib/libvirt/swtpm
 defaultTLSx509certdir: /etc/pki/qemu

At this time all features present in the QEMU driver are available when
running in embedded mode, availability matching whether the embedded
driver is privileged or unprivileged.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agolibvirt: support an "embed" URI path selector for opening drivers
Daniel P. Berrangé [Fri, 17 May 2019 11:42:04 +0000 (12:42 +0100)]
libvirt: support an "embed" URI path selector for opening drivers

The driver URI scheme:

  "$drivername:///embed?root=/some/path"

enables a new way to use the drivers by embedding them directly in the
calling process. To use this the process must have a thread running the
libvirt event loop. This URI will then cause libvirt to dynamically load
the driver module and call its global initialization function. This
syntax is applicable to any driver, but only those will have been
modified to support a custom root directory and embed URI path will
successfully open.

The application can now make normal libvirt API calls which are all
serviced in-process with no RPC layer involved.

It is required to specify an explicit root directory, and locks will be
acquired on this directory to avoid conflicting with another app that
might accidentally pick the same directory.

Use of '/' is not explicitly forbidden, but note that the file layout
used underneath the embedded driver root does not match the file
layout used by system/session mode drivers. So this cannot be used as
a backdoor to interact with, or fake, the system/session mode drivers.

Libvirt will create arbitrary files underneath this root directory. The
root directory can be kept untouched across connection open attempts if
the application needs persistence. The application is responsible for
purging everything underneath this root directory when finally no longer
required.

Even when a virt driver is used in embedded mode, it is still possible
for it to in turn use functionality that calls out to other secondary
drivers in libvirtd. For example an embedded instance of QEMU can open
the network, secret or storage drivers in the system libvirtd.

That said, the application would typically want to at least open an
embedded secret driver ("secret:///embed?root=/some/path"). Note that
multiple different embedded drivers can use the same root prefix and
co-operate just as they would inside a normal libvirtd daemon.

A key thing to note is that for this to work, the application that links
to libvirt *MUST* be built with -Wl,--export-dynamic to ensure that
symbols from libvirt.so are exported & thus available to the dynamically
loaded driver module. If libvirt.so itself was dynamically loaded then
RTLD_GLOBAL must be passed to dlopen().

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agolibvirt: pass a directory path into drivers for embedded usage
Daniel P. Berrangé [Fri, 17 May 2019 11:30:45 +0000 (12:30 +0100)]
libvirt: pass a directory path into drivers for embedded usage

The intent here is to allow the virt drivers to be run directly embedded
in an arbitrary process without interfering with libvirtd. To achieve
this they need to store all their configuration & state in a separate
directory tree from the main system or session libvirtd instances.

This can be useful for doing testing of the virt drivers in "make check"
without interfering with the user's own libvirtd instances.

It can also be used for applications using KVM/QEMU as a piece of
infrastructure to build an service, rather than for general purpose
OS hosting. A long standing example is libguestfs, which would prefer
if its temporary VMs did show up in the main libvirtd VM list, because
this confuses apps such as OpenStack Nova. A more recent example would
be Kata which is using KVM as a technology to build containers.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoutil: add helper API for getting URI parameters
Daniel P. Berrangé [Fri, 20 Dec 2019 14:59:47 +0000 (14:59 +0000)]
util: add helper API for getting URI parameters

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: explicitly disable virgl when requested
Jonathon Jongsma [Fri, 24 Jan 2020 23:12:26 +0000 (17:12 -0600)]
qemu: explicitly disable virgl when requested

If a domain is configured to have an egl-headless display and a virtio
video device, virgl will be enabled automatically within the guest, even
if the video device is configured with accel3d='no'.

In this case we should explicitly pass 'virgl=off' to qemu.

See https://bugzilla.redhat.com/show_bug.cgi?id=1791236 for more
information.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agonews: Update news for rng backend type builtin
Han Han [Thu, 9 Jan 2020 08:00:09 +0000 (16:00 +0800)]
news: Update news for rng backend type builtin

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Implement builtin rng backend
Han Han [Thu, 9 Jan 2020 08:00:08 +0000 (16:00 +0800)]
qemu: Implement builtin rng backend

Since v4.2-rc0, QEMU introduced a builtin rng backend that uses
getrandom() syscall to generate random. Add it to libvirt with the
backend model 'builtin'.

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

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconf: Add rng backend model builtin
Han Han [Thu, 9 Jan 2020 08:00:07 +0000 (16:00 +0800)]
conf: Add rng backend model builtin

The 'builtin' rng backend model can be used as following:
  <rng model='virtio'>
    <backend model='builtin'/>
  </rng>

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoutil: Do not assume comma after object id
Han Han [Thu, 9 Jan 2020 08:00:06 +0000 (16:00 +0800)]
util: Do not assume comma after object id

For qemu object like rng-builtin, there are no properties after id
property. We should always set comma after object id. Otherwise it will
cause trailing comma on object:
    -object rng-builtin,id=ID,

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu_capabilities: Introduce QEMU_CAPS_OBJECT_RNG_BUILTIN
Han Han [Thu, 9 Jan 2020 08:00:05 +0000 (16:00 +0800)]
qemu_capabilities: Introduce QEMU_CAPS_OBJECT_RNG_BUILTIN

It is used to check if qemu is capable of rng-builtin object.

This object is added since qemu-4.2.0-rc0, commit 6c4e9d48.

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu_capabilities: Rework domain caps cache
Michal Privoznik [Fri, 24 Jan 2020 09:43:29 +0000 (10:43 +0100)]
qemu_capabilities: Rework domain caps cache

Since v5.6.0-48-g270583ed98 we try to cache domain capabilities,
i.e. store filled virDomainCaps in a hash table in virQEMUCaps
for future use. However, there's a race condition in the way it's
implemented. We use virQEMUCapsGetDomainCapsCache() to obtain the
pointer to the hash table, then we search the hash table for
cached data and if none is found the domcaps is constructed and
put into the table. Problem is that this is all done without any
locking, so if there are two threads trying to do the same, one
will succeed and the other will fail inserting the data into the
table.

Also, the API looks a bit fishy - obtaining pointer to the hash
table is dangerous.

The solution is to use a mutex that guards the whole operation
with the hash table. Then, the API can be changes to return
virDomainCapsPtr directly.

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

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agoqemu_conf: Avoid dereferencing NULL in virQEMUDriverGetHost{NUMACaps,CPU}
Michal Privoznik [Fri, 24 Jan 2020 09:24:45 +0000 (10:24 +0100)]
qemu_conf: Avoid dereferencing NULL in virQEMUDriverGetHost{NUMACaps,CPU}

When fixing [1] I've ran attached reproducer and had it spawn
1024 threads and query capabilities XML in each one of them. This
lead libvirtd to hit the RLIMIT_NOFILE limit which was kind of
expected. What wasn't expected was a subsequent segfault. It
happened because virCPUProbeHost failed and returned NULL. We've
taken the NULL and passed it to virCapabilitiesHostNUMARef()
which dereferenced it. Code inspection showed the same flas in
virQEMUDriverGetHostNUMACaps(), so I'm fixing both places.

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

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agocpu.c: Check properly for virCapabilitiesGetNodeInfo() retval
Michal Privoznik [Fri, 24 Jan 2020 09:22:13 +0000 (10:22 +0100)]
cpu.c: Check properly for virCapabilitiesGetNodeInfo() retval

The virCapabilitiesGetNodeInfo() function has the usual return
value semantics for integeres: a negative value means an error,
zero or a positive value means success. However, the function
call done in virCPUProbeHost() doesn't check for the return value
accordingly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agoqemu: monitor: Improve error message when QEMU reply is too large
Peter Krempa [Mon, 20 Jan 2020 15:06:42 +0000 (16:06 +0100)]
qemu: monitor: Improve error message when QEMU reply is too large

Don't use ERANGE as it doesn't make much sense in the error message.
Also point out that the reply from qemu was too large which is not
obvious from the original error:

 error: No complete monitor response found in 10485760 bytes: Numerical result out of range

The new message will read:

 error: internal error: QEMU monitor reply exceeds buffer size (10485760 bytes)

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoqemu: block: Don't skip creation of 'luks' formatted images
Peter Krempa [Mon, 20 Jan 2020 12:02:58 +0000 (13:02 +0100)]
qemu: block: Don't skip creation of 'luks' formatted images

libvirt treats 'luks' images as raw+encryption. The logic in
qemuBlockStorageSourceCreateFormat skipped the creation if the requested
image was raw but didn't take into account the encryption.

This manifested itself e.g. when attempting to do a virsh blockcopy with
the following XML:

    <disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='/tmp/enccpy'>
        <encryption format='luks'>
          <secret type='passphrase' uuid='0a81f5b2-8403-7b23-c8d6-21ccc2f80d6f'/>
        </encryption>
      </source>
    </disk>

Where qemu would report the following error:

 unable to execute QEMU command 'blockdev-add': Volume is not in LUKS format

rather than actually formatting the image first.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agotests: hash: Test case for adding duplicate hash entry
Peter Krempa [Thu, 16 Jan 2020 14:30:53 +0000 (15:30 +0100)]
tests: hash: Test case for adding duplicate hash entry

Test that adding a duplicate entry is rejected properly. This also
allows to see the error message of the duplicate key addition in verbose
mode.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoutil: hash: Improve debugability of "Duplicate key" error message
Peter Krempa [Thu, 16 Jan 2020 14:13:06 +0000 (15:13 +0100)]
util: hash: Improve debugability of "Duplicate key" error message

If we get a user reporting this error message being shown it's pretty
useless in terms of actually debugging it since we don't know which hash
and which key are actually subject to the error.

This patch adds a new hash table callback which formats the
user-readable version of the hash key and reports it in the new message
which will look like:

"Duplicate hash table key 'blah'"

That way we will at least have an anchor point where to start the
search.

There are two special implementations of keys which are numeric so we
add specific printer functions for them.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: backup: Implement support for backup disk bitmap name configuration
Peter Krempa [Fri, 20 Dec 2019 11:38:16 +0000 (12:38 +0100)]
qemu: backup: Implement support for backup disk bitmap name configuration

Use the user-configured name of the bitmap when merging the appropriate
bitmaps for an incremental backup so that the user can see it as
configured. Additionally expose the default bitmap name if nothing is
configured.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoqemu: backup: Implement support for backup disk export name configuration
Peter Krempa [Fri, 20 Dec 2019 11:33:02 +0000 (12:33 +0100)]
qemu: backup: Implement support for backup disk export name configuration

Pass the exportname as configured when exporting the image via NBD and
fill it with the default if it's not configured.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoconf: backup: Allow configuration of names exported via NBD
Peter Krempa [Fri, 20 Dec 2019 10:37:40 +0000 (11:37 +0100)]
conf: backup: Allow configuration of names exported via NBD

If users wish to use different name for exported disks or bitmaps
the new fields allow to do so. Additionally they also document the
current settings.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: Fix value of 'device' argument for block-commit
Peter Krempa [Mon, 20 Jan 2020 12:19:43 +0000 (13:19 +0100)]
qemu: Fix value of 'device' argument for block-commit

When using blockdev configurations the 'device' argument of
'blockdev-commit' must correspond to the topmost node in the block node
graph. Libvirt didn't do this properly in case when 'copy_on_read'
option was enabled on the disk.

Use qemuDomainDiskGetTopNodename to fix it when calling block-commit.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: Fix value of 'device' argument for blockdev-mirror
Peter Krempa [Mon, 20 Jan 2020 12:19:43 +0000 (13:19 +0100)]
qemu: Fix value of 'device' argument for blockdev-mirror

When using blockdev configurations the 'device' argument of
'blockdev-mirror' must correspond to the topmost node in the block node
graph. Libvirt didn't do this properly in case when 'copy_on_read'
option was enabled on the disk.

Use qemuDomainDiskGetTopNodename to fix it for the blockdev-mirror calls
in qemuDomainBlockCopy and the non-shared-storage migration.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: domain: Extract code to determine topmost nodename to qemuDomainDiskGetTopNodename
Peter Krempa [Fri, 17 Jan 2020 13:28:14 +0000 (14:28 +0100)]
qemu: domain: Extract code to determine topmost nodename to qemuDomainDiskGetTopNodename

There are more places which require getting the topmost nodename to be
passed to qemu. Separate it out into a new function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: blockcopy: Actually unplug unused images when mirror job fails to start
Peter Krempa [Fri, 17 Jan 2020 13:07:34 +0000 (14:07 +0100)]
qemu: blockcopy: Actually unplug unused images when mirror job fails to start

If a mirror job fails to start in -blockdev mode we'd not unplug the
backing files we added first because the code on the error path checked
the wrong value. 'rc' is used as status of the code which added the
images, but the state of the 'block(dev)-mirror' call is stored in 'ret'
at that point.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: fixing auto-detecting binary in domain capabilities
Daniel P. Berrangé [Fri, 17 Jan 2020 13:25:02 +0000 (13:25 +0000)]
qemu: fixing auto-detecting binary in domain capabilities

The virConnectGetDomainCapabilities API accepts either a binary path
to the emulator, or desired guest arch. If guest arch is not given,
then the host arch is assumed.

In the case where the binary is not given, the code tried to find the
emulator binary in the existing list of cached emulator capabilities.
This is not valid since we switched to lazy population of the cache in:

  commit 3dd91af01f30c5bda6328454ef49f3afece755d6
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   Mon Dec 2 13:04:26 2019 +0000

    qemu: stop creating capabilities at driver startup

As a result of this change, if there are no persistent guests defined
using the requested guest architecture, virConnectGetDomainCapabilities
will fail to find an emulator binary.

The solution is to stop relying on the cached capabilities to find the
binary and instead use the same logic we use to pick default a binary
per arch when populating capabilities.

Tested-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Tested-by: Richard W.M. Jones <rjones@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: Refuse to use "ps2" on machines that do not have this bus
Thomas Huth [Wed, 15 Jan 2020 12:23:56 +0000 (13:23 +0100)]
qemu: Refuse to use "ps2" on machines that do not have this bus

The "ps2" bus is only available on certain machines like x86. On
machines like s390x, we should refuse to add a device to this bus
instead of silently ignoring it.

Looking at the QEMU sources, PS/2 is only available if the QEMU binary
has the "i8042" device, so let's check for that and only allow "ps2"
devices if this QEMU device is available, or if we're on x86 anyway
(so we don't have to fake the QEMU_CAPS_DEVICE_I8042 capability in
all the tests that use <input ... bus='ps2'/> in their xml data).

Reported-by: Sebastian Mitterle <smitterl@redhat.com>
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1763191
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agolxc: Add support to lxcDomainInterfaceAddresses() function
Julio Faracco [Tue, 21 Jan 2020 03:37:11 +0000 (00:37 -0300)]
lxc: Add support to lxcDomainInterfaceAddresses() function

LXC driver is not able to retrieve IP addresses from domains. This
function was not implemented yet. It can be done using DHCP lease and
ARP table. Different from QEMU, LXC does not have an agent to fetch
this info, but other sources can be used.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Converting DHCP and ARP functions to domain conf
Julio Faracco [Tue, 21 Jan 2020 03:37:10 +0000 (00:37 -0300)]
qemu: Converting DHCP and ARP functions to domain conf

QEMU driver has two functions: qemuGetDHCPInterfaces() and
qemuARPGetInterfaces() that are being used inside only one single
function. They can be turned into generic functions that other drivers
can use. This commit move both from QEMU driver tree to domain conf
tree.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agonodedev: Use autofree for more local variables
Jonathon Jongsma [Fri, 10 Jan 2020 21:51:07 +0000 (15:51 -0600)]
nodedev: Use autofree for more local variables

Simplify function logic by using g_autofree to free local variables so
that we can remove some goto statements that are used for cleanup.

Introduce a g_autoptr cleanup function for virNodeDeviceDef.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agosrc: remove WITH_GNUTLS usage
Pavel Hrdina [Wed, 22 Jan 2020 16:21:35 +0000 (17:21 +0100)]
src: remove WITH_GNUTLS usage

Since commit <60d9ad6f1e42618fce10baeb0f02c35e5ebd5b24> we require
GnuTLS and since commit <ac0d21c762351f58dd5d2dafa2014ed48a8b49f3>
we can actually drop the usage of WITH_GNUTLS.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotest: let qemuhotplugtest report details of init fails
Christian Ehrhardt [Thu, 16 Jan 2020 08:13:28 +0000 (09:13 +0100)]
test: let qemuhotplugtest report details of init fails

If virHostdevManagerGetDefault in qemuhotplugtest fails it works
for quite a while to later segfault when accessing
mgr->activePCIHostdevs.

Report the error details and break on a failed init to see the
real issue right away.

Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
5 years agolibxl: initialize shutdown inhibit callback
Marek Marczykowski-Górecki [Sat, 18 Jan 2020 02:37:42 +0000 (03:37 +0100)]
libxl: initialize shutdown inhibit callback

The libxl driver already tries to call shutdown inhibit callback in the
right places, but only if it's set. That last part was missing,
resulting in premature shutdown when running libvirtd
--timeout=...

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
5 years agorun.in: Include tools directory on $PATH.
Richard W.M. Jones [Thu, 16 Jan 2020 17:15:42 +0000 (17:15 +0000)]
run.in: Include tools directory on $PATH.

You normally want to run the locally compiled copy of virsh.  Trying
to run the installed version with the locally compiled library is a
recipe for problems with missing symbols and so on.  By adding tools
to the path we can ensure that (eg) the libguestfs test suite will use
compatible copies of the library and virsh.

Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agorun.in: Add intelligent prepend function.
Richard W.M. Jones [Thu, 16 Jan 2020 17:15:41 +0000 (17:15 +0000)]
run.in: Add intelligent prepend function.

This has been used in libguestfs and libnbd for quite a while as it
makes the ./run script easier to read and write.

See also:
http://stackoverflow.com/a/9631350

Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: end the agent job in qemuDomainSetTimeAgent
Ján Tomko [Mon, 20 Jan 2020 06:55:48 +0000 (07:55 +0100)]
qemu: end the agent job in qemuDomainSetTimeAgent

This function grabs an agent job but ends a monitor job.
End the agent job instead.

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reported-by: Dan Zheng <dzheng@redhat.com>
Fixes: e005c95f56fee9ed780be7f8db103d690bd34cbd
5 years agodocs: fixing typos 'libivrt' > 'libvirt'
Julio Faracco [Fri, 17 Jan 2020 15:12:21 +0000 (12:12 -0300)]
docs: fixing typos 'libivrt' > 'libvirt'

This is only 2 simple typo fixes for wrong documentation wording.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agoautogen.sh: fix autoreconf step
Pavel Hrdina [Wed, 18 Dec 2019 13:26:58 +0000 (14:26 +0100)]
autogen.sh: fix autoreconf step

Running bootstrap and autoreconf from autogen.sh produced different
files in build-aux directory.  The reason is that gnulib usually have
newer version of these files and overwrites them after the autoreconf
step.

In order to fix it remove the --install and --force options, in addition
introduce --verbose option in order to reflect what bootstrap is doing.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosyntax-check: remove deleted daemon directory from space_indent_check
Pavel Hrdina [Wed, 11 Dec 2019 14:40:31 +0000 (15:40 +0100)]
syntax-check: remove deleted daemon directory from space_indent_check

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobootstrap.conf: stop creating AUTHORS file
Pavel Hrdina [Wed, 8 Jan 2020 21:54:31 +0000 (22:54 +0100)]
bootstrap.conf: stop creating AUTHORS file

The existence of AUTHORS file is required for GNU projects but since
commit <8bfb36db40f38e92823b657b5a342652064b5adc> we do not require
these files to exist.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobootstrap.conf: disable VC ignore files
Pavel Hrdina [Wed, 11 Dec 2019 09:19:21 +0000 (10:19 +0100)]
bootstrap.conf: disable VC ignore files

We already ignore most of these files and the .gitignore files as well.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobootstrap.conf: declare bootstrap sync in configuration file
Pavel Hrdina [Wed, 11 Dec 2019 09:18:29 +0000 (10:18 +0100)]
bootstrap.conf: declare bootstrap sync in configuration file

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobootstrap.conf: always copy files
Pavel Hrdina [Wed, 11 Dec 2019 09:17:27 +0000 (10:17 +0100)]
bootstrap.conf: always copy files

Preparation for having bootstrap result in git.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobootstrap.conf: drop gnulib tests from libvirt
Pavel Hrdina [Wed, 11 Dec 2019 09:14:38 +0000 (10:14 +0100)]
bootstrap.conf: drop gnulib tests from libvirt

We are in process of removing gnulib and adopting meson as our build
system.  In order to help with the transition let's drop gnulib tests.

This will also help with the fact that before we will be able to drop
gnulib completely we will store output of bootstrap in git.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobootstrap.conf: add threadlib module
Pavel Hrdina [Fri, 17 Jan 2020 14:50:47 +0000 (15:50 +0100)]
bootstrap.conf: add threadlib module

It is pulled in by tests and used by our build system as well.
Make an explicit dependency on threadlib.  This can be later removed
by using GLib GThread.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoconfigure.ac: add check for getegid function
Pavel Hrdina [Wed, 11 Dec 2019 11:28:34 +0000 (12:28 +0100)]
configure.ac: add check for getegid function

We already use this function and so far we've been lucky that the same
check is done by gnulib.  This will change once we will drop gnulib and
also make it obvious that we have to do the same check in Meson as well.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosecret: move virSecretGetSecretString into virsecret
Pavel Hrdina [Thu, 24 Oct 2019 16:00:55 +0000 (18:00 +0200)]
secret: move virSecretGetSecretString into virsecret

The function virSecretGetSecretString calls into secret driver and is
used from other hypervisors drivers and as such makes more sense in
util.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoman: fix section of virt-sanlock-cleanup
Christian Ehrhardt [Thu, 16 Jan 2020 10:42:12 +0000 (11:42 +0100)]
man: fix section of virt-sanlock-cleanup

Reported at build time by lintian:
manpage-section-mismatch usr/share/man/man8/virt-sanlock-cleanup.8.gz:3 8 != 1

And indeed the rst file says 1 while the makefile say 8:
 if WITH_SANLOCK
   manpages8_rst += manpages/virt-sanlock-cleanup.rst
 else ! WITH_SANLOCK

8 "System administration commands and daemons" seems to match, so fix
the rst file to match.

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agosrc: conditionalize / remove use of sys/ioctl.h
Daniel P. Berrangé [Fri, 17 Jan 2020 12:17:58 +0000 (12:17 +0000)]
src: conditionalize / remove use of sys/ioctl.h

Remove many imports of sys/ioctl.h which are redundant,
and conditionalize remaining usage that needs to compile
on Windows platforms.

The previous change to remove the "nonblocking" gnulib
module indirectly caused the loss of the "ioctl" gnulib
module that we did not explicitly list in bootstrap.conf
despite relying on.

Rather than re-introduce the "ioctl" module this patch
makes it redundant.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobhyve: fix typos checking CPU dies
Daniel P. Berrangé [Fri, 17 Jan 2020 12:31:16 +0000 (12:31 +0000)]
bhyve: fix typos checking CPU dies

This fixes a build bug introduced by

  commit fbf27730a36da573b1065c179f4d96b9a751f22f
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   Mon Dec 16 11:16:51 2019 +0000

    conf: add support for specifying CPU "dies" parameter

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