]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
5 years agolxc: add LXC version 3 network parser
Julio Faracco [Mon, 3 Feb 2020 01:28:33 +0000 (22:28 -0300)]
lxc: add LXC version 3 network parser

LXC version 3 or higher introduced indexes for network interfaces.
Libvirt should be able to parse entries like `lxc.net.2.KEY`. This
commit adds functions to parse this type of field. That's why array
structures are so important this time.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agolxc: refactor lxcNetworkParseData pointers to use new structures
Julio Faracco [Mon, 3 Feb 2020 01:28:32 +0000 (22:28 -0300)]
lxc: refactor lxcNetworkParseData pointers to use new structures

Struct lxcNetworkParseData is being used as a single pointer which
iterates through LXC config lines. It means that it will be applied as a
network each time that a new type appears. After, the same struct is
used to populate a new network interface. This commit changes this logic
to multiple lxcNetworkParseData to move this strcuture to an array. It
makes more sense if we are using indexes to fill interface settings.
This is better to improve code clarity.

This commit still introduces *Legacy() functions to keep support of
network old style definitions.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: Add capabilities for QEMU 5.0.0 on aarch64
Andrea Bolognani [Fri, 31 Jan 2020 12:55:26 +0000 (13:55 +0100)]
tests: Add capabilities for QEMU 5.0.0 on aarch64

This will be the first QEMU version that will support the
kvm-no-adjvtime CPU feature.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoDrop virAtomic module
Michal Privoznik [Fri, 31 Jan 2020 16:32:39 +0000 (17:32 +0100)]
Drop virAtomic module

Now, that every use of virAtomic was replaced with its g_atomic
equivalent, let's remove the module.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agosrc: Drop virAtomicIntDecAndTest() with g_atomic_int_dec_and_test()
Michal Privoznik [Fri, 31 Jan 2020 16:12:11 +0000 (17:12 +0100)]
src: Drop virAtomicIntDecAndTest() with g_atomic_int_dec_and_test()

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agosrc: Replace virAtomicIntInc() with g_atomic_int_add()
Michal Privoznik [Fri, 31 Jan 2020 16:04:24 +0000 (17:04 +0100)]
src: Replace virAtomicIntInc() with g_atomic_int_add()

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agosrc: Replace virAtomicIntSet() with g_atomic_int_set()
Michal Privoznik [Fri, 31 Jan 2020 16:08:35 +0000 (17:08 +0100)]
src: Replace virAtomicIntSet() with g_atomic_int_set()

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agosrc: Replace virAtomicIntGet() with g_atomic_int_get()
Michal Privoznik [Fri, 31 Jan 2020 16:07:00 +0000 (17:07 +0100)]
src: Replace virAtomicIntGet() with g_atomic_int_get()

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: Drop viratomictest
Michal Privoznik [Fri, 31 Jan 2020 16:01:47 +0000 (17:01 +0100)]
tests: Drop viratomictest

In future commits our virAtomic* APIs will be replaced with their
GLib variants. Instead of trying to update the test after each
commit and eventually removing the test anyway, remove it upfront
and save the hassle.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotest_driver: Replace virAtomicIntAdd() with g_atomic_int_add()
Michal Privoznik [Fri, 31 Jan 2020 16:13:25 +0000 (17:13 +0100)]
test_driver: Replace virAtomicIntAdd() with g_atomic_int_add()

Instead of calling virAtomicIntAdd(&var, 1); we can call
g_atomic_int_add() directly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: drop unused variable
Ján Tomko [Fri, 31 Jan 2020 16:02:26 +0000 (17:02 +0100)]
qemu: drop unused variable

The g_auto conversion made clang realize the variable is unused:
../../src/qemu/qemu_domain.c:10349:36: error: unused variable
    'cfg' [-Werror,-Wunused-variable]
    g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: 20fa2bc6e52e01feaf39d12d38bcf8eaec4c9a46
5 years agobuild: Drop execute permissions on virsh bash completion command
Jim Fehlig [Thu, 30 Jan 2020 18:29:41 +0000 (11:29 -0700)]
build: Drop execute permissions on virsh bash completion command

rpmlint complains about "script-without-shebang" due to the execute
permissions on /usr/share/bash-completion/completions/vsh. Use
INSTALL_DATA instead of INSTALL_SCRIPT to avoid the unnecessary
execute permissions.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Fix domain ID allocation
Ján Tomko [Fri, 31 Jan 2020 14:27:37 +0000 (15:27 +0100)]
qemu: Fix domain ID allocation

The rewrite to use GLib's atomic ops functions changed the behavior
of virAtomicIntInc - before it returned the pre-increment value.

Most of the callers using its value were adjusted, but the one
in qemuDriverAllocateID was not. If libvirtd would reconnect to
a running domain during startup, the next started domain would get
the same ID:

$ virsh list
 Id   Name       State
--------------------------
 1    f28live    running
 1    f28live1   running

Use the g_atomic_add function directly (as recommended in viratomic.h)
and add 1 to the result.

This also restores the usual numbering from 1 instead of 0.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: 7b9645a7d127a374b8d1c83fdf9789706dbab2c9
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agodocs: fix a typo
Ján Tomko [Fri, 31 Jan 2020 14:57:00 +0000 (15:57 +0100)]
docs: fix a typo

s/axnd/and/

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: f0f34056ab26eaa9f903a51cd1fa155088fd640f
5 years agoqemu_domain_address.c: turn qemuDomainFillDeviceIsolationGroup to void
Daniel Henrique Barboza [Thu, 9 Jan 2020 18:33:48 +0000 (15:33 -0300)]
qemu_domain_address.c: turn qemuDomainFillDeviceIsolationGroup to void

Starting on commit 1f43393283ff, qemuDomainFillDeviceIsolationGroup()
returns 0 in all circunstances. Let's turn it to 'void' make it
clearer that the function will not fail. This also spares a
check for < 0 return in qemu_hotplug.c. The
qemuDomainFillDeviceIsolationGroupIter() callback now returns
0 at all times - which is already happening anyway.

Refer to 1f43393283ff commit message for more details on why
the function was changed to never return an error.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu_domain.c: turn qemuDomainChrDefDropDefaultPath to void
Daniel Henrique Barboza [Thu, 9 Jan 2020 18:33:47 +0000 (15:33 -0300)]
qemu_domain.c: turn qemuDomainChrDefDropDefaultPath to void

qemuDomainChrDefDropDefaultPath() returns an int, but it's
always returning 0. Callers are checking for result < 0 to
run their cleanup code needlessly.

Turn the function to 'void' and adjust the callers.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu_domain.c: removing unneeded cleanup labels
Daniel Henrique Barboza [Thu, 9 Jan 2020 18:33:46 +0000 (15:33 -0300)]
qemu_domain.c: removing unneeded cleanup labels

Previous patches deprecated some 'cleanup' labels. Let's remove
them.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu_domain.c: use g_autoptr when possible
Daniel Henrique Barboza [Thu, 9 Jan 2020 18:33:45 +0000 (15:33 -0300)]
qemu_domain.c: use g_autoptr when possible

Avoid some of the virObjectUnref() calls by using g_autoptr.
Aside from the 'cleanup' label in qemuDomainSetFakeReboot(),
all other now deprecated cleanup labels will be removed in
the next patch.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu_domain.c: use g_autofree when possible
Daniel Henrique Barboza [Thu, 9 Jan 2020 18:33:44 +0000 (15:33 -0300)]
qemu_domain.c: use g_autofree when possible

Use g_autofree to remove VIR_FREE() calls used for cleanups.
Labels that became deprecated will be removed in a later
patch.

In qemuDomainSetupDisk(), the 'dst' variable is not used at
all and could be removed.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu_domain.c: remove redundant virObjectUnref()
Daniel Henrique Barboza [Thu, 9 Jan 2020 18:33:43 +0000 (15:33 -0300)]
qemu_domain.c: remove redundant virObjectUnref()

The 'caps' variable in qemuDomainObjPrivateXMLParseAutomaticPlacement()
is set to auto clean via g_autoptr(), but a 'virObjectUnref(caps)' is
being executed in the 'cleanup' label.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconf/domain_addr.c: remove unneeded 'cleanup' labels
Daniel Henrique Barboza [Thu, 9 Jan 2020 18:33:42 +0000 (15:33 -0300)]
conf/domain_addr.c: remove unneeded 'cleanup' labels

Previous patch used 'g_autofree' to eliminate instances of
VIR_FREE(), making some cleanup labels obsolete. This
patch removes them.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconf/domain_addr.c: use g_autofree in strings
Daniel Henrique Barboza [Thu, 9 Jan 2020 18:33:41 +0000 (15:33 -0300)]
conf/domain_addr.c: use g_autofree in strings

Use g_autofree in strings when possible to spare a VIR_FREE()
call. Unneeded 'cleanup' labels will be taken care of in the
next patch.

The 'str' string in virDomainVirtioSerialAddrReserve() was
never used by the logic, only being used in cleanup by
VIR_FREE(). Let's remove it.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemuMigrationCookieAddNBD: Fix filling of 'capacity' when blockdev is used
Peter Krempa [Thu, 30 Jan 2020 14:35:06 +0000 (15:35 +0100)]
qemuMigrationCookieAddNBD: Fix filling of 'capacity' when blockdev is used

With -blockdev we must look up via the nodename rather than the 'drive'
alias which is not present any more.

This fixes the pre-creation of storage volumes on migration with
non-shared storage.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemuMigrationCookieAddNBD: Remove 'ret' variable and 'cleanup' label
Peter Krempa [Thu, 30 Jan 2020 14:06:14 +0000 (15:06 +0100)]
qemuMigrationCookieAddNBD: Remove 'ret' variable and 'cleanup' label

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemuMigrationCookieAddNBD: Use virHashNew and automatic freeing of virHashTablePtr
Peter Krempa [Thu, 30 Jan 2020 14:01:41 +0000 (15:01 +0100)]
qemuMigrationCookieAddNBD: Use virHashNew and automatic freeing of virHashTablePtr

Swithc to the helper which doesn't require checking of the return value.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemuMigrationCookieAddNBD: Move monitor call out of the loop
Peter Krempa [Thu, 30 Jan 2020 13:57:56 +0000 (14:57 +0100)]
qemuMigrationCookieAddNBD: Move monitor call out of the loop

The data is gathered only once so we can move the whole block which
fetches the data out of the loop and get rid of the logic which
prevents multiple calls.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemuMigrationCookieAddNBD: Use glib memory allocators
Peter Krempa [Thu, 30 Jan 2020 13:56:05 +0000 (14:56 +0100)]
qemuMigrationCookieAddNBD: Use glib memory allocators

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemuMigrationCookieNBD: Extract embedded struct
Peter Krempa [Thu, 30 Jan 2020 13:53:26 +0000 (14:53 +0100)]
qemuMigrationCookieNBD: Extract embedded struct

Extract the struct so that it's type has a name.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemuMigrationCookieAddNBD: Exit early if there are no disks
Peter Krempa [Thu, 30 Jan 2020 13:47:25 +0000 (14:47 +0100)]
qemuMigrationCookieAddNBD: Exit early if there are no disks

Refactor the logic to skip the body of the function if there's nothing
to do.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoRemove checking of return value of virHashNew
Peter Krempa [Tue, 28 Jan 2020 12:40:24 +0000 (13:40 +0100)]
Remove checking of return value of virHashNew

There are two calls to virHashNew which check the return value. It's not
necessary any more as virHashNew always returns a valid pointer.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconf: domain: Remove checking of return value of virHashCreateFull
Peter Krempa [Tue, 28 Jan 2020 12:40:24 +0000 (13:40 +0100)]
conf: domain: Remove checking of return value of virHashCreateFull

This module has last two direct checks whether the value returned by
virHashCreateFull is NULL. Remove them so that static analyzers don't
get the false idea that checking the value is necessary.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoutil: hash: Use g_new0 for allocating hash internals
Peter Krempa [Tue, 28 Jan 2020 12:34:43 +0000 (13:34 +0100)]
util: hash: Use g_new0 for allocating hash internals

Use the glib helpers and remove the mention of returning NULL on failure
of virHashNew, virHashCreate and virHashCreateFull.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agodocs: update Rust releases and resources links
Sahid Orentino Ferdjaoui [Thu, 30 Jan 2020 14:19:29 +0000 (15:19 +0100)]
docs: update Rust releases and resources links

This is updating the releases and resources links so they point now to
crates.io for the releases and docs.rs for the api ref.

Signed-off-by: Sahid Orentino Ferdjaoui <sahid.ferdjaoui@canonical.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agodocs: Update godoc URLs for Go packages
Andrea Bolognani [Thu, 30 Jan 2020 17:10:35 +0000 (18:10 +0100)]
docs: Update godoc URLs for Go packages

Since

  commit 201156ec6e65e08cdb04d6fdefe013652fb7fa87
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   Mon Dec 16 10:06:50 2019 +0000

    docs: add pages to support Go module package resolution

it's possible to use

  import "libvirt.org/libvirt-go"
  import "libvirt.org/libvirt-go-xml"

in Go programs, which will result in the Go packages being
fetched directly from libvirt.org instead of GitHub.

The godoc website offers the API documentation for the updated
imports, and that's where we should send users.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agodocs: Update download location for Go packages
Andrea Bolognani [Thu, 30 Jan 2020 17:05:49 +0000 (18:05 +0100)]
docs: Update download location for Go packages

We haven't ever made releases of the Go components, which makes
sense because that's just not how that specific ecosystem works.

For people who are looking to use libvirt from Go, the brief
introductory pages located at the same URLs used to import the
packages are a better entry point than an empty directory
listing, so let's send them there instead.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoapparmor: fix qemu_bridge_helper for named profile
Christian Ehrhardt [Thu, 30 Jan 2020 07:12:38 +0000 (08:12 +0100)]
apparmor: fix qemu_bridge_helper for named profile

Since a3ab6d42 "apparmor: convert libvirtd profile to a named profile"
the detection of the subelement for qemu_bridge_helper is wrong.

In combination with the older 123cc3e1 "apparmor: allow
/usr/lib/qemu/qemu-bridge-helper" it now detects qemu-bridge-helper no
more with its path, but instead as a proper subelement of the named profile
like: label=libvirtd//qemu_bridge_helper

In the same fashion the reverse rule in the qemu_bridge_helper
sub-profile still uses the path and not the named profile label.

Triggering denies like:
apparmor="DENIED" operation="file_inherit"
  profile="libvirtd//qemu_bridge_helper" pid=5629 comm="qemu-bridge-hel"
  family="unix" sock_type="stream" protocol=0 requested_mask="send receive"
  denied_mask="send receive" addr=none peer_addr=none peer="libvirtd"

This patch fixes the unix socket rules for the communication between
libvirtd and qemu-bridge-helper to match that.

Fixes: a3ab6d42d825499af44b8f19f9299e150d9687bc
Fixes: https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1655111
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
5 years agonwfilter: Use immediate packet delivery mode rather than buffering
Erik Skultety [Thu, 30 Jan 2020 12:51:30 +0000 (13:51 +0100)]
nwfilter: Use immediate packet delivery mode rather than buffering

Our nwfilter code doesn't set any timeout on the pcap packet buffer which
means that when DHCP snooping is enabled on a guest interface and
libvirt is trying to learn the IP address from guest's DHCP traffic, it
takes up to 4x longer to ping a guest successfully compared to a case
where nwfilter isn't enabled at all or libvirt uses the cached nwfilter
leases to populate the corresponding rules to ebtables.
With the pcap filter and rate limiting already in place, we should be
able to afford enabling the immediate packet delivery, FWIW immediate
mode was actually the default prior libpcap-1.5.0 (CentOS 6) regardless
of whether a buffer was requested.

The lack of any kind of timeout on the pcap buffer messed with the
libvirt TCK test suite which, even with a generous timeout in place,
timeouts every single time simply because it takes a while until
guest actually starts producing any kind of traffic to fill up
the buffer in place (apart from the DHCP traffic which happens fairly
early on).

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agolibpcap: Bump the minimum required version to >= 1.5.0
Erik Skultety [Thu, 30 Jan 2020 12:05:54 +0000 (13:05 +0100)]
libpcap: Bump the minimum required version to >= 1.5.0

libpcap-1.5.0 introduced a function to enforce immediate mode (on all
platforms) which the follow-up patches will rely on.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoAdd a space before ending a comment
Ján Tomko [Fri, 24 Jan 2020 20:30:04 +0000 (21:30 +0100)]
Add a space before ending a comment

Also add a space after the start in some of the cases.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agoapparmor: Drop 'Last modified' comment from profiles
Michal Privoznik [Thu, 30 Jan 2020 06:58:25 +0000 (07:58 +0100)]
apparmor: Drop 'Last modified' comment from profiles

At the beginning of each profile we have a comment that says when
the profile was last updated. In theory, it makes sense because
one can see immediately if they are using an outdated profile.
However, we don't do a good job in keeping the comments in sync
with reality and also sysadmins should rather use their package
manager to find out libvirt version which installed the profiles.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
5 years agoapparmor: Allow some more BIOS/UEFI paths
Michal Privoznik [Sat, 25 Jan 2020 08:38:53 +0000 (09:38 +0100)]
apparmor: Allow some more BIOS/UEFI paths

There are two more paths that we are missing in the default
domain profile: /usr/share/edk2-ovmf/ and /usr/share/sgabios/.
These exist on my Gentoo box and contain UEFI and BIOS images
respectively.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
5 years agoapparmor: Sort paths in blocks in libvirt-qemu profile
Michal Privoznik [Sat, 25 Jan 2020 08:28:47 +0000 (09:28 +0100)]
apparmor: Sort paths in blocks in libvirt-qemu profile

Even though we construct a domain specific profile for each
domain we start (which should cover domain specific paths), there
is also another file that is included from the profile and which
contains domain agnostic paths (e.g. to cover libraries that qemu
links with). The paths in the file are split into blocks divided
by comments. Sort the paths in each block individually (ignoring
case sensitivity).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
5 years agolibxl: support getting and setting parameters for the Credit2
Dario Faggioli [Wed, 29 Jan 2020 11:05:15 +0000 (12:05 +0100)]
libxl: support getting and setting parameters for the Credit2

With Credit2 being Xen default scheduler, it's definitely the case to
allow Credit2's scheduling parameters to be get and set via libvirt.

This is easy, as Credit and Credit2 have (at least as of now) the very
same parameters ('weight' and 'cap'). So we can just let credit2 pass
the scheduler-type check and the same code will work for both.

Signed-off-by: Dario Faggioli <dfaggioli@suse.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
5 years agodocs: document <interface> subelement <teaming>
Laine Stump [Fri, 24 Jan 2020 02:34:01 +0000 (21:34 -0500)]
docs: document <interface> subelement <teaming>

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: add wait-unplug to qemu migration status enum
Laine Stump [Wed, 15 Jan 2020 21:38:57 +0000 (16:38 -0500)]
qemu: add wait-unplug to qemu migration status enum

Aside from itinerant error (actually warning) messages due to an
unrecognized response from qemu, this isn't even necessary - the
migration proceeds successfully to completion anyway.

(I'm not sure where to see this status reported in the API though - do
we need to add an extra state, or recognition of a new event somewhere?)

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: allow migration with assigned PCI hostdev if <teaming> is set
Laine Stump [Fri, 10 Jan 2020 00:39:47 +0000 (19:39 -0500)]
qemu: allow migration with assigned PCI hostdev if <teaming> is set

Normally a PCI hostdev can't be migrated, so
qemuMigrationSrcIsAllowedHostdev() won't permit it. In the case of a a
hostdev network interface that has <teaming type='transient'/> set,
QEMU will automatically unplug the device prior to migration, and
re-plug a corresponding device on the destination. This patch modifies
qemuMigrationSrcIsAllowedHostdev() to allow domains with those devices
to be migrated.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: support interface <teaming> functionality
Laine Stump [Thu, 23 Jan 2020 20:34:53 +0000 (15:34 -0500)]
qemu: support interface <teaming> functionality

The QEMU driver uses the <teaming type='persistent|transient'
persistent='blah'/> element to setup a "failover" pair of devices -
the persistent device must be a virtio emulated NIC, with the only
extra configuration being the addition of ",failover=on" to the device
commandline, and the transient device must be a hostdev NIC
(<interface type='hostdev'> or <interface type='network'> with a
network that is a pool of SRIOV VFs) where the extra configuration is
the addition of ",failover_pair_id=$aliasOfVirtio" to the device
commandline. These new options are supported in QEMU 4.2.0 and later.

Extra qemu-specific validation is added to ensure that the device
type/model is appropriate and that the qemu binary supports these
commandline options.

The result of this will be:

1) The virtio device presented to the guest will have an extra bit set
in its PCI capabilities indicating that it can be used as a failover
backup device. The virtio guest driver will need to be equipped to do
something with this information - this is included in the Linux
virtio-net driver in kernel 4.18 and above (and also backported to
some older distro kernels). Unfortunately there is no way for libvirt
to learn whether or not the guest driver supports failover - if it
doesn't then the extra PCI capability will be ignored and the guest OS
will just see two independent devices. (NB: the current virtio guest
driver also requires that the MAC addresses of the two NICs match in
order to pair them into a bond).

2) When a migration is requested, QEMu will automatically unplug the
transient/hostdev NIC from the guest on the source host before
starting migration, and automatically re-plug a similar device after
restarting the guest CPUs on the destination host. While the transient
NIC is unplugged, all network traffic will go through the
persistent/virtio device, but when the hostdev NIC is plugged in, it
will get all the traffic. This means that in normal circumstances the
guest gets the performance advantage of vfio-assigned "real hardware"
networking, but it can still be migrated with the only downside being
a performance penalty (due to using an emulated NIC) during the
migration.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoconf: parse/format <teaming> subelement of <interface>
Laine Stump [Wed, 22 Jan 2020 21:24:10 +0000 (16:24 -0500)]
conf: parse/format <teaming> subelement of <interface>

The subelement <teaming> of <interface> devices is used to configure a
simple teaming association between two interfaces in a domain. Example:

  <interface type='bridge'>
    <source bridge='br0'/>
    <model type='virtio'/>
    <mac address='00:11:22:33:44:55'/>
    <alias name='ua-backup0'/>
    <teaming type='persistent'/>
  </interface>
  <interface type='hostdev'>
    <source>
      <address type='pci' bus='0x02' slot='0x10' function='0x4'/>
    </source>
    <mac address='00:11:22:33:44:55'/>
    <teaming type='transient' persistent='ua-backup0'/>
  </interface>

The interface with <teaming type='persistent'/> is assumed to always
be present, while the interface with type='transient' may be be
unplugged and later re-plugged; the persistent='blah' attribute (and
in the one currently available implementation, also the matching MAC
addresses) is what associates the two devices with each other. It is
up to the hypervisor and the guest network drivers to determine what
to do with this information.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: add capabilities flag for failover feature
Laine Stump [Sun, 8 Dec 2019 19:22:34 +0000 (14:22 -0500)]
qemu: add capabilities flag for failover feature

Presence of the virtio-net-pci option called "failover" indicates
support in a qemu binary of a simplistic bonding of a virtio-net
device with another PCI device. This feature allows migration of
guests that have a network device assigned to a guest with VFIO, by
creating a network bond device in the guest consisting of the
VFIO-assigned device and a virtio-net-pci device, then temporarily
(and automatically) unplugging the VFIO net device prior to migration
(and hotplugging an equivalent device on the migration
destination). (The feature is called "failover" because the bond
device uses the vfio-pci netdev for normal guest networking, but
"fails over" to the virtio-net-pci netdev once the vfio-pci device is
unplugged for migration.)

Full functioning of the feature also requires support in the
virtio-net driver in the guest OS (since that is where the bond device
resides), but if the "failover" commandline option is present for the
virtio-net-pci device in qemu, at least the qemu part of the feature
is available, and libvirt can add the proper options to both the
virtio-net-pci and vfio-pci device commandlines to indicate qemu
should attempt doing the failover during migration.

This patch just adds the qemu capabilities flag "virtio-net.failover".

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobootstrap: remove 18 more gnulib modules
Daniel P. Berrangé [Wed, 22 Jan 2020 16:04:35 +0000 (16:04 +0000)]
bootstrap: remove 18 more gnulib modules

* chown: use is conditionally compiled
* configmake: functionality imported to Makefile.am
* getaddrinfo: we have no portability problems
  with Windows impl
* getpass: simplified impl is imported
* mgetgroups: getgrouplist is used directly
* net_if: header includes are conditionalized
* netdb: header includes are conditionalized
* passfd: simplified impl is imported
* posix-shell: functionality was unused & removed
* sigaction: usage is conditionalized
* sigpipe: usage is conditionalized
* stat-time: struct stat is used directly
* strchrnul: usage is eliminated
* strtok_r: usage is not a portability problem
* sys_stat: usage is conditionalized
* uname: rewritten to use native Win32 function to
  get host arch
* waitpid: usage is conditionalized
* wcwidth: rewritten using g_unichar APIs

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: conditionalize EAI_ADDRFAMILY
Daniel P. Berrangé [Thu, 23 Jan 2020 11:40:39 +0000 (11:40 +0000)]
src: conditionalize EAI_ADDRFAMILY

The EAI_ADDRFAMILY constant has been removed from FreeBSD
headers, supposedly because it is deprecated by new RFC
drafts.

Previously GNULIB was providing a replacement because
MinGW lacked it too. The replacement provided for MinGW
was thus being used on FreeBSD too, but with a completely
bogus integer value.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotests: conditionalize use of SIGPIPE
Daniel P. Berrangé [Wed, 22 Jan 2020 17:59:39 +0000 (17:59 +0000)]
tests: conditionalize use of SIGPIPE

SIGPIPE is not available on the Windows platform.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: convert all code to use virsocket.h
Daniel P. Berrangé [Tue, 14 Jan 2020 17:38:59 +0000 (17:38 +0000)]
src: convert all code to use virsocket.h

There are a large number of different header files that
are related to the sockets APIs. The virsocket.h header
includes all of the relevant headers for Windows and UNIX
in one convenient place. If virsocketaddr.h is already
included, then there's no need for virsocket.h

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: conditionalize use of chown & stat constants
Daniel P. Berrangé [Fri, 17 Jan 2020 11:24:19 +0000 (11:24 +0000)]
src: conditionalize use of chown & stat constants

chown and some stat constants are not available on
the Windows platform.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: conditionalize use of O_BINARY
Daniel P. Berrangé [Wed, 22 Jan 2020 11:48:05 +0000 (11:48 +0000)]
src: conditionalize use of O_BINARY

The O_BINARY flag is not defined on all platforms so we must
conditionalize its use once we remove GNULIB.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: conditionalize use of O_DIRECT
Daniel P. Berrangé [Wed, 22 Jan 2020 11:46:59 +0000 (11:46 +0000)]
src: conditionalize use of O_DIRECT

The O_DIRECT flag is not available on all platforms, so we
must introduce a compat define the same way gnulib does.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: conditionalize use of F_DUPFD_CLOEXEC
Daniel P. Berrangé [Wed, 22 Jan 2020 11:45:55 +0000 (11:45 +0000)]
src: conditionalize use of F_DUPFD_CLOEXEC

The F_DUPFD_CLOEXEC functionality is not available on
some platformms. We must thus explicitly call the
virSetCloexec function once we remove GNULIB's equiv
fix for this.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: ensure O_CLOEXEC is defined on Windows
Daniel P. Berrangé [Wed, 22 Jan 2020 11:44:16 +0000 (11:44 +0000)]
src: ensure O_CLOEXEC is defined on Windows

Windows uses _O_NOINHERIT as the name for its O_CLOEXEC
equivalent. Define O_CLOEXEC to match this to fix
portability when we remove GNULIB.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: stop using O_DIRECTORY in resctrl
Daniel P. Berrangé [Wed, 22 Jan 2020 11:42:18 +0000 (11:42 +0000)]
src: stop using O_DIRECTORY in resctrl

The O_DIRECTORY flag causes open() to return an error
if the filename is a directory. There's no obvious
reason why resctrl needs to use this, while the rest of
libvirt code does not. Removing it avoids build issues
on platforms where O_DIRECTORY is not defined, once we
remove GNULIB.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoconfigure: request system specific extensions
Daniel P. Berrangé [Wed, 22 Jan 2020 11:40:42 +0000 (11:40 +0000)]
configure: request system specific extensions

The AC_USE_SYSTEM_EXTENSIONS macro causes things like
"USE_GNU" to be defined, which enables access to OS
specific extensions to POSIX. We currently got this
indirectly via GNULIB's 'extensions' module which is
a dependancy of other GNULIB modules we use.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: conditionalize use of S_ISSOCK macro
Daniel P. Berrangé [Fri, 17 Jan 2020 11:17:49 +0000 (11:17 +0000)]
src: conditionalize use of S_ISSOCK macro

The S_ISSOCK macro is not available on Windows platforms.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoconfigure: add check for sys/ioctl.h
Daniel P. Berrangé [Fri, 17 Jan 2020 16:24:26 +0000 (16:24 +0000)]
configure: add check for sys/ioctl.h

We currently get the sys/ioctl.h check indirectly
via GNULIB, but this will soon stop happening.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: conditionalize use of net/if.h
Daniel P. Berrangé [Wed, 22 Jan 2020 11:48:45 +0000 (11:48 +0000)]
src: conditionalize use of net/if.h

The net/if.h is not portable so we must check for its
existance and avoid using it when missing. Some use
of net/if.h was redundant and could be removed.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoutil: conditionalize virProcess APIs on Windows
Daniel P. Berrangé [Thu, 16 Jan 2020 11:24:27 +0000 (11:24 +0000)]
util: conditionalize virProcess APIs on Windows

Many of the virProcess APIs are relying on GNULIB providing
POSIX API stubs. Even with these stubs the APIs don't do
anything useful once compiled. We can thus conditionalize
the code so that we don't compile anything at all.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: remove all traces of Cygwin support
Daniel P. Berrangé [Tue, 14 Jan 2020 18:34:26 +0000 (18:34 +0000)]
src: remove all traces of Cygwin support

Cygwin is not a supported build platform for libvirt and
has no testing coverage in our CI systems. Stop pretending
the code is usable and remove it so there is less to port
to Meson.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoutil: conditionalize more of virCommand on WIN32
Daniel P. Berrangé [Tue, 14 Jan 2020 10:44:32 +0000 (10:44 +0000)]
util: conditionalize more of virCommand on WIN32

A large part of the virCommand code is still built on
WIN32, despite the fact that the core fork() & execve()
functions are not available. So despite succesfully
building most of the code, at runtime the APIs are
none the less unusuable. With the elimination of GNULIB
many of the APIs being used in this code no longer have
portability wrappers/shims for Windows.

Rather than try to add portability wrappers, or do tests
for each individual function, it is clearer to conditionalize
nearly all of the code using #ifdef WIN32.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agom4: disable polkit build on Windows
Daniel P. Berrangé [Fri, 17 Jan 2020 18:28:03 +0000 (18:28 +0000)]
m4: disable polkit build on Windows

polkit is only useful on Linux systems

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: replace mkdir() with g_mkdir()
Daniel P. Berrangé [Fri, 17 Jan 2020 11:21:29 +0000 (11:21 +0000)]
src: replace mkdir() with g_mkdir()

g_mkdir() provides portability to Windows platforms.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: only import sys/uio.h when journald is built
Daniel P. Berrangé [Wed, 22 Jan 2020 11:49:45 +0000 (11:49 +0000)]
src: only import sys/uio.h when journald is built

The sys/uio.h header is only needed when building logging
code with journald support enabled. Conditionally include
it so that we avoid break on platforms which lack this
header.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agorpc: conditionalize signal handling
Daniel P. Berrangé [Fri, 17 Jan 2020 11:16:48 +0000 (11:16 +0000)]
rpc: conditionalize signal handling

The Windows platform does not have the signal handling
support we need, so it must be disabled in several parts
of the codebase.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: implement APIs for passing FDs over UNIX sockets
Daniel P. Berrangé [Fri, 17 Jan 2020 11:57:17 +0000 (11:57 +0000)]
src: implement APIs for passing FDs over UNIX sockets

This is a simplified variant of gnulib's passfd module
without the portability code that we do not require.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agostorage: remove use of stat-time.h headers
Daniel P. Berrangé [Wed, 22 Jan 2020 11:38:28 +0000 (11:38 +0000)]
storage: remove use of stat-time.h headers

The gnulib stat-time.h header provides wrapper functions
to hide the differences in 'struct stat' between various
platforms.

Linux and FreeBSD support the same names, except for
birthtime which Linux only provides in the new 'statx()'
syscall we're not using. macOS has completely different
naming. Since we only rely on this code in one place
we just use conditionals at time of need.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoutil: explicitly include windows.h
Daniel P. Berrangé [Fri, 17 Jan 2020 17:32:05 +0000 (17:32 +0000)]
util: explicitly include windows.h

The virProcess code relies on windows.h and is getting it
indirectly via some GNULIB header fixes. This dependancy
needs to be made explicit.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: remove unused sys/utsname.h includes
Daniel P. Berrangé [Fri, 17 Jan 2020 17:31:51 +0000 (17:31 +0000)]
src: remove unused sys/utsname.h includes

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotools: replace wcwidth() with g_unichar_* APIs
Daniel P. Berrangé [Fri, 17 Jan 2020 13:40:54 +0000 (13:40 +0000)]
tools: replace wcwidth() with g_unichar_* APIs

The combination of g_unichar_iszerowidth and
g_unichar_iswide is sufficient to replicate the logic
of wcwidth() for libvirt.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoutil: use getgrouplist() directly instead of mgetgroups
Daniel P. Berrangé [Fri, 17 Jan 2020 12:33:37 +0000 (12:33 +0000)]
util: use getgrouplist() directly instead of mgetgroups

The mgetgroups function is a GNULIB custom wrapper around
getgrouplist(). This implements a simplified version of
that code directly.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: generate configmake.h in root directory
Daniel P. Berrangé [Fri, 17 Jan 2020 11:32:09 +0000 (11:32 +0000)]
build: generate configmake.h in root directory

Currently we rely on gnulib creating configmake.h, but we
can easily create it ourselves instead.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: remove usage of strchrnul function
Daniel P. Berrangé [Tue, 14 Jan 2020 10:43:37 +0000 (10:43 +0000)]
src: remove usage of strchrnul function

The strchrnul function doesn't exist on Windows and rather
than attempt to implement it, it is simpler to just avoid
its usage, as any callers are easily adapted.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoutil: add API for reading password from the console
Daniel P. Berrangé [Tue, 14 Jan 2020 10:40:52 +0000 (10:40 +0000)]
util: add API for reading password from the console

This imports a simpler version of GNULIB's getpass() function
impl for Windows. Note that GNULIB's impl was buggy as it
returned a static string on UNIX, and a heap allocated string
on Windows. This new impl always heap allocates.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoutil: add a virArchFromHost() impl for Windows
Daniel P. Berrangé [Thu, 16 Jan 2020 10:51:35 +0000 (10:51 +0000)]
util: add a virArchFromHost() impl for Windows

Instead of relying on GNULIb's uname() impl, directly use the
Windows API for determining CPU architecture.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotests: stop setting $SHELL env variable
Daniel P. Berrangé [Thu, 16 Jan 2020 10:50:35 +0000 (10:50 +0000)]
tests: stop setting $SHELL env variable

None of the tests appear to reference a SHELL env variable
explicitly and they all succeeed when it is not set. This
eliminates the only use of the gnulib posix-shell module.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agodocs: add warning about virt-qemu-run being experimental
Daniel P. Berrangé [Wed, 29 Jan 2020 11:17:54 +0000 (11:17 +0000)]
docs: add warning about virt-qemu-run being experimental

We currently note that the QEMU embedded driver is experimental
in the drvqemu.html file, but we should do the same in the
virt-qemu-run man page.

Reviewed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosecurity: do not remember/recall labels for VFIO
Daniel Henrique Barboza [Mon, 27 Jan 2020 18:23:21 +0000 (15:23 -0300)]
security: do not remember/recall labels for VFIO

Files inside /dev/vfio/ can't be opened more than once, meaning
that any subsequent open calls will fail. This behavior was
introduced in kernel v3.11, commit 6d6768c61b39.

When using the VFIO driver, we open a FD to /dev/vfio/N and
pass it to QEMU. If any other call attempt for the same
/dev/vfio/N happens while QEMU is still using the file, we are
unable to open it and QEMU will report -EBUSY. This can happen
if we hotplug a PCI hostdev that belongs to the same IOMMU group
of an existing domain hostdev.

The problem and solution is similar to what we already dealt
with for TPM in commit 4e95cdcbb3. This patch changes both
DAC and SELinux drivers to disable 'remember' for VFIO hostdevs
in virSecurityDACSetHostdevLabelHelper() and
virSecurityDACSetHostdevLabel(), and 'recall'
in virSecurityDACRestoreHostdevLabel() and
virSecuritySELinuxRestoreHostdevSubsysLabel().

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agosecurity: Allow 'remember' to be set for HostdevLabelHelper
Daniel Henrique Barboza [Mon, 27 Jan 2020 18:23:20 +0000 (15:23 -0300)]
security: Allow 'remember' to be set for HostdevLabelHelper

There is a case in which we do not want 'remember' to be
set to true in SetOwnership() calls inside the
HostdevLabelHelper() functions of both DAC and SELinux drivers.
Next patch will explain and handle that scenario.

For now, let's make virSecurityDACSetOwnership() and
virSecuritySELinuxSetHostdevLabelHelper() accept a 'remember'
flag, which will be used to set the 'remember' parameter
of their respective SetOwnership() calls. No functional
change is made.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agodocs: use --strict arg when processing rst docs
Daniel P. Berrangé [Wed, 29 Jan 2020 10:17:45 +0000 (10:17 +0000)]
docs: use --strict arg when processing rst docs

The --strict arg forces the rst tools to abort with an error instead
of printing warnings to stderr, or the output document.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agodocs: fix various duplicate link targets in virsh.rst
Daniel P. Berrangé [Wed, 29 Jan 2020 10:16:03 +0000 (10:16 +0000)]
docs: fix various duplicate link targets in virsh.rst

You can't have two links with the same text when using named
link references (a single "_"). If you need multiple links
with the same text you must use anonymous link references
(a double "_").

There are also some duplicate section headers causing the
same problem with duplicate link targets.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: when leaving iotune group update xml properly
Nikolay Shirokovskiy [Wed, 8 Jan 2020 06:49:31 +0000 (09:49 +0300)]
qemu: when leaving iotune group update xml properly

Currently when disk is removed from iotune group (by setting
all tunables to zero) group name is leaved in config. Let's fix
it.

Given iotune defaults are taken from the destination group setting
tunables to zero may require different set of zero settings in API
call. Let's prohibit removing from group while specifying different
group name then current for the sanity sake.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: get defaults from iotune group we move disk into
Nikolay Shirokovskiy [Wed, 8 Jan 2020 06:49:30 +0000 (09:49 +0300)]
qemu: get defaults from iotune group we move disk into

For example if disk is not in the group and we want to move it
there then it makes sense to specify only the group name in API call.
Currently the destination group iotune settings will be overwritten
with the disk settings which I would say is not what one would expect.
Thus let's get defaults from the group we are moving to.

And if we are moving the brand new group then is makes sense to
copy the current disk iotune settings to the group.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: fix using defaults when setting persistent iotune params
Nikolay Shirokovskiy [Wed, 8 Jan 2020 06:49:28 +0000 (09:49 +0300)]
qemu: fix using defaults when setting persistent iotune params

virDomainSetBlockIoTune not simply sets the iotune params given in API
but use current settings for all the omitted params. Unfortunately
it uses current settings for active config when setting inactive
params. Let's fix it.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: check iotune params same for all disk in group
Nikolay Shirokovskiy [Wed, 8 Jan 2020 06:49:27 +0000 (09:49 +0300)]
qemu: check iotune params same for all disk in group

Currently it is possible to start a domain which have disks
in same iotune group and at the same time having different iotune
params. Both params set are passed to qemu in command line and the one
that is passed later down command line is get actually set.
Let's prohibit such configurations.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: propagate iotune settings to all disks in the group
Nikolay Shirokovskiy [Wed, 8 Jan 2020 06:49:29 +0000 (09:49 +0300)]
qemu: propagate iotune settings to all disks in the group

Currently upon successfull call to qemu's implementation of
virDomainSetBlockIoTune iotune settings are changed only for the
disk given in API if the disk is in iotune group while we need
to change the settings for all disks in the group.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconf: expand iotune params if only group name is given
Nikolay Shirokovskiy [Wed, 8 Jan 2020 06:49:26 +0000 (09:49 +0300)]
conf: expand iotune params if only group name is given

Currently, if only iotune group name is given for some disk and
no any params then later start of domain will fail. I guess it
will be convenient to allow such configuration if there is
another disk in the same iotune group with iotune params set. The
meaning is that the first disk have same iotunes and the latter.
Thus one can easily add a disk to iotune group - just add group
name parameter and no need to copy all the params.

Also let's expand iotunes params in the described case so we don't
need to refer to another disk to know iotunes and this will make
logic in many places simple.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Move qemuDiskConfigBlkdeviotuneHas* to conf
Nikolay Shirokovskiy [Wed, 8 Jan 2020 06:49:25 +0000 (09:49 +0300)]
qemu: Move qemuDiskConfigBlkdeviotuneHas* to conf

And introduce virDomainBlockIoTuneInfoHasAny.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agodocs: secret: Unify and sanitize examples on how to set secret value
Peter Krempa [Fri, 10 Jan 2020 15:35:11 +0000 (16:35 +0100)]
docs: secret: Unify and sanitize examples on how to set secret value

Discourage passing secrets as commandline arguments.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotools: virsh: Add --interactive flag for secret-set-value command
Peter Krempa [Fri, 24 Jan 2020 15:37:27 +0000 (16:37 +0100)]
tools: virsh: Add --interactive flag for secret-set-value command

Simplify human usage of secret-set-value by adding --interactive which
will read the value of the secret from the terminal.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovirsh: secret: Add --plain switch for secret-set-value
Peter Krempa [Fri, 24 Jan 2020 15:28:19 +0000 (16:28 +0100)]
virsh: secret: Add --plain switch for secret-set-value

Allow using the contents of --file without base64 decoding.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovirsh: secret: Print warning that passing secret on command-line is insecure
Peter Krempa [Fri, 24 Jan 2020 15:16:27 +0000 (16:16 +0100)]
virsh: secret: Print warning that passing secret on command-line is insecure

Print a warning if users pass in secrets as command line arguments and
mention it in the man page.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovirsh: secret: Add --file 'filename' support for secret-set-value
Peter Krempa [Fri, 10 Jan 2020 14:54:05 +0000 (15:54 +0100)]
virsh: secret: Add --file 'filename' support for secret-set-value

The necessity to specify the secret value as command argument is
insecure. Allow reading the secret from a file.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovirsh: secret: Add --plain flag for secret-get-value
Peter Krempa [Fri, 10 Jan 2020 14:12:16 +0000 (15:12 +0100)]
virsh: secret: Add --plain flag for secret-get-value

Users might want to get the raw value instead of dealing with base64
encoding. This might be useful for redirection to file and also for
simple human-readable secrets.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovirsh: secret: Refactor cleanup in cmdSecretGetValue
Peter Krempa [Fri, 24 Jan 2020 14:42:02 +0000 (15:42 +0100)]
virsh: secret: Refactor cleanup in cmdSecretGetValue

Automatically clean the secret object and get rid of the cleanup label
and 'ret' valiable.

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