]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
5 years agoqemu: Introduce virQEMUCapsGetMachineDefaultCPU
Jiri Denemark [Thu, 26 Sep 2019 13:22:38 +0000 (15:22 +0200)]
qemu: Introduce virQEMUCapsGetMachineDefaultCPU

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Probe for default CPU types
Jiri Denemark [Thu, 18 Jul 2019 17:21:55 +0000 (19:21 +0200)]
qemu: Probe for default CPU types

QEMU 4.2.0 will report default CPU types used by each machine type and
we will want to start using it.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Probe machine types for both KVM and TCG
Jiri Denemark [Thu, 24 Oct 2019 12:21:46 +0000 (14:21 +0200)]
qemu: Probe machine types for both KVM and TCG

Almost all TCG query-machines replies match KVM. The only exceptions are
4.2.0 replies on s390x which differ in the reported default CPU type.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Make probed machine types depend on accelerator
Jiri Denemark [Thu, 24 Oct 2019 12:19:38 +0000 (14:19 +0200)]
qemu: Make probed machine types depend on accelerator

Some specifics of machine types may depend on the accelerator and thus
the data should be moved to virQEMUCapsAccel. The TCG machine types are
just copied from the ones probed for KVM to simplify the changes to
qemucapabilitiestest data files.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Introduce virQEMUCapsCopyMachineTypes
Jiri Denemark [Thu, 24 Oct 2019 09:35:10 +0000 (11:35 +0200)]
qemu: Introduce virQEMUCapsCopyMachineTypes

The function copies machine type data from one QEMU caps structure to
another.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Use typedef for virQEMUCapsMachineType
Jiri Denemark [Wed, 30 Oct 2019 00:04:06 +0000 (01:04 +0100)]
qemu: Use typedef for virQEMUCapsMachineType

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Move machine type data in capabilities cache
Jiri Denemark [Thu, 24 Oct 2019 07:04:58 +0000 (09:04 +0200)]
qemu: Move machine type data in capabilities cache

In preparation for making machine types dependent on the accelerator,
the <machine> elements are formatted between <cpu type='kvm'> and
<cpu type='tcg'>.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Pass virDomainVirtType to APIs dealing with machine types
Jiri Denemark [Thu, 24 Oct 2019 06:52:21 +0000 (08:52 +0200)]
qemu: Pass virDomainVirtType to APIs dealing with machine types

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Split out virQEMUCapsFormatCache
Jiri Denemark [Wed, 23 Oct 2019 16:29:39 +0000 (18:29 +0200)]
qemu: Split out virQEMUCapsFormatCache

All the code for formatting machine type data was moved to a standalone
virQEMUCapsFormatMachines function.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Split out virQEMUCapsLoadCache
Jiri Denemark [Wed, 23 Oct 2019 16:05:45 +0000 (18:05 +0200)]
qemu: Split out virQEMUCapsLoadCache

All the code for loading machine type data was moved to a standalone
virQEMUCapsLoadMachines function.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Make virQEMUCapsIsMachineSupported static
Jiri Denemark [Wed, 23 Oct 2019 15:51:50 +0000 (17:51 +0200)]
qemu: Make virQEMUCapsIsMachineSupported static

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Make virQEMUCapsGetMachineTypesCaps static
Jiri Denemark [Wed, 23 Oct 2019 15:08:57 +0000 (17:08 +0200)]
qemu: Make virQEMUCapsGetMachineTypesCaps static

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Refactor probing of accelerator dependent data
Jiri Denemark [Wed, 23 Oct 2019 14:48:17 +0000 (16:48 +0200)]
qemu: Refactor probing of accelerator dependent data

To avoid duplicating code which selects the right virQEMUCapsAccel data
to be filled during probing.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Introduce virQEMUCapsProbeCPUDefinitionsTest
Jiri Denemark [Wed, 23 Oct 2019 12:08:16 +0000 (14:08 +0200)]
qemu: Introduce virQEMUCapsProbeCPUDefinitionsTest

It is a tiny wrapper around virQEMUCapsProbeQMPCPUDefinitions which will
soon get private parameters and thus it cannot be exposed outside
qemu_capabilities.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Refactor virQEMUCapsFormatAccel
Jiri Denemark [Wed, 23 Oct 2019 11:00:31 +0000 (13:00 +0200)]
qemu: Refactor virQEMUCapsFormatAccel

And make it use virQEMUCapsGetAccel once rather than repeating the same
code in all functions called from virQEMUCapsFormatAccel.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Refactor virQEMUCapsLoadAccel
Jiri Denemark [Wed, 23 Oct 2019 10:59:43 +0000 (12:59 +0200)]
qemu: Refactor virQEMUCapsLoadAccel

And make it use virQEMUCapsGetAccel once rather than repeating the same
code in all functions called from virQEMUCapsLoadAccel.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Drop virQEMUCapsGetHostCPUData
Jiri Denemark [Wed, 23 Oct 2019 10:57:20 +0000 (12:57 +0200)]
qemu: Drop virQEMUCapsGetHostCPUData

It was very similar to virQEMUCapsGetAccel.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Introduce and use virQEMUCapsGetAccel
Jiri Denemark [Wed, 23 Oct 2019 10:46:28 +0000 (12:46 +0200)]
qemu: Introduce and use virQEMUCapsGetAccel

The function can be used to get the pointer to all data which depend on
the accelerator.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Introduce virQEMUCapsAccelClear
Jiri Denemark [Wed, 23 Oct 2019 10:42:54 +0000 (12:42 +0200)]
qemu: Introduce virQEMUCapsAccelClear

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Introduce virQEMUCapsAccelCopy
Jiri Denemark [Wed, 23 Oct 2019 10:41:31 +0000 (12:41 +0200)]
qemu: Introduce virQEMUCapsAccelCopy

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Introduce virQEMUCapsAccel structure
Jiri Denemark [Wed, 23 Oct 2019 10:29:52 +0000 (12:29 +0200)]
qemu: Introduce virQEMUCapsAccel structure

This is container for capabilities data that depend on the accelerator.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Add virQEMUCaps{Load,Format}Accel
Jiri Denemark [Wed, 23 Oct 2019 08:24:46 +0000 (10:24 +0200)]
qemu: Add virQEMUCaps{Load,Format}Accel

The new functions are designed to load and format capabilities which
depend on the accelerator (host CPU expansion and CPU models).

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Drop unused virQEMUCapsGetDefaultMachine
Jiri Denemark [Thu, 26 Sep 2019 13:26:45 +0000 (15:26 +0200)]
qemu: Drop unused virQEMUCapsGetDefaultMachine

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Store typename from query-cpu-definitions in qemuCaps
Jiri Denemark [Thu, 19 Sep 2019 18:47:37 +0000 (20:47 +0200)]
qemu: Store typename from query-cpu-definitions in qemuCaps

We need to create a mapping between CPU model names and their
corresponding QOM types.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoconf: Drop virDomainCapsCPUModelsAddSteal
Jiri Denemark [Fri, 20 Sep 2019 21:08:55 +0000 (23:08 +0200)]
conf: Drop virDomainCapsCPUModelsAddSteal

Both virDomainCapsCPUModelsAdd and virDomainCapsCPUModelsAddSteal are so
simple we can just squash the code in a single function.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoconf: Drop unused virDomainCapsCPUModelsFilter
Jiri Denemark [Fri, 20 Sep 2019 21:00:14 +0000 (23:00 +0200)]
conf: Drop unused virDomainCapsCPUModelsFilter

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Switch qemuCaps to use qemuMonitorCPUDefs
Jiri Denemark [Tue, 24 Sep 2019 14:38:05 +0000 (16:38 +0200)]
qemu: Switch qemuCaps to use qemuMonitorCPUDefs

We will need to keep some QEMU-specific data for each CPU model
supported by a QEMU binary. Instead of complicating the generic
virDomainCapsCPUModelsPtr, we can just directly store
qemuMonitorCPUDefsPtr returned by the capabilities probing code.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Split virQEMUCapsFetchCPUModels
Jiri Denemark [Wed, 9 Oct 2019 08:16:17 +0000 (10:16 +0200)]
qemu: Split virQEMUCapsFetchCPUModels

Most of the code moved to a new virQEMUCapsFetchCPUDefinitions function
and the existing virQEMUCapsFetchCPUModels just becomes a small wrapper
around virQEMUCapsFetchCPUDefinitions and virQEMUCapsCPUDefsToModels.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Rename virQEMUCaps{Get,Fetch}CPUDefinitions
Jiri Denemark [Wed, 9 Oct 2019 08:14:59 +0000 (10:14 +0200)]
qemu: Rename virQEMUCaps{Get,Fetch}CPUDefinitions

The functions return virDomainCapsCPUModelsPtr and thus they should be
called *CPUModels for consistency. Functions called *CPUDefinitions will
work on qemuMonitorCPUDefsPtr.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Introduce virQEMUCapsCPUDefsToModels
Jiri Denemark [Tue, 24 Sep 2019 13:59:34 +0000 (15:59 +0200)]
qemu: Introduce virQEMUCapsCPUDefsToModels

The function translates qemuMonitorCPUDefsPtr (used by QEMU caps probing
code) into virDomainCapsCPUModelsPtr used by domain capabilities.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Use virDomainCapsCPUUsable in qemuMonitorCPUDefInfo
Jiri Denemark [Tue, 29 Oct 2019 13:36:11 +0000 (14:36 +0100)]
qemu: Use virDomainCapsCPUUsable in qemuMonitorCPUDefInfo

While virDomainCapsCPUModel structure contains 'usable' field with
virDomainCapsCPUUsable type, the lower level structure specific to QEMU
driver used virTriStateBool for the same thing and we had to translate
between them.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Use g_autofree in virQEMUCapsLoadCPUModels
Jiri Denemark [Tue, 24 Sep 2019 12:55:26 +0000 (14:55 +0200)]
qemu: Use g_autofree in virQEMUCapsLoadCPUModels

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Add qemuMonitorCPUDefsCopy
Jiri Denemark [Tue, 24 Sep 2019 15:12:34 +0000 (17:12 +0200)]
qemu: Add qemuMonitorCPUDefsCopy

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Flatten qemuMonitorCPUDefs.cpus
Jiri Denemark [Tue, 24 Sep 2019 11:45:37 +0000 (13:45 +0200)]
qemu: Flatten qemuMonitorCPUDefs.cpus

Let's store qemuMonitorCPUDefInfo directly in the array of CPUs in
qemuMonitorCPUDefs rather then using an array of pointers.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Introduce qemuMonitorCPUDefs struct
Jiri Denemark [Tue, 24 Sep 2019 11:42:00 +0000 (13:42 +0200)]
qemu: Introduce qemuMonitorCPUDefs struct

It is a container for a CPU models list (qemuMonitorCPUDefInfo) and a
number of elements in this list.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Change return type of virQEMUCapsFetchCPUDefinitions
Jiri Denemark [Thu, 10 Oct 2019 14:44:40 +0000 (16:44 +0200)]
qemu: Change return type of virQEMUCapsFetchCPUDefinitions

The function would return a valid virDomainCapsCPUModelsPtr with empty
CPU models list if query-cpu-definitions exists in QEMU, but returns
GenericError meaning it's not in fact implemented. This behaviour is a
bit strange especially after such virDomainCapsCPUModels structure is
stored in capabilities XML and parsed back, which will result in NULL
virDomainCapsCPUModelsPtr rather than a structure containing nothing.

Let's just keep virDomainCapsCPUModelsPtr NULL if the QMP command is not
implemented and change the return value to int so that callers can
easily check for failure or success.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Use g_autoptr in qemuMonitorJSONGetCPUDefinitions
Jiri Denemark [Tue, 24 Sep 2019 11:20:49 +0000 (13:20 +0200)]
qemu: Use g_autoptr in qemuMonitorJSONGetCPUDefinitions

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Use virQEMUCapsGetCPUDefinitions more
Jiri Denemark [Fri, 20 Sep 2019 20:54:13 +0000 (22:54 +0200)]
qemu: Use virQEMUCapsGetCPUDefinitions more

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Filter models in virQEMUCapsGetCPUDefinitions
Jiri Denemark [Fri, 20 Sep 2019 20:48:13 +0000 (22:48 +0200)]
qemu: Filter models in virQEMUCapsGetCPUDefinitions

Some callers of virQEMUCapsGetCPUDefinitions will need to filter the
returned list of CPU models. Let's add the filtering parameters directly
to virQEMUCapsGetCPUDefinitions to avoid copying the CPU models list
twice.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Copy CPU models in virQEMUCapsGetCPUDefinitions
Jiri Denemark [Fri, 20 Sep 2019 20:41:34 +0000 (22:41 +0200)]
qemu: Copy CPU models in virQEMUCapsGetCPUDefinitions

Rather than returning a direct pointer the list stored in qemuCaps the
function now creates a new copy of the CPU models list.

The main purpose of this seemingly useless change is to update callers
to free the result returned by virQEMUCapsGetCPUDefinitions because the
internals of this function will change significantly in the following
patches.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: Update 4.2.0 capabilities data on ppc64
Jiri Denemark [Thu, 31 Oct 2019 14:47:09 +0000 (15:47 +0100)]
tests: Update 4.2.0 capabilities data on ppc64

Generated with "spapr/kvm: Set default cpu model for all machine
classes" fix for QEMU applied.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: Add capabilities for QEMU 4.2.0 on s390x
Jiri Denemark [Tue, 15 Oct 2019 11:48:34 +0000 (13:48 +0200)]
tests: Add capabilities for QEMU 4.2.0 on s390x

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agosrc: rewrite polkit ACL generator in Python
Daniel P. Berrangé [Fri, 30 Aug 2019 12:22:54 +0000 (13:22 +0100)]
src: rewrite polkit ACL generator in Python

As part of a goal to eliminate Perl from libvirt build tools,
rewrite the genpolkit.pl tool in Python.

This was a straight conversion, manually going line-by-line to
change the syntax from Perl to Python. Thus the overall structure
of the file and approach is the same.

Tested-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: rewrite ACL rule checker in Python
Daniel P. Berrangé [Fri, 30 Aug 2019 12:22:54 +0000 (13:22 +0100)]
src: rewrite ACL rule checker in Python

As part of a goal to eliminate Perl from libvirt build tools,
rewrite the check-aclrules.pl tool in Python.

This was a straight conversion, manually going line-by-line to
change the syntax from Perl to Python. Thus the overall structure
of the file and approach is the same.

Tested-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: rewrite driver impl checker in Python
Daniel P. Berrangé [Fri, 30 Aug 2019 12:22:54 +0000 (13:22 +0100)]
src: rewrite driver impl checker in Python

As part of a goal to eliminate Perl from libvirt build tools,
rewrite the check-driverimpls.pl tool in Python.

This was a straight conversion, manually going line-by-line to
change the syntax from Perl to Python. Thus the overall structure
of the file and approach is the same.

Tested-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: rewrite driver name checker in Python
Daniel P. Berrangé [Fri, 30 Aug 2019 12:22:54 +0000 (13:22 +0100)]
src: rewrite driver name checker in Python

As part of a goal to eliminate Perl from libvirt build tools,
rewrite the check-drivername.pl tool in Python.

This was mostly a straight conversion, manually going line-by-line
to change the syntax from Perl to Python. Thus the overall structure
of the file and approach is the same.

In testing though it was discovered the existing code was broken
since it hadn't been updated after driver.h was split into many
files. Since the old code is being thrown away, the fix was done
as part of the rewrite rather than split into a separate commit.

Tested-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: rewrite systemtap function generator in Python
Daniel P. Berrangé [Fri, 30 Aug 2019 12:22:54 +0000 (13:22 +0100)]
src: rewrite systemtap function generator in Python

As part of a goal to eliminate Perl from libvirt build tools,
rewrite the gensystemtap.pl tool in Python.

This was a straight conversion, manually going line-by-line to
change the syntax from Perl to Python. Thus the overall structure
of the file and approach is the same.

Tested-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: rewrite systemtap probe generator in Python
Daniel P. Berrangé [Fri, 30 Aug 2019 12:22:54 +0000 (13:22 +0100)]
src: rewrite systemtap probe generator in Python

As part of a goal to eliminate Perl from libvirt build tools,
rewrite the dtrace2systemtap.pl tool in Python.

This was a straight conversion, manually going line-by-line to
change the syntax from Perl to Python. Thus the overall structure
of the file and approach is the same.

The "--with-modules" flag was dropped because this functionality
is not implicitly always enabled.

Tested-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: rewrite symfile library checker in Python
Daniel P. Berrangé [Fri, 30 Aug 2019 12:22:54 +0000 (13:22 +0100)]
src: rewrite symfile library checker in Python

As part of a goal to eliminate Perl from libvirt build tools,
rewrite the check-symfile.pl tool in Python.

This was a straight conversion, manually going line-by-line to
change the syntax from Perl to Python. Thus the overall structure
of the file and approach is the same.

Tested-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: rewrite symfile sorting checker in Python
Daniel P. Berrangé [Fri, 30 Aug 2019 12:22:54 +0000 (13:22 +0100)]
src: rewrite symfile sorting checker in Python

As part of a goal to eliminate Perl from libvirt build tools,
rewrite the check-symsorting.pl tool in Python.

This was a straight conversion, manually going line-by-line to
change the syntax from Perl to Python. Thus the overall structure
of the file and approach is the same.

Tested-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: rewrite ACL permissions checker in Python
Daniel P. Berrangé [Fri, 30 Aug 2019 12:22:54 +0000 (13:22 +0100)]
src: rewrite ACL permissions checker in Python

As part of a goal to eliminate Perl from libvirt build tools,
rewrite the check-aclperms.pl tool in Python.

This was a straight conversion, manually going line-by-line to
change the syntax from Perl to Python. Thus the overall structure
of the file and approach is the same.

Tested-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild-aux: rewrite header ifdef checker in Python
Daniel P. Berrangé [Fri, 30 Aug 2019 12:22:54 +0000 (13:22 +0100)]
build-aux: rewrite header ifdef checker in Python

As part of a goal to eliminate Perl from libvirt build tools,
rewrite the header-ifdef.pl tool in Python.

This was a straight conversion, manually going line-by-line to
change the syntax from Perl to Python. Thus the overall structure
of the file and approach is the same.

Tested-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild-aux: rewrite mock inline checker in Python
Daniel P. Berrangé [Fri, 30 Aug 2019 12:22:54 +0000 (13:22 +0100)]
build-aux: rewrite mock inline checker in Python

As part of a goal to eliminate Perl from libvirt build tools,
rewrite the mock-noinline.pl tool in Python.

This was a straight conversion, manually going line-by-line to
change the syntax from Perl to Python. Thus the overall structure
of the file and approach is the same.

Tested-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: checkpoint: Use qemuMonitorTransactionBitmapMergeSourceAddBitmap
Peter Krempa [Mon, 7 Oct 2019 14:33:49 +0000 (16:33 +0200)]
qemu: checkpoint: Use qemuMonitorTransactionBitmapMergeSourceAddBitmap

Use the new helper in qemuCheckpointDiscard rather than constructing the
array manually.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Forcibly mknod() even if it exists
Michal Privoznik [Fri, 8 Nov 2019 08:41:35 +0000 (09:41 +0100)]
qemu: Forcibly mknod() even if it exists

Another weird bug appeared concerning qemu namespaces. Basically
the problem is as follows:

1) Issue an API that causes libvirt to create a node in domain's
   namespace, say /dev/nvme0n1 with 8:0 as major:minor (the API can
   be attach-disk for instance). Or simply create the node from a
   console by hand.

2) Detach the disk from qemu.

3) Do something that makes /dev/nvme0n1 change it's minor number.

4) Try to attach the disk again.

The problem is, in a few cases - like disk-detach - we don't
remove the corresponding /dev node from the mount namespace
(because it may be used by some other disk's backing chain). But
this creates a problem, because if the node changes its MAJ:MIN
numbers we don't propagate the change into the domain's
namespace. We do plain mknod() and ignore EEXIST which obviously
is not enough because it doesn't guarantee that the node has
updated MAJ:MIN pair.

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

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agognulib: remove mk*temp modules
Ján Tomko [Wed, 20 Nov 2019 12:07:18 +0000 (13:07 +0100)]
gnulib: remove mk*temp modules

After commits 4ac47730408eaf91683f6502ec10541f4f711a5c and
ef88698668e4a87c794d70879eeffefb52aa0017, we use the GLib versions
of these functions.

Remove the corresponding gnulib modules.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agobootstrap.conf: drop c-strcasestr gnulib module
Pavel Hrdina [Tue, 19 Nov 2019 14:22:58 +0000 (15:22 +0100)]
bootstrap.conf: drop c-strcasestr gnulib module

Last usage was removed by commit
<41f88886198e231285cc813f8c0687c8ec5c9488> and commit
<0f4d31720430b4e3735064cc0d8f88a1a438e154> forgot to drop include.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agognulib: Remove use of 'strsep' module
Peter Krempa [Thu, 14 Nov 2019 09:31:53 +0000 (10:31 +0100)]
gnulib: Remove use of 'strsep' module

We don't use strsep any more.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
5 years agobootstrap: remove regex module
Ján Tomko [Wed, 13 Nov 2019 15:57:53 +0000 (16:57 +0100)]
bootstrap: remove regex module

Now that we use GRegex everywhere, there is no need for this module.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agosyntax-check: forbid usage of snprintf
Pavel Hrdina [Wed, 13 Nov 2019 16:33:27 +0000 (17:33 +0100)]
syntax-check: forbid usage of snprintf

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agosyntax-check: update of sprintf rule to mention g_snprintf
Pavel Hrdina [Wed, 13 Nov 2019 16:33:26 +0000 (17:33 +0100)]
syntax-check: update of sprintf rule to mention g_snprintf

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agobootstrap.conf: remove usage of snprintf gnulib module
Pavel Hrdina [Wed, 13 Nov 2019 16:33:25 +0000 (17:33 +0100)]
bootstrap.conf: remove usage of snprintf gnulib module

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agognulib: remove use of 'vsnprintf' module
Ján Tomko [Wed, 13 Nov 2019 13:18:18 +0000 (14:18 +0100)]
gnulib: remove use of 'vsnprintf' module

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agognulib: remove use of 'byteswap' module
Ján Tomko [Wed, 13 Nov 2019 13:17:31 +0000 (14:17 +0100)]
gnulib: remove use of 'byteswap' module

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agognulib: remove 'areadlink' module
Peter Krempa [Wed, 13 Nov 2019 13:16:42 +0000 (14:16 +0100)]
gnulib: remove 'areadlink' module

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: monitor: Remove non-transaction based dirty bitmap APIs
Peter Krempa [Thu, 26 Sep 2019 15:00:44 +0000 (17:00 +0200)]
qemu: monitor: Remove non-transaction based dirty bitmap APIs

We replaced them by use of transaction to simplify possible failure
scenarios.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: checkpoint: Fix rollback and access to unlocked 'vm' when deleting checkpoints
Peter Krempa [Thu, 26 Sep 2019 14:56:16 +0000 (16:56 +0200)]
qemu: checkpoint: Fix rollback and access to unlocked 'vm' when deleting checkpoints

Delete/merge bitmaps when deleting checkpoints using a 'transaction' so
that we don't have to deal with halfway-failed scenarios and also fix
access to 'vm' while in the monitor lock.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: virschema: Propagate errors from directory traversal in testSchemaDir
Peter Krempa [Tue, 19 Nov 2019 10:55:05 +0000 (11:55 +0100)]
tests: virschema: Propagate errors from directory traversal in testSchemaDir

testSchemaDir is a helper which invokes the schema test using virTestRun
on all schema files. Since the function itself is not called inside
virTestRun any helper function call is not dispatched to the user and
thus it's hard to debug the test. Propagate errors from the directory
traversal.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: utils: Introduce helper for dispatching libvirt errors
Peter Krempa [Tue, 19 Nov 2019 10:52:40 +0000 (11:52 +0100)]
tests: utils: Introduce helper for dispatching libvirt errors

In cases when we call a libvirt helper which reports an error the error
would be hidden unless libvirt library debug is on. This produces a lot
of output and is hard to debug.

The helper provides a way to dispatch the libvirt error in specific
cases sice we do already dispatch it in case when virTestRun is used.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: schema: Simplify memory handling using g_autofree
Peter Krempa [Tue, 19 Nov 2019 10:16:34 +0000 (11:16 +0100)]
tests: schema: Simplify memory handling using g_autofree

Refactor various functions to avoid multiple freeing function calls.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agolib: fix documentation typo in virDomainGetGuestInfo()
Jonathon Jongsma [Tue, 19 Nov 2019 19:59:06 +0000 (13:59 -0600)]
lib: fix documentation typo in virDomainGetGuestInfo()

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agoremote_daemon_stream: Fix @client locking in daemonStreamFilter()
LanceLiu [Tue, 19 Nov 2019 11:39:50 +0000 (19:39 +0800)]
remote_daemon_stream: Fix @client locking in daemonStreamFilter()

When dispatching a message read from client it is first passed
through registered filters. If one of the filters consumes the
message no further processing of the message is done. However,
the filter callbacks are called with the client object locked.
This breaks lock ordering in case of virStream filter, we always
acquire stream private data lock without the client object
locked. In other words, the daemonStreamFilter() does not follow
the lock ordering.

Signed-off-by: LanceLiu <liu.lance.89@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: remove unneeded cleanup labels
Daniel Henrique Barboza [Tue, 12 Nov 2019 20:46:29 +0000 (17:46 -0300)]
tests: remove unneeded cleanup labels

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agovbox: remove unneeded cleanup labels
Daniel Henrique Barboza [Tue, 12 Nov 2019 20:46:28 +0000 (17:46 -0300)]
vbox: remove unneeded cleanup labels

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: remove unneeded cleanup labels
Daniel Henrique Barboza [Tue, 12 Nov 2019 20:46:27 +0000 (17:46 -0300)]
qemu: remove unneeded cleanup labels

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 agonetwork: Check for QOS before blindly using it
John Ferlan [Tue, 12 Nov 2019 23:36:22 +0000 (18:36 -0500)]
network: Check for QOS before blindly using it

If networkAllocatePort calls networkPlugBandwidth eventually the
port->bandwidth would be passed to virNetDevBandwidthPlug which
requires that the parameter is non-NULL.  Coverity additionally
notes that since (!port->bandwidth) is checked earlier in the
networkAllocatePort method that the subsequent call to blindly
use if for a function that requires it needs to check.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agonetwork: Use local variables in networkUpdatePortBandwidth
John Ferlan [Tue, 12 Nov 2019 21:15:04 +0000 (16:15 -0500)]
network: Use local variables in networkUpdatePortBandwidth

We go through the trouble of checking {old|new}Bandwidth[->in] and
storing the result in local @old_floor and @new_floor, but then
we don't use them. Instead we make derefs to the longer name. This
caused Coverity to note dereferencing newBandwidth->in without first
checking @newBandwidth like was done for new_floor could cause a
NULL dereference.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoutil: Remove unnecessary check in virFileRewrite
John Ferlan [Tue, 12 Nov 2019 21:10:12 +0000 (16:10 -0500)]
util: Remove unnecessary check in virFileRewrite

Since g_strdup_printf will abort, we know @newfile won't be NULL.

Found by Coverity

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoqemuProcessStop: Set @def early
Michal Privoznik [Mon, 18 Nov 2019 16:39:46 +0000 (17:39 +0100)]
qemuProcessStop: Set @def early

The @def variable holds pointer to the domain defintion, but is
set only somewhere in the middle of the function. This is
suboptimal.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agoAdd news for virDomainAgentSetResponseTimeout()
Jonathon Jongsma [Mon, 18 Nov 2019 22:38:49 +0000 (16:38 -0600)]
Add news for virDomainAgentSetResponseTimeout()

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agog_mkstemp_full: pass O_RDWR
Ján Tomko [Mon, 18 Nov 2019 16:45:54 +0000 (17:45 +0100)]
g_mkstemp_full: pass O_RDWR

This flag is not implied by g_mkstemp_full, only by g_mkstemp.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reported-by: Bjoern Walk <bwalk@linux.ibm.com>
Fixes: 4ac47730408eaf91683f6502ec10541f4f711a5c
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agobuild-aux: rewrite duplicate header checker in Python
Daniel P. Berrangé [Fri, 30 Aug 2019 12:22:54 +0000 (13:22 +0100)]
build-aux: rewrite duplicate header checker in Python

As part of an goal to eliminate Perl from libvirt build tools,
rewrite the prohibit-duplicate-header.pl tool in Python.

This was a straight conversion, manually going line-by-line to
change the syntax from Perl to Python. Thus the overall structure
of the file and approach is the same.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: Fix NULL ptr dereference caused by qemuDomainDefFormatBufInternal
Erik Skultety [Mon, 18 Nov 2019 12:46:14 +0000 (13:46 +0100)]
qemu: Fix NULL ptr dereference caused by qemuDomainDefFormatBufInternal

qemuDomainDefFormatBufInternal function wasn't testing whether the CPU
was actually defined in the XML and saving such a domain resulted in the
following backtrace:

0 in qemuDomainMakeCPUMigratable (cpu=0x0)
1 in qemuDomainDefFormatBufInternal()
2 in qemuDomainDefFormatXMLInternal()
3 in qemuDomainDefFormatLive()
4 in qemuDomainSaveInternal()
5 in qemuDomainSaveFlags()
6 in qemuDomainSave()
7 in virDomainSave()

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoqemu_process: fix starting VMs if machine group has limited cpuset.cpus
Pavel Hrdina [Thu, 7 Nov 2019 21:23:04 +0000 (22:23 +0100)]
qemu_process: fix starting VMs if machine group has limited cpuset.cpus

Commit <f136b83139c63f20de0df3285d9e82df2fb97bfc> reworked process
affinity setting but did not take cgroups into account which introduced
an issue when starting VM with custom cpuset.cpus for the whole machine
group.

If the machine group is limited to some pCPUs libvirt should not try to
set a VM to run on all pCPUs as it will result in permission denied when
writing to cpuset.cpus.

To fix this the affinity has to be set separately from cgroups cpuset.

Resolves: <https://bugzilla.redhat.com/show_bug.cgi?id=1746517>

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agovirbpf: Fix typecast to __aligned_u64 type
Michal Privoznik [Mon, 18 Nov 2019 07:33:40 +0000 (08:33 +0100)]
virbpf: Fix typecast to __aligned_u64 type

In functions implemented here we fill this attr union (type of
bpf_attr) and just pass it to syscall(2). Thing is that some of
the union members are type of __aligned_u64. This is not regular
uint64_t. This one is explicitly aligned to 8 bytes, while
uint64_t can be aligned to 4 bytes (on 32 bits). We've used
explicit typecast to uint64_t to shut compiler which would
otherwise complain of assigning a pointer into an integer. Well,
we have uintptr_t just for that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
5 years agovircgroupv2devices: Fix format string for size_t variable
Michal Privoznik [Mon, 18 Nov 2019 07:10:15 +0000 (08:10 +0100)]
vircgroupv2devices: Fix format string for size_t variable

In virCgroupV2DevicesReallocMap() we are debug printing both
arguments passed to the function. However, the @size argument is
type of size_t but '%lu' is used to format it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
5 years agonews: mention 'ramfb' mdev attribute
Jonathon Jongsma [Fri, 15 Nov 2019 15:58:52 +0000 (09:58 -0600)]
news: mention 'ramfb' mdev attribute

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
5 years agovirbpf: Check if syscall() is available
Michal Privoznik [Fri, 15 Nov 2019 15:08:51 +0000 (16:08 +0100)]
virbpf: Check if syscall() is available

There are some OSes which don't have syscall() nor
<sys/syscall.h>. We already check for the header file in
configure phase, so we just need to add check for
HAVE_SYS_SYSCALL_H to HAVE_DECL_BPF_PROG_QUERY.

While I'm at it, some header files we are including are not
needed, so their includes can be safely dropped.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
5 years agospec: Remove build-time list of edk2 firmwares
Jim Fehlig [Thu, 14 Nov 2019 16:06:43 +0000 (09:06 -0700)]
spec: Remove build-time list of edk2 firmwares

Fedora now advertises supported firmwares via descriptor files.
Since the upstream spec file assumes recent Fedora, remove the
build-time list of firmwares, which can produce a warning after
commit 75597f022a.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconf: validate video resolution
Jonathon Jongsma [Thu, 14 Nov 2019 21:59:17 +0000 (15:59 -0600)]
conf: validate video resolution

Ensure that both x and y are non-zero when resolution is specified for a
video device.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
5 years agoconf: report errors when parsing video acceleration
Jonathon Jongsma [Thu, 14 Nov 2019 21:59:16 +0000 (15:59 -0600)]
conf: report errors when parsing video acceleration

Since this function is now only called when an 'acceleration' element is
present in the xml, any failure to parse the element will be considered
an error.

Previously, we detected some types of errors, but we would only log an
error (virReportError()), but still return a partially-specified accel
object to the caller. This patch returns NULL for all parsing errors and
reports that error back up to the caller.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
5 years agoconf: report errors when parsing video resolution
Jonathon Jongsma [Thu, 14 Nov 2019 21:59:15 +0000 (15:59 -0600)]
conf: report errors when parsing video resolution

The current code doesn't properly handle errors when parsing a video
device's resolution.  We were returning a NULL structure for the case
where 'x' or 'y' were missing. But for the other error cases, we were
logging an error (virReportError()), but still returning an
under-specified structure. That under-specified structure was used by
the calling function rather than properly reporting an error.

This patch changes the parse function to return NULL on any parsing
error and changes the calling function to report an error when NULL is
returned.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
5 years agoconf: iterate video model children in parent function
Jonathon Jongsma [Thu, 14 Nov 2019 21:59:14 +0000 (15:59 -0600)]
conf: iterate video model children in parent function

Previously, we were passing the video "model" node to the "acceleration"
and "resolution" parsing functions and requiring them to iterate over
the children to discover and parse the appropriate node. It makes more
sense to move this responsibility up to the parent function and just
pass these functions the node that needs to be parsed.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
5 years agovircgroup: Ensure /machine group is associated with its parent
Miguel Ángel Arruga Vivas [Mon, 4 Nov 2019 14:55:23 +0000 (15:55 +0100)]
vircgroup: Ensure /machine group is associated with its parent

Call first virCgroupNew on the parent group virCgroupNewPartition if
it is available on before the creation of the child group.  This
ensures that the creation of a first level group on the unified
architecture, as the check at virCgroupV2ParseControllersFile as the
parent file is there.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1760233
Signed-off-by: Miguel Ángel Arruga Vivas <rosen644835@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agodoc: cgroups: Remove unwanted references to systemd
Miguel Ángel Arruga Vivas [Mon, 4 Nov 2019 14:55:22 +0000 (15:55 +0100)]
doc: cgroups: Remove unwanted references to systemd

The non-systemd configurations do not create system neither user
control groups.  The title of the diagram referenced systemd too.

Signed-off-by: Miguel Ángel Arruga Vivas <rosen644835@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoAllow a zfs pool or dataset as source for zfs storage backend
Gregor Kopka [Thu, 7 Nov 2019 04:03:14 +0000 (04:03 +0000)]
Allow a zfs pool or dataset as source for zfs storage backend

Enables hosting a pool on an existing zfs pool without affecting
other datasets there.
Specify dataset instead of pool as source to use.
Parent of dataset must exist for pool-build to succeed.
Beware that pool-delete destroys the source dataset and all children.

Solves: https://www.redhat.com/archives/libvirt-users/2017-April/msg00041.html

Signed-off-by: Gregor Kopka <gregor@kopka.net>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoreplace use of gnulib snprintf by g_snprintf
Pavel Hrdina [Wed, 13 Nov 2019 13:53:42 +0000 (14:53 +0100)]
replace use of gnulib snprintf by g_snprintf

Glib implementation follows the ISO C99 standard so it's safe to replace
the gnulib implementation.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agovircgroupmock: mock virCgroupV2DevicesAvailable
Pavel Hrdina [Mon, 24 Jun 2019 13:13:37 +0000 (15:13 +0200)]
vircgroupmock: mock virCgroupV2DevicesAvailable

We need to mock virCgroupV2DevicesAvailable() in order to remove any
dependency on kernel as BPF devices might not be available.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovircgroup: workaround devices in hybrid mode
Pavel Hrdina [Thu, 14 Nov 2019 10:44:42 +0000 (11:44 +0100)]
vircgroup: workaround devices in hybrid mode

So the issue here is that you can end up with configuration where
you have cgroup v1 and v2 enabled at the same time and the devices
controllers is enabled for cgroup v1.

In cgroup v2 there is no devices controller, the device access is
controlled using BPF and since it is not a cgroup controller both
of them can exists at the same time and both of them are applied while
resolving access to devices.

In order to avoid configuring both BPF and cgroup v1 devices we will
use BPF if possible and otherwise fallback to cgroup v1 devices.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovircgroup: introduce virCgroupV2DenyAllDevices
Pavel Hrdina [Fri, 11 Jan 2019 13:56:48 +0000 (14:56 +0100)]
vircgroup: introduce virCgroupV2DenyAllDevices

If we want to deny all devices we just need to replace any existing
program with new program with empty map.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>