]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
6 years agovirprocess: Make virProcessRunInMountNamespace use virProcessRunInFork
Michal Privoznik [Tue, 16 Oct 2018 09:24:39 +0000 (11:24 +0200)]
virprocess: Make virProcessRunInMountNamespace use virProcessRunInFork

Both virProcessRunInMountNamespace() and virProcessRunInFork()
look very similar. De-duplicate the code and make
virProcessRunInMountNamespace() call virProcessRunInFork().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovirprocess: Introduce virProcessRunInFork
Michal Privoznik [Tue, 16 Oct 2018 08:50:33 +0000 (10:50 +0200)]
virprocess: Introduce virProcessRunInFork

This new helper can be used to spawn a child process and run
passed callback from it. This will come handy esp. if the
callback is not thread safe.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: add memfd source type
Marc-André Lureau [Thu, 15 Nov 2018 11:55:53 +0000 (15:55 +0400)]
qemu: add memfd source type

Add a new memoryBacking source type "memfd", supported by QEMU (when
the capability is available).

A memfd is a specialized anonymous memory kind. As such, an anonymous
source type could be automatically using a memfd. However, there are
some complications when migrating from different memory backends in
qemu (mainly due to the internal object naming at this point, but
there could be more). For now, it is simpler and safer to simply
introduce a new source type "memfd". Eventually, the "anonymous" type
could learn to use memfd transparently in a separate change.

The main benefits are that it doesn't need to create filesystem files,
and it also enforces sealing, providing a bit more safety.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoqemu: check memory-backend-memfd.hugetlb capability
Marc-André Lureau [Thu, 15 Nov 2018 11:55:52 +0000 (15:55 +0400)]
qemu: check memory-backend-memfd.hugetlb capability

QEMU 3.1 should only expose the property if the host is actually
capable of creating hugetable-backed memfd. However, it may fail
at runtime depending on requested "hugetlbsize".

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoqemu: add memory-backend-memfd capability check
Marc-André Lureau [Thu, 15 Nov 2018 11:55:51 +0000 (15:55 +0400)]
qemu: add memory-backend-memfd capability check

Check availability of "-object memory-backend-memfd".

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoqemu_process.c: removing qemuProcessStartValidateXML
Daniel Henrique Barboza [Wed, 14 Nov 2018 19:52:07 +0000 (17:52 -0200)]
qemu_process.c: removing qemuProcessStartValidateXML

Commit ("qemu_domain.c: moving maxCpu validation to
qemuDomainDefValidate") shortened the code of qemuProcessStartValidateXML.
The function is called only by qemuProcessStartValidate, in the
same file, and its code is now a single check that calls virDomainDefValidate.

Instead of leaving a function call just to execute a single check,
this patch puts the check in the body of qemuProcessStartValidate in the
place where qemuProcessStartValidateXML was being called. The function can
now be removed.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu_process.c: moving qemuValidateCpuCount to qemu_domain.c
Daniel Henrique Barboza [Wed, 14 Nov 2018 19:52:06 +0000 (17:52 -0200)]
qemu_process.c: moving qemuValidateCpuCount to qemu_domain.c

Previous patch removed the call to qemuProcessValidateCpuCount
from qemuProcessStartValidateXML, in qemu_process.c. The only
caller left is qemuDomainDefValidate, in qemu_domain.c.

Instead of having a public function declared inside qemu_process.c
that isn't used in that file, this patch moves the function to
qemu_domain.c, making in static and renaming it to
qemuDomainValidateCpuCount to be compliant with other static
functions names in the file.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu_domain.c: moving maxCpu validation to qemuDomainDefValidate
Daniel Henrique Barboza [Wed, 14 Nov 2018 19:52:05 +0000 (17:52 -0200)]
qemu_domain.c: moving maxCpu validation to qemuDomainDefValidate

Adding maxCpu validation in qemuDomainDefValidate allows the user to
spot over the board maxCpus counts at editing time, instead of
facing a runtime error when starting the domain. This check is also
arch independent.

This leaves us with 2 calls to qemuProcessValidateCpuCount: one in
qemuProcessStartValidateXML and the new one at qemuDomainDefValidate.

The call in qemuProcessStartValidateXML is redundant. Following
up in that code, there is a call to virDomainDefValidate, which
in turn will call config.domainValidateCallback. In this case, the
callback function is qemuDomainDefValidate. This means that, on startup
time, qemuProcessValidateCpuCount will be called twice.

To avoid that, let's also remove the qemuProcessValidateCpuCount call
from qemuProcessStartValidateXML.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu_process.c: make qemuValidateCpuCount public
Daniel Henrique Barboza [Wed, 14 Nov 2018 19:52:04 +0000 (17:52 -0200)]
qemu_process.c: make qemuValidateCpuCount public

qemuValidateCpuCount validates the maxCpus value of a domain at
startup time, preventing it to start if the value exceeds a maximum.

This checking is also done at qemu_domain.c, qemuDomainDefValidate.
However, it is done only for x86 (and even then, in a specific
scenario). We want this check to be done for all archs.

To accomplish this, let's first make qemuValidateCpuCount public so
it can be used inside qemuDomainDefValidate. The function was renamed
to qemuProcessValidateCpuCount to be compliant with the other public
methods at qemu_process.h. The method signature was slightly adapted
to fit the const 'def' variable used in qemuDomainDefValidate. This
change has no downside in in its original usage at
qemuProcessStartValidateXML.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu_process.c: adding maxCpus value to error message
Daniel Henrique Barboza [Wed, 14 Nov 2018 19:52:03 +0000 (17:52 -0200)]
qemu_process.c: adding maxCpus value to error message

Adding the maxCpus value in the error message of qemuValidateCpuCount
allows the user to set an acceptable maxCpus count without knowing
QEMU internals.

x86 guests, that might have been created prior to the x86
qemuDomainDefValidate maxCpus check code (that validates the maxCpus value
in editing time), will also benefit from this change.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: agent: Avoid agentError when closing the QEMU agent
Wang Yechao [Fri, 12 Oct 2018 02:19:28 +0000 (10:19 +0800)]
qemu: agent: Avoid agentError when closing the QEMU agent

The commit 89563efc0209b854d2b2e554423423d7602acdbd fix the
monitor error when closing the QEMU monitor. The QEMU agent
has a problem similar to QEMU monitor. So fix the QEMU agent
with the same method.

Signed-off-by: Wang Yechao <wang.yechao255@zte.com.cn>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoutil: Fix virpci compilation on non-Linux
Andrea Bolognani [Thu, 15 Nov 2018 14:50:21 +0000 (15:50 +0100)]
util: Fix virpci compilation on non-Linux

We were mistakenly skipping virZPCIDeviceAddressIsEmpty() and
virZPCIDeviceAddressIsValid() when compiling on non-Linux,
which unsurprisingly ended up causing linking failures later
in the build process.

Clue-stick-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 years agonews: Update news for PCI address extension attributes
Yi Min Zhao [Thu, 8 Nov 2018 11:00:32 +0000 (19:00 +0800)]
news: Update news for PCI address extension attributes

Signed-off-by: Yi Min Zhao <zyimin@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.ibm.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemu: Add hotpluging support for PCI devices on S390 guests
Yi Min Zhao [Thu, 8 Nov 2018 11:00:30 +0000 (19:00 +0800)]
qemu: Add hotpluging support for PCI devices on S390 guests

This commit adds hotplug support for PCI devices on S390 guests.
There's no need to implement hot unplug for zPCI as QEMU implements
an unplug callback which will unplug both PCI and zPCI device in a
cascaded way.
Currently, the following PCI devices are supported:
  virtio-blk-pci
  virtio-net-pci
  virtio-rng-pci
  virtio-input-host-pci
  virtio-keyboard-pci
  virtio-mouse-pci
  virtio-tablet-pci
  vfio-pci
  SCSIVhost device

Signed-off-by: Yi Min Zhao <zyimin@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemu: Generate and use zPCI device in QEMU command line
Yi Min Zhao [Thu, 8 Nov 2018 11:00:29 +0000 (19:00 +0800)]
qemu: Generate and use zPCI device in QEMU command line

Add new functions to generate zPCI command string and append it to
QEMU command line. And the related tests are added.

Signed-off-by: Yi Min Zhao <zyimin@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agodocs: Add 'uid' and 'fid' information
Yi Min Zhao [Thu, 8 Nov 2018 11:00:31 +0000 (19:00 +0800)]
docs: Add 'uid' and 'fid' information

Update 'Device address' section to describe 'zpci' element and
its two attributes 'uid' and 'fid'.

Signed-off-by: Yi Min Zhao <zyimin@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.ibm.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoconf: Allocate/release 'uid' and 'fid' in PCI address
Yi Min Zhao [Thu, 8 Nov 2018 11:00:28 +0000 (19:00 +0800)]
conf: Allocate/release 'uid' and 'fid' in PCI address

This patch adds new functions for reservation, assignment and release
to handle the uid/fid. If the uid/fid is defined in the domain XML,
they will be reserved directly in the collecting phase. If any of them
is not defined, we will find out an available value for them from the
zPCI address hashtable, and reserve them. For the hotplug case there
might not be a zPCI definition. So allocate and reserve uid/fid the
case. Assign if needed and reserve uid/fid for the defined case.

Signed-off-by: Yi Min Zhao <zyimin@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemu: Add zPCI address definition check
Yi Min Zhao [Thu, 8 Nov 2018 11:00:27 +0000 (19:00 +0800)]
qemu: Add zPCI address definition check

We should ensure that QEMU supports zPCI when a zPCI address is defined
in XML and otherwise report an error. This patch introduces a generic
validation function qemuDomainDeviceDefValidateAddress() which calls
qemuDomainDeviceDefValidateZPCIAddress() if address type is PCI address.

Signed-off-by: Yi Min Zhao <zyimin@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoconf: Introduce parser, formatter for uid and fid
Yi Min Zhao [Thu, 8 Nov 2018 11:00:26 +0000 (19:00 +0800)]
conf: Introduce parser, formatter for uid and fid

This patch introduces new XML parser/formatter functions. Uid is
16-bit and non-zero. Fid is 32-bit. They are the two attributes of zpci
which is introduced as PCI address element. Zpci element is parsed and
formatted along with PCI address. And add the related test cases.

Signed-off-by: Yi Min Zhao <zyimin@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoconf: use virXMLFormatElement() in virDomainDeviceInfoFormat()
Yi Min Zhao [Thu, 8 Nov 2018 11:00:25 +0000 (19:00 +0800)]
conf: use virXMLFormatElement() in virDomainDeviceInfoFormat()

In order to add zPCI child element for PCI address, we update
virDomainDeviceInfoFormat() to format device info by helper function
virXMLFormatElement(). Then we could simply format zPCI address into
child buffer later.

Signed-off-by: Yi Min Zhao <zyimin@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemu: Auto add pci-root for s390/s390x guests
Yi Min Zhao [Thu, 8 Nov 2018 11:00:23 +0000 (19:00 +0800)]
qemu: Auto add pci-root for s390/s390x guests

The pci-root depends on zpci capability. So autogenerate pci-root if
zpci exists.

Signed-off-by: Yi Min Zhao <zyimin@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoconf: Introduce address caching for PCI extensions
Yi Min Zhao [Thu, 8 Nov 2018 11:00:24 +0000 (19:00 +0800)]
conf: Introduce address caching for PCI extensions

This patch provides a caching mechanism for the device address
extensions uid and fid on S390. For efficient sparse address allocation,
we introduce two hash tables for uid/fid which hold the address set
information per domain. Also in order to improve performance of
searching available value, we introduce our own callbacks for the two
hashtables. In this way, uid/fid is saved in hash key and hash value
could be any non-NULL pointer due to no operation on hash value. That is
also the reason why we don't introduce hash value free callback.

Signed-off-by: Yi Min Zhao <zyimin@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoconf: Introduce extension flag and zPCI member for PCI address
Yi Min Zhao [Thu, 8 Nov 2018 11:00:21 +0000 (19:00 +0800)]
conf: Introduce extension flag and zPCI member for PCI address

This patch introduces PCI address extension flag for virDomainDeviceInfo
and virPCIDeviceAddress. The extension flag in virDomainDeviceInfo is
used internally during calculating PCI extension flag. The one in
virPCIDeviceAddress is the duplicate to indicate extension address is
being used. Currently only zPCI extension address is introduced to deal
with 'uid' and 'fid' on the S390 platform.

Signed-off-by: Yi Min Zhao <zyimin@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemu: Enable PCI multi bus for S390 guests
Yi Min Zhao [Thu, 8 Nov 2018 11:00:22 +0000 (19:00 +0800)]
qemu: Enable PCI multi bus for S390 guests

QEMU on s390 supports PCI multibus since forever.

Signed-off-by: Yi Min Zhao <zyimin@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemu: Introduce zPCI capability
Yi Min Zhao [Thu, 8 Nov 2018 11:00:20 +0000 (19:00 +0800)]
qemu: Introduce zPCI capability

Let's introduce zPCI capability.

Signed-off-by: Yi Min Zhao <zyimin@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoconf: Add definitions for 'uid' and 'fid' PCI address attributes
Yi Min Zhao [Thu, 8 Nov 2018 11:00:19 +0000 (19:00 +0800)]
conf: Add definitions for 'uid' and 'fid' PCI address attributes

Add zPCI definitions in preparation of extending the PCI address
with parameters uid (user-defined identifier) and fid (PCI function
identifier).

Signed-off-by: Yi Min Zhao <zyimin@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agonews: mention Hyper-V PV IPI and Enlightened VMCS support
Vitaly Kuznetsov [Wed, 14 Nov 2018 22:46:08 +0000 (23:46 +0100)]
news: mention Hyper-V PV IPI and Enlightened VMCS support

The QEMU driver now has support for Hyper-V PV IPI and Enlightened VMCS
for Windows and Hyper-V guests.

Suggested-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
6 years agoqemu: add support for Hyper-V Enlightened VMCS
Vitaly Kuznetsov [Wed, 14 Nov 2018 22:46:07 +0000 (23:46 +0100)]
qemu: add support for Hyper-V Enlightened VMCS

QEMU 3.1 supports Hyper-V Enlightened VMCS feature which significantly
speeds up nested Hyper-V on KVM environments.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
6 years agoconf: add support for Hyper-V Enlightened VMCS
Vitaly Kuznetsov [Wed, 14 Nov 2018 22:46:06 +0000 (23:46 +0100)]
conf: add support for Hyper-V Enlightened VMCS

Support Hyper-V Enlightened VMCS in domain config. QEMU support will
be implemented in the next patch, adding interim VIR_DOMAIN_HYPERV_EVMCS
cases to src/qemu/* for now.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
6 years agoqemu: add support for Hyper-V PV IPIs
Vitaly Kuznetsov [Wed, 14 Nov 2018 22:46:05 +0000 (23:46 +0100)]
qemu: add support for Hyper-V PV IPIs

QEMU 3.1 supports Hyper-V-style PV IPIs making it cheaper for Windows
guests to send an IPI, especially when it targets many CPUs.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
6 years agoconf: add support for Hyper-V PV IPIs
Vitaly Kuznetsov [Wed, 14 Nov 2018 22:46:04 +0000 (23:46 +0100)]
conf: add support for Hyper-V PV IPIs

Support Hyper-V PV IPI enlightenment in domain config. QEMU support will
be implemented in the next patch, adding interim VIR_DOMAIN_HYPERV_IPI
cases to src/qemu/* for now.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
6 years agodocs: remove extra whitespace from Hyper-V enlightenments options
Vitaly Kuznetsov [Wed, 14 Nov 2018 22:46:03 +0000 (23:46 +0100)]
docs: remove extra whitespace from Hyper-V enlightenments options

Remove redundant leading whitespaces from "<td> on, off</td>".

Suggested-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
6 years agorpc: Remove duplicate check from filter function return.
Julio Faracco [Wed, 14 Nov 2018 17:49:00 +0000 (15:49 -0200)]
rpc: Remove duplicate check from filter function return.

This is a simple removal of a duplicated check of the return of the
filter function. There is a nested conditional checking exactly the same
thing since commit c9ede1cf removed the (ret > 0) check condition.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: Using virStringListFreeCount instead VIR_FREE to free tmpPaths.
Julio Faracco [Wed, 14 Nov 2018 17:32:31 +0000 (15:32 -0200)]
qemu: Using virStringListFreeCount instead VIR_FREE to free tmpPaths.

The function qemuDomainGetHostdevPath() is using VIR_FREE to free the
paths stored in tmpPaths. Both syntax analyzer are reporting a warning
about this. Replacing the old method to function
virStringListFreeCount() fixes the warnings/errors.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agotests: Adding tests cases to cover rebased settings for LXC 3.0.
Julio Faracco [Wed, 14 Nov 2018 17:25:46 +0000 (15:25 -0200)]
tests: Adding tests cases to cover rebased settings for LXC 3.0.

This commit includes new test cases to cover LXC version 3.0 and higher.
This LXC version rebased some settings entries and deprecated other ones.
As we support both, we should include tests to minimize problems with
integration between them.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agolxc: Include support to lxc version 3.0 or higher.
Julio Faracco [Wed, 14 Nov 2018 17:25:45 +0000 (15:25 -0200)]
lxc: Include support to lxc version 3.0 or higher.

This patch introduce the new settings for LXC 3.0 or higher. The older
versions keep the compatibility to deprecated settings for LXC, but
after release 3.0, the compatibility was removed. This commit adds the
support to the refactored settings.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agotests: Augment vcgrouptest to add virCgroupGetMemoryStat
John Ferlan [Wed, 7 Nov 2018 23:40:43 +0000 (18:40 -0500)]
tests: Augment vcgrouptest to add virCgroupGetMemoryStat

Add a test to fetch the GetMemoryStat output. This only gets
data for v1 only right now since the v2 data from commit 61ff6021
is rather useless returning all 0's. The v1 data was originally
added in commit d1452470.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
6 years agoutil: Fix virCgroupGetMemoryStat
Peter Chubb [Wed, 7 Nov 2018 23:40:24 +0000 (18:40 -0500)]
util: Fix virCgroupGetMemoryStat

Commit 901d2b9c introduced virCgroupGetMemoryStat and replaced
the LXC virLXCCgroupGetMemStat logic in commit e634c7cd0. However,
in doing so the replacement wasn't exact as the LXC logic used
getline() to process the cgroup controller data, while the new
virCgroupGetMemoryStat used "memory.stat" manual buffer read/
processing which neglected to forward through @line in order
to read each line in the output.

To fix that, we should be sure to carry forward the @line value
for each line read updating it beyond that current @newLine value
once we've calculated the values that we want.

Signed-off-by: Peter Chubb <peter.chubb@data61.csiro.au>
Reviewed-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
6 years agoqemu: Set identity for the reconnect all thread
John Ferlan [Mon, 12 Nov 2018 13:27:26 +0000 (08:27 -0500)]
qemu: Set identity for the reconnect all thread

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

If polkit authentication is enabled, an attempt to open
the connection failed during virAccessDriverPolkitGetCaller
when the call to virIdentityGetCurrent returned NULL resulting
in the errors:

  virAccessDriverPolkitGetCaller:87 : access denied:
  Policy kit denied action org.libvirt.api.connect.getattr from <anonymous>

Because qemuProcessReconnect runs in a thread during
daemonRunStateInit processing it doesn't have the thread
local identity. Thus when the virGetConnectNWFilter is
called as part of the qemuProcessFiltersInstantiate when
virDomainConfNWFilterInstantiate is run the attempt to get
the idenity fails and results in the anonymous error above.

To fix this, let's grab/use the virIdenityPtr of the process
that will be creating the thread, e.g. what daemonRunStateInit
has set and use that for our thread. That way any other similar
processing that uses/requires an identity for any other call
that would have previously been successfully run won't fail in
a similar manner.

Signed-off-by: John Ferlan <jferlan@redhat.com>
6 years agoaccess: Modify the VIR_ERR_ACCESS_DENIED to include driverName
John Ferlan [Mon, 12 Nov 2018 13:15:02 +0000 (08:15 -0500)]
access: Modify the VIR_ERR_ACCESS_DENIED to include driverName

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

Changes made to manage and utilize a secondary connection
driver to APIs outside the scope of the primary connection
driver have resulted in some confusion processing polkit rules
since the simple "access denied" error message doesn't provide
enough of a clue when combined with the "authentication failed:
access denied by policy" as to which connection driver refused
or failed the ACL check.

In order to provide some context, let's modify the existing
"access denied" error returned from the various vir*EnsureACL
API's to provide the connection driver name that is causing
the failure. This should provide the context for writing the
polkit rules that would allow access via the driver, but yet
still adhere to the virAccessManagerSanitizeError commentary
regarding not telling the user why access was denied.

Signed-off-by: John Ferlan <jferlan@redhat.com>
6 years agoRevert "access: Modify the VIR_ERR_ACCESS_DENIED to include driverName"
John Ferlan [Mon, 12 Nov 2018 12:33:06 +0000 (07:33 -0500)]
Revert "access: Modify the VIR_ERR_ACCESS_DENIED to include driverName"

This reverts commit ccc72d5cbdd85f66cb737134b3be40aac1df03ef.

Based on upstream comment to a follow-up patch, this didn't take the
right approach and the right thing to do is revert and rework.

Signed-off-by: John Ferlan <jferlan@redhat.com>
6 years agoutil: Fix memory leak in virResctrlMonitorGetStats
John Ferlan [Wed, 14 Nov 2018 19:01:06 +0000 (14:01 -0500)]
util: Fix memory leak in virResctrlMonitorGetStats

Missed during review and surprisingly my run through Coverity also
didn't see this. I only noticed it when reading the code while fixing
the build breaker for commit 36780a86a.

With all those continues we would leak @stats.

Signed-off-by: John Ferlan <jferlan@redhat.com>
6 years agoutil: Change usage of ent->d_type != DT_DIR
John Ferlan [Wed, 14 Nov 2018 18:55:13 +0000 (13:55 -0500)]
util: Change usage of ent->d_type != DT_DIR

Fix a broken non-Linux build to use the !virFileIsDir instead

Signed-off-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: Refactor qemuDomainGetStatsCpu
Wang Huaqiang [Mon, 12 Nov 2018 13:31:46 +0000 (21:31 +0800)]
qemu: Refactor qemuDomainGetStatsCpu

Refactoring qemuDomainGetStatsCpu, make it possible to add
more CPU statistics.

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: enable resctrl monitor in qemu
Wang Huaqiang [Mon, 12 Nov 2018 13:31:45 +0000 (21:31 +0800)]
qemu: enable resctrl monitor in qemu

Add functions for creating, destroying, reconnecting resctrl
monitor in qemu according to the configuration in domain XML.

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoconf: Introduce cache monitor element in cachetune
Wang Huaqiang [Mon, 12 Nov 2018 13:31:44 +0000 (21:31 +0800)]
conf: Introduce cache monitor element in cachetune

Introducing <monitor> element under <cachetune> to represent
a cache monitor.

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoconf: Remove virDomainResctrlAppend and introduce virDomainResctrlNew
Wang Huaqiang [Mon, 12 Nov 2018 13:31:43 +0000 (21:31 +0800)]
conf: Remove virDomainResctrlAppend and introduce virDomainResctrlNew

Introduced virDomainResctrlNew to do the most part of virDomainResctrlAppend
and move the operation of appending resctrl to @def->resctrls out of
function.

Rather than rely on virDomainResctrlAppend to perform the allocation, move
the onus to the caller and make use of virBitmapNewCopy for @vcpus and
virObjectRef for @alloc, thus removing the need to set each to NULL after the
call.

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoutil: Add more interfaces for resctrl monitor
Wang Huaqiang [Mon, 12 Nov 2018 13:31:41 +0000 (21:31 +0800)]
util: Add more interfaces for resctrl monitor

Add interfaces monitor group to support operations such
as GetID, SetID, Remove, SetAlloc, etc.

Implement the internal virResctrlMonitorGetStats to fetch all
the statistical data and the virResctrlMonitorGetCacheOccupancy
in order to fetch the cache specific "llc_occupancy" value.

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoutil: Refactor virResctrlAllocSetID to set allocation ID
Wang Huaqiang [Mon, 12 Nov 2018 13:31:40 +0000 (21:31 +0800)]
util: Refactor virResctrlAllocSetID to set allocation ID

Refactor virResctrlAllocSetID generating an error if an attempt
is made to overwrite the existing value.

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoutil: Add interface for creating monitor group
Wang Huaqiang [Mon, 12 Nov 2018 13:31:39 +0000 (21:31 +0800)]
util: Add interface for creating monitor group

Add interface for creating the resource monitoring group according
to '@virResctrlMonitor->path'.

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoutil: Refactor code for creating resctrl group
Wang Huaqiang [Mon, 12 Nov 2018 13:31:38 +0000 (21:31 +0800)]
util: Refactor code for creating resctrl group

The code for creating resctrl allocation group could be reused
for monitoring group, refactor it for reuse in the later patch.

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoutil: Add interface for adding PID to the monitor
Wang Huaqiang [Mon, 12 Nov 2018 13:31:37 +0000 (21:31 +0800)]
util: Add interface for adding PID to the monitor

Add interface for adding task PID to the monitor.

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoutil: Refactor code for adding PID to the resource group
Wang Huaqiang [Mon, 12 Nov 2018 13:31:36 +0000 (21:31 +0800)]
util: Refactor code for adding PID to the resource group

The code of adding PID to the allocation could be reused, refactor it
for later reuse.

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoutil: Add interface to determine monitor path
Wang Huaqiang [Mon, 12 Nov 2018 13:31:35 +0000 (21:31 +0800)]
util: Add interface to determine monitor path

Add interface for resctrl monitor to determine the path.

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoutil: Refactor code for determining allocation path
Wang Huaqiang [Mon, 12 Nov 2018 13:31:34 +0000 (21:31 +0800)]
util: Refactor code for determining allocation path

The code for determining resctrl allocation path could be reused
for monitor. Refactor it for reuse.

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoutil: Introduce resctrl monitor for CMT
Wang Huaqiang [Mon, 12 Nov 2018 13:31:33 +0000 (21:31 +0800)]
util: Introduce resctrl monitor for CMT

Cache Monitoring Technology (aka CMT) provides the capability
to report cache utilization information of system task.

This patch introduces the concept of resctrl monitor through
data structure virResctrlMonitor.

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agodocs,util: Refactor schemas and virresctrl to support optional cache
Wang Huaqiang [Mon, 12 Nov 2018 13:31:32 +0000 (21:31 +0800)]
docs,util: Refactor schemas and virresctrl to support optional cache

Refactor schemas and virresctrl to support optional <cache> element
in <cachetune>.

Later, the monitor entry will be introduced and to be placed
under <cachetune>. Either cache entry or monitor entry is
an optional element of <cachetune>.

An cachetune has no <cache> element is taking the default resource
allocating policy defined in '/sys/fs/resctrl/schemata'.

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoutil: fix handling of unspecified port in URI
Daniel P. Berrangé [Tue, 13 Nov 2018 11:30:03 +0000 (11:30 +0000)]
util: fix handling of unspecified port in URI

When no server name is provided in the URI, modern versions of libxml2
will set the port to '-1'. This is a change from behaviour with earlier
versions which set it to 0.

Libvirt expects the port to be 0 in these cases and as a result we get a
bug when connecting to URIs which lack a server name:

$ virsh  -c test+ssh:///default list
error: failed to connect to the hypervisor
error: Cannot recv data: Bad port '-1': Connection reset by peer

This libxml2 change was attempting to fix another bug identified by
libvirt where it didn't roundtrip URIs correctly in:

  https://github.com/GNOME/libxml2/commit/beb7281055dbf0ed4d041022a67c6c5cfd126f25

Essentially libxml2 was not expecting apps to look at the URI port
field when the server name is not provided. This was a reasonable
assumption, but none the less libvirt did look at it :-)

The fix is to ensure we explicitly set port to 0 when server name
is not present, avoiding undefined behaviour for the port field in
libxml2.

Reviewed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agolibvirt: add daemon itself as shutdown reason
Nikolay Shirokovskiy [Mon, 8 Oct 2018 11:21:08 +0000 (14:21 +0300)]
libvirt: add daemon itself as shutdown reason

This patch introduces a new shutdown reason "daemon" in order
to indicate that the daemon needed to force shutdown the domain
as the best course of action to take at the moment.

This action would occur during reconnection when processing
encounters an error once the monitor reconnection is successful.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agobuild: Fix uninstall when WITH_APPARMOR_PROFILES is defined
Jim Fehlig [Thu, 8 Nov 2018 00:38:27 +0000 (17:38 -0700)]
build: Fix uninstall when WITH_APPARMOR_PROFILES is defined

When libvirt configuration includes '--with-apparmor-profiles', the
make uninstall target fails

make[1]: Entering directory '/home/jim/upstream/libvirt/examples'
 ( cd '/etc/apparmor.d//abstractions' && rm -f libvirt-qemu libvirt-lxc )
 ( cd '/etc/apparmor.d/' && rm -f usr.lib.libvirt.virt-aa-helper usr.sbin.libvirtd )
make[1]: *** No rule to make target 'uninstall-apparmor-local', needed by
'uninstall-local'.  Stop.

Add missing 'uninstall-apparmor-local' target to the examples Makefile.am.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agovirSecuritySELinuxTransactionCommit: Return -1 if no transaction is set
Marc Hartmayer [Tue, 13 Nov 2018 16:32:29 +0000 (17:32 +0100)]
virSecuritySELinuxTransactionCommit: Return -1 if no transaction is set

Return -1 and report an error message if no transaction is set and
virSecuritySELinuxTransactionCommit is called.

The function description of virSecuritySELinuxTransactionCommit says:

  "Also it is considered as error if there's no transaction set and this
   function is called."

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
6 years agovirSecuritySELinuxTransactionCommit: Don't mask error
Michal Privoznik [Tue, 13 Nov 2018 15:45:52 +0000 (16:45 +0100)]
virSecuritySELinuxTransactionCommit: Don't mask error

In 4674fc6afd6 I've implemented transactions for selinux driver.
Well, now that I am working in this area I've noticed a subtle
bug: @ret is initialized to 0 instead of -1. Facepalm.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
6 years agoexamples: Add missing quotes
Andrea Bolognani [Tue, 13 Nov 2018 17:11:49 +0000 (18:11 +0100)]
examples: Add missing quotes

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 years agotravis: Switch from Docker Hub to quay.io
Andrea Bolognani [Tue, 13 Nov 2018 12:20:20 +0000 (13:20 +0100)]
travis: Switch from Docker Hub to quay.io

As it's currently impossible for us to create new automated
builds on Docker Hub (see [1]), and quay.io doesn't suffer
from the same problem while still having all the feature we
need, switch to the latter.

[1] https://github.com/docker/hub-feedback/issues/1676

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoconf: Move VFIO AP validation from post parse to QEMU validation code
Erik Skultety [Mon, 12 Nov 2018 11:24:42 +0000 (12:24 +0100)]
conf: Move VFIO AP validation from post parse to QEMU validation code

VFIO AP has a limitation on a single device per domain, however, when
commit 11708641 added the support for vfio-ap, check for this limitation
was performed as part of the post parse code. Generally, checks like that
should be performed within the driver's validation callback to eliminate
any slight chance of failing in post parse, which could potentially
result in the domain XML config vanishing.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
6 years agoqemu: Extract MDEV VFIO PCI validation code into a separate helper
Erik Skultety [Mon, 12 Nov 2018 08:35:21 +0000 (09:35 +0100)]
qemu: Extract MDEV VFIO PCI validation code into a separate helper

Since we'll need to validate other models apart from VFIO PCI too,
having a helper for each model should keep the code base cleaner.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
6 years agoconf: Add new module node_device_util
Erik Skultety [Wed, 19 Sep 2018 11:34:35 +0000 (13:34 +0200)]
conf: Add new module node_device_util

There's a lot of stuff going on in src/conf/nodedev_conf which is
sometimes not directly related to config and we're not really consistent
with putting only parser/formatter related stuff here, e.g. like we do
for domains. So, let's start simply by adding a new module
node_device_util containing some of the helpers. Unfortunately, even
though these helpers tend to open a secondary driver connection and would
be much therefore better suited as a nodedev driver module, we can't do
that without pulling headers from the driver into conf/ and that's wrong
because we want conf/ to stay driver-agnostic.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Acked-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoqemu: Drop priv->gotShutdown
Jiri Denemark [Wed, 7 Nov 2018 13:40:57 +0000 (14:40 +0100)]
qemu: Drop priv->gotShutdown

The gotShutdown bool has been redundant since we started setting
VIR_DOMAIN_SHUTDOWN state after receiving SHUTDOWN event from QEMU.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: Drop unreachable code from qemuProcessHandleStop
Jiri Denemark [Wed, 7 Nov 2018 13:37:41 +0000 (14:37 +0100)]
qemu: Drop unreachable code from qemuProcessHandleStop

If gotShutdown is true, the domain state cannot be running because of
the following code in qemuProcessHandleShutdown:

    priv->gotShutdown = true;

    VIR_DEBUG("Transitioned guest %s to shutdown state",
              vm->def->name);
    virDomainObjSetState(vm,
                         VIR_DOMAIN_SHUTDOWN,
                         VIR_DOMAIN_SHUTDOWN_UNKNOWN);

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: Fix segfault in qemuDomainPrimeVirtioDeviceAddresses
Wang Yechao [Fri, 9 Nov 2018 06:41:23 +0000 (14:41 +0800)]
qemu: Fix segfault in qemuDomainPrimeVirtioDeviceAddresses

On aarch64, lauch vm with the follow configuration:

<interface type="hostdev" managed="yes">
  <mac address="fa:16:3e:14:41:00"/>
  <source>
    <address type="pci" domain="0x0000" bus="0x01" slot="0x0b" function="0x2"/>
  </source>
</interface>

libvirtd will crash when accessing net->model.

Signed-off-by: Wang Yechao <wang.yechao255@zte.com.cn>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agonews: Add entry for soft reset support in Xen
Jim Fehlig [Thu, 8 Nov 2018 15:50:09 +0000 (08:50 -0700)]
news: Add entry for soft reset support in Xen

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agosnapshot: Don't hose list on deletion failure
Eric Blake [Thu, 18 Oct 2018 00:24:34 +0000 (19:24 -0500)]
snapshot: Don't hose list on deletion failure

If qemuDomainSnapshotDiscard() fails for any reason (rare,
but possible with an ill-timed ENOMEM or if
qemuDomainSnapshotForEachQcow2() has problems talking to the
qemu guest monitor), then an attempt to retry the snapshot
deletion API will crash because we didn't undo the effects
of virDomainSnapshotDropParent() temporarily rearranging the
internal list structures, and the second attempt to drop
parents will dereference NULL.  Fix it by instead noting that
there are only two callers to qemuDomainSnapshotDiscard(),
and only one of the two callers wants the parent to be updated;
thus we can move the call to virDomainSnapshotDropParent()
into a code path that only gets executed on success.

Signed-off-by: Eric Blake <eblake@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agospec: Drop support for Fedora 27
Andrea Bolognani [Thu, 8 Nov 2018 12:10:14 +0000 (13:10 +0100)]
spec: Drop support for Fedora 27

In accordance with our platform support policy, now that
Fedora 29 is out we no longer support building on Fedora 27.

This allows us to remove a few version checks.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoqemu: Don't ignore resume events
Jiri Denemark [Wed, 7 Nov 2018 13:34:52 +0000 (14:34 +0100)]
qemu: Don't ignore resume events

Since commit v4.7.0-302-ge6d77a75c4 processing RESUME event is mandatory
for updating domain state. But the event handler explicitly ignored this
event in some cases. Thus the state would be wrong after a fake reboot
or when a domain was rebooted after it crashed.

BTW, the code to ignore RESUME event after SHUTDOWN didn't make sense
even before making RESUME event mandatory. Most likely it was there as a
result of careless copy&paste from qemuProcessHandleStop.

The corresponding debug message was clarified since the original state
does not have to be "paused" only and while we have a "resumed" event,
the state is called "running".

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
6 years agotests: Use correct function name in error path
John Ferlan [Wed, 7 Nov 2018 23:18:42 +0000 (18:18 -0500)]
tests: Use correct function name in error path

Commit id 5eb61e6846 neglected to change the name in the wrong value
output to virCgroupGetPercpuStats from virCgroupGetMemoryUsage.

Signed-off-by: John Ferlan <jferlan@redhat.com>
6 years agolxc: Clang is complaining about possible NULL pointer.
Julio Faracco [Wed, 7 Nov 2018 20:57:02 +0000 (18:57 -0200)]
lxc: Clang is complaining about possible NULL pointer.

The array "mount" inside lxc_container is not being checked before for
loop. Clang syntax scan is complaining about this segmentation fault.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: Narrow the shutdown reconnection failure reason window
John Ferlan [Thu, 1 Nov 2018 15:19:02 +0000 (11:19 -0400)]
qemu: Narrow the shutdown reconnection failure reason window

The current qemuProcessReconnect logic paints a broad brush
determining that the shutdown reason must be crashed if it was
determined that the domain was started with -no-shutdown; however,
there's many other ways to get to the error label, so let's narrow
our reasoning window for using VIR_DOMAIN_SHUTOFF_CRASHED to the
period where we essentially know we've tried to create to the
monitor and before we were successful in opening the connection.

Failures that occur outside that window would thus be considered
as VIR_DOMAIN_SHUTOFF_UNKNOWN, at least for now.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoqemu: Restore lost shutdown reason
John Ferlan [Tue, 16 Oct 2018 12:38:27 +0000 (08:38 -0400)]
qemu: Restore lost shutdown reason

When qemuProcessReconnectHelper was introduced (commit d38897a5d)
reconnection failure used VIR_DOMAIN_SHUTOFF_FAILED; however, that
was changed in commit bda2f17d to either VIR_DOMAIN_SHUTOFF_CRASHED
or VIR_DOMAIN_SHUTOFF_UNKNOWN.

When QEMU_CAPS_NO_SHUTDOWN checking was removed in commit fe35b1ad6
the conditional state was just left at VIR_DOMAIN_SHUTOFF_CRASHED.

So introduce qemuDomainIsUsingNoShutdown which will manage the
condition when the domain was started with -no-shutdown so that
when/if reconnection failure occurs we can restore the decision
point used to determine whether CRASHED or UNKNOWN is provided.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agolibxl: Properly dispose libxl_domain_config object
Jim Fehlig [Tue, 6 Nov 2018 22:21:19 +0000 (15:21 -0700)]
libxl: Properly dispose libxl_domain_config object

V2 of the libxl soft reset patch, which was pushed as commit da4b0fd9,
dropped the hunk that disposed of the libxl_domain_config object. Add
the missing hunk to properly dispose the object.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
6 years agolibxl: add support for soft reset
Jim Fehlig [Wed, 31 Oct 2018 17:03:37 +0000 (11:03 -0600)]
libxl: add support for soft reset

The pvops Linux kernel implements machine_ops.crash_shutdown as

static void xen_hvm_crash_shutdown(struct pt_regs *regs)
{
        native_machine_crash_shutdown(regs);
        xen_reboot(SHUTDOWN_soft_reset);
}

but currently the libxl driver does not handle the soft reset
shutdown event. As a result, the guest domain never proceeds
past xen_reboot(), making it impossible for HVM domains to save
a crash dump using kexec.

This patch adds support for handling the soft reset event by
calling libxl_domain_soft_reset() and re-enabling domain death
events, which is similar to the xl tool handling of soft reset
shutdown event.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agolibxl: Remove some goto labels in libxlDomainShutdownThread
Jim Fehlig [Wed, 31 Oct 2018 16:54:14 +0000 (10:54 -0600)]
libxl: Remove some goto labels in libxlDomainShutdownThread

There are too many goto labels in libxlDomainShutdownThread. Convert the
'destroy' and 'restart' labels to helper functions, leaving only the
commonly used pattern of 'endjob' and 'cleanup' labels.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agolibxl: remove redundant calls to virObjectEventStateQueue
Jim Fehlig [Wed, 31 Oct 2018 16:41:28 +0000 (10:41 -0600)]
libxl: remove redundant calls to virObjectEventStateQueue

In libxlDomainShutdownThread, virObjectEventStateQueue is needlessly
called in the destroy and restart labels. The cleanup label aready
queues whatever event was created based on libxl_shutdown_reason.
There is no need to handle destroy and restart differently.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoqemuBuildChrChardevStr: increase scope of qemuBuildChrChardevStr
Ján Tomko [Wed, 3 Oct 2018 15:35:40 +0000 (17:35 +0200)]
qemuBuildChrChardevStr: increase scope of qemuBuildChrChardevStr

Make it avaiable to other chardev types.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemuBuildChrChardevStr: split attribute formatting
Ján Tomko [Wed, 3 Oct 2018 14:08:56 +0000 (16:08 +0200)]
qemuBuildChrChardevStr: split attribute formatting

Remove repetition of the 'socket' device and its alias.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemuProcessPrepareDomain: pass xmlopt when creating monConfig
Ján Tomko [Wed, 3 Oct 2018 16:51:16 +0000 (18:51 +0200)]
qemuProcessPrepareDomain: pass xmlopt when creating monConfig

Pass the driver's xmlopt to allocate the chardev source private
data correctly.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agocheck-spacing: do not kill C++-style comments
Ján Tomko [Fri, 5 Oct 2018 11:39:03 +0000 (13:39 +0200)]
check-spacing: do not kill C++-style comments

Our HACKING guide forbids these.
There's no point in exempting these from the spacing check
if their existence is against our coding style.

Note that the non-usage of these comments itself is not enforced
by syntax check, probably because of the need to implement a C parser.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agosyntax-check: revert indentation checks
Ján Tomko [Fri, 5 Oct 2018 11:07:14 +0000 (13:07 +0200)]
syntax-check: revert indentation checks

Recent patches added indentation checks that discovered some cosmetic
issues at the cost of making this check last as long as the rest of
syntax-check combined on my system. Also, they're moving closer
to us implementing yet another C parser (docs/apibuild.py being the
other one).

Revert the following commits:
commit 11e1f11dd34f2688169c63c13ea8d99a64724369
    syntax-check: Check for incorrect indentation in function body
commit 2585a79e32e8b0d994ab35fd7c641eb9b96632e3
    build-aux:check-spacing: Introduce a new rule to check misaligned stuff in parenthesises
commit a033182f042a07ffbd4b9a50418670778ceddbf3
    build-aux:check-spacing: Add wrapper function of CheckCurlyBrackets
commit 6225626b6f0a4817d1f17de0bc5200c5d7986a3e
    build-aux:check-spacing: Add wrapper function of CheckWhiteSpaces
commit c3875129d9bd094ffe90d54fbec86624ae88c40b
    build-aux:check-spacing: Add wrapper function of KillComments
commit e995904c5691be3c21f4c6dbc1f067fe0c8e8515
    build-aux:check-spacing: Add wrapper function of CheckFunctionBody
commit 11e1f11dd34f2688169c63c13ea8d99a64724369
    syntax-check: Check for incorrect indentation in function body

This brings the speed of the script to a tolerable level and lets it
focus on the more visible issues.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agodocs: Enhance polkit documentation to describe secondary connection
John Ferlan [Sun, 23 Sep 2018 15:56:46 +0000 (11:56 -0400)]
docs: Enhance polkit documentation to describe secondary connection

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

Since commit 8259255 usage of a primary connection driver for
a virConnect has been modified to open (virConnectOpen) and use
a connection to the specific driver in order to handle the API
calls to/for that driver. This causes some confusion and issues
for ACL polkit rule scripts to know exactly which driver by
name will be used.

Add some documentation describing the processing of the primary
and secondary connection as well as the list of the connect_driver
names used for each driver.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoaccess: Modify the VIR_ERR_ACCESS_DENIED to include driverName
John Ferlan [Sun, 14 Oct 2018 14:09:32 +0000 (10:09 -0400)]
access: Modify the VIR_ERR_ACCESS_DENIED to include driverName

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

Changes made to manage and utilize a secondary connection
driver to APIs outside the scope of the primary connection
driver have resulted in some confusion processing polkit rules
since the simple "access denied" error message doesn't provide
enough of a clue when combined with the "authentication failed:
access denied by policy" as to which connection driver refused
or failed the ACL check.

In order to provide some context, let's modify the existing
"access denied" error returne from the various vir*EnsureACL
API's to provide the connection driver name that is causing
the failure. This should provide the context for writing the
polkit rules that would allow access via the driver.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agonwfilter: Instantiate active filter bindings during driver init
Nikolay Shirokovskiy [Mon, 15 Oct 2018 08:26:28 +0000 (11:26 +0300)]
nwfilter: Instantiate active filter bindings during driver init

Commit 57f5621f modified nwfilterInstantiateFilter to detect when
a filter binding was already present before attempting to add the
new binding and instantiate it. Additionally, the change to
nwfilterStateInitialize to call virNWFilterBindingObjListLoadAllConfigs
(from commit c21679fa3f) to load active domain filter bindings, but
not instantiate them eventually leads to a problem for the QEMU
driver reconnection logic after a daemon restart where the filter
bindings would no longer be instantiated.

Subsequent commit f14c37ce4c replaced the nwfilterInstantiateFilter
with virDomainConfNWFilterInstantiate which uses @ignoreExists to
detect presence of the filter and still did not restore the filter
instantiation call when making the new nwfilter bindings logic active.

Thus in order to instantiate any active domain filter, we will call
virNWFilterBuildAll with 'false' to indicate the need to go through
all the active bindings calling virNWFilterInstantiateFilter to
instantiate the filter bindings.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agonodedev: Document the udevEventHandleThread
John Ferlan [Thu, 18 Oct 2018 14:22:18 +0000 (10:22 -0400)]
nodedev: Document the udevEventHandleThread

Commit cdbe1332 neglected to document the API. So let's add some
details about the algorithm and why it was used to help future
readers understand the issues encountered.

NB: Management of the processing udev device notification is a
delicate balance between the udev process, the scheduler, and when
exactly the data from/for the socket is received. The balance is
particularly important for environments when multiple devices are
added into the system more or less simultaneously such as is done
for mdev or SRIOV. In these cases old libudev blocking on the udev
recv() occurs more frequently. It's expected that future devices
will follow similar algorithms. Even though the algorithm does
present some challenges for older OS's (such as Centos 6), trying
to rewrite the algorithm to fit both models would be more complex
and involve pulling the monitor object out of the private data
lockable object and would need to be guarded by a separate lock.
Devising such an algorithm to work around issues with older OS's
at the expense of more modern OS algorithms in newer event processing
code may result in unexpected issues, so the choice is to encourage
use of newer OS's with newer udev event processing code.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoqemu: Dissolve qemuBuildVhostuserCommandLine in qemuBuildInterfaceCommandLine
Michal Privoznik [Thu, 1 Nov 2018 17:21:12 +0000 (18:21 +0100)]
qemu: Dissolve qemuBuildVhostuserCommandLine in qemuBuildInterfaceCommandLine

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

The qemuBuildVhostuserCommandLine builds command line for
vhostuser type interfaces. It is duplicating some code of the
function it is called from (qemuBuildInterfaceCommandLine)
because of the way it's called. If we merge it into the caller
not only we save a few lines but we also enable checks that we
would have to duplicate otherwise (e.g. QoS availability).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoqemuBuildInterfaceCommandLine: Reorder VIR_FREE
Michal Privoznik [Fri, 2 Nov 2018 15:12:45 +0000 (16:12 +0100)]
qemuBuildInterfaceCommandLine: Reorder VIR_FREE

When we have variables A, B, C then there are two ways to free
them. Either in the order they are declared or the reversed one.
Any other ordering is confusing. In this commit I'm reordering
calls to VIR_FREE in the reversed order.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoPost-release version bump to 4.10.0
Michal Privoznik [Mon, 5 Nov 2018 07:46:39 +0000 (08:46 +0100)]
Post-release version bump to 4.10.0

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoLibvirt release 4.9.0
Daniel Veillard [Sun, 4 Nov 2018 16:50:44 +0000 (17:50 +0100)]
Libvirt release 4.9.0

* docs/news.xml: updated for release

Signed-off-by: Daniel Veillard <veillard@redhat.com>
6 years agonews: Update for 4.9.0 release
Andrea Bolognani [Fri, 2 Nov 2018 13:53:40 +0000 (14:53 +0100)]
news: Update for 4.9.0 release

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
6 years agorpc: fix handling of SSH auth failure code
Daniel P. Berrangé [Fri, 31 Aug 2018 10:13:39 +0000 (11:13 +0100)]
rpc: fix handling of SSH auth failure code

The result of libssh2_userauth_password is being assigned to 'ret' in
one branch and 'rc' in the other branch. Checks are all done against the
'ret' variable, so one branch never does the correct check.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agonews: Update news for vfio-ap support
Boris Fiuczynski [Thu, 18 Oct 2018 14:54:08 +0000 (16:54 +0200)]
news: Update news for vfio-ap support

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Chris Venteicher <cventeic@redhat.com>
6 years agoqemu: vfio-ap device support
Boris Fiuczynski [Thu, 18 Oct 2018 14:54:07 +0000 (16:54 +0200)]
qemu: vfio-ap device support

Adjusting domain format documentation, adding device address
support and adding command line generation for vfio-ap.
Since only one mediated hostdev with model vfio-ap is supported a check
disallows to define domains with more than one such hostdev device.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Chris Venteicher <cventeic@redhat.com>
6 years agoqemu: add vfio-ap capability
Boris Fiuczynski [Thu, 18 Oct 2018 14:54:06 +0000 (16:54 +0200)]
qemu: add vfio-ap capability

Introduce vfio-ap capability.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Chris Venteicher <cventeic@redhat.com>