]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
5 years agovirStorageSourceUpdateCapacity: Drop 'probe' argument
Peter Krempa [Fri, 21 Feb 2020 11:21:56 +0000 (12:21 +0100)]
virStorageSourceUpdateCapacity: Drop 'probe' argument

Both callers pass false. Since we frown upon format probing, remove the
unused possibility to do the probing.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: virstorage: Fix backing file format of created image
Peter Krempa [Fri, 21 Feb 2020 11:06:49 +0000 (12:06 +0100)]
tests: virstorage: Fix backing file format of created image

We create some images for testing our code. We've recorded wrong format
of the backing file for one of the images though.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoapparmor: allow to call vhost-user-gpu
Christian Ehrhardt [Thu, 13 Feb 2020 11:29:00 +0000 (12:29 +0100)]
apparmor: allow to call vhost-user-gpu

Configuring vhost-user-gpu like:
    <video>
      <driver name='vhostuser'/>
      <model type='virtio' heads='1'/>
    </video>
Triggers an apparmor denial like:
    apparmor="DENIED" operation="exec" profile="libvirtd"
    name="/usr/lib/qemu/vhost-user-gpu" pid=888257 comm="libvirtd"
    requested_mask="x" denied_mask="x" fsuid=0 ouid=0

This helper is provided by qemu for vhost-user-gpu and thereby being
in the same path as qemu_bridge_helper. Due to that adding a rule allowing
to call uses the same path list.

Reviewed-by: Jim Fehlig <jfehlig@suse.com>
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
5 years agodocs: add a kbase explaining security protections for QEMU passthrough
Daniel P. Berrangé [Thu, 6 Feb 2020 12:46:10 +0000 (12:46 +0000)]
docs: add a kbase explaining security protections for QEMU passthrough

When using command line passthrough users will often trip up over the
security protections like SELinux, DAC, namespaces, etc which will
deny access to files they are passing. This document explains the
various protections and how to deal with their policy, and/or how
to disable them.

Reviewed-by: Kashyap Chamarthy <kchamart@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: use correct backendType when checking memfd capability
Ján Tomko [Mon, 24 Feb 2020 12:32:30 +0000 (13:32 +0100)]
qemu: use correct backendType when checking memfd capability

The backend name is memory-backend-memfd but we've been checking
for memory-backend-memory.

Reported by GCC on rawhide:
../../../src/internal.h:75:22: error: 'strcmp' of a string of length 21 and
an array of size 21 evaluates to nonzero [-Werror=string-compare]
../../../src/qemu/qemu_command.c:3525:20: note: in expansion of macro 'STREQ'
 3525 |         } else if (STREQ(backendType, "memory-backend-memory") &&
      |                    ^~~~~

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: 24b74d187cab48a9dc9f409ea78900154c709579
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotravis: Use dedicated images for MinGW builds
Andrea Bolognani [Mon, 10 Feb 2020 17:07:57 +0000 (18:07 +0100)]
travis: Use dedicated images for MinGW builds

Now that we treat MinGW like any other cross-build target, we
should update our Travis CI configuration.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
5 years agoci: Make container environment available to scripts
Andrea Bolognani [Mon, 10 Feb 2020 17:02:55 +0000 (18:02 +0100)]
ci: Make container environment available to scripts

For container images targeted at cross-building, we bake a small
amount of architecture-specific information in the environment so
that builds can work as expected without requiring additional work
from the user; unfortunately this information got lost as soon as
we called sudo. Explicitly allow it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
5 years agodocs: add news item about gnulib removal
Daniel P. Berrangé [Fri, 7 Feb 2020 16:20:13 +0000 (16:20 +0000)]
docs: add news item about gnulib removal

While we have CI testing coverage for many platforms, we don't test any
non-glibc based Linux and there are other non-Linux platforms we don't
officially target, both of which might hit regressions.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agodocs: reduce excessive spacing in ToC for RST files
Daniel P. Berrangé [Thu, 6 Feb 2020 16:24:52 +0000 (16:24 +0000)]
docs: reduce excessive spacing in ToC for RST files

The table of contents in the RST based files uses <p> tags inside the
<li>, which results in 1em's worth of spacing above & below each
entry. This results in way too much whitespace in the ToC.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovz: Fix return value in error path
Rikard Falkeborn [Sat, 22 Feb 2020 23:22:47 +0000 (00:22 +0100)]
vz: Fix return value in error path

If PrlVmDev_GetType(), PrlVmDev_GetIndex() or PrlVmCfg_GetBootDevCount()
fails, return false to indicate error. Returning -1 would be interpreted
as true when used in an if-statement.

Fixes: 8c9252aa6d95247537da0939b54fdd2f31695e32
Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoesx: Same order of arguments in definition and declaration
Rikard Falkeborn [Sat, 22 Feb 2020 23:22:25 +0000 (00:22 +0100)]
esx: Same order of arguments in definition and declaration

The order of arguments were not the same in the definition and
declaration. All callers use the same order as the definition, so there
is no bug, but change the function declaration to match the
implementation to avoid confusion.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: vireventglibwatch: watch for G_IO_HUP and G_IO_ERR
Ján Tomko [Wed, 19 Feb 2020 00:00:49 +0000 (01:00 +0100)]
util: vireventglibwatch: watch for G_IO_HUP and G_IO_ERR

To more closely match the previous usage in virEventPollDispatchHandles,
where called the handle callback for any revents returned by poll.

This should fix the virtlogd error on subsequent domain startup:
  error: can't connect to virtlogd: Cannot open log file:
  '/var/log/libvirt/qemu/f28live.log': Device or resource busy
as well as virtlogd spinning caused by virLogHandlerDomainLogFileEvent
never being called on hangup.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: f8ab47cb4491dd72d866c1a96a9d94b8c3341de9
Fixes: 946a25274c46ffff46323c62f567ae7e753aa921
Tested-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agobhyve: driver: factor out conn
Ryan Moeller [Sat, 22 Feb 2020 06:38:45 +0000 (01:38 -0500)]
bhyve: driver: factor out conn

Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agobhyve: monitor: eliminate rc variable
Ryan Moeller [Sat, 22 Feb 2020 06:38:44 +0000 (01:38 -0500)]
bhyve: monitor: eliminate rc variable

Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agobhyve: fix indentation
Ryan Moeller [Sat, 22 Feb 2020 06:38:43 +0000 (01:38 -0500)]
bhyve: fix indentation

Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agobhyve: remove redundant parameter to virBhyveProcessStart()
Ryan Moeller [Sat, 22 Feb 2020 06:38:42 +0000 (01:38 -0500)]
bhyve: remove redundant parameter to virBhyveProcessStart()

Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agobhyve: simplify driver caps helpers
Ryan Moeller [Sat, 22 Feb 2020 06:38:41 +0000 (01:38 -0500)]
bhyve: simplify driver caps helpers

Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agobhyve: command: remove unused includes
Ján Tomko [Sun, 23 Feb 2020 13:33:30 +0000 (14:33 +0100)]
bhyve: command: remove unused includes

These were needed for virBhyveTapGetRealDeviceName
but were not deleted after the function was moved
to src/util.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: a1bd8d2546c3e469f6a5ce119fad7da1cd473db5
5 years agosyms: fix comment for domain_driver.h
Ján Tomko [Sun, 23 Feb 2020 13:32:32 +0000 (14:32 +0100)]
syms: fix comment for domain_driver.h

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: 8595948bc855bc5fb65c8362a5e5832a30f97f7e
5 years agovircgroup: add virCgroupGetCpuPeriodQuota()
Daniel Henrique Barboza [Mon, 17 Feb 2020 21:29:21 +0000 (16:29 -0500)]
vircgroup: add virCgroupGetCpuPeriodQuota()

Another vircgroup helper to avoid code repetition between
the LXC and QEMU driver.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agodomain_cgroup.c: add virDomainCgroupSetMemoryLimitParameters()
Daniel Henrique Barboza [Mon, 17 Feb 2020 21:29:20 +0000 (16:29 -0500)]
domain_cgroup.c: add virDomainCgroupSetMemoryLimitParameters()

lxcDomainSetMemoryParameters() and qemuDomainSetMemoryParameters()
has duplicated chunks of code that can be put in a new
helper.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agodomain_driver.c: add virDomainDriverSetupPersistentDefBlkioParams()
Daniel Henrique Barboza [Mon, 17 Feb 2020 21:29:19 +0000 (16:29 -0500)]
domain_driver.c: add virDomainDriverSetupPersistentDefBlkioParams()

This new helper avoids more code repetition inside
lxcDomainSetBlkioParameters() and qemuDomainSetBlkioParameters().

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agodomain_cgroup.c: add virDomainCgroupSetupDomainBlkioParameters()
Daniel Henrique Barboza [Mon, 17 Feb 2020 21:29:18 +0000 (16:29 -0500)]
domain_cgroup.c: add virDomainCgroupSetupDomainBlkioParameters()

After the introduction of virDomainDriverMergeBlkioDevice() in a
previous patch, it is now clear that lxcDomainSetBlkioParameters() and
qemuDomainSetBlkioParameters() uses the same loop to set cgroup
blkio parameter of a domain.

Avoid the repetition by adding a new helper called
virDomainCgroupSetupDomainBlkioParameters().

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agodomain_driver.c: add virDomainDriverParseBlkioDeviceStr()
Daniel Henrique Barboza [Mon, 17 Feb 2020 21:29:17 +0000 (16:29 -0500)]
domain_driver.c: add virDomainDriverParseBlkioDeviceStr()

lxcDomainParseBlkioDeviceStr() and qemuDomainParseBlkioDeviceStr()
are the same function. Avoid code repetition by putting the code
in a new helper.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agosrc/hypervisor: introduce domain_driver.c
Daniel Henrique Barboza [Mon, 17 Feb 2020 21:29:16 +0000 (16:29 -0500)]
src/hypervisor: introduce domain_driver.c

lxcDomainMergeBlkioDevice() and qemuDomainMergeBlkioDevice()
are the same functions. This duplicated code can't be put in
the existing domain_cgroup.c since it's not cgroup related.

This patch introduces a new src/hypervisor/domain_driver.c to
host this more generic code that can be shared between virt
drivers. This new file is then used to create a new helper
called virDomainDeivceMergeBlkioDevice() to eliminate the code
repetition mentioned above. Callers in LXC and QEMU files
were updated.

This change is a preliminary step for more code reduction of
cgroup related code inside lxcDomainSetBlkioParameters() and
qemuDomainSetBlkioParameters().

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovircgroup.c: add virCgroupSetupCpuPeriodQuota()
Daniel Henrique Barboza [Mon, 17 Feb 2020 21:29:15 +0000 (16:29 -0500)]
vircgroup.c: add virCgroupSetupCpuPeriodQuota()

qemuSetupCgroupVcpuBW() and lxcSetVcpuBWLive() shares the
same code to set CPU CFS period and quota. This code can be
moved to a new virCgroupSetupCpuPeriodQuota() helper to
avoid code repetition.

A similar code is also executed in virLXCCgroupSetupCpuTune(),
but without the rollback on error. Use the new helper in this
function as well since the 'period' rollback, if not a
straight improvement for virLXCCgroupSetupCpuTune(), is
benign. And we end up cutting more code repetition.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovircgroup.c: add virCgroupSetupCpuShares()
Daniel Henrique Barboza [Mon, 17 Feb 2020 21:29:14 +0000 (16:29 -0500)]
vircgroup.c: add virCgroupSetupCpuShares()

The code that calls virCgroupSetCpuShares() and virCgroupGetCpuShares()
is repeated in 4 different places. Let's put it in a new
virCgroupSetupCpuShares() to avoid code repetition.

There's a reason of why we execute a Get in the same value we
just executed Set, explained in detail by commit 97814d8ab3.
Let's add a gist of the reasoning behind it as a comment in
this new function as well.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovircgroup.c: add virCgroupSetupCpusetCpus()
Daniel Henrique Barboza [Mon, 17 Feb 2020 21:29:13 +0000 (16:29 -0500)]
vircgroup.c: add virCgroupSetupCpusetCpus()

The code from qemuSetupCgroupCpusetCpus() and virLXCCgroupSetupCpusetTune()
can be centralized in a new helper called virCgroupSetupCpusetCpus().

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agodomain_cgroup.c: add virDomainCgroupSetupMemtune()
Daniel Henrique Barboza [Mon, 17 Feb 2020 21:29:12 +0000 (16:29 -0500)]
domain_cgroup.c: add virDomainCgroupSetupMemtune()

virLXCCgroupSetupMemTune() and qemuSetupMemoryCgroup() shares
duplicated code that can be put in a new helper to avoid
code repetition.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agosrc: introduce hypervisor/domain_cgroup.c
Daniel Henrique Barboza [Mon, 17 Feb 2020 21:29:11 +0000 (16:29 -0500)]
src: introduce hypervisor/domain_cgroup.c

There is duplicated code between virt drivers that needs to
be moved to avoid code repetition. In the case of duplicated
code between lxc_cgroup.c and qemu_cgroup.c a common place
would be utils/vircgroup.c. The problem is that this would
introduce /conf related definitions that shouldn't be imported
to vircgroup.c, which is supposed to be a place for utilitary
cgroups functions only. And syntax-check would forbid it anyway
due to cross-directory includes being used.

An alternative would be to overload domain_conf.c, which already
contains all the definitions required. But that file is already
crowded with XML handling code and we wouldn't do any favors to
it by putting more utilitary, non-XML parsing/formatting code
there.

In [1], Cole suggested a 'domain_cgroup' file to host common code
between lxc_cgroup and qemu_cgroup, and Daniel suggested a
'src/hypervisor' dir to host these type of files. This patch
introduces src/hypervisor/domain_cgroup.c and, to get started,
introduces a new virDomainCgroupSetupBlkio() function to host shared
code between virLXCCgroupSetupBlkioTune() and qemuSetupBlkioCgroup().

[1] https://www.redhat.com/archives/libvir-list/2019-December/msg00817.html

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovircgroup.c: turn virCgroup{Get/Set}BlkioDevice* into static
Daniel Henrique Barboza [Mon, 17 Feb 2020 21:29:10 +0000 (16:29 -0500)]
vircgroup.c: turn virCgroup{Get/Set}BlkioDevice* into static

Previous patch moved all duplicated code that were setting
and getting BlkioDevice parameters to vircgroup.c. We can
turn them into static and spare a few symbols in
libvirt_private.syms.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agolxc,qemu: use virCgroupSetupBlkioDevice* helpers
Daniel Henrique Barboza [Mon, 17 Feb 2020 21:29:09 +0000 (16:29 -0500)]
lxc,qemu: use virCgroupSetupBlkioDevice* helpers

There are code repetition of set() and get() blkio device
parameters across lxc and qemu files. Use the new vircgroup
helpers to trim the repetition a bit.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovircgroup.c: add virCgroupSetupBlkioDevice* helpers
Daniel Henrique Barboza [Mon, 17 Feb 2020 21:29:08 +0000 (16:29 -0500)]
vircgroup.c: add virCgroupSetupBlkioDevice* helpers

The current use of the functions that set and get
BlkioDevice attributes is doing a set(), followed by
a get() of the same parameter right after. This is done
because there is no guarantee that the kernel will accept
the desired value given by the set() call, thus we need to
execute a get() right after to get the actual value.

This patch adds helpers inside vircgroup.c to execute these
operations. Next patch will use these helpers to reduce
code repetition in LXC and QEMU files.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agofix paths to openrc.init.in files
Ján Tomko [Sun, 23 Feb 2020 11:21:02 +0000 (12:21 +0100)]
fix paths to openrc.init.in files

The inc.am Makfiles are included by src/Makefile.am.
Adjust the paths added to OPENRC_INIT_FILES_IN
accordingly.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: f4b1c020a2c8493473bf868231cee6a952d57e6f
5 years agoAdd virtlockd and virtlogd init scripts
Ryan Moeller [Sat, 22 Feb 2020 05:01:39 +0000 (00:01 -0500)]
Add virtlockd and virtlogd init scripts

These are missing files for OpenRC.

Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agodocs: Expand documentation for the tickpolicy timer attribute
Andrea Bolognani [Tue, 18 Feb 2020 20:43:08 +0000 (21:43 +0100)]
docs: Expand documentation for the tickpolicy timer attribute

The current documentation is fairly terse and not easy to decode
for someone who's not intimately familiar with the inner workings
of timer devices. Expand on it by providing a somewhat verbose
description of what behavior each policy will result in, as seen
from both the guest OS and host point of view.

This is lifted directly from QEMU commit

  commit 2a7d957596786404c4ed16b089273de95a9580ad
  Author: Andrea Bolognani <abologna@redhat.com>
  Date:   Tue Feb 11 19:37:44 2020 +0100

    qapi: Expand documentation for LostTickPolicy

  v4.2.0-1442-g2a7d957596

The original text also matched word for word the documentation
found in QEMU.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemuTestParseCapabilitiesArch: Free @binary
Michal Privoznik [Fri, 21 Feb 2020 07:28:13 +0000 (08:28 +0100)]
qemuTestParseCapabilitiesArch: Free @binary

The variable is allocated, but never freed.

==119642== 29 bytes in 1 blocks are definitely lost in loss record 409 of 671
==119642==    at 0x483579F: malloc (vg_replace_malloc.c:309)
==119642==    by 0x5AB075F: __vasprintf_internal (in /lib64/libc-2.29.so)
==119642==    by 0x57C1A28: g_vasprintf (in /usr/lib64/libglib-2.0.so.0.6000.7)
==119642==    by 0x579A0CC: g_strdup_vprintf (in /usr/lib64/libglib-2.0.so.0.6000.7)
==119642==    by 0x4AE6D58: vir_g_strdup_printf (glibcompat.c:197)
==119642==    by 0x136EEE: qemuTestParseCapabilitiesArch (testutilsqemu.c:291)
==119642==    by 0x138506: testQemuInfoSetArgs (testutilsqemu.c:763)
==119642==    by 0x135FFF: mymain (qemuxml2argvtest.c:3093)
==119642==    by 0x13A60E: virTestMain (testutils.c:839)
==119642==    by 0x1368C2: main (qemuxml2argvtest.c:3121)

Fixes: 42b3e5b9e4b919644afe55a815992c07fb79b9dc
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirDomainNetDefClear: Free @persistent name
Michal Privoznik [Fri, 21 Feb 2020 07:28:04 +0000 (08:28 +0100)]
virDomainNetDefClear: Free @persistent name

The persistent alias name @persistent is allocated in
virDomainNetDefParseXML() but never freed.

==119642== 22 bytes in 2 blocks are definitely lost in loss record 178 of 671
==119642==    at 0x483579F: malloc (vg_replace_malloc.c:309)
==119642==    by 0x58F89F1: xmlStrndup (in /usr/lib64/libxml2.so.2.9.9)
==119642==    by 0x4BA3B74: virXMLPropString (virxml.c:520)
==119642==    by 0x4BDB0C5: virDomainNetDefParseXML (domain_conf.c:11876)
==119642==    by 0x4BF9EF4: virDomainDefParseXML (domain_conf.c:21196)
==119642==    by 0x4BFCD5B: virDomainDefParseNode (domain_conf.c:21943)
==119642==    by 0x4BFCC36: virDomainDefParse (domain_conf.c:21901)
==119642==    by 0x4BFCCCB: virDomainDefParseFile (domain_conf.c:21924)
==119642==    by 0x114A9D: testCompareXMLToArgv (qemuxml2argvtest.c:452)
==119642==    by 0x13894F: virTestRun (testutils.c:143)
==119642==    by 0x11F46E: mymain (qemuxml2argvtest.c:1316)
==119642==    by 0x13A60E: virTestMain (testutils.c:839

Fixes: fb0509d06ac57434c2edbd81ee63deb32a0e598a
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirDomainFSDefFree: Unref private data
Michal Privoznik [Fri, 21 Feb 2020 07:27:50 +0000 (08:27 +0100)]
virDomainFSDefFree: Unref private data

The privateData object is allocated in virDomainFSDefNew() but
never unref'd.

==119642== 480 bytes in 20 blocks are definitely lost in loss record 656 of 671
==119642==    at 0x4837B86: calloc (vg_replace_malloc.c:762)
==119642==    by 0x57806A0: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.6000.7)
==119642==    by 0x4AE7392: virAllocVar (viralloc.c:331)
==119642==    by 0x4B64395: virObjectNew (virobject.c:241)
==119642==    by 0x48F1464: qemuDomainFSPrivateNew (qemu_domain.c:1427)
==119642==    by 0x4BBF004: virDomainFSDefNew (domain_conf.c:2307)
==119642==    by 0x4BD859A: virDomainFSDefParseXML (domain_conf.c:11217)
==119642==    by 0x4BF9DD1: virDomainDefParseXML (domain_conf.c:21179)
==119642==    by 0x4BFCD5B: virDomainDefParseNode (domain_conf.c:21943)
==119642==    by 0x4BFCC36: virDomainDefParse (domain_conf.c:21901)
==119642==    by 0x4BFCCCB: virDomainDefParseFile (domain_conf.c:21924)
==119642==    by 0x114A9D: testCompareXMLToArgv (qemuxml2argvtest.c:452)

Fixes: 5120577ed79f89e172e3deed534fa9b585f4701f
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemumonitorjsontest: add test for cpu baseline
Collin Walling [Thu, 20 Feb 2020 22:01:48 +0000 (17:01 -0500)]
qemumonitorjsontest: add test for cpu baseline

Signed-off-by: Collin Walling <walling@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemumonitorjsontest: add tests for cpu comparison
Collin Walling [Thu, 20 Feb 2020 22:01:47 +0000 (17:01 -0500)]
qemumonitorjsontest: add tests for cpu comparison

Signed-off-by: Collin Walling <walling@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemumonitorjsontest: load schema based on specified arch
Collin Walling [Thu, 20 Feb 2020 22:01:46 +0000 (17:01 -0500)]
qemumonitorjsontest: load schema based on specified arch

There are some architectures that support capabilities that others
do not (e.g. s390x supports cpu comparison and baseline via QEMU).

Let's make testQEMUSchemaLoad accept a string to specify the schema
to load based on the specified arch.

Signed-off-by: Collin Walling <walling@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agodocs: add info about <portOptions isolated='yes'/> to news file
Laine Stump [Mon, 17 Feb 2020 03:54:45 +0000 (22:54 -0500)]
docs: add info about <portOptions isolated='yes'/> to news file

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoconf: extra validation for <port isolated='yes'/>
Laine Stump [Mon, 17 Feb 2020 03:34:59 +0000 (22:34 -0500)]
conf: extra validation for <port isolated='yes'/>

During the hypervisor-agnostic validation of network devices, verify
that the interface type is either "network" or "bridge", and that if
there is any <virtualport>, that it doesn't have any type associated
with it.

This needs to be done both for the parse-time validation and for
runtime validation (after a port has been acquired from any associated
network), because an interface with type='network' could have an
actual type at runtime of "hostdev" or "direct", neither of which
support isolated='true' (yet). Likewise, if an interface is
type='network', then at runtime a <virtualport> with a type that
doesn't support isolated='yes' (e.g. "openvswitch", "802.1Qbh" -
currently *none* of the available virtualport types support it)

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: support updating <port isolated='yes|no'/> during device update
Laine Stump [Fri, 14 Feb 2020 18:51:31 +0000 (13:51 -0500)]
qemu: support updating <port isolated='yes|no'/> during device update

This setting can be updating very easily on an already active
interface by just changing it in sysfs. If the bridge used for
connection is also changed, there is no need to separately update it,
because the new setting isf done as a part of connecting to the bridge
anyway.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu/lxc: plumb isolatedPort from config down through bridge attachment
Laine Stump [Thu, 13 Feb 2020 17:57:47 +0000 (12:57 -0500)]
qemu/lxc: plumb isolatedPort from config down through bridge attachment

This patch pushes the isolatedPort setting from the <interface> down
all the way to the callers of virNetDevBridgeAddPort(), and sets
BR_ISOLATED on the port (using virNetDevBridgePortSetIsolated()) after
the port has been successfully added to the bridge.

Signed-off-by: Laine Stump <laine@redhat.com>
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agonetwork: propagate <port isolated='yes'/> between network and domain
Laine Stump [Thu, 6 Feb 2020 23:15:25 +0000 (18:15 -0500)]
network: propagate <port isolated='yes'/> between network and domain

Similar to the way that the <vlan>, <bandwidth>, and <virtualport>
elements and the trustGuestRxFilters attribute in a <network> (or in
the appropriate <portgroup> element of a <network> can be applied to a
port when it is allocated for a domain's network interface, this patch
checks for a configured value of <port isolated="yes|no"/> in
either the domain <interface> or in the network, setting isolatedPort
in the <networkport> to the first one it finds (the setting from the
domain's <interface> is preferred). This, in turn, is passed back to
the domain when a port is allocated, so that the domain will use that
setting.

(One difference from <vlan>, <bandwidth>, <virtualport>, and
trustGuestRxFilters, is that all of those can be set in a <portgroup>
so that they can be applied only to a subset of interfaces connected
to the network. This didn't really make sense for the isolated setting
due to the way that it's implemented in Linux - the BR_ISOLATED flag
will prevent traffic from passing between two ports that both have
BR_ISOLATED set, but traffic can still go between those ports and
other ports that *don't* have BR_ISOLATED. (It would be nice if all
traffic from a BR_ISOLATED port could be blocked except traffic going
to/from a designated egress port or ports, but instead the entire
feature is implemented as a single flag. Because of this, it's really
only useful if all the ports on a network are isolated, so setting it
for a subset has no practical utility.)

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoconf: parse/format <port isolated='yes|no'/>
Laine Stump [Wed, 29 Jan 2020 15:29:21 +0000 (10:29 -0500)]
conf: parse/format <port isolated='yes|no'/>

This is a very simple thing to parse and format, but needs to be done
in 4 places, so two trivial utility functions have been made that can
be called from all the higher level parser/formatters:

  <domain><interface>
  <domain><interface><actual> (only in domain status)
  <network>
  <networkport>

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: query/set BR_ISOLATED flag on netdevs attached to bridge
Laine Stump [Mon, 20 Jan 2020 21:27:02 +0000 (16:27 -0500)]
util: query/set BR_ISOLATED flag on netdevs attached to bridge

When this flag is set for an interface attached to a bridge, traffic
to/from the specified interface can only enter/exit the bridge via
another attached interface that *doesn't* have the BR_ISOLATED flag
set. This can be used to permit guests to communicate with the rest of
the network, but not with each other.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: save/restore original error when recovering from failed bridge attach
Laine Stump [Thu, 13 Feb 2020 16:57:43 +0000 (11:57 -0500)]
qemu: save/restore original error when recovering from failed bridge attach

Not only was the original error code destroyed in the case of
encountering an error during recovery from a failed attach to the
bridge (and then *that* error was destroyed by logging a *second*
error about the failure to recover - virNetDevBridgeAddPort() already
logs an error, so the one about failing to recover was redundant), but
if the recovery was successful, the function would then return success
to the caller even though it had failed.

Fixes: 2711ac87160d7ac7d550c57f4339e6c6749942fa
(overwritten errors were introduced along with this functionality)
Fixes: 6bde0a1a37424c84492658223ff845b1ebb0e25c
(the wrong return value was introduced by a refactor)

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoschema: add missing vlan element to networkport RNG
Laine Stump [Fri, 14 Feb 2020 23:59:52 +0000 (18:59 -0500)]
schema: add missing vlan element to networkport RNG

This is in the data structure and the parse/format functions, and is
getting passed all around correctly, it just was omitted from the RNG,
which hasn't been noticed because no human is creating <networkport>
XML, and so it's never getting validated against the schema.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoschema: trivial indentation fix
Laine Stump [Sun, 26 Jan 2020 01:11:24 +0000 (20:11 -0500)]
schema: trivial indentation fix

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agom4: libxl: properly fail when libxl is required
Ján Tomko [Thu, 20 Feb 2020 14:53:08 +0000 (15:53 +0100)]
m4: libxl: properly fail when libxl is required

We specify "true" as the fail-action for LIBVIRT_CHECK_PKG.

This was used when we had a fallback to non-pkg-config detection,
then removed in commit 5bdcef13d13560512c7d6d8c9e8822e456889e0c
later re-introduced in commit dc3d2c9f8c7678a950abedd227b1587ca62335c4
and then left in when removing the old detection again in
commit 18981877d2e20390a79d068861a24e716f8ee422

Remove it to properly error out when libxl was requested but not
detected.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: 18981877d2e20390a79d068861a24e716f8ee422
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agoqemu_migration: Rearrange some checks in qemuMigrationSrcIsAllowed()
Michal Privoznik [Thu, 20 Feb 2020 10:54:44 +0000 (11:54 +0100)]
qemu_migration: Rearrange some checks in qemuMigrationSrcIsAllowed()

Firstly, the check for disk I/O error can be moved into 'if
(!offline)' section a few lines below.
Secondly, checks for vmstate and slirp should be moved under the
same section because they reflect live state of a domain. For
offline migration no QEMU is involved and thus these restrictions
are not valid.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Don't explicitly remove pidfile after virPidFileForceCleanupPath()
Michal Privoznik [Thu, 20 Feb 2020 10:46:24 +0000 (11:46 +0100)]
qemu: Don't explicitly remove pidfile after virPidFileForceCleanupPath()

In two places where virPidFileForceCleanupPath() is called, we
try to unlink() the pidfile again. This is needless because
virPidFileForceCleanupPath() has done just that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirpidfile: Set correct retval in virPidFileReadPath()
Michal Privoznik [Thu, 20 Feb 2020 10:36:07 +0000 (11:36 +0100)]
virpidfile: Set correct retval in virPidFileReadPath()

The virPidFileReadPath() function is supposed to return 0 on
success or a negative value on failure. But the negative value
has a special meaning - it's negated errno. Therefore, when
converting string to int we shouldn't return -1 which translates
to EPERM. Returning EINVAL looks closer to the truth.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirStorageFileGetMetadataRecurse: Remove 'cleanup' label
Peter Krempa [Mon, 17 Feb 2020 12:04:26 +0000 (13:04 +0100)]
virStorageFileGetMetadataRecurse: Remove 'cleanup' label

There's nothing to clean up. Make it obvious what is returned.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agovirStorageFileGetMetadataRecurse: Extract storage access
Peter Krempa [Mon, 17 Feb 2020 11:51:19 +0000 (12:51 +0100)]
virStorageFileGetMetadataRecurse: Extract storage access

Extract the code that directly deals with storage. This allows further
simplification and clarification of virStorageFileGetMetadataRecurse.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agovirStorageFileGetMetadataRecurse: Use virHashHasEntry instead of fake pointers
Peter Krempa [Mon, 17 Feb 2020 11:36:59 +0000 (12:36 +0100)]
virStorageFileGetMetadataRecurse: Use virHashHasEntry instead of fake pointers

Replacing virHashLookup by virHashHasEntry allows us to use NULL as the
payload of the hash table rather than putting a fake '1' pointer into
the table.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agovirStorageFileGetMetadataRecurse: Expect NULL src->path
Peter Krempa [Mon, 17 Feb 2020 11:27:41 +0000 (12:27 +0100)]
virStorageFileGetMetadataRecurse: Expect NULL src->path

The path can be NULL e.g. for NBD disks. Use NULLSTR to prevent use of
NULL in %s.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agovirStorageFileGetMetadataRecurse: Shuffle around assignment of backing chain depth
Peter Krempa [Mon, 17 Feb 2020 09:34:47 +0000 (10:34 +0100)]
virStorageFileGetMetadataRecurse: Shuffle around assignment of backing chain depth

Move the assignment to a place where we know that the backing store is
present rather than having to check in the cleanup section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agovirStorageFileGetMetadataRecurse: Remove impossible error report
Peter Krempa [Fri, 14 Feb 2020 15:36:26 +0000 (16:36 +0100)]
virStorageFileGetMetadataRecurse: Remove impossible error report

We call virStorageFileSupportsBackingChainTraversal which already checks
that the 'storageFileRead' callback is non-NULL, which in turn means
that virStorageFileRead will not return -2.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoutil: storagefile: Drop image format probing by file suffix
Peter Krempa [Mon, 17 Feb 2020 08:26:46 +0000 (09:26 +0100)]
util: storagefile: Drop image format probing by file suffix

Probing by file suffix was meant to be a last resort if probing by
contents fails or is not supported. For most formats we never specified
any suffix. There's a few formats implementing both magic bytes and
suffix and finally DMG which had only suffix probing. Since suffix
probing is nowhere reliable and only one format depends on in which has a
comment that qemu doesn't do the probing either drop the whole
infrastructure.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agocpu_conf: Format vendor_id for host-model CPUs
Jiri Denemark [Wed, 19 Feb 2020 12:48:39 +0000 (13:48 +0100)]
cpu_conf: Format vendor_id for host-model CPUs

In commit v5.9.0-400-gaf8e39921a I removed printing model's fallback and
vendor_id attributes when no model is specified. However, vendor_id
makes sense even without a specific CPU model (for host-model CPUs).

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuxml2xmltest: Add case for host-model vendor_id
Jiri Denemark [Wed, 19 Feb 2020 12:10:27 +0000 (13:10 +0100)]
qemuxml2xmltest: Add case for host-model vendor_id

This patch shows a bug in our code: the

    <model vendor_id="Libvirt QEMU"/>

element present in the source XML is lost when the parsed CPU definition
is formatted back to XML.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuDomainGetStatsIOThread: Don't leak array with 0 iothreads
Peter Krempa [Wed, 19 Feb 2020 07:40:59 +0000 (08:40 +0100)]
qemuDomainGetStatsIOThread: Don't leak array with 0 iothreads

qemuMonitorGetIOThreads returns a NULL-terminated list even when 0
iothreads are present. The caller didn't perform cleanup if there were 0
iothreads leaking the array.

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

Fixes: d1eac92784573559b6fd56836e33b215c89308e3
Reported-by: Jing Yan <jiyan@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agodocs: QoS parameter 'floor' is supported for 'open' networks too
Pavel Mores [Fri, 14 Feb 2020 16:26:24 +0000 (17:26 +0100)]
docs: QoS parameter 'floor' is supported for 'open' networks too

Relevant code seems to treat forward modes 'route', 'nat', 'open' and 'none'
the same but documentation hasn't reflected that so far.

Signed-off-by: Pavel Mores <pmores@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: call networkPlugBandwidth() for all types of network
Pavel Mores [Fri, 14 Feb 2020 16:26:23 +0000 (17:26 +0100)]
qemu: call networkPlugBandwidth() for all types of network

To fix the actual bug, it was necessary to make networkPlugBandwidth() be
called also for 'bridge'-type networks implemented using macvtap's 'bridge'
mode (previously it was only called for those implemented on top of an
existing bridge).

However, it seems beneficial to call it for other network types as well, at
least because it removes an inconsistency in types of bandwidth configuration
changes permissible in inactive and active domain configs.  It should also be
safe as the function pretty much amounts to NOP if no QoS is requested and the
new behaviour should not be any worse than before if it is.

Signed-off-by: Pavel Mores <pmores@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: check if 'floor' is supported for given interface and network
Pavel Mores [Fri, 14 Feb 2020 16:26:20 +0000 (17:26 +0100)]
qemu: check if 'floor' is supported for given interface and network

Even if an interface of type 'network', setting 'floor' is only supported
if the network's forward type is nat, route, open or none.

Signed-off-by: Pavel Mores <pmores@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: fail on attempt to set 'floor' if interface type is not 'network'
Pavel Mores [Fri, 14 Feb 2020 16:26:21 +0000 (17:26 +0100)]
qemu: fail on attempt to set 'floor' if interface type is not 'network'

QoS 'floor' setting is documented to be only supported for interfaces of
type 'network'.  Fail with an error message on attempt to set 'floor' on
an interface of any other type.

Signed-off-by: Pavel Mores <pmores@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: test if bandwidth has 'floor' factored out to separate function
Pavel Mores [Fri, 14 Feb 2020 16:26:19 +0000 (17:26 +0100)]
qemu: test if bandwidth has 'floor' factored out to separate function

This compound condition will be useful in several places so it
makes sense to give it a name for better readability.

Signed-off-by: Pavel Mores <pmores@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agovirStorageSourceParseBackingJSONRaw: Parse 'offset' and 'size' attributes
Peter Krempa [Wed, 5 Feb 2020 17:09:55 +0000 (18:09 +0100)]
virStorageSourceParseBackingJSONRaw: Parse 'offset' and 'size' attributes

If the parsed 'raw' format JSON string has 'offset' or 'size' attributes
parse them as the format slice.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: qemu: Add test data for the new <slice> element
Peter Krempa [Wed, 5 Feb 2020 17:18:39 +0000 (18:18 +0100)]
tests: qemu: Add test data for the new <slice> element

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Add support for slices of type 'storage'
Peter Krempa [Mon, 10 Feb 2020 13:37:14 +0000 (14:37 +0100)]
qemu: Add support for slices of type 'storage'

Implement support for the slice of type 'storage' which allows to set
the offset and size which modifies where qemu should look for the start
of the format container inside the image.

Since slicing is done using the 'raw' driver we need to add another
layer into the blockdev tree if there's any non-raw image format driver
used to access the data.

This patch adds the blockdev integration and setup of the image data so
that we can use the slices for any backing image.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: qemublock: Add cases for creating image overlays on top of disks with <slice>
Peter Krempa [Wed, 12 Feb 2020 16:26:18 +0000 (17:26 +0100)]
tests: qemublock: Add cases for creating image overlays on top of disks with <slice>

Add a set of test data to see whether the backing store strings are
formatted reasonably. Note that we don't support direct creation of such
images so those tests are not enabled.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: block: Properly format storage slice into backing store strings
Peter Krempa [Wed, 12 Feb 2020 16:25:12 +0000 (17:25 +0100)]
qemu: block: Properly format storage slice into backing store strings

When creating overlay images e.g. for snapshots or when merging
snapshots we often specify the backing store string to use. Make the
formatter aware of backing chain entries which have a <slice>
configured so that we record it properly. Otherwise such images
would not work without the XML (when detecting the backing chain).

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: domain: Store nodenames of slice in status XML
Peter Krempa [Mon, 10 Feb 2020 13:26:08 +0000 (14:26 +0100)]
qemu: domain: Store nodenames of slice in status XML

The storage slice will require a specific node name in cases when the
image format is not raw. Store and format them in the status XML.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoconf: Implement support for <slices> of disk source
Peter Krempa [Mon, 3 Feb 2020 16:36:09 +0000 (17:36 +0100)]
conf: Implement support for <slices> of disk source

Implement parsing and formatting of the 'storage' slice.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agodocs: Document the new <slices> sub-element of disk's <source>
Peter Krempa [Wed, 5 Feb 2020 17:00:23 +0000 (18:00 +0100)]
docs: Document the new <slices> sub-element of disk's <source>

We are going to add support for specifying offset and size attributes
which will allow controling where the image and where the guest data
itself starts in the source of the disk. This will be represented by
a <slices> element filled with either a <slice type='storage'> for the
offset of the image format data.

Add the XML documentation and RNG schema.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: block: forbid creation of storage sources with <slice>
Peter Krempa [Wed, 12 Feb 2020 16:26:47 +0000 (17:26 +0100)]
qemu: block: forbid creation of storage sources with <slice>

Specifically creating such images via libvirt during blockjobs would
be much more hassle than it's worth. Just forbid them for now.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuDomainValidateStorageSource: Reject unsupported slices
Peter Krempa [Wed, 5 Feb 2020 13:51:12 +0000 (14:51 +0100)]
qemuDomainValidateStorageSource: Reject unsupported slices

We support explicit storage slices only when using blockdev. Storage
slices expressed via the backing store string are left to qemu to
open correctly.

Reject storage slices configured via the XML for non-blockdev usage.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuBlockStorageSourceGetFormatRawProps: format 'offset' and 'size' for slice
Peter Krempa [Wed, 5 Feb 2020 17:08:55 +0000 (18:08 +0100)]
qemuBlockStorageSourceGetFormatRawProps: format 'offset' and 'size' for slice

If we have a 'format' type slice for a raw driver we can directly format
the values.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: virstoragefile: Add data structure for storing storage source slices
Peter Krempa [Mon, 3 Feb 2020 16:14:52 +0000 (17:14 +0100)]
util: virstoragefile: Add data structure for storing storage source slices

Introduce virStorageSourceSlice which will store the 'offset' and 'size'
of a virStorageSource and declare it as 'sliceStorage' and 'sliceFormat'
attributes of a virStorageSource.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: virstorage: Add test data for json specified raw image with offset/size
Peter Krempa [Thu, 16 Jan 2020 15:02:15 +0000 (16:02 +0100)]
tests: virstorage: Add test data for json specified raw image with offset/size

QEMU allows specifying the offset and size into a raw file to expose a
sub-slice of the image to the guest with the raw driver. Libvirt
currently doesn't support it but we can add test case for future
reference.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agodocs: formatdomain: Close <source> on one of disk examples
Peter Krempa [Wed, 5 Feb 2020 16:59:38 +0000 (17:59 +0100)]
docs: formatdomain: Close <source> on one of disk examples

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: domain: Refactor formatting of node names into status XML
Peter Krempa [Mon, 10 Feb 2020 13:23:30 +0000 (14:23 +0100)]
qemu: domain: Refactor formatting of node names into status XML

Use virXMLFormatElement to simplify the logic.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu_domain: Modify access to a NVMe disk iff needed
Michal Privoznik [Fri, 14 Feb 2020 12:59:02 +0000 (13:59 +0100)]
qemu_domain: Modify access to a NVMe disk iff needed

If a domain has a NVMe disk it already has the access configured.
Trying to configure it again on a commit or some other operation
is wrong and condemned to failure.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agonews: Mention the armvtimer timer
Andrea Bolognani [Fri, 7 Feb 2020 13:00:22 +0000 (14:00 +0100)]
news: Mention the armvtimer timer

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agodocs: List the armvtimer timer among all others
Andrea Bolognani [Fri, 7 Feb 2020 12:35:00 +0000 (13:35 +0100)]
docs: List the armvtimer timer among all others

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: Add test case for the armvtimer timer
Andrea Bolognani [Fri, 7 Feb 2020 12:11:42 +0000 (13:11 +0100)]
tests: Add test case for the armvtimer timer

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Format the armvtimer timer on the command line
Andrea Bolognani [Fri, 7 Feb 2020 11:45:49 +0000 (12:45 +0100)]
qemu: Format the armvtimer timer on the command line

Its behavior is controlled by a KVM-specific CPU feature.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Validate configuration for the armvtimer timer
Andrea Bolognani [Fri, 7 Feb 2020 09:15:02 +0000 (10:15 +0100)]
qemu: Validate configuration for the armvtimer timer

Its use is limited to certain guest types, and it only supports
a subset of all possible tick policies.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoconf: Introduce VIR_DOMAIN_TIMER_NAME_ARMVTIMER
Andrea Bolognani [Thu, 6 Feb 2020 15:54:45 +0000 (16:54 +0100)]
conf: Introduce VIR_DOMAIN_TIMER_NAME_ARMVTIMER

This new timer model will be used to control the behavior of the
virtual timer for KVM ARM/virt guests.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Add the QEMU_CAPS_CPU_KVM_NO_ADJVTIME capability
Andrea Bolognani [Fri, 31 Jan 2020 13:28:57 +0000 (14:28 +0100)]
qemu: Add the QEMU_CAPS_CPU_KVM_NO_ADJVTIME capability

We will use this capability to detect whether the QEMU binary
supports the kvm-no-adjvtime CPU feature.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Use switch statement in qemuBuildCpuCommandLine()
Andrea Bolognani [Fri, 7 Feb 2020 09:22:08 +0000 (10:22 +0100)]
qemu: Use switch statement in qemuBuildCpuCommandLine()

Make sure we are taking all possible virDomainTimerNameType values
into account. This will make upcoming changes easier.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: drop support for monitor connections on PTYs
Daniel P. Berrangé [Wed, 12 Feb 2020 10:50:49 +0000 (10:50 +0000)]
qemu: drop support for monitor connections on PTYs

Libvirt switched to using a UNIX socket for monitors in
2009 for version 0.7.0. It seems unlikely that there is
a running QEMU process that hasn't been restarted for
11 years while also taking a libvirt upgrade. Therefore
we can drop support for opening a PTY for the QEMU
monitor.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: use closefrom() for mass closing of FDs
Your Name [Wed, 12 Feb 2020 10:53:59 +0000 (10:53 +0000)]
src: use closefrom() for mass closing of FDs

On FreeBSD 12 the default ulimit settings allow for 100,000
open file descriptors. As a result spawning processes in
libvirt is abominably slow. Fortunately FreeBSD has long
since provided a good solution in the form of closefrom(),
which closes all FDs equal to or larger than the specified
parameter.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovirt-aa-helper: Add support for smartcard host-certificates
Arnaud Patard [Thu, 5 Dec 2019 17:11:41 +0000 (18:11 +0100)]
virt-aa-helper: Add support for smartcard host-certificates

When emulating smartcard with host certificates, qemu needs to
be able to read the certificates files. Add necessary code to
add the smartcard certificates file path to the apparmor profile.

Passthrough support has been tested with spicevmc and remote-viewer.

v2:
- Fix CodingStyle
- Add support for 'host' case.
- Add a comment to mention that the passthrough case doesn't need
  some configuration
- Use one rule with '{,*}' instead of two rules.

Signed-off-by: Arnaud Patard <apatard@hupstream.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
Acked-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
5 years agodocs: Improve documentation for <serial> and <console>
Andrea Bolognani [Tue, 11 Feb 2020 14:37:05 +0000 (15:37 +0100)]
docs: Improve documentation for <serial> and <console>

Users expect to be able to configure the <console> element and see
that configuration reflected into the <serial> element or at least
sticking, however due to our crazy back-compat code that doesn't
always happen.

There's really not much we can do to make this kind of corner cases
work as the user would expect, especially not without introducing
additional complexity in a part of libvirt that already has more
than a fair share of it; we can, however, improve the documentation
so that it will nudge said users in the right direction.

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotestutils: remove now unused virTestCaptureProgramOutput
Ján Tomko [Sun, 9 Feb 2020 01:04:13 +0000 (02:04 +0100)]
testutils: remove now unused virTestCaptureProgramOutput

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>