]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
4 years agonodedev: Build a non-loadable driver lib
Jonathon Jongsma [Thu, 18 Jun 2020 21:06:00 +0000 (16:06 -0500)]
nodedev: Build a non-loadable driver lib

In order to test the nodedev driver, we need to link against a
non-loadable module. Similar to other loadable modules already in the
repository, create an _impl library that can be linked against the unit
tests and then create a loadable module from that.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agonodedev: add mdev support to virNodeDeviceCreateXML()
Jonathon Jongsma [Thu, 18 Jun 2020 21:05:59 +0000 (16:05 -0500)]
nodedev: add mdev support to virNodeDeviceCreateXML()

With recent additions to the node device xml schema, an xml schema can
now describe a mdev device sufficiently for libvirt to create and start
the device using the mdevctl utility.

Note that some of the the configuration for a mediated device must be
passed to mdevctl as a JSON-formatted file. In order to avoid creating
and cleaning up temporary files, the JSON is instead fed to stdin and we
pass the filename /dev/stdin to mdevctl. While this may not be portable,
neither are mediated devices, so I don't believe it should cause any
problems.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agonodedev: store mdev UUID in mdev caps
Jonathon Jongsma [Thu, 18 Jun 2020 21:05:58 +0000 (16:05 -0500)]
nodedev: store mdev UUID in mdev caps

In order to allow libvirt to create and start new mediated devices, we
need to be able to verify that the device has been started. In order to
do this, we'll need to save the UUID of newly-discovered devices within
the virNodeDevCapMdev structure. This allows us to search the device
list by UUID and verify whether the expected device has been started.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agonodedev: refactor nodeDeviceFindNewDevice()
Jonathon Jongsma [Thu, 18 Jun 2020 21:05:57 +0000 (16:05 -0500)]
nodedev: refactor nodeDeviceFindNewDevice()

In preparation for creating mediated devices in libvirt, we will need to
wait for new mediated devices to be created as well. Refactor
nodeDeviceFindNewDevice() so that we can re-use the main logic from this
function to wait for different device types by passing a different
'find' function.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agonodedev: add support for mdev attributes
Jonathon Jongsma [Thu, 18 Jun 2020 21:05:56 +0000 (16:05 -0500)]
nodedev: add support for mdev attributes

Mediated devices support arbitrary vendor-specific attributes that can
be attached to a mediated device. These attributes are ordered, and are
written to sysfs in order after a device is created. This patch adds
support for these attributes to the mdev data types and XML schema.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agonodedev: factor out nodeDeviceHasCapability()
Jonathon Jongsma [Thu, 18 Jun 2020 21:05:55 +0000 (16:05 -0500)]
nodedev: factor out nodeDeviceHasCapability()

Currently nodeDeviceCreateXML() and nodeDeviceDestroy() only support
NPIV HBAs, but we want to be able to create mdev devices as well. This
is a first step to enabling that support.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agonodedev: make iommuGroup optional for mdevs
Jonathon Jongsma [Thu, 18 Jun 2020 21:05:54 +0000 (16:05 -0500)]
nodedev: make iommuGroup optional for mdevs

When parsing a nodedev xml file, the iommuGroup element should be
optional. This element should be read-only and is determined by the
device driver. While this is a change to existing behavior, it doesn't
break backwards-compatibility because it makes the parser less strict.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoFix allocation of virDomainFSDef
Ján Tomko [Thu, 18 Jun 2020 09:58:29 +0000 (11:58 +0200)]
Fix allocation of virDomainFSDef

Some less commonly used drivers were omitted when we switched
the allocator from a plain VIR_ALLOC to virDomainFSDefNew.

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

Fixes: da665fbd4858890fbb3bbf5da2a7b6ca37bb3220
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
4 years agoutil: remove outdated comment from virLogFormatString
Ján Tomko [Thu, 18 Jun 2020 13:07:28 +0000 (15:07 +0200)]
util: remove outdated comment from virLogFormatString

Introduced by commit 72ab0b6dc8129a388aff260a6e444d48495b0e93 which
added some code depending on libvirt's log format string into
qemuProcessReadLogOutput. This function was deleted by commit
932534e85f34a479c7eac174e997bfd9c85bd22d later.

Drop the comment.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Closes: https://gitlab.com/libvirt/libvirt/-/issues/35
4 years agoqemuSecurityDomainRestorePathLabel: Introduce @ignoreNS argument
Michal Privoznik [Wed, 17 Jun 2020 10:37:06 +0000 (12:37 +0200)]
qemuSecurityDomainRestorePathLabel: Introduce @ignoreNS argument

In a few cases we might set seclabels on a path outside of
namespaces. For instance, when restoring a domain from a file,
the file is opened, relabelled and only then the namespace is
created and the FD is passed to QEMU (see v6.3.0-rc1~108 for more
info). Therefore, when restoring the label on the restore file,
we must ignore domain namespaces and restore the label directly
in the host.

This bug demonstrates itself when restoring a domain from a block
device. We don't create the block device inside the domain
namespace and thus the following error is reported at the end of
(otherwise successful) restore:

error : virProcessRunInFork:1236 : internal error: child reported (status=125): unable to stat: /dev/sda: No such file or directory
error : virProcessRunInFork:1240 : unable to stat: /dev/sda: No such file or directory

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agoqemu: Rename qemuSecurityRestoreSavedStateLabel()
Michal Privoznik [Wed, 17 Jun 2020 10:40:28 +0000 (12:40 +0200)]
qemu: Rename qemuSecurityRestoreSavedStateLabel()

The function calls virSecurityManagerDomainRestorePathLabel()
after all.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agosecurity: Rename virSecurityManagerRestoreSavedStateLabel()
Michal Privoznik [Wed, 17 Jun 2020 09:32:53 +0000 (11:32 +0200)]
security: Rename virSecurityManagerRestoreSavedStateLabel()

The new name is virSecurityManagerDomainRestorePathLabel().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agosecurity: Drop unused virSecurityManagerSetSavedStateLabel()
Michal Privoznik [Wed, 17 Jun 2020 09:12:30 +0000 (11:12 +0200)]
security: Drop unused virSecurityManagerSetSavedStateLabel()

After previous commit this function is used no more.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agoqemu: Drop unused qemuSecuritySetSavedStateLabel()
Michal Privoznik [Wed, 17 Jun 2020 09:10:49 +0000 (11:10 +0200)]
qemu: Drop unused qemuSecuritySetSavedStateLabel()

After previous commit this function is used no more.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agoqemu: Use qemuSecurityDomainSetPathLabel() to set seclabes on not saved state files
Michal Privoznik [Wed, 17 Jun 2020 09:01:05 +0000 (11:01 +0200)]
qemu: Use qemuSecurityDomainSetPathLabel() to set seclabes on not saved state files

There are two places within qemu driver that misuse
qemuSecuritySetSavedStateLabel() to set seclabels on tempfiles
that are not state files: qemuDomainScreenshot() and
qemuDomainMemoryPeek(). They are doing so because of lack of
qemuSecurityDomainSetPathLabel() at the time of their
introduction.

In all three secdrivers (well, four if you count NOP driver) the
implementation of .domainSetSavedStateLabel and
.domainSetPathLabel callbacks is the same anyway.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agoNEWS.rst: document the 'auto-fill' feature
Daniel Henrique Barboza [Thu, 18 Jun 2020 11:12:25 +0000 (08:12 -0300)]
NEWS.rst: document the 'auto-fill' feature

Although this can be considered a new feature, from the user
standpoint is more of a QoL improvement.

Suggested-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoformatdomain.html.in: document the NUMA cpus auto fill feature
Daniel Henrique Barboza [Wed, 10 Jun 2020 18:35:53 +0000 (15:35 -0300)]
formatdomain.html.in: document the NUMA cpus auto fill feature

We're not mentioning that we're replicating QEMU behavior on purpose.
First because QEMU will one day, maybe, change the behavior and
start to refuse incomplete NUMA setups, and then our documentation
is now deprecated. Second, auto filling the CPUs in the first
cell will work regardless of QEMU changes in the future.

The idea is to encourage the user to provide a complete NUMA CPU topology,
not relying on the CPU auto fill mechanic.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuxml2xmltest.c: add NUMA vcpus auto fill tests
Daniel Henrique Barboza [Wed, 10 Jun 2020 18:35:52 +0000 (15:35 -0300)]
qemuxml2xmltest.c: add NUMA vcpus auto fill tests

Add a unit test to verify the NUMA vcpus autocomplete implemented
in the previous patch.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu_domain.c: NUMA CPUs auto-fill for incomplete topologies
Daniel Henrique Barboza [Wed, 10 Jun 2020 18:35:51 +0000 (15:35 -0300)]
qemu_domain.c: NUMA CPUs auto-fill for incomplete topologies

Libvirt allows the user to define an incomplete NUMA topology, where
the sum of all CPUs in each cell is less than the total of VCPUs.
What ends up happening is that QEMU allocates the non-enumerated CPUs
in the first NUMA node. This behavior is being flagged as 'to be
deprecated' at least since QEMU commit ec78f8114bc4 ("numa: use
possible_cpus for not mapped CPUs check").

In [1], Maxiwell suggested that we forbid the user to define such
topologies. In his review [2], Peter Krempa pointed out that we can't
break existing guests, and suggested that Libvirt should emulate the
QEMU behavior of putting the remaining vCPUs in the first NUMA node
in these cases.

This patch implements Peter Krempa's suggestion. Since we're going
to most likely end up with disjointed NUMA configuration in node 0
after the auto-fill, we're making auto-fill dependent on QEMU_CAPS_NUMA.

A following patch will update the documentation not just to inform
about the auto-fill mechanic with incomplete NUMA topologies, but also
to discourage the user to create such topologies in the future. This
approach also makes Libvirt independent of whether QEMU changes
its current behavior since we're either auto-filling the CPUs in
node 0 or the user (hopefully) is aware that incomplete topologies,
although supported in Libvirt, are to be avoided.

[1] https://www.redhat.com/archives/libvir-list/2019-June/msg00224.html
[2] https://www.redhat.com/archives/libvir-list/2019-June/msg00263.html

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agonuma_conf.c: add helper functions for cpumap operations
Daniel Henrique Barboza [Wed, 10 Jun 2020 18:35:50 +0000 (15:35 -0300)]
numa_conf.c: add helper functions for cpumap operations

These helpers will be used in an auto-fill feature for incomplete
NUMA topologies in the next patch.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoci: Makefile: Mention CI_MAKE_ARGS and CI_CONFIGURE_ARGS in ci-help
Erik Skultety [Wed, 17 Jun 2020 14:17:52 +0000 (16:17 +0200)]
ci: Makefile: Mention CI_MAKE_ARGS and CI_CONFIGURE_ARGS in ci-help

Document the CI_MAKE_ARGS and CI_CONFIGURE_ARGS so that users don't have
to skim through the Makefile to be able to pass arbitrary recognized
make targets to the build system.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
4 years agolxc: drop compat code for capability constants
Daniel P. Berrangé [Wed, 17 Jun 2020 10:59:19 +0000 (11:59 +0100)]
lxc: drop compat code for capability constants

Given our supported platform matrix, we can safely assume that
all the capability constants we need are defined by the system
headers.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agolxc: drop compat code for clone constants
Daniel P. Berrangé [Wed, 17 Jun 2020 10:59:19 +0000 (11:59 +0100)]
lxc: drop compat code for clone constants

Given our supported platform matrix, we can safely assume that
all the clone constants we need are defined by the system
headers.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agolxc: drop compat code for mount constants
Daniel P. Berrangé [Wed, 17 Jun 2020 10:59:19 +0000 (11:59 +0100)]
lxc: drop compat code for mount constants

Given our supported platform matrix, we can safely assume that
all the mount constants we need are defined by the system
headers.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: do not add model when actual iface type is hostdev
Paulo de Rezende Pinatti [Tue, 16 Jun 2020 14:32:10 +0000 (16:32 +0200)]
qemu: do not add model when actual iface type is hostdev

No default model should be added to the interface
entry at post parse when its actual network type is hostdev
as doing so might cause a mismatch between the interface
definition and its actual device type.

Signed-off-by: Paulo de Rezende Pinatti <ppinatti@linux.ibm.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agoUpdate translation files
Weblate [Fri, 5 Jun 2020 14:06:02 +0000 (16:06 +0200)]
Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

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

Signed-off-by: Fedora Weblate Translation <i18n@lists.fedoraproject.org>
Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

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

Signed-off-by: Fedora Weblate Translation <i18n@lists.fedoraproject.org>
4 years agoTranslated using Weblate (Ukrainian)
Yuri Chornoivan [Fri, 5 Jun 2020 14:05:59 +0000 (16:05 +0200)]
Translated using Weblate (Ukrainian)

Currently translated at 100.0% (10291 of 10291 strings)

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

Signed-off-by: Yuri Chornoivan <yurchor@ukr.net>
Translated using Weblate (Ukrainian)

Currently translated at 97.7% (10056 of 10291 strings)

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

Signed-off-by: Yuri Chornoivan <yurchor@ukr.net>
4 years agospec: Require Fedora 31
Andrea Bolognani [Wed, 17 Jun 2020 08:02:09 +0000 (10:02 +0200)]
spec: Require Fedora 31

Fedora 30 has been EOL for almost a month now.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoci: Makefile: Fix 'overridde' typo
Erik Skultety [Wed, 17 Jun 2020 09:45:22 +0000 (11:45 +0200)]
ci: Makefile: Fix 'overridde' typo

Signed-off-by: Erik Skultety <eskultet@redhat.com>
4 years agoqemu: Avoid deprecated migrate-set-cache-size QMP command
Jiri Denemark [Wed, 10 Jun 2020 14:13:15 +0000 (16:13 +0200)]
qemu: Avoid deprecated migrate-set-cache-size QMP command

The same functionality can be achieved using migrate-set-parameters QMP
command with xbzrle-cache-size parameter.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemu: Avoid deprecated query-migrate-cache-size QMP command
Jiri Denemark [Wed, 10 Jun 2020 14:13:15 +0000 (16:13 +0200)]
qemu: Avoid deprecated query-migrate-cache-size QMP command

The same functionality can be achieved using query-migrate-parameters
QMP command and checking the xbzrle-cache-size parameter.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemu: Avoid deprecated migrate_set_downtime QMP command
Jiri Denemark [Wed, 10 Jun 2020 14:13:15 +0000 (16:13 +0200)]
qemu: Avoid deprecated migrate_set_downtime QMP command

The same functionality can be achieved using migrate-set-parameters QMP
command with downtime-limit parameter.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemu: Avoid deprecated migrate_set_speed QMP command
Jiri Denemark [Wed, 10 Jun 2020 14:13:15 +0000 (16:13 +0200)]
qemu: Avoid deprecated migrate_set_speed QMP command

The same functionality can be achieved using migrate-set-parameters QMP
command with max-bandwidth parameter.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemu: Probe for a few params supported by migrate-set-parameters
Jiri Denemark [Wed, 10 Jun 2020 13:09:00 +0000 (15:09 +0200)]
qemu: Probe for a few params supported by migrate-set-parameters

These parameters were originally set via dedicated commands which are
now deprecated. We want to use migrate-set-parameters instead if
possible.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirsysinfo: Don't leak fw_cfg
Michal Privoznik [Tue, 16 Jun 2020 11:01:38 +0000 (13:01 +0200)]
virsysinfo: Don't leak fw_cfg

In v6.4.0-72-g3dda889a44 I've introduced parsing and formatting
of new sysinfo type 'fwcfg'. However, I've forgot to introduce
code that would free parsed data.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoqemuDomainSetNumaParamsLive: set nodeset for root cgroup
Daniel Henrique Barboza [Thu, 11 Jun 2020 18:54:57 +0000 (15:54 -0300)]
qemuDomainSetNumaParamsLive: set nodeset for root cgroup

This function handles the change of NUMA nodeset for a given
guest, setting CpusetMems for the emulator, vcpus and IOThread
sub-groups. It doesn't set the same  nodeset to the root cgroup
though. This means that cpuset.mems of the root cgroup ends up
holding the new nodeset and the old nodeset as well. For
a guest with placement=strict, nodeset='0', doing

virsh numatune <vm> 0 8 --live

Will make cpuset.mems of emulator, vcpus and iothread to be
"8", but cpuset.mems of the root cgroup will be "0,8".

This means that any new tasks that ends up landing in the
root cgroup, aside from the emulator/vcpus/iothread sub-groups,
will be split between the old nodeset and the new nodeset,
which is not what we want.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoconf: Fix memory leak in virCPUDefParseXML
John Ferlan [Tue, 16 Jun 2020 12:07:09 +0000 (08:07 -0400)]
conf: Fix memory leak in virCPUDefParseXML

Since a08669c31, @tsc is not automatically free'd by any g_auto* method.

Found by Coverity.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoconf: Fix memory leak in openvzReadFSConf
John Ferlan [Tue, 16 Jun 2020 12:07:08 +0000 (08:07 -0400)]
conf: Fix memory leak in openvzReadFSConf

Since 1f5deed9, @veid_str has been leaked in the error path.

Found by Coverity.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoconf: Fix memory leak in openvzWriteConfigParam
John Ferlan [Tue, 16 Jun 2020 12:07:07 +0000 (08:07 -0400)]
conf: Fix memory leak in openvzWriteConfigParam

Since 60623a7c, @temp_file was not properly free'd on the non error path.

Found by Coverity.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agotest: Fix memory leak in testParseXMLDocFromFile
John Ferlan [Tue, 16 Jun 2020 12:07:06 +0000 (08:07 -0400)]
test: Fix memory leak in testParseXMLDocFromFile

Since ceb3255c, @absFile is leaked.

Found by Coverity.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoutil: Fix memory leak in virPCIProbeStubDriver
John Ferlan [Tue, 16 Jun 2020 12:07:05 +0000 (08:07 -0400)]
util: Fix memory leak in virPCIProbeStubDriver

Since 9ea90206, @drvpath could be overwritten if we jumped to recheck

Found by Coverity.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agolxc: Fix memory leak in virLXCControllerPopulateDevices
John Ferlan [Tue, 16 Jun 2020 12:07:04 +0000 (08:07 -0400)]
lxc: Fix memory leak in virLXCControllerPopulateDevices

Since 5b82f7f3, @path should have been placed inside the for loop
since it'd need to be free'd for each pass through the loop; otherwise,
we'd leak like a sieve.

Found by Coverity.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoutil: Fix memory leak in virAuthConfigLookup
John Ferlan [Tue, 16 Jun 2020 12:07:03 +0000 (08:07 -0400)]
util: Fix memory leak in virAuthConfigLookup

Since 5084091a, @authcred is filled by a g_key_file_get_string which is
now an allocated string as opposed to some hash table lookup value, so
we need to treat it as so.

Found by Coverity

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoutil: Fix memory leak in virAuthGetCredential
John Ferlan [Tue, 16 Jun 2020 12:07:02 +0000 (08:07 -0400)]
util: Fix memory leak in virAuthGetCredential

Since 5084091a, @tmp is filled by a g_key_file_get_string which is
now an allocated string as opposed to some hash table lookup value,
so we need to treat it as so.

Found by Coverity

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agomanpages/virsh.rst: clarify numatune memory migration on Linux
Daniel Henrique Barboza [Thu, 11 Jun 2020 17:00:29 +0000 (14:00 -0300)]
manpages/virsh.rst: clarify numatune memory migration on Linux

On Linux, changing the nodeset on 'numatune' does not imply that
the guest memory will be migrated on the spot to the new nodeset.
The memory migration is tied on guest usage of the memory pages,
and an idle guest will take longer to have its memory migrated
to the new nodeset.

This is a behavior explained in detail in the Linux kernel
documentation in Documentation/admin-guide/cgroup-v1/cpusets.rst.
The user doesn't need this level of detail though - just needs
his/her expectations under check. Running 'numastat' and hoping
for instant memory migration from the previous nodeset to the new
one is not viable.

There's also parts of the memory that are locked by QEMU in the
same place, e.g. when VFIO devices are present. Let's also
mention it as another factor that impacts the results the
user might expect from NUMA memory migration with numatune.

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

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
4 years agovirQEMUDriverConfigNew: Add slash to cfg->defaultTLSx509certdir for non-embedded...
Peter Krempa [Tue, 16 Jun 2020 10:36:55 +0000 (12:36 +0200)]
virQEMUDriverConfigNew: Add slash to cfg->defaultTLSx509certdir for non-embedded driver

Commit 068efae5b1a9ef accidentally removed the slash.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
4 years agoqemuxml2*test: Add cases for CPU pinning to large host CPU IDs
Jiri Denemark [Thu, 11 Jun 2020 11:57:07 +0000 (13:57 +0200)]
qemuxml2*test: Add cases for CPU pinning to large host CPU IDs

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoconf: Increase cpuset length limit for CPU pinning
Jiri Denemark [Thu, 11 Jun 2020 11:53:27 +0000 (13:53 +0200)]
conf: Increase cpuset length limit for CPU pinning

Domains are now allowed to be pinned to host CPUs with IDs up to 16383.
The new limit is as arbitrary as the old one. It's just bigger.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agodocs: Describe protected virtualization guest setup
Viktor Mihajlovski [Mon, 15 Jun 2020 08:28:12 +0000 (10:28 +0200)]
docs: Describe protected virtualization guest setup

Protected virtualization/IBM Secure Execution for Linux protects
guest memory and state from the host.

Add some basic information about technology and a brief guide
on setting up secure guests with libvirt.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.ibm.com>
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Paulo de Rezende Pinatti <ppinatti@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agodocs: Update AMD launch secure description
Boris Fiuczynski [Mon, 15 Jun 2020 08:28:11 +0000 (10:28 +0200)]
docs: Update AMD launch secure description

Update document with changes in qemu capability caching and the added
secure guest support checking for AMD SEV in virt-host-validate.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agotools: Secure guest check for AMD in virt-host-validate
Boris Fiuczynski [Mon, 15 Jun 2020 08:28:10 +0000 (10:28 +0200)]
tools: Secure guest check for AMD in virt-host-validate

Add checking in virt-host-validate for secure guest support
on x86 for AMD Secure Encrypted Virtualization.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Paulo de Rezende Pinatti <ppinatti@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agotools: Secure guest check on s390 in virt-host-validate
Boris Fiuczynski [Mon, 15 Jun 2020 08:28:09 +0000 (10:28 +0200)]
tools: Secure guest check on s390 in virt-host-validate

Add checking in virt-host-validate for secure guest support
on s390 for IBM Secure Execution.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Tested-by: Viktor Mihajlovski <mihajlov@linux.ibm.com>
Reviewed-by: Paulo de Rezende Pinatti <ppinatti@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agoqemu: Check if AMD secure guest support is enabled
Paulo de Rezende Pinatti [Mon, 15 Jun 2020 08:28:08 +0000 (10:28 +0200)]
qemu: Check if AMD secure guest support is enabled

Implement secure guest check for AMD SEV (Secure Encrypted
Virtualization) in order to invalidate the qemu capabilities
cache in case the availability of the feature changed.

For AMD SEV the verification consists of:
 - checking if /sys/module/kvm_amd/parameters/sev contains the
   value '1': meaning SEV is enabled in the host kernel;
 - checking if /dev/sev exists

Signed-off-by: Paulo de Rezende Pinatti <ppinatti@linux.ibm.com>
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agoqemu: Check if s390 secure guest support is enabled
Paulo de Rezende Pinatti [Mon, 15 Jun 2020 08:28:07 +0000 (10:28 +0200)]
qemu: Check if s390 secure guest support is enabled

This patch introduces a common function to verify if the
availability of the so-called Secure Guest feature on the host
has changed in order to invalidate the qemu capabilities cache.
It can be used as an entry point for verification on different
architectures.

For s390 the verification consists of:
- checking if /sys/firmware/uv is available: meaning the HW
facility is available and the host OS supports it;
- checking if the kernel cmdline contains 'prot_virt=1': meaning
the host OS wants to use the feature.

Whenever the availability of the feature does not match the secure
guest flag in the cache then libvirt will re-build it in order to
pick up the new set of capabilities available.

Signed-off-by: Paulo de Rezende Pinatti <ppinatti@linux.ibm.com>
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Tested-by: Viktor Mihajlovski <mihajlov@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agoutil: Introduce a parser for kernel cmdline arguments
Paulo de Rezende Pinatti [Mon, 15 Jun 2020 08:28:06 +0000 (10:28 +0200)]
util: Introduce a parser for kernel cmdline arguments

Introduce two utility functions to parse a kernel command
line string according to the kernel code parsing rules in
order to enable the caller to perform operations such as
verifying whether certain argument=value combinations are
present or retrieving an argument's value.

Signed-off-by: Paulo de Rezende Pinatti <ppinatti@linux.ibm.com>
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agoconf: use g_steal_pointer in network_conf.c
Laine Stump [Thu, 11 Jun 2020 04:04:39 +0000 (00:04 -0400)]
conf: use g_steal_pointer in network_conf.c

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agoconf: convert network_conf.c to use g_auto* pointers
Laine Stump [Wed, 10 Jun 2020 03:43:56 +0000 (23:43 -0400)]
conf: convert network_conf.c to use g_auto* pointers

This was mostly boilerplate conversion, but in one case I needed to
define several differently named char* to take the place of a single
char *tmp that was re-used multiple times, and in another place there
was a single char* that was used at the toplevel of the function, and
then later used repeatedly inside a for loop, so I defined a new
separate char* inside the loop.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agonetwork: wire up support for IPv6 NAT rules
Daniel P. Berrangé [Mon, 8 Jun 2020 13:40:15 +0000 (14:40 +0100)]
network: wire up support for IPv6 NAT rules

Now that we have support for IPv6 in the iptables helpers, and a new
option in the XML schema, we can wire up support for it in the network
driver.

Reviewed-by: Laine Stump <laine@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoconf: add an attribute to turn on NAT for IPv6 virtual networks
Daniel P. Berrangé [Mon, 8 Jun 2020 13:35:02 +0000 (14:35 +0100)]
conf: add an attribute to turn on NAT for IPv6 virtual networks

Historically IPv6 did not support NAT, so when IPv6 was added to
libvirt's virtual networks, when requesting <forward mode="nat"/>
libvirt will NOT apply NAT to IPv6 traffic, only IPv4 traffic.

This is an annoying historical design decision as it means we
cannot enable IPv6 automatically. We thus need to introduce a
new attribute

   <forward mode="nat">
     <nat ipv6="yes"/>
   </forward>

Reviewed-by: Laine Stump <laine@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoutil: add support for IPv6 masquerade rules
Daniel P. Berrangé [Mon, 8 Jun 2020 13:28:20 +0000 (14:28 +0100)]
util: add support for IPv6 masquerade rules

IPv6 does support masquerade since Linux 3.9.0 / ip6tables 1.4.18,
which is Fedora 18 / RHEL-7 vintage, which covers all our supported
Linux versions.

Reviewed-by: Laine Stump <laine@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirDevMapperGetTargetsImpl: Check for dm major properly
Michal Privoznik [Thu, 11 Jun 2020 10:14:33 +0000 (12:14 +0200)]
virDevMapperGetTargetsImpl: Check for dm major properly

In v6.4.0-rc1~143 I've introduced a check that is supposed to
return from the function early, if given path is not a dm target.
While the idea is still valid, the implementation had a flaw.
It calls stat() over given path and the uses major(sb.st_dev) to
learn the major of the device. This is then passed to
dm_is_dm_major() which returns true or false depending whether
the device is under devmapper's control or not.

The problem with this approach is in how the major of the device
is obtained - paths managed by devmapper are special files and
thus we want to be using st_rdev instead of st_dev to obtain the
major number. Well, that's what virIsDevMapperDevice() does
already so might as well us that.

Fixes: 01626c668ecfbe465d18799ac4628e6127ea1d47
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1839992

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agoutil: Move virIsDevMapperDevice() to virdevmapper.c
Michal Privoznik [Thu, 11 Jun 2020 09:57:14 +0000 (11:57 +0200)]
util: Move virIsDevMapperDevice() to virdevmapper.c

When introducing virdevmapper.c (in v4.3.0-rc1~427) I didn't
realize there is a function that calls in devmapper. The function
is called virIsDevMapperDevice() and lives in virutil.c. Now that
we have a special file for handling devmapper move it there.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agodocs: Remove libvirt-dockerfiles from CI dashboard
Andrea Bolognani [Mon, 15 Jun 2020 09:57:50 +0000 (11:57 +0200)]
docs: Remove libvirt-dockerfiles from CI dashboard

The repository is now obsolete, and it never had proper GitLab CI
support anyway.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agodocs: add kbase entry showing KVM real time guest config
Daniel P. Berrangé [Mon, 1 Jun 2020 11:35:24 +0000 (12:35 +0100)]
docs: add kbase entry showing KVM real time guest config

There are many different settings that required to config a KVM guest
for real time, low latency workoads. The documentation included here is
based on guidance developed & tested by the Red Hat KVM real time team.

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoRemove use of variables passed only to 'VIR_FREE'
Peter Krempa [Thu, 11 Jun 2020 08:22:09 +0000 (10:22 +0200)]
Remove use of variables passed only to 'VIR_FREE'

Compilers are not very good at detecting this problem. Fixed by manual
inspection of compilation warnings after replacing 'VIR_FREE' with an
empty macro.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com
4 years agovboxDomainScreenshot: Don't pass uninitialized 'screenData' to VIR_FREE
Peter Krempa [Thu, 11 Jun 2020 08:38:05 +0000 (10:38 +0200)]
vboxDomainScreenshot: Don't pass uninitialized 'screenData' to VIR_FREE

If one of the early checks to get screen resolution fails 'screenData'
would be passed to VIR_FREE uninitialized. Unfortunately the compiler
isn't able to detect this when VIR_FREE is implemented using
g_clear_pointer.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com
4 years agoremoteDispatchDomainMigratePrepare*: Don't pass uninitialized variable to VIR_FREE
Peter Krempa [Thu, 11 Jun 2020 08:34:21 +0000 (10:34 +0200)]
remoteDispatchDomainMigratePrepare*: Don't pass uninitialized variable to VIR_FREE

'uri_out' may be passed to VIR_FREE uninitialized if 'conn' is NULL.
Unfortunately the compiler isn't able to detect this problem when
VIR_FREE is implemented using g_clear_pointer. Initialize the variable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com
4 years agovirTPMEmulatorInit: Don't use temporary variable to free path
Peter Krempa [Thu, 11 Jun 2020 08:26:19 +0000 (10:26 +0200)]
virTPMEmulatorInit: Don't use temporary variable to free path

Use VIR_FREE directly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com
4 years agocputest: Avoid use of temporary variable in DO_TEST macro
Peter Krempa [Thu, 11 Jun 2020 08:24:54 +0000 (10:24 +0200)]
cputest: Avoid use of temporary variable in DO_TEST macro

Use g_free directly to free the returned pointer from
virTestLogContentAndReset rather than store it in a temp variable which
was necessary when we only allowed VIR_FREE.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com
4 years agotestVirFindSCSIHostByPCI: Remove unused 'path_addr'
Peter Krempa [Thu, 11 Jun 2020 08:23:52 +0000 (10:23 +0200)]
testVirFindSCSIHostByPCI: Remove unused 'path_addr'

The path is formatted but then just freed without any use since
introduction of the test function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com
4 years agolibxlDomainMigrationDstPrepareDef: remove use of temporary variable
Peter Krempa [Thu, 11 Jun 2020 08:16:34 +0000 (10:16 +0200)]
libxlDomainMigrationDstPrepareDef: remove use of temporary variable

We can free 'def->name' directly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com
4 years agoci: Swap mipsel and ppc64le builds
Andrea Bolognani [Thu, 11 Jun 2020 18:06:02 +0000 (20:06 +0200)]
ci: Swap mipsel and ppc64le builds

Debian sid is currently broken on mipsel, so use Debian 10 for
that architecture; at the same time, move the ppc64le build from
Debian 10 to Debian sid to keep things balanced.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
4 years agoci: Update build system integration
Andrea Bolognani [Tue, 2 Jun 2020 15:28:58 +0000 (17:28 +0200)]
ci: Update build system integration

The ci-* targets need to know where our container images are stored
and how they are called to work, so now that we use the GitLab
container registry instead of Quay some changes are necessary.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoci: Use GitLab container registry
Andrea Bolognani [Tue, 2 Jun 2020 15:28:57 +0000 (17:28 +0200)]
ci: Use GitLab container registry

Instead of using pre-built containers hosted on Quay, build
containers as part of the GitLab CI pipeline and upload them to the
GitLab container registry for later use.

This will not significantly slow down builds, because containers are
only rebuilt when the corresponding Dockerfile has been modified.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoci: Use variables to build image names
Andrea Bolognani [Tue, 2 Jun 2020 15:28:55 +0000 (17:28 +0200)]
ci: Use variables to build image names

This removes a lot of repetition and makes the configuration much
easier to read.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agodocs: Document CIRRUS_GITHUB_REPO variable
Andrea Bolognani [Wed, 10 Jun 2020 16:11:04 +0000 (18:11 +0200)]
docs: Document CIRRUS_GITHUB_REPO variable

This needs to be set for every repository for Cirrus CI integration
to work.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoconf: snapshot: Drop unused variable 'creation'
Yi Li [Thu, 11 Jun 2020 03:26:29 +0000 (11:26 +0800)]
conf: snapshot: Drop unused variable 'creation'

Signed-off-by: Yi Li <yili@winhong.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agoci: Reduce number of stages
Andrea Bolognani [Wed, 10 Jun 2020 10:11:30 +0000 (12:11 +0200)]
ci: Reduce number of stages

Right now we're dividing the jobs into three stages: prebuild, which
includes DCO checking as well as building artifacts such as the
website, and native_build/cross_build, which do exactly what you'd
expect based on their names.

This organization is nice from the logical point of view, but results
in poor utilization of the available CI resources: in particular, the
fact that cross_build jobs can only start after all native_build jobs
have finished means that if even a single one of the latter takes a
bit longer the pipeline will stall, and with native builds taking
anywhere from less than 10 minutes to more than 20, this happens all
the time.

Building artifacts in a separate pipeline stage also doesn't have any
advantages, and only delays further stages by a couple of minutes.
The only job that really makes sense in its own stage is the DCO
check, because it's extremely fast (less than 1 minute) and, if that
fails, we can avoid kicking off all other jobs.

Reducing the number of stages results in significant speedups:
specifically, going from three stages to two stages reduces the
overall completion time for a full CI pipeline from ~45 minutes[1]
to ~30 minutes[2].

[1] https://gitlab.com/abologna/libvirt/-/pipelines/154751893
[2] https://gitlab.com/abologna/libvirt/-/pipelines/154771173

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agonews: Document -fw_cfg
Michal Privoznik [Thu, 4 Jun 2020 18:24:40 +0000 (20:24 +0200)]
news: Document -fw_cfg

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: Generate command line for -fw_cfg
Michal Privoznik [Tue, 2 Jun 2020 15:07:59 +0000 (17:07 +0200)]
qemu: Generate command line for -fw_cfg

This is pretty straightforward and self explanatory.

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

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agosecdrivers: Relabel firmware config files
Michal Privoznik [Tue, 2 Jun 2020 18:56:09 +0000 (20:56 +0200)]
secdrivers: Relabel firmware config files

For the case where -fw_cfg uses a file, we need to set the
seclabels on it to allow QEMU the access. While QEMU allows
writing into the file (if specified on the command line), so far
we are enabling reading only and thus we can use read only label
(in case of SELinux).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: Introduce fw_cfg capability
Michal Privoznik [Tue, 2 Jun 2020 14:57:56 +0000 (16:57 +0200)]
qemu: Introduce fw_cfg capability

This capability tracks whether QEMU supports -fw_cfg command line
option, more specifically whether it allows specifying filename.

There are some releases of QEMU which support -fw_cfg but not
filename. If this is ever a problem we can refine the capability
later on.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: Validate firmware blob configuration
Michal Privoznik [Tue, 2 Jun 2020 14:38:05 +0000 (16:38 +0200)]
qemu: Validate firmware blob configuration

There are recommendations and limitations to the name of the
config blobs we need to follow [1].

We don't want users to change any value only add new blobs. This
means, that the name must have "opt/" prefix and at the same time
must not begin with "opt/ovmf" nor "opt/org.qemu" as these are
reserved for OVMF or QEMU respectively.

1: docs/specs/fw_cfg.txt from qemu.git

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoconf: Add firmware blob configuration
Michal Privoznik [Thu, 4 Jun 2020 12:15:40 +0000 (14:15 +0200)]
conf: Add firmware blob configuration

QEMU has -fw_cfg which allows users to tweak how firmware
configures itself and/or provide new configuration blobs.
Introduce new <sysinfo/> type "fwcfg" that will hold these
new blobs.

It's possible to either specify new value as a string or
provide a filename which contents then serve as the value.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirsysinfo: Parse OEM strings
Michal Privoznik [Tue, 2 Jun 2020 08:15:38 +0000 (10:15 +0200)]
virsysinfo: Parse OEM strings

Setting OEM strings for a domain was introduced in
v4.1.0-rc1~315. However, any application that wanted to use them
(e.g. to point to an URL where a config file is stored) had to
'dmidecode -u --oem-string N' (where N is index of the string).
Well, we can expose them under our <sysinfo/> XML and if the
domain is running Libvirt inside it can be obtained using
virConnectGetSysinfo() API.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirsysinfo: Drop global @sysinfoDmidecode
Michal Privoznik [Mon, 8 Jun 2020 10:53:04 +0000 (12:53 +0200)]
virsysinfo: Drop global @sysinfoDmidecode

Since nobody sets custom dmidecode path anymore, we can drop all
code that exists only because of that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agosysinfotest: Move from custom dmidecode scripts to virCommandSetDryRun()
Michal Privoznik [Mon, 8 Jun 2020 10:51:07 +0000 (12:51 +0200)]
sysinfotest: Move from custom dmidecode scripts to virCommandSetDryRun()

Problem with custom dmidecode scripts is that they are hard to
modify, especially if we will want them to act differently based
on passed arguments. So far, we have two scripts which do no more
than 'cat $sysinfo' where $sysinfo is saved dmidecode output.

The virCommandSetDryRun() can be used to trick
virSysinfoReadDMI() thinking it executed real dmidecode.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agosysinfotest: Dissolve sysinfotest_run() in testSysinfo()
Michal Privoznik [Mon, 8 Jun 2020 10:32:52 +0000 (12:32 +0200)]
sysinfotest: Dissolve sysinfotest_run() in testSysinfo()

There is no real need to have two separate functions. They can be
merged together which not only saves couple of lines, but
prepares the structure of the code for future expansion. See next
commits.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agotestSysinfo: Use more g_auto*()
Michal Privoznik [Mon, 8 Jun 2020 09:56:45 +0000 (11:56 +0200)]
testSysinfo: Use more g_auto*()

Some variables defined in the function can be freed
automatically when going out of scope. This renders @result
variable and cleanup label needless.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirSysinfoReadDMI: Drop needless virFindFileInPath()
Michal Privoznik [Mon, 8 Jun 2020 08:49:36 +0000 (10:49 +0200)]
virSysinfoReadDMI: Drop needless virFindFileInPath()

When trying to decode DMI table, just before constructing
virCommand() the decoder is looked for in PATH using
virFindFileInPath(). Well, this is not necessary because
virCommandRun() will do this too (in virExec()).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirSysinfoReadDMI: Use more g_auto*()
Michal Privoznik [Mon, 8 Jun 2020 08:44:19 +0000 (10:44 +0200)]
virSysinfoReadDMI: Use more g_auto*()

Virtually every variable defined in the function can be freed
automatically when going out of scope.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoci: Remove Travis CI
Andrea Bolognani [Mon, 8 Jun 2020 12:14:01 +0000 (14:14 +0200)]
ci: Remove Travis CI

Since we now use Cirrus CI for macOS jobs, we no longer need to
keep Travis CI around.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agoci: Enable Cirrus CI integration
Andrea Bolognani [Fri, 5 Jun 2020 18:37:55 +0000 (20:37 +0200)]
ci: Enable Cirrus CI integration

We use cirrus-run to trigger Cirrus CI jobs from GitLab CI jobs,
making it possible to extend our platform coverage to include
FreeBSD without having to maintain our own runners; additionally,
we'll be able to ditch Travis CI and, since results for Cirrus CI
jobs are reflected back to the GitLab CI jobs that triggered them,
we will be able to get all information from a single dashboard.

The FreeBSD and macOS job definitions can be improved further: for
example, we will want to enable caching to speed up builds, and
ultimately we should figure out a way to generate at least part of
them, notably the list of packages to be installed, using lcitool.
All of that will happen in later patches: for now, this is good
enough to start using Cirrus CI.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agoqemu: Pass migratable=on|off property for -cpu host
Jiri Denemark [Tue, 2 Jun 2020 19:06:02 +0000 (21:06 +0200)]
qemu: Pass migratable=on|off property for -cpu host

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu: Fill default value in //cpu/@migratable attribute
Jiri Denemark [Tue, 2 Jun 2020 13:34:07 +0000 (15:34 +0200)]
qemu: Fill default value in //cpu/@migratable attribute

Before QEMU introduced migratable CPU property, "-cpu host" included all
features that could be enabled on the host, even those which would block
migration. In other words, the default was equivalent to migratable=off.
When the migratable property was introduced, the default changed to
migratable=on. Let's record the default in domain XML.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu: Advertise migratable attribute for CPU in domcaps
Jiri Denemark [Tue, 2 Jun 2020 22:28:10 +0000 (00:28 +0200)]
qemu: Advertise migratable attribute for CPU in domcaps

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoconf: Advertise migratable attribute for CPU in domcaps
Jiri Denemark [Tue, 2 Jun 2020 22:28:10 +0000 (00:28 +0200)]
conf: Advertise migratable attribute for CPU in domcaps

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoconf: Introduce migratable attribute for the <cpu> element
Jiri Denemark [Tue, 2 Jun 2020 10:29:57 +0000 (12:29 +0200)]
conf: Introduce migratable attribute for the <cpu> element

The attribute is only allowed for host-passthrough CPUs and it can be
used to request only migratable or all supported features to be enabled
in the virtual CPU.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu: Avoid probing unsupported migratable CPU expansion
Jiri Denemark [Tue, 2 Jun 2020 23:07:06 +0000 (01:07 +0200)]
qemu: Avoid probing unsupported migratable CPU expansion

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu: Probe for migrtability support in CPU expansion
Jiri Denemark [Tue, 2 Jun 2020 23:05:36 +0000 (01:05 +0200)]
qemu: Probe for migrtability support in CPU expansion

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>