]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
3 years agoqemu: add support for tsc.on_reboot element
Paolo Bonzini [Thu, 24 Mar 2022 09:48:39 +0000 (10:48 +0100)]
qemu: add support for tsc.on_reboot element

QEMU 7.0.0 adds a new property tsc-clear-on-reset to x86 CPU, corresponding
to Libvirt's <tsc on_reboot="clear"/> element.  Plumb it in the validation,
command line handling and tests.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agodomain: add tsc.on_reboot element
Paolo Bonzini [Thu, 24 Mar 2022 09:48:38 +0000 (10:48 +0100)]
domain: add tsc.on_reboot element

Some versions of Windows hang on reboot if their TSC value is greater
than 2^54.  The workaround is to reset the TSC to a small value.  Add
to the domain configuration an attribute for this.  It can be used
by QEMU and in principle also by ESXi, which has a property called
monitor_control.enable_softResetClearTSC as well.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agotests: add dependencies to meson declaration
Paolo Bonzini [Thu, 24 Mar 2022 09:36:56 +0000 (10:36 +0100)]
tests: add dependencies to meson declaration

Make sure that all tests are run after the helpers and mocks are
(re)built.  This enables for example using "meson test" as the
command line passed to "git bisect run".

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agomeson: do not look for libparted if not requested
Paolo Bonzini [Thu, 24 Mar 2022 10:53:04 +0000 (11:53 +0100)]
meson: do not look for libparted if not requested

libparted_dep is not used if -Dstorage_disk=disabled. Do not
bother looking for this library if the disk storage backend was
not requested.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
3 years agomeson: do not look for librbd/librados if not requested
Paolo Bonzini [Thu, 24 Mar 2022 10:53:03 +0000 (11:53 +0100)]
meson: do not look for librbd/librados if not requested

rbd_dep is not used if -Dstorage_rbd=disabled.  Do not bother looking for
the libraries that compose it if the rbd storage backend was not requested.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoch: use virDomainJob enum instead of virCHDomainJob
Kristina Hanicova [Thu, 24 Mar 2022 15:32:46 +0000 (16:32 +0100)]
ch: use virDomainJob enum instead of virCHDomainJob

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agolibxl: use virDomainJob enum instead of libxlDomainJob
Kristina Hanicova [Thu, 24 Mar 2022 15:32:45 +0000 (16:32 +0100)]
libxl: use virDomainJob enum instead of libxlDomainJob

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agolxc: use virDomainJob enum instead of virLXCDomainJob
Kristina Hanicova [Thu, 24 Mar 2022 15:32:44 +0000 (16:32 +0100)]
lxc: use virDomainJob enum instead of virLXCDomainJob

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu: move macros QEMU_X into hypervisor as VIR_X
Kristina Hanicova [Thu, 24 Mar 2022 15:32:43 +0000 (16:32 +0100)]
qemu: move macros QEMU_X into hypervisor as VIR_X

It makes sense to have these in the same file as the definitions
of enums.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agomove jobs enums QEMU_X into hypervisor as VIR_X
Kristina Hanicova [Thu, 24 Mar 2022 15:32:42 +0000 (16:32 +0100)]
move jobs enums QEMU_X into hypervisor as VIR_X

These enums are essentially the same and always sorted in the
same order in every hypervisor with jobs. They can be generalized
by using the qemu enums as the main ones as they are the most
extensive.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoTranslated using Weblate (German)
Tom Wieczorek [Sat, 19 Mar 2022 09:16:55 +0000 (10:16 +0100)]
Translated using Weblate (German)

Currently translated at 48.4% (5045 of 10404 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/de/

Co-authored-by: Tom Wieczorek <tom@bibbu.net>
Signed-off-by: Tom Wieczorek <tom@bibbu.net>
3 years agoqemu: remove else branches after return in qemuMigrationSrcPerform()
Kristina Hanicova [Thu, 24 Mar 2022 14:34:08 +0000 (15:34 +0100)]
qemu: remove else branches after return in qemuMigrationSrcPerform()

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: remove unnecessary else branches after return / goto
Kristina Hanicova [Thu, 24 Mar 2022 14:34:07 +0000 (15:34 +0100)]
qemu: remove unnecessary else branches after return / goto

I think the code looks cleaner without else branches.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agokbase: Fix the syntax of the snapshot link in index.rst
Han Han [Fri, 25 Mar 2022 06:48:36 +0000 (14:48 +0800)]
kbase: Fix the syntax of the snapshot link in index.rst

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu_command: Generate prealloc-threads property
Michal Privoznik [Mon, 21 Mar 2022 16:10:15 +0000 (17:10 +0100)]
qemu_command: Generate prealloc-threads property

Let's generate prealloc-threads property onto the cmd line if
domain configuration requests so.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
3 years agoqemu_validate: Validate prealloc threads against qemuCpas
Michal Privoznik [Mon, 21 Mar 2022 16:09:40 +0000 (17:09 +0100)]
qemu_validate: Validate prealloc threads against qemuCpas

Only fairly new QEMUs are capable of user provided number of
preallocation threads. Validate this assumption.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
3 years agoqemu_capabilities: Detect memory-backend-*.prealloc-threads property
Michal Privoznik [Mon, 21 Mar 2022 15:55:05 +0000 (16:55 +0100)]
qemu_capabilities: Detect memory-backend-*.prealloc-threads property

The prealloc-threads is property of memory-backend class which is
parent to the other three classes memory-backend-{ram,file,memfd}.
Therefore the property is present for all, or none if QEMU is
older than v5.0.0-rc0~75^2~1^2~3 which introduced the property.

Anyway, the .reserve property is the same story, and we chose
memory-backend-file to detect it, so stick with our earlier
decision and use the same backend to detect this new property.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
3 years agoconf: Introduce memory allocation threads
Michal Privoznik [Mon, 21 Mar 2022 15:49:25 +0000 (16:49 +0100)]
conf: Introduce memory allocation threads

Since its v5.0.0 release QEMU is capable of specifying number of
threads used to allocate memory. It defaults to 1, which may be
too low for humongous guests with gigantic pages.

In general, on QEMU cmd line level it is possible to use
different number of threads per each memory-backend-* object, in
practical terms it's not useful. Therefore, use <memoryBacking/>
to set guest wide value and let all memory devices 'inherit' it,
silently. IOW, don't introduce per device knob because that would
only complicate things for a little or no benefit.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
3 years agokeycodemapdb: Update git submodule
Andrea Bolognani [Tue, 22 Mar 2022 13:12:16 +0000 (14:12 +0100)]
keycodemapdb: Update git submodule

This brings in all the fixes made since April 2020.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoci: integration: Rename all Avocado standard stream log files to *.log
Erik Skultety [Tue, 22 Mar 2022 11:31:49 +0000 (12:31 +0100)]
ci: integration: Rename all Avocado standard stream log files to *.log

By default, stdout/stderr Avocado test log files do not have any file
extension which confuses GitLab's web UI to mangle the MIME type for
these and so the browser will never offer the option to open such file
from in a text editor rather than dowloading it.
Since GitLab sets a proper MIME for .txt and .log file extensions,
rename all Avocado log files without an extension to *.log . This pairs
nicely with the coredumpctl info file which we already name as
'coredumpctl.txt' because of this.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agoci: integration: Collect stack traces with coredumpctl
Erik Skultety [Mon, 21 Mar 2022 17:05:16 +0000 (18:05 +0100)]
ci: integration: Collect stack traces with coredumpctl

Some Red Hat-like distros have cores limited with a soft limit of 0
which means that neither a stack trace nor a core file will be
available. Since we want the stack trace we need to set the core limit
with systemd globally to unlimited/infinity.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoci: Define the integration job tag dynamically via a variable
Erik Skultety [Mon, 21 Mar 2022 12:51:53 +0000 (13:51 +0100)]
ci: Define the integration job tag dynamically via a variable

Custom runners are private to a project, so naturally forks cannot run
any workloads on these. The integration test suite which requires
access to our custom runner is naturally disabled on forks and can be
enabled by setting LIBVIRT_CI_INTEGRATION=1.
The problem is that the current integration jobs definitions have tags
statically defined as 'redhat-vm-host'. If users are going to supply
their own private runners for their forks, they can define whatever
tags they want with it and so unless they add 'redhat-vm-host' to their
own runner's tags, the pipeline won't run.
To solve this, define the integration job tag using a variable. The
repo config will use the value defined in the job for the variable
while users can override the value easily on a project/pipeline level
thanks to GitLab's CI variable precedence [1].

[1] https://docs.gitlab.com/ee/ci/variables/#cicd-variable-precedence

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agonwfilter: merge updateMutex and updateLock
Daniel P. Berrangé [Mon, 7 Mar 2022 11:11:48 +0000 (11:11 +0000)]
nwfilter: merge updateMutex and updateLock

The updateLock is a R/W lock held by anything which needs to read or
modify the rules associated with an NWFilter.

APIs for defining/undefining NW filters rules hold a write lock on
updateLock.

APIs for creating/deleting NW filter bindings hold a read lock on
updateLock, which prevents define/undefine taking place concurrently.

The problems arise when we attempt to creating two NW filter bindings in
parallel.

Thread 1 can acquire the mutex for filter A

Thread 2 can acquire the mutex for filter B

Consider if filters A and B both reference filters C and D, but in
different orders:

  Filter A
     -> filter C
     -> filter D

  Filter B
     -> filter D
     -> filter C

Thread 1 will try to acquire locks in order A, C, D while thread 1 will
try to acquire in order A, D, C. Deadlock can still occur.

Think we can sort the list of filters before acquiring locks on all of
them ? Nope, we allow arbitrary recursion:

  Filter A
     -> filter C
          -> filter E
             -> filter F
                -> filter H
                -> filter K
     -> filter D
         -> filter G
         -> filter I

So we can't tell from looking at 'A' which filters we're going to
need to lock. We can only see the first level of filters references
and we need to lock those before we can see the second level of
filters, etc.

We could probably come up with some cleverness to address this but
it isn't worth the time investment. It is simpler to just keep the
process of creating NW filter bindings totally serialized.

Using two separate locks for this serialization though is pointless.

Every code path which gets a read(updateLock) will go on to hold
updateMutex. It is simpler to just hold write(updateLock) and
get rid of updateMutex. At that point we don't need updateLock
to be a R/W lock, it can be a plain mutex.

Thus this patch gets rid of the current updateLock and updateMutex
and introduces a new top level updateMutex.

This has a secondary benefit of introducing fairness into the
locking.  With a POSIX R/W lock, you get writer starvation if
you have lots of readers. IOW, if we call virNWFilterBIndingCreate
and virNWFilterBindingDelete in a tight loop from a couple of
threads, we can prevent virNWFilterDefine from ever acquiring
a write lock.

Getting rid of the R/W lock gives us FIFO lock acquisition
preventing starvation of any API call servicing.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agodocs: Update obsolete reference to formatdomain.html.in
Andrea Bolognani [Tue, 22 Mar 2022 10:01:38 +0000 (11:01 +0100)]
docs: Update obsolete reference to formatdomain.html.in

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
3 years agoschemas: move out of docs, fix no-docs build
Claudio Fontana [Tue, 22 Mar 2022 08:18:57 +0000 (09:18 +0100)]
schemas: move out of docs, fix no-docs build

schemas are used for more than just documentation,
virsh edit fails if schemas are not available.

Therefore, fix the no-docs build by moving schemas/
to the parsing code inside src/conf/.

Signed-off-by: Claudio Fontana <cfontana@suse.de>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agokbase: Introduce 'snapshots' page and describe the new 'manual' snapshot
Peter Krempa [Wed, 9 Mar 2022 16:05:14 +0000 (17:05 +0100)]
kbase: Introduce 'snapshots' page and describe the new 'manual' snapshot

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuSnapshotCreateActiveExternal: Implement manual snapshot mode
Peter Krempa [Fri, 4 Mar 2022 13:37:13 +0000 (14:37 +0100)]
qemuSnapshotCreateActiveExternal: Implement manual snapshot mode

In case we are snapshotting at least one 'manual' disk we will pause the
VM and keep it paused.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1866400
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoconf: snapshot: Introduce 'manual' mode for snapshot of a disk
Peter Krempa [Fri, 4 Mar 2022 14:50:19 +0000 (15:50 +0100)]
conf: snapshot: Introduce 'manual' mode for snapshot of a disk

The idea of the manual mode is to allow a synchronized snapshot in cases
when the storage is outsourced to an unmanaged storage provider which
requires cooperation with snapshotting.

The mode will instruct the hypervisor to pause along when the other
components are snapshotted and the 'manual' disk can be snapshotted
along. This increases latency of the snapshot but allows them in
otherwise impossible situations.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuDomainDefNamespaceFormatXML*: Convert to virXMLFormatElement
Peter Krempa [Wed, 16 Mar 2022 10:15:15 +0000 (11:15 +0100)]
qemuDomainDefNamespaceFormatXML*: Convert to virXMLFormatElement

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: fix recording of CPU deprecations
Daniel P. Berrangé [Thu, 17 Mar 2022 17:50:43 +0000 (17:50 +0000)]
qemu: fix recording of CPU deprecations

The code parsing thue query-cpu-definitions response will short-circuit
the for loop in the case where usable=yes, resulting in us failing to
parse the CPU deprecation flag.

IOW, we only reported deprecations in domain capabilities for CPU models
which were not runnable on the host.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agovirNWFilterLockIface: Preserve correct lock ordering
Michal Privoznik [Fri, 18 Mar 2022 16:14:54 +0000 (17:14 +0100)]
virNWFilterLockIface: Preserve correct lock ordering

In the not so distant past, the lock ordering in
virNWFilterLockIface() was as follows: global mutex ifaceMapLock
was acquired, then internal representation of given interface was
looked up in a hash table (or created brand new if none was
found), the global lock was released and the lock of the
interface was acquired.

But this was mistakenly changed as the function was rewritten to
use automatic mutexes, because now the global lock is held
throughout the whole run of the function and thus the interface
specific lock is acquired with the global lock held. This results
in a deadlock.

Fixes: dd8150c48dcf94e8d3b0481be08eeef822b98b02
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
3 years agoqemu_process: Be nicer to killing QEMU when probing caps
Michal Privoznik [Fri, 4 Feb 2022 09:33:20 +0000 (10:33 +0100)]
qemu_process: Be nicer to killing QEMU when probing caps

The qemuProcessQMPStop() function is intended to kill this dummy
QEMU process we started only for querying capabilities.
Nevertheless, it may be not plain QEMU binary we executed, but
in fact it may be a memcheck tool (e.g. valgrind) that executes
QEMU later. By switching to virProcessKillPainfully() we allow
this wrapper tool to exit gracefully.

Another up side is that virProcessKillPainfully() reports an
error so no need for us to VIR_ERROR() ourselves.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
3 years agoci: only run integration tests if $LIBVIRT_CI_INTEGRATION=1 is set
Daniel P. Berrangé [Thu, 17 Mar 2022 16:29:52 +0000 (16:29 +0000)]
ci: only run integration tests if $LIBVIRT_CI_INTEGRATION=1 is set

Right now the jobs have no rules so they will always be created in
a pipeline. If the user's fork has no runner configured, then the
jobs will never be able to execute and the pipeline will not finish.

Even on upstream, there might be times the runner has to be taken
offline for maint work, or unexpectedly fail. We need a quick way
to disable the integration tests if we decide we don't want to
have pipelines queued until the runner comes back online.

Both these problems can be addressed by requiring a environment
variable to be set

   LIBVIRT_CI_INTEGRATION=1

This can be done in the GitLab repo CI settings for permanent
enablement. Alternatively it can be set for individual
scheduled jobs, or using a push option

  git push -o ci.variable=LIBVIRT_CI_INTEGRATION=1

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
3 years agoci: rename integration test template
Daniel P. Berrangé [Thu, 17 Mar 2022 16:29:51 +0000 (16:29 +0000)]
ci: rename integration test template

Although we split out jobs across many files, the template / job
namespace is global, so we should use something more specific
than '.tests' as the template name.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
3 years agovirnwfilterobj: Don't use virObjectLockGuard() with virNWFilterObj
Michal Privoznik [Fri, 18 Mar 2022 10:36:47 +0000 (11:36 +0100)]
virnwfilterobj: Don't use virObjectLockGuard() with virNWFilterObj

While its name would suggest that virNWFilterObj is an actual
virObject it is not. It's a plain structure (with virMutex as its
first member). Therefore, when locking the struct
virObjectLockGuard() can' be used and virLockGuardLock() must be
used instead.

Spotted-by: Martin Kletzander <mkletzan@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
3 years agoqemu: use qemuDomainSaveStatus() and remove qemuDomainObjSaveStatus()
Kristina Hanicova [Fri, 18 Mar 2022 10:17:28 +0000 (11:17 +0100)]
qemu: use qemuDomainSaveStatus() and remove qemuDomainObjSaveStatus()

It does not make sense to have both of these, since one of them
is only a wrapper for the other one. I decided to preserve the
more general one, which requires only virDomainObj and rewrote it
a bit, so that it pulls the qemu driver from privateData.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
3 years agoqemu_conf: Use automatic memory management
Tim Wiederhake [Tue, 8 Mar 2022 14:59:06 +0000 (15:59 +0100)]
qemu_conf: Use automatic memory management

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agonwfilter_driver: Use automatic mutex management
Tim Wiederhake [Tue, 8 Mar 2022 09:54:23 +0000 (10:54 +0100)]
nwfilter_driver: Use automatic mutex management

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoremote_daemon_stream: Use automatic memory management
Tim Wiederhake [Tue, 8 Mar 2022 14:34:50 +0000 (15:34 +0100)]
remote_daemon_stream: Use automatic memory management

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agovirnetlink: Use automatic memory management
Tim Wiederhake [Wed, 16 Mar 2022 17:54:32 +0000 (18:54 +0100)]
virnetlink: Use automatic memory management

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agovirNetlinkEventAddClient: Remove goto
Tim Wiederhake [Mon, 14 Mar 2022 14:03:23 +0000 (15:03 +0100)]
virNetlinkEventAddClient: Remove goto

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agonwfilter_ipaddrmap: Use automatic mutex management
Tim Wiederhake [Tue, 8 Mar 2022 13:37:47 +0000 (14:37 +0100)]
nwfilter_ipaddrmap: Use automatic mutex management

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agonwfilter_learnipaddr: Use automatic mutex management
Tim Wiederhake [Tue, 8 Mar 2022 13:11:02 +0000 (14:11 +0100)]
nwfilter_learnipaddr: Use automatic mutex management

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agonwfilter_dhcpsnoop: Replace virNWFilterSnoopReqLock functions
Tim Wiederhake [Wed, 16 Mar 2022 22:00:45 +0000 (23:00 +0100)]
nwfilter_dhcpsnoop: Replace virNWFilterSnoopReqLock functions

Use automatic mutex management instead.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agonwfilter_dhcpsnoop: Replace virNWFilterSnoopLock macros
Tim Wiederhake [Wed, 16 Mar 2022 22:08:47 +0000 (23:08 +0100)]
nwfilter_dhcpsnoop: Replace virNWFilterSnoopLock macros

Use automatic mutex management instead.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agonwfilter_dhcpsnoop: Replace virNWFilterSnoopActiveLock macros
Tim Wiederhake [Tue, 8 Mar 2022 11:45:38 +0000 (12:45 +0100)]
nwfilter_dhcpsnoop: Replace virNWFilterSnoopActiveLock macros

Use automatic mutex management instead.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agonwfilter_gentech: Use automatic mutex management
Tim Wiederhake [Mon, 7 Mar 2022 16:45:05 +0000 (17:45 +0100)]
nwfilter_gentech: Use automatic mutex management

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agonwfilter_driver: Split up nwfilterStateCleanup
Tim Wiederhake [Tue, 8 Mar 2022 09:49:09 +0000 (10:49 +0100)]
nwfilter_driver: Split up nwfilterStateCleanup

This allows nwfilterStateCleanupLocked to be used in
nwfilterStateInitialize in a later patch.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agonwfilter_driver: Statically initialize mutex
Tim Wiederhake [Tue, 15 Feb 2022 12:17:21 +0000 (13:17 +0100)]
nwfilter_driver: Statically initialize mutex

This enables a later patch to simplify locking during initialization
and cleanup of virNWFilterDriverState.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoconf: fix inverted parameters in hash iterator callbacks
Daniel P. Berrangé [Thu, 17 Mar 2022 12:14:13 +0000 (12:14 +0000)]
conf: fix inverted parameters in hash iterator callbacks

virHashTableForEach unhelpfully has payload/key args in
its callback reversed compared to g_hash_table_foreach.
When converting from one to the other the semantics
change but you don't get a compile error

Reviewed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agoesx_stream: Fix NULL dereferences
Tim Wiederhake [Thu, 17 Mar 2022 10:30:16 +0000 (11:30 +0100)]
esx_stream: Fix NULL dereferences

A wrong reordering caused "priv" to be derefenced before the NULL-check
in esxStreamSend and esxStreamRecvFlags.

Fixes: 12e19f172d2a908eec2a4557202ff764cdbb951e
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agogitlab-ci: Introduce new 'integration_tests' pipeline stage
Erik Skultety [Tue, 5 Oct 2021 09:02:24 +0000 (11:02 +0200)]
gitlab-ci: Introduce new 'integration_tests' pipeline stage

This stage will download build artifacts from both the libvirt and
libvirt-perl (multi-project CI) builds, install all them on the custom
runners and configures libvirt debug logging on the runners prior to
executing the actual test suite. In case of a failure, libvirt and
Avocado logs will be saved and published as pipeline artifacts.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoci: manifest: Publish RPMs as artifacts on CentOS Stream and Fedoras
Erik Skultety [Tue, 5 Oct 2021 09:01:34 +0000 (11:01 +0200)]
ci: manifest: Publish RPMs as artifacts on CentOS Stream and Fedoras

We're already building libvirt in the containers already, if we publish
the build in form of, say, RPMs, later stages of the pipeline can
consume the RPMs instead of re-building libvirt from scratch.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoci: gitlab: Refresh gitlab.yml
Erik Skultety [Thu, 3 Mar 2022 12:53:40 +0000 (13:53 +0100)]
ci: gitlab: Refresh gitlab.yml

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agomeson: Check for os-release's ID_LIKE in addition to ID
Andrea Bolognani [Wed, 26 Jan 2022 14:09:52 +0000 (15:09 +0100)]
meson: Check for os-release's ID_LIKE in addition to ID

This makes it possible to reduce the number of cases we have to
consider, because 'sles' declares itself to be like 'suse' and
both 'rhel' and 'centos' declare themselves to be like 'fedora'.

We have to move the check for Ubuntu before the one for Debian,
however, because 'ubuntu' declares itself to be like 'debian'
and it would end up with the wrong defaults otherwise.

Suggested-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agospec: Move virkey* manual pages from -daemon to -client
Andrea Bolognani [Thu, 27 Jan 2022 14:20:31 +0000 (15:20 +0100)]
spec: Move virkey* manual pages from -daemon to -client

The documentation included in these manual pages is mostly useful
to users of the 'send-key' virsh command, and the virsh manual
page refers to them, so it makes more sense to install them along
with virsh instead of libvirtd.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
3 years agoDrop YouCompleteMe and color_coded integration
Andrea Bolognani [Mon, 7 Mar 2022 09:41:56 +0000 (10:41 +0100)]
Drop YouCompleteMe and color_coded integration

I introduced support for these vim plugins several years ago
but have since moved away from them. These days developers
are likely better served by lsp-based tooling, which doesn't
require additional per-project configuration.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoAdd .gitattributes file
Andrea Bolognani [Mon, 7 Mar 2022 08:20:35 +0000 (09:20 +0100)]
Add .gitattributes file

The files marked as export-ignore here are not going to be
included in the tarball produced by 'meson dist' when using
meson >= 0.60.

Older versions of meson excluded a small subset of these files
automatically, but since we have more control now we can be
more aggressive and leave out anything that doesn't make sense
in a release tarball.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoconf: use a hash table for storing nwfilter object list
Daniel P. Berrangé [Tue, 8 Mar 2022 17:01:36 +0000 (17:01 +0000)]
conf: use a hash table for storing nwfilter object list

The current use of an array for nwfilter objects requires
the caller to iterate over all elements to find a filter,
and also requires locking each filter.

Switching to a pair of hash tables enables O(1) lookups
both by name and uuid, with no locking required.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agonwfilter: update comment about locking filter updates
Daniel P. Berrangé [Wed, 9 Mar 2022 17:25:36 +0000 (17:25 +0000)]
nwfilter: update comment about locking filter updates

The comment against the 'updateMutex' refers to a problem with
lock ordering when looking up filters in the virNWFilterObjList
which uses an array. That problem does indeed exist.

Unfortunately it claims that switching to a hash table would
solve the lock ordering problems during instantiation. That
is not correct because there is a second lock ordering
problem related to how we traverse related filters when
instantiating filters. Consider a set of filters:

  Filter A:
     Reference Filter C
     Reference Filter D

  Filter B:
     Reference Filter D
     Reference Filter C

In one example, we lock A, C, D, in the other example
we lock A, D, C.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agonwfilter: fix crash when counting number of network filters
Daniel P. Berrangé [Tue, 8 Mar 2022 17:28:38 +0000 (17:28 +0000)]
nwfilter: fix crash when counting number of network filters

The virNWFilterObjListNumOfNWFilters method iterates over the
driver->nwfilters, accessing virNWFilterObj instances. As such
it needs to be protected against concurrent modification of
the driver->nwfilters object.

This API allows unprivileged users to connect, so users with
read-only access to libvirt can cause a denial of service
crash if they are able to race with a call of virNWFilterUndefine.
Since network filters are usually statically defined, this is
considered a low severity problem.

This is assigned CVE-2022-0897.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agoAdd Alpine builds to CI
Martin Kletzander [Tue, 15 Mar 2022 09:26:46 +0000 (10:26 +0100)]
Add Alpine builds to CI

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
3 years agonodedev: trigger mdev device definition update on udev add and remove
Boris Fiuczynski [Thu, 17 Mar 2022 09:48:30 +0000 (10:48 +0100)]
nodedev: trigger mdev device definition update on udev add and remove

When nodedev objects are added and removed if possible check if mdev-types is
supported by the object and trigger a mdev device definition update to correct
the associated parent nodedevs.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
3 years agonodedev: update mdevs on parent change
Boris Fiuczynski [Thu, 17 Mar 2022 09:48:29 +0000 (10:48 +0100)]
nodedev: update mdevs on parent change

The parent of the mdev definition can change due to the existance of the
parent device. The parents existance can e.g. depend on the device
driver load state.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
3 years agovirnodedeviceobj: export virNodeDeviceObjHasCap
Boris Fiuczynski [Thu, 17 Mar 2022 09:48:28 +0000 (10:48 +0100)]
virnodedeviceobj: export virNodeDeviceObjHasCap

The function will be reused in the nodedev drivers udev handling.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
3 years agonodedev: fix typo in mdevctl update warning
Boris Fiuczynski [Thu, 17 Mar 2022 09:48:27 +0000 (10:48 +0100)]
nodedev: fix typo in mdevctl update warning

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agovirnetdev: Use VIR_WITH_MUTEX_LOCK_GUARD in virNetDevGenerateName()
Michal Privoznik [Thu, 17 Mar 2022 08:19:39 +0000 (09:19 +0100)]
virnetdev: Use VIR_WITH_MUTEX_LOCK_GUARD in virNetDevGenerateName()

The virNetDevGenerateName() function uses a global array of
virNetDevGenName structs to find next unused name for network
device. This obviously needs some locking and in fact each member
of the array has its own lock. However, these members are not
virObjects, they are just plain structs, therefore
VIR_WITH_MUTEX_LOCK_GUARD() must be used instead of
VIR_WITH_OBJECT_LOCK_GUARD() to lock individual mutexes.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
3 years agoqemu: domainjob: Allow InitJob if cb is not set in qemuDomainObjInitJob()
Kristina Hanicova [Wed, 16 Mar 2022 14:08:39 +0000 (15:08 +0100)]
qemu: domainjob: Allow InitJob if cb is not set in qemuDomainObjInitJob()

This allows init job even if cb structure is not set. This patch
also includes slight rewriting of the function to make it look
cleaner when freeing resources, by allocating privateData at the
end.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu: domainjob: Allow operations if cb is not set in job structure
Kristina Hanicova [Wed, 16 Mar 2022 14:08:38 +0000 (15:08 +0100)]
qemu: domainjob: Allow operations if cb is not set in job structure

We should allow resetting / freeing / restoring / parsing /
formatting qemuDomainJobObj even if 'cb' attribute is not set.
This is theoretical for now, but the attribute must not be always
set in the future. It is sufficient to check if 'cb' exists
before dereferencing it.

This commit partially reverts af16e754cd4efc3ca1.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu_cgroup: Don't deny devices from cgroupDeviceACL
Michal Privoznik [Tue, 15 Mar 2022 11:45:54 +0000 (12:45 +0100)]
qemu_cgroup: Don't deny devices from cgroupDeviceACL

On domain startup a couple of devices are allowed in the devices
controller no matter the domain configuration. The aim is to
allow devices crucial for QEMU or one of its libraries, or user
is passing through a device (e.g. through additional cmd line
arguments) and wants QEMU to access it.

However, during unplug it may happen that a device is configured
to use one of such devices and since we deny /dev nodes on
hotplug we would deny such device too. For example,
/dev/urandom belongs onto the list of implicit devices and users
can hotplug and hotunplug an RNG device with /dev/urandom as
backend.

The fix is fortunately simple - just consult the list of implicit
devices before removing the device from the namespace.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
3 years agoqemu_cgroup: Introduce and use qemuCgroupDenyDevicePath()
Michal Privoznik [Tue, 15 Mar 2022 11:41:45 +0000 (12:41 +0100)]
qemu_cgroup: Introduce and use qemuCgroupDenyDevicePath()

In all cases virCgroupDenyDevicePath() is followed by
virDomainAuditCgroupPath(). Might as well pack that into one
function and call it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
3 years agoqemu_cgroup: Introduce and use qemuCgroupAllowDevicePath()
Michal Privoznik [Tue, 15 Mar 2022 15:08:24 +0000 (16:08 +0100)]
qemu_cgroup: Introduce and use qemuCgroupAllowDevicePath()

In all cases virCgroupAllowDevicePath() is followed by
virDomainAuditCgroupPath(). Might as well pack that into one
function and call it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
3 years agoqemu_cgroup: Drop ENOENT special case for RNG devices
Michal Privoznik [Tue, 15 Mar 2022 11:37:44 +0000 (12:37 +0100)]
qemu_cgroup: Drop ENOENT special case for RNG devices

When allowing or denying RNG device in CGroups there's a special
check if the backend device exists (errno == ENOENT) in which
case success is returned to caller. This is in contrast with the
rest of the functions and in fact wrong too - if the backend
device doesn't exist then QEMU will fail opening it. Might as
well signal error here.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
3 years agostorage: Use automatic mutex management
Tim Wiederhake [Fri, 4 Mar 2022 13:04:52 +0000 (14:04 +0100)]
storage: Use automatic mutex management

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agostorage: Removing mutex locking in initialization and cleanup
Tim Wiederhake [Fri, 4 Mar 2022 12:58:44 +0000 (13:58 +0100)]
storage: Removing mutex locking in initialization and cleanup

These functions are only ever called in a single threaded
environment and the mutex would not have prevented concurrent
access anyway.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoesx_vi: Use automatic mutex management
Tim Wiederhake [Wed, 16 Feb 2022 16:07:30 +0000 (17:07 +0100)]
esx_vi: Use automatic mutex management

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoesx_stream: Use automatic mutex management
Tim Wiederhake [Wed, 16 Feb 2022 15:54:13 +0000 (16:54 +0100)]
esx_stream: Use automatic mutex management

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoadmin: Use automatic mutex management
Tim Wiederhake [Wed, 16 Feb 2022 15:34:47 +0000 (16:34 +0100)]
admin: Use automatic mutex management

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agonodesuspend: Use automatic mutex management
Tim Wiederhake [Wed, 16 Feb 2022 15:20:55 +0000 (16:20 +0100)]
nodesuspend: Use automatic mutex management

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agonetdev: Use automatic mutex management
Tim Wiederhake [Wed, 16 Feb 2022 15:15:02 +0000 (16:15 +0100)]
netdev: Use automatic mutex management

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoremote_daemon_dispatch: Use automatic mutex management
Tim Wiederhake [Fri, 11 Feb 2022 13:05:24 +0000 (14:05 +0100)]
remote_daemon_dispatch: Use automatic mutex management

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoopenvz: Use automatic mutex management
Tim Wiederhake [Fri, 11 Feb 2022 12:54:11 +0000 (13:54 +0100)]
openvz: Use automatic mutex management

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agotest: Use automatic mutex management
Tim Wiederhake [Tue, 8 Feb 2022 14:05:35 +0000 (15:05 +0100)]
test: Use automatic mutex management

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu_namespace: Be less aggressive in removing /dev nodes from namespace
Michal Privoznik [Mon, 14 Mar 2022 12:35:15 +0000 (13:35 +0100)]
qemu_namespace: Be less aggressive in removing /dev nodes from namespace

When creating /dev nodes in a QEMU domain's namespace the first
thing we simply do is unlink() the path and create it again. This
aims to solve the case when a file changed type/major/minor in
the host and thus we need to reflect this in the guest's
namespace. Fair enough, except we can be a bit more clever about
it: firstly check whether the path doesn't already exist or isn't
already of the correct type/major/minor and do the
unlink+creation only if needed.

Currently, this is implemented only for symlinks and
block/character devices. For regular files/directories (which are
less common) this might be implemented one day, but not today.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu_namespace: Don't unlink paths from cgroupDeviceACL
Michal Privoznik [Mon, 14 Mar 2022 14:05:11 +0000 (15:05 +0100)]
qemu_namespace: Don't unlink paths from cgroupDeviceACL

When building namespace for a domain there are couple of devices
that are created independent of domain config (see
qemuDomainPopulateDevices()). The idea behind is that these
devices are crucial for QEMU or one of its libraries, or user is
passing through a device and wants us to create it in the
namespace too.  That's the reason that these devices are allowed
in the devices CGroup controller as well.

However, during unplug it may happen that a device is configured
to use one of such devices and since we remove /dev nodes on
hotplug we would remove such device too. For example,
/dev/urandom belongs onto the list of implicit devices and users
can hotplug and hotunplug an RNG device with /dev/urandom as
backend.

The fix is fortunately simple - just consult the list of implicit
devices before removing the device from the namespace.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirsh: Don't open code virshEnumComplete()
Michal Privoznik [Sat, 12 Mar 2022 04:41:56 +0000 (05:41 +0100)]
virsh: Don't open code virshEnumComplete()

Now that we have a function that generates string list for given
enum, let's use that instead of open coding it.

Note, after this there are still some 'candidates' left (e.g,
virshNetworkEventNameCompleter(), or
virshNetworkUpdateCommandCompleter()). These are not converted
because either they don't have a convenient int2str function or
they don't start from the very beginning of the enum.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
3 years agovirsh: Introduce virshEnumComplete()
Michal Privoznik [Sat, 12 Mar 2022 04:37:50 +0000 (05:37 +0100)]
virsh: Introduce virshEnumComplete()

We have plenty of completers which iterate over all values of
given enum and do nothing more than translate every member into
string (using corresponding virXXXTypeToString()).

Introduce a convenience function so that callers can pass just
VIR_XXX_LAST and virXXXTypeToString and the rest is taken care
of.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
3 years agovirsh: Properly terminate string list in virshDomainInterfaceSourceModeCompleter()
Michal Privoznik [Fri, 11 Mar 2022 08:13:56 +0000 (09:13 +0100)]
virsh: Properly terminate string list in virshDomainInterfaceSourceModeCompleter()

A completer must return a NULL terminated list of strings, which
means that when dealing with enums, it has to allocate one
pointer more than the value of VIR_XXX_LAST. But this is not
honoured in virshDomainInterfaceSourceModeCompleter() leading to
out of bounds read.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
3 years agoqemuBlockJobDiskNew: Remove misleading return value description
Peter Krempa [Thu, 10 Mar 2022 12:10:51 +0000 (13:10 +0100)]
qemuBlockJobDiskNew: Remove misleading return value description

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuMigrationSrcNBDStorageCopyOne: Refactor cleanup
Peter Krempa [Thu, 10 Mar 2022 12:09:58 +0000 (13:09 +0100)]
qemuMigrationSrcNBDStorageCopyOne: Refactor cleanup

Autofree the temporary string and shuffle around the success path to
avoid the 'cleanup' label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoNEWS: Mention that VIR_MIGRATE_PARAM_TLS_DESTINATION works now for non-shared storage...
Peter Krempa [Thu, 10 Mar 2022 12:06:21 +0000 (13:06 +0100)]
NEWS: Mention that VIR_MIGRATE_PARAM_TLS_DESTINATION works now for non-shared storage migration

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: migration: Use 'VIR_MIGRATE_PARAM_TLS_DESTINATION' for the NBD connection
Peter Krempa [Thu, 10 Mar 2022 11:59:30 +0000 (12:59 +0100)]
qemu: migration: Use 'VIR_MIGRATE_PARAM_TLS_DESTINATION' for the NBD connection

The NBD connection for non-shared storage migration can have the same
issue regarding TLS certificate name match as the migration connection
itself.

Propagate the configured name also for the NBD connections.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1901394
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoconf: Add support for setting expected TLS hostname for NBD disks
Peter Krempa [Thu, 10 Mar 2022 09:05:53 +0000 (10:05 +0100)]
conf: Add support for setting expected TLS hostname for NBD disks

In cases when the hostname of the NBD server doesn't match the hostname
in the TLS certificate the new attribute 'tlsHostname' can be used to
override it.

Add the XML infrastructure and tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: Add support for 'tlsHostname' setting of virStorageSource
Peter Krempa [Thu, 10 Mar 2022 08:57:09 +0000 (09:57 +0100)]
qemu: Add support for 'tlsHostname' setting of virStorageSource

Add validation and formatting of the blockdev props.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agostorage_source: Add 'tlsHostname' field to virStorageSource
Peter Krempa [Thu, 10 Mar 2022 08:51:49 +0000 (09:51 +0100)]
storage_source: Add 'tlsHostname' field to virStorageSource

The value will be used to override the hostname used for validation of
TLS certificates.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuMigrationSrcRun: Fix misleading comment about NBD with TLS support
Peter Krempa [Thu, 10 Mar 2022 08:34:16 +0000 (09:34 +0100)]
qemuMigrationSrcRun: Fix misleading comment about NBD with TLS support

We do support non-shared storage migration with TLS now. Fix the comment
claiming otherwise.

Fixes: a8dc146a4d14b6f169f27b6d238452beb254a637
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: capabilities: Introduce QEMU_CAPS_BLOCKDEV_NBD_TLS_HOSTNAME
Peter Krempa [Thu, 10 Mar 2022 08:24:46 +0000 (09:24 +0100)]
qemu: capabilities: Introduce QEMU_CAPS_BLOCKDEV_NBD_TLS_HOSTNAME

Detect that qemu can override TLS hostname setting for NBD clients.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agotests: qemucapabilities: Update caps_7.0.0.x86_64
Peter Krempa [Tue, 22 Feb 2022 13:42:39 +0000 (14:42 +0100)]
tests: qemucapabilities: Update caps_7.0.0.x86_64

Update to commit v6.2.0-2296-g9f0369efb0

Notable changes:
  - 'tls-hostname' field for NBD client to override local hostname
  - machine types 'pc-i440fx-1.7' and older are now deprecated
  - 'snapshot-access' block driver added
  - The 'protocol' field of 'set_password' and 'expire_password'
    parameter is now an enum instead of a pure string allowing 'vnc' and
    'spice' as value and the arguments are also covered by the schema.
  - 'copy-before-write' block driver now has a 'bitmap' property
  - 'query-migrate' now reports 'precopy-bytes', 'downtime-bytes',
    'postcopy-bytes' for 'ram' and 'disk' statistics
  - RTC_CHANGE event now has a 'qom-path' property to identify the RTC
  - 'umip' cpu feature is now migratable
  - SGX property 'section-size' reinstated after regression

Changes in build setting:
  - fuse block export support now enabled

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agodocs: downloads: fix link to libvirt GitLab group
Ján Tomko [Fri, 11 Mar 2022 13:29:31 +0000 (14:29 +0100)]
docs: downloads: fix link to libvirt GitLab group

s/libvirt.org/libvirt/

Signed-off-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuSnapshotCreateActiveExternal: Remove duplicit assignment
Peter Krempa [Fri, 4 Mar 2022 13:37:13 +0000 (14:37 +0100)]
qemuSnapshotCreateActiveExternal: Remove duplicit assignment

The block of code pausing the VM assigns 'resume' to true but it's
already true because of the previous condition.

The code is deliberately kept in two blocks as upcoming changes will
modify both conditions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>