]> git.ipfire.org Git - thirdparty/libvirt.git/log
thirdparty/libvirt.git
6 years agoapi: disallow virConnectGetDomainCapabilities on read-only connections v3.7-maint
Ján Tomko [Fri, 14 Jun 2019 07:16:14 +0000 (09:16 +0200)] 
api: disallow virConnectGetDomainCapabilities on read-only connections

This API can be used to execute arbitrary emulators.
Forbid it on read-only connections.

Fixes: CVE-2019-10167
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit 8afa68bac0cf99d1f8aaa6566685c43c22622f26)
Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agoapi: disallow virDomainManagedSaveDefineXML on read-only connections
Ján Tomko [Fri, 14 Jun 2019 07:14:53 +0000 (09:14 +0200)] 
api: disallow virDomainManagedSaveDefineXML on read-only connections

The virDomainManagedSaveDefineXML can be used to alter the domain's
config used for managedsave or even execute arbitrary emulator binaries.
Forbid it on read-only connections.

Fixes: CVE-2019-10166
Reported-by: Matthias Gerstner <mgerstner@suse.de>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit db0b78457f183e4c7ac45bc94de86044a1e2056a)
Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agoapi: disallow virDomainSaveImageGetXMLDesc on read-only connections
Ján Tomko [Fri, 14 Jun 2019 06:47:42 +0000 (08:47 +0200)] 
api: disallow virDomainSaveImageGetXMLDesc on read-only connections

The virDomainSaveImageGetXMLDesc API is taking a path parameter,
which can point to any path on the system. This file will then be
read and parsed by libvirtd running with root privileges.

Forbid it on read-only connections.

Fixes: CVE-2019-10161
Reported-by: Matthias Gerstner <mgerstner@suse.de>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit aed6a032cead4386472afb24b16196579e239580)
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Conflicts:
  src/libvirt-domain.c
  src/remote/remote_protocol.x

Upstream commit 12a51f372 which introduced the VIR_DOMAIN_SAVE_IMAGE_XML_SECURE
alias for VIR_DOMAIN_XML_SECURE is not backported.
Just skip the commit since we now disallow the whole API on read-only
connections, regardless of the flag.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
7 years agonwfilter: increase pcap buffer size to be compatible with TPACKET_V3
Laine Stump [Wed, 25 Apr 2018 21:12:03 +0000 (17:12 -0400)] 
nwfilter: increase pcap buffer size to be compatible with TPACKET_V3

When an nwfilter rule sets the parameter CTRL_IP_LEARNING to "dhcp",
this turns on the "dhcpsnoop" thread, which uses libpcap to monitor
traffic on the domain's tap device and extract the IP address from the
DHCP response.

If libpcap on the host is built with HAVE_TPACKET3 defined (to enable
support for TPACKET_V3), the dhcpsnoop code's initialization of the
libpcap socket would fail with the following error:

  virNWFilterSnoopDHCPOpen:1134 : internal error: pcap_setfilter: can't remove kernel filter: Bad file descriptor

It turns out that this was because TPACKET_V3 requires a larger buffer
size than libvirt was setting (we were setting it to 128k). Changing
the buffer size to 256k eliminates the error, and the dhcpsnoop thread
once again works properly.

A fuller explanation of why TPACKET_V3 requires such a large buffer,
for future git spelunkers:

libpcap calls setsockopt(... SOL_PACKET, PACKET_RX_RING...) to setup a
ring buffer for receiving packets; two of the attributes sent to this
API are called tp_frame_size, and tp_frame_nr. If libpcap was built
with HAVE_TPACKET3 defined, tp_trame_size is set to MAXIMUM_SNAPLEN
(defined in libpcap sources as 262144) and tp_frame_nr is set to:

 [the buffer size we set, i.e. PCAP_BUFFERSIZE i.e. 262144] / tp_frame_size.

So if PCAP_BUFFERSIZE < MAXIMUM_SNAPLEN, then tp_frame_nr (the number
of frames in the ring buffer) is 0, which is nonsensical. This same
value is later used as a multiplier to determine the size for a call
to malloc() (which would also fail).

(NB: if HAVE_TPACKET3 is *not* defined, then tp_frame_size is set to
the snaplen set by the user (in our case 576) plus a small amount to
account for ethernet headers, so 256k is far more than adequate)

Since the TPACKET_V3 code in libpcap actually reads multiple packets
into each frame, it's not a problem to have only a single frame
(especially when we are monitoring such infrequent traffic), so it's
okay to set this relatively small buffer size (in comparison to the
default, which is 2MB), which is important since every guest using
dhcp snooping in a nwfilter rule will hold 2 of these buffers for the
entire life of the guest.

Thanks to Christian Ehrhardt for discovering that buffer size was the
problem (this was not at all obvious from the error that was logged!)

Resolves: https://bugzilla.redhat.com/1547237
Fixes: https://bugs.launchpad.net/libvirt/+bug/1758037
Signed-off-by: Laine Stump <laine@laine.org>
Reviewed-by: Christian Ehrhardt <christian.ehrhardt@canonical.com> (V1)
Reviewed-by: John Ferlan <jferlan@redhat.com>
Tested-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
(cherry picked from commit ce5aebeacd10a1c15cb3ee46a59c8b5ff235589e)

7 years agovbox: fix SEGV during dumpxml of a serial port
Laine Stump [Sun, 21 Jan 2018 02:11:05 +0000 (21:11 -0500)] 
vbox: fix SEGV during dumpxml of a serial port

commit 77a12987a48 changed the "virDomainChrSourceDef source" inside
virDomainChrDef to "virDomainChrSourceDefPtr source", and started
allocating source inside virDomainChrDefNew(), but vboxDumpSerial()
was allocating a virDomainChrDef with a simple VIR_ALLOC() (i.e. never
calling virDomainChrDefNew()), so source was never initialized,
leading to a SEGV any time a serial port was present. The same problem
was created in vboxDumpParallel().

This patch changes vboxDumpSerial() and vboxDumpParallel() to use
virDomainChrDefNew() instead of VIR_ALLOC(), and changes both of those
functions to return an error if virDomainChrDef() (or any other
allocation) fails.

This resolves: https://bugzilla.redhat.com/1536649

(cherry picked from commit 9c27e464e3b4603cbe13c00787f4c89e5b1e7a68)

Signed-off-by: Laine Stump <laine@laine.org>
7 years agoqemuDomainAttachDeviceMknodHelper: Remove symlink before creating it
Michal Privoznik [Thu, 4 Jan 2018 10:11:53 +0000 (11:11 +0100)] 
qemuDomainAttachDeviceMknodHelper: Remove symlink before creating it

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

So imagine you have /dev/blah symlink which points to /dev/sda.
You attach /dev/blah as disk to your domain. Libvirt correctly
creates the /dev/blah -> /dev/sda symlink in the qemu namespace.
However, then you detach the disk, change the symlink so that it
points to /dev/sdb and tries to attach the disk again. This time,
however, the attach fails (well, qemu attaches wrong disk)
because the code assumes that symlinks don't change. Well they
do.

This is inspired by test fix written by Eduardo Habkost.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
(cherry picked from commit db98e7f67ea0d7699410f514f01947cef5128a6c)

7 years agolog: fix deadlock obtaining hostname (related CVE-2018-6764)
Daniel P. Berrangé [Mon, 12 Feb 2018 10:03:08 +0000 (10:03 +0000)] 
log: fix deadlock obtaining hostname (related CVE-2018-6764)

The fix for CVE-2018-6764 introduced a potential deadlock scenario
that gets triggered by the NSS module when virGetHostname() calls
getaddrinfo to resolve the hostname:

 #0  0x00007f6e714b57e7 in futex_wait
 #1  futex_wait_simple
 #2  __pthread_once_slow
 #3  0x00007f6e71d16e7d in virOnce
 #4  0x00007f6e71d0997c in virLogInitialize
 #5  0x00007f6e71d0a09a in virLogVMessage
 #6  0x00007f6e71d09ffd in virLogMessage
 #7  0x00007f6e71d0db22 in virObjectNew
 #8  0x00007f6e71d0dbf1 in virObjectLockableNew
 #9  0x00007f6e71d0d3e5 in virMacMapNew
 #10 0x00007f6e71cdc50a in findLease
 #11 0x00007f6e71cdcc56 in _nss_libvirt_gethostbyname4_r
 #12 0x00007f6e724631fc in gaih_inet
 #13 0x00007f6e72464697 in __GI_getaddrinfo
 #14 0x00007f6e71d19e81 in virGetHostnameImpl
 #15 0x00007f6e71d1a057 in virGetHostnameQuiet
 #16 0x00007f6e71d09936 in virLogOnceInit
 #17 0x00007f6e71d09952 in virLogOnce
 #18 0x00007f6e714b5829 in __pthread_once_slow
 #19 0x00007f6e71d16e7d in virOnce
 #20 0x00007f6e71d0997c in virLogInitialize
 #21 0x00007f6e71d0a09a in virLogVMessage
 #22 0x00007f6e71d09ffd in virLogMessage
 #23 0x00007f6e71d0db22 in virObjectNew
 #24 0x00007f6e71d0dbf1 in virObjectLockableNew
 #25 0x00007f6e71d0d3e5 in virMacMapNew
 #26 0x00007f6e71cdc50a in findLease
 #27 0x00007f6e71cdc839 in _nss_libvirt_gethostbyname3_r
 #28 0x00007f6e71cdc724 in _nss_libvirt_gethostbyname2_r
 #29 0x00007f6e7248f72f in __gethostbyname2_r
 #30 0x00007f6e7248f494 in gethostbyname2
 #31 0x000056348c30c36d in hosts_keys
 #32 0x000056348c30b7d2 in main

Fortunately the extra stuff virGetHostname does is totally irrelevant to
the needs of the logging code, so we can just inline a call to the
native hostname() syscall directly.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit c2dc6698c88fb591639e542c8ecb0076c54f3dfb)

7 years agoutil: Fix syntax-check
Andrea Bolognani [Wed, 7 Feb 2018 13:39:18 +0000 (14:39 +0100)] 
util: Fix syntax-check

Broken by 759b4d1b0fe5f4d84d98b99153dfa7ac289dd167.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
(cherry picked from commit 6ce3acc129bfdbe7fd02bcb8bbe8af6d13903684)

7 years agovirlog: determine the hostname on startup CVE-2018-6764
Lubomir Rintel [Sat, 27 Jan 2018 22:43:58 +0000 (23:43 +0100)] 
virlog: determine the hostname on startup CVE-2018-6764

At later point it might not be possible or even safe to use getaddrinfo(). It
can in turn result in a load of NSS module.

Notably, on a LXC container startup we may find ourselves with the guest
filesystem already having replaced the host one. Loading a NSS module
from the guest tree would allow a malicous guest to escape the
confinement of its container environment because libvirt will not yet
have locked it down.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
(cherry picked from commit 759b4d1b0fe5f4d84d98b99153dfa7ac289dd167)

7 years agoqemu: monitor: Decrease logging verbosity
Peter Krempa [Wed, 20 Dec 2017 12:09:07 +0000 (13:09 +0100)] 
qemu: monitor: Decrease logging verbosity

The PROBE macro used in qemuMonitorIOProcess and the VIR_DEBUG message
in qemuMonitorJSONIOProcess create a lot of logging churn when debug
logging is enabled during monitor communication.

The messages logged from the PROBE macro are rather useless since they
are reporting the partial state of receiving the reply from qemu. The
actual full reply is still logged in qemuMonitorJSONIOProcessLine once
the full message is received.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
(cherry picked from commit f10bb3347b43d900ff361cda5fe1996782284991)

7 years agoutil: probe: Add quiet versions of the "PROBE" macro
Peter Krempa [Wed, 20 Dec 2017 11:58:36 +0000 (12:58 +0100)] 
util: probe: Add quiet versions of the "PROBE" macro

PROBE macro adds a logging entry, when used in places seeing a lot of
traffic this can cause a significant slowdown.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
(cherry picked from commit f06e488d5484031a76e7ed231c8fef8fa1181d2c)

7 years agotpm: Use /dev/null for cancel path if none was found
Stefan Berger [Thu, 29 Jun 2017 18:01:11 +0000 (14:01 -0400)] 
tpm: Use /dev/null for cancel path if none was found

TPM 2 does not implement sysfs files for cancellation of commands.
We therefore use /dev/null for the cancel path passed to QEMU.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Tested-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
(cherry picked from commit dfbb15b75433e520fb1b905c1c3e28753e53e4a5)

7 years agoqemu: ensure TLS clients always verify the server certificate
Daniel P. Berrange [Thu, 5 Oct 2017 16:54:28 +0000 (17:54 +0100)] 
qemu: ensure TLS clients always verify the server certificate

The default_tls_x509_verify (and related) parameters in qemu.conf
control whether the QEMU TLS servers request & verify certificates
from clients. This works as a simple access control system for
servers by requiring the CA to issue certs to permitted clients.
This use of client certificates is disabled by default, since it
requires extra work to issue client certificates.

Unfortunately the code was using this configuration parameter when
setting up both TLS clients and servers in QEMU. The result was that
TLS clients for character devices and disk devices had verification
turned off, meaning they would ignore errors while validating the
server certificate.

This allows for trivial MITM attacks between client and server,
as any certificate returned by the attacker will be accepted by
the client.

This is assigned CVE-2017-1000256  / LSN-2017-0002

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit 441d3eb6d1be940a67ce45a286602a967601b157)

7 years agoRelease of libvirt-3.7.0 v3.7.0
Daniel Veillard [Mon, 4 Sep 2017 10:14:11 +0000 (12:14 +0200)] 
Release of libvirt-3.7.0

* docs/news.xml: update for release
* po/*.po*: regenerated

7 years agovmx: Expose VMware Managed Object Reference (moref) in XML.
Richard W.M. Jones [Fri, 25 Aug 2017 13:36:58 +0000 (14:36 +0100)] 
vmx: Expose VMware Managed Object Reference (moref) in XML.

If you use the VDDK library to access virtual machines remotely, you
really need to know the Managed Object Reference ("moref") of the VM.
This must be passed each time you connect to the API.

For example nbdkit's VDDK plugin requires a moref to be passed to
mount up a VM's disk remotely:

 nbdkit vddk user=root password=+/tmp/rootpw \
             server=esxi.example.com thumbprint=xx:xx:xx:... \
             vm=moref=2 \
             file="[datastore1] Fedora/Fedora.vmdk"

Getting the moref is a huge pain.  To get some idea of what it is, why
it is needed, and how much trouble it is to get it, see:
https://blogs.vmware.com/vsphere/2012/02/uniquely-identifying-virtual-machines-in-vsphere-and-vcloud-part-1-overview.html
https://blogs.vmware.com/vsphere/2012/02/uniquely-identifying-virtual-machines-in-vsphere-and-vcloud-part-2-technical.html

However the moref is available conveniently in the internals of the
libvirt VMX driver.  This patch exposes it as a custom XML element
using the same "vmware:" namespace which was previously used for the
datacenterpath (see libvirt commit 636a99058758a044).

It appears in the XML like this:

<domain type='vmware' xmlns:vmware='http://libvirt.org/schemas/domain/vmware/1.0'>
  <name>Fedora</name>
...
  <vmware:datacenterpath>ha-datacenter</vmware:datacenterpath>
  <vmware:moref>2</vmware:moref>
</domain>

Note that the moref can appear as either a simple ID (for esx://
connections) or as a "vm-<ID>" (for vpx:// connections).  It should be
treated by users as an opaque string.

Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
7 years agodocs: Remove <code> from <summary> entries due to RNG error
John Ferlan [Sat, 2 Sep 2017 12:05:32 +0000 (08:05 -0400)] 
docs: Remove <code> from <summary> entries due to RNG error

commit '96e55048' caused make check failure for virschematest:

1929) Checking ../docs/news.xml against ../news.rng                     ... libvirt: XML Util error : XML document failed to validate against schema: Unable to validate doc against /home/jferlan/git/libvirt.work/docs/schemas/../news.rng
Datatype element summary has child elements
Element summary failed to validate content
Datatype element summary has child elements
Element summary failed to validate content
^[[31m^[[1mFAILED^[[0m

That's because <code> elements don't appear to be allowed in the schema.
Rather than attempt to fix the schema, figured it was simpler to just
remove them and let the schema fix happen later.

7 years agonews: Prepare for 3.7.0 release
Andrea Bolognani [Fri, 1 Sep 2017 14:17:44 +0000 (16:17 +0200)] 
news: Prepare for 3.7.0 release

Documents some changes that have slipped through the cracks
during the development cycle.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agodocs: Document managedsave-edit commands support
Kothapally Madhu Pavan [Wed, 30 Aug 2017 10:53:54 +0000 (16:23 +0530)] 
docs: Document managedsave-edit commands support

This patch documents support for managedsave-dumpxml,
managedsave-define and managedsave-edit commands.

Signed-off-by: Kothapally Madhu Pavan <kmp@linux.vnet.ibm.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
7 years agonews: Add stuff for 3.7.0
Peter Krempa [Fri, 1 Sep 2017 12:57:01 +0000 (14:57 +0200)] 
news: Add stuff for 3.7.0

7 years agovirnetdaemon: Don't deadlock when talking to D-Bus
Michal Privoznik [Fri, 1 Sep 2017 08:33:12 +0000 (10:33 +0200)] 
virnetdaemon: Don't deadlock when talking to D-Bus

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

In ace45e67abbd I tried to fix a problem that we get the reply to
a D-Bus call while we were sleeping. In that case the callback
was never set. So I changed the code that the callback is called
directly in this case. However, I hadn't realized that since the
callback is called out of order it locks the virNetDaemon.
Exactly the very same virNetDaemon object that we are dealing
with right now and that we have locked already (in
virNetDaemonAddShutdownInhibition())

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoqemu: handle -1 for pid in qemuDomainGetMachineName
Nikolay Shirokovskiy [Thu, 31 Aug 2017 09:01:44 +0000 (12:01 +0300)] 
qemu: handle -1 for pid in qemuDomainGetMachineName

We call qemuDomainGetMachineName on domain start. On first
start (after daemon start) pid is 0 and virSystemdGetMachineNameByPID
don't get called. But after domain shutting down pid became -1 so
on next start virSystemdGetMachineNameByPID is called and returned an error.
Error is ignored so it is not critical. But at least on my system
(systemd-219 with extra patches) systemd-machined is crashed on
this request.

This behaviour is triggered by eaf2c9f89.

Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
7 years agoqemu: Forbid rx/tx_queue_size change explicitly
Michal Privoznik [Thu, 31 Aug 2017 09:33:06 +0000 (11:33 +0200)] 
qemu: Forbid rx/tx_queue_size change explicitly

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

When updating a virtio enabled vNIC and trying to change either
of rx_queue_size or tx_queue_size success is reported although no
operation is actually performed. Moreover, there's no way how to
change these on the fly. This is due to way we check for changes:
explicitly for each struct member. Therefore it's easy to miss
one.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agodocs: Add entry for ZStack to apps page
Shuang He [Tue, 29 Aug 2017 08:14:32 +0000 (16:14 +0800)] 
docs: Add entry for ZStack to apps page

Signed-off-by: Shuang He <shuang.he@zstack.io>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
7 years agonews: add an entry for chardev reconnect feature
Pavel Hrdina [Thu, 31 Aug 2017 10:32:35 +0000 (12:32 +0200)] 
news: add an entry for chardev reconnect feature

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agostorage: Use virStorageBackendRefreshVolTargetUpdate after wipeVol v3.7.0-rc2
John Ferlan [Thu, 24 Aug 2017 22:19:14 +0000 (18:19 -0400)] 
storage: Use virStorageBackendRefreshVolTargetUpdate after wipeVol

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

Rather than using refreshVol which essentially only updates the
allocation, capacity, and permissions for the volume, but not
the format which does get updated in a pool refresh - let's use
the same helper that pool refresh uses in order to update the
volume target.

7 years agostorage: Introduce virStorageBackendRefreshVolTargetUpdate
John Ferlan [Thu, 24 Aug 2017 21:56:47 +0000 (17:56 -0400)] 
storage: Introduce virStorageBackendRefreshVolTargetUpdate

Create a separate function to handle the volume target update
via probe processing.

7 years agoqemu: set bind mode for chardev while parsing XML
Pavel Hrdina [Wed, 30 Aug 2017 13:56:52 +0000 (15:56 +0200)] 
qemu: set bind mode for chardev while parsing XML

Currently while parsing domain XML we clear the UNIX path if it matches
one of the auto-generated paths by libvirt.  After that when the guest
is started new path is generated but the mode is also changed to "bind".

In the real-world use-case the mode should not change, it only happens
if a user provides a mode='connect' and path that matches one of the
auto-generated path or not provides a path at all.

Before *reconnect* feature was introduced there was no issue, but with
the new feature we need to make sure that it's used only with "connect"
mode, therefore we need to move the mode change into parsing in order
to have a proper error reported by validation code.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agotests: don't use unix socket path that matches auto-generated path
Pavel Hrdina [Tue, 29 Aug 2017 15:51:07 +0000 (17:51 +0200)] 
tests: don't use unix socket path that matches auto-generated path

The test was introduced by 60135b22db6d.

The auto-generated path is removed by post-parse callback which
also changes the mode from "connect" to "bind" since the auto-generated
path makes sense only for "bind" mode.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoconf: add reconnect to virDomainChrSourceDef(Copy|IsEqual)
Pavel Hrdina [Tue, 29 Aug 2017 11:38:28 +0000 (13:38 +0200)] 
conf: add reconnect to virDomainChrSourceDef(Copy|IsEqual)

Missed by 9aa72a6dd5b3.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agotests: remove unused file
Pavel Hrdina [Tue, 29 Aug 2017 10:09:24 +0000 (12:09 +0200)] 
tests: remove unused file

Introduced by 95fd63b1700d.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoFix TLS test suites with gnutls 3.6.0
Daniel P. Berrange [Tue, 29 Aug 2017 15:24:26 +0000 (16:24 +0100)] 
Fix TLS test suites with gnutls 3.6.0

With gnutls 3.6.0, SHA1 is no longer accepted for certificate
signatures. We must usw SHA256 instead.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
7 years agodoc: Fix docs/news.xml structure
Kothapally Madhu Pavan [Wed, 30 Aug 2017 10:14:35 +0000 (15:44 +0530)] 
doc: Fix docs/news.xml structure

Signed-off-by: Kothapally Madhu Pavan <kmp@linux.vnet.ibm.com>
7 years agotests: Fix virnetsockettest after SSH command line changes
Martin Kletzander [Wed, 30 Aug 2017 08:50:17 +0000 (10:50 +0200)] 
tests: Fix virnetsockettest after SSH command line changes

Commit e4cb8500810a changed the way ssh command line is created by
adding '--' before the hostname in order to fix a potential security
flaw.  However it failed to modify the tests, so let's do that.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7 years agodocs: Document yet another limitation of tx_queue_size
Michal Privoznik [Tue, 29 Aug 2017 15:01:16 +0000 (17:01 +0200)] 
docs: Document yet another limitation of tx_queue_size

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

Turns out, only vhostuser type of interfaces are supported
currently.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agorpc: avoid ssh interpreting malicious hostname as arguments
Daniel P. Berrange [Fri, 11 Aug 2017 16:19:53 +0000 (17:19 +0100)] 
rpc: avoid ssh interpreting malicious hostname as arguments

Inspired by the recent GIT / Mercurial security flaws
(http://blog.recurity-labs.com/2017-08-10/scm-vulns),
consider someone/something manages to feed libvirt a bogus
URI such as:

  virsh -c qemu+ssh://-oProxyCommand=gnome-calculator/system

In this case, the hosname "-oProxyCommand=gnome-calculator"
will get interpreted as an argument to ssh, not a hostname.
Fortunately, due to the set of args we have following the
hostname, SSH will then interpret our bit of shell script
that runs 'nc' on the remote host as a cipher name, which is
clearly invalid. This makes ssh exit during argv parsing and
so it never tries to run gnome-calculator.

We are lucky this time, but lets be more paranoid, by using
'--' to explicitly tell SSH when it has finished seeing
command line options. This forces it to interpret
"-oProxyCommand=gnome-calculator" as a hostname, and thus
see a fail from hostname lookup.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
7 years agoqemu: Also treat directories properly when using namespaces
Martin Kletzander [Fri, 18 Aug 2017 15:33:08 +0000 (17:33 +0200)] 
qemu: Also treat directories properly when using namespaces

When recreating folders with namespaces, the directory type was not
being handled at all.  It's not special, we probably just didn't know
that that can be used as a volume path as well.  The code failed
gracefully, but we want to allow that so that we can use <disk
type='dir'> in domains again.

Partially-resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1443434

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7 years agoqemu: Don't mangle the storage format for type='dir'
Martin Kletzander [Fri, 25 Aug 2017 12:45:56 +0000 (14:45 +0200)] 
qemu: Don't mangle the storage format for type='dir'

Our backing probing code handles directory file types properly in
virStorageFileGetMetadataRecurse(), by that I mean it leaves them
alone.  However its caller, the virStorageFileGetMetadata() resets the
type to raw before probing, without even checking the type.  We need
to special-case TYPE_DIR in order to achieve desired results.

Also, in order to properly test this, we need to stop resetting format
of volumes in tests for TYPE_DIR (probably the reason why we didn't
catch that and why the test data didn't need to be modified).

Partially-resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1443434

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7 years agovirsh: Implement managedsave-edit command v3.7.0-rc1
Kothapally Madhu Pavan [Tue, 8 Aug 2017 08:02:55 +0000 (13:32 +0530)] 
virsh: Implement managedsave-edit command

Add a simple virsh command handler which makes use of the new API.

Signed-off-by: Kothapally Madhu Pavan <kmp@linux.vnet.ibm.com>
7 years agovirsh: Implement managedsave-dumpxml command
Kothapally Madhu Pavan [Tue, 8 Aug 2017 08:02:54 +0000 (13:32 +0530)] 
virsh: Implement managedsave-dumpxml command

Add a simple virsh command handler which makes use of the new API.

Signed-off-by: Kothapally Madhu Pavan <kmp@linux.vnet.ibm.com>
7 years agovirsh: Implement managedsave-define command
Kothapally Madhu Pavan [Tue, 8 Aug 2017 08:02:53 +0000 (13:32 +0530)] 
virsh: Implement managedsave-define command

Add a simple virsh command handler which makes use of the new API.

Signed-off-by: Kothapally Madhu Pavan <kmp@linux.vnet.ibm.com>
7 years agoqemu: Implement qemuDomainManagedSaveDefineXML
Kothapally Madhu Pavan [Tue, 8 Aug 2017 08:02:52 +0000 (13:32 +0530)] 
qemu: Implement qemuDomainManagedSaveDefineXML

This commit adds qemu driver implementation to edit xml
configuration of managed save state file of a domain.

Signed-off-by: Kothapally Madhu Pavan <kmp@linux.vnet.ibm.com>
7 years agoqemu: Implement qemuDomainManagedSaveGetXMLDesc
Kothapally Madhu Pavan [Tue, 8 Aug 2017 08:02:51 +0000 (13:32 +0530)] 
qemu: Implement qemuDomainManagedSaveGetXMLDesc

This commit adds qemu driver implementation to get xml description
for managed save state domain.

Signed-off-by: Kothapally Madhu Pavan <kmp@linux.vnet.ibm.com>
7 years agolib: Add API to edit domain's managed save state xml configuration
Kothapally Madhu Pavan [Tue, 8 Aug 2017 08:02:50 +0000 (13:32 +0530)] 
lib: Add API to edit domain's managed save state xml configuration

Similar to domainSaveImageDefineXML this commit adds domainManagedSaveDefineXML
API which allows to edit domain's managed save state xml configuration.

Signed-off-by: Kothapally Madhu Pavan <kmp@linux.vnet.ibm.com>
7 years agolib: Add API to dump xml configuration of managed save state domain
Kothapally Madhu Pavan [Tue, 8 Aug 2017 08:02:49 +0000 (13:32 +0530)] 
lib: Add API to dump xml configuration of managed save state domain

Similar to domainSaveImageGetXMLDesc this commit adds domainManagedSaveGetXMLDesc
API which allows to get the xml of managed save state domain.

Signed-off-by: Kothapally Madhu Pavan <kmp@linux.vnet.ibm.com>
7 years agoqemu: Honour <on_reboot/>
Michal Privoznik [Mon, 31 Jul 2017 14:55:58 +0000 (16:55 +0200)] 
qemu: Honour <on_reboot/>

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

For some reason, we completely ignore <on_reboot/> setting for
domains. The implementation is simply not there. It never was.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoqemuDomainUndefineFlags: Grab QEMU_JOB_MODIFY
Michal Privoznik [Mon, 7 Aug 2017 11:28:48 +0000 (13:28 +0200)] 
qemuDomainUndefineFlags: Grab QEMU_JOB_MODIFY

This API is definitely modifying state of @vm. Therefore it
should grab a job.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Introduce and use qemuDomainRemoveInactiveJob
Michal Privoznik [Tue, 15 Aug 2017 07:12:43 +0000 (09:12 +0200)] 
qemu: Introduce and use qemuDomainRemoveInactiveJob

At some places we either already have synchronous job or we just
released it. Also, some APIs might want to use this code without
having to release their job. Anyway, the job acquire code is
moved out to qemuDomainRemoveInactiveJob so that
qemuDomainRemoveInactive does just what it promises.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoconf: Clean up and report error in virDomainGenerateMachineName
Martin Kletzander [Mon, 21 Aug 2017 07:02:09 +0000 (09:02 +0200)] 
conf: Clean up and report error in virDomainGenerateMachineName

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7 years agoconf: Clean up and report error in virDomainCapsFormat
Martin Kletzander [Mon, 21 Aug 2017 06:50:47 +0000 (08:50 +0200)] 
conf: Clean up and report error in virDomainCapsFormat

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7 years agoutil: Use virBufferCheckError to its full potential.
Martin Kletzander [Mon, 21 Aug 2017 06:38:34 +0000 (08:38 +0200)] 
util: Use virBufferCheckError to its full potential.

We can now check for the error and not care about the return value as
it will be properly handled in virBufferContentAndReset() anyway.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7 years agoutil: Umark virBufferCheckErrorInternal as ATTRIBUTE_RETURN_CHECK
Martin Kletzander [Wed, 16 Aug 2017 09:09:47 +0000 (11:09 +0200)] 
util: Umark virBufferCheckErrorInternal as ATTRIBUTE_RETURN_CHECK

The function is useful even without using the return value.  And if
needed, the return value can be obtained by other calls as well.  The
potential for clean-up can be seen in the following patch.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7 years agodocs: Update news with domain name bug fixes
Martin Kletzander [Wed, 23 Aug 2017 11:46:36 +0000 (13:46 +0200)] 
docs: Update news with domain name bug fixes

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7 years agoqemu: Use short domain name in qemuDomainGetPreservedMountPath
Martin Kletzander [Wed, 23 Aug 2017 08:39:57 +0000 (10:39 +0200)] 
qemu: Use short domain name in qemuDomainGetPreservedMountPath

Otherwise longer domain names might generate paths that are too long
to be created.  This follows what other parts of the code do as well.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7 years agoconf: Properly truncate wide character names in virDomainObjGetShortName
Martin Kletzander [Wed, 23 Aug 2017 11:18:19 +0000 (13:18 +0200)] 
conf: Properly truncate wide character names in virDomainObjGetShortName

We always truncated the name at 20 bytes instead of characters.  In
case 20 bytes were in the middle of a multi-byte character, then the
string became invalid and various parts of the code would error
out (e.g. XML parsing of that string).  Let's instead properly
truncate it after 20 characters instead.

We cannot test this in our test suite because we would need to know
what locales are installed on the system where the tests are ran and
if there is supported one (most probably there will be, but we cannot
be 100% sure), we could initialize gettext in qemuxml2argvtest, but
there would still be a chance of getting two different (both valid,
though) results.

In order to test this it is enough to start a machine with a name for
which trimming it after 20 bytes would create invalid sequence (e.g.
1234567890123456789č where č is any multi-byte character).  Then start
the domain and restart libvirtd.  The domain would disappear because
such illegal sequence will not go through the XML parser.  And that's
not a bug of the parser, it should not be in the XML in the first
place, but since we don't use any sophisticated formatter, just
mash some strings together, the formatting succeeds.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7 years agovirsh: Honour --readonly with cmdConnect and no name
Martin Kletzander [Fri, 18 Aug 2017 14:35:23 +0000 (16:35 +0200)] 
virsh: Honour --readonly with cmdConnect and no name

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7 years agodocs: Update news with virtio-vga/gpu's max_outputs= parameter
Martin Kletzander [Wed, 23 Aug 2017 12:10:57 +0000 (14:10 +0200)] 
docs: Update news with virtio-vga/gpu's max_outputs= parameter

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7 years agoqemu: Add support for virtio-vga/gpu's max_outputs= parameter
Martin Kletzander [Wed, 23 Aug 2017 12:06:41 +0000 (14:06 +0200)] 
qemu: Add support for virtio-vga/gpu's max_outputs= parameter

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7 years agoqemu: Add capabilities for virtio-vga/gpu's max_outputs= parameter
Martin Kletzander [Wed, 23 Aug 2017 12:06:17 +0000 (14:06 +0200)] 
qemu: Add capabilities for virtio-vga/gpu's max_outputs= parameter

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7 years agotests: add qemu chardev source reconnect tests
Pavel Hrdina [Fri, 25 Aug 2017 17:11:24 +0000 (19:11 +0200)] 
tests: add qemu chardev source reconnect tests

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoqemu: implement chardev source reconnect
Pavel Hrdina [Fri, 25 Aug 2017 16:57:15 +0000 (18:57 +0200)] 
qemu: implement chardev source reconnect

The reconnect attribute for chardev devices in QEMU is used to
configure the reconnect timeout in seconds.  Setting '0' value disables
the reconnect functionality thus we don't allow to set '0' for QEMU.
To disable the reconnect user should use <reconnect enabled='no'/>.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agotests: add generic xml chardev source reconnect tests
Pavel Hrdina [Wed, 23 Aug 2017 15:48:14 +0000 (17:48 +0200)] 
tests: add generic xml chardev source reconnect tests

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoconf: introduce reconnect element for chardev source
Pavel Hrdina [Wed, 23 Aug 2017 15:08:07 +0000 (17:08 +0200)] 
conf: introduce reconnect element for chardev source

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoqemu: introduce QEMU_CAPS_CHARDEV_RECONNECT
Pavel Hrdina [Wed, 9 Aug 2017 13:06:40 +0000 (15:06 +0200)] 
qemu: introduce QEMU_CAPS_CHARDEV_RECONNECT

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agonetwork: Fix virNetworkObjBridgeInUse return type
John Ferlan [Thu, 17 Aug 2017 19:41:37 +0000 (15:41 -0400)] 
network: Fix virNetworkObjBridgeInUse return type

Rather than an int, it returns a bool - so let's define it that way

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agoRevert "interface: Consume @def in virInterfaceObjNew"
John Ferlan [Sat, 29 Jul 2017 11:20:59 +0000 (07:20 -0400)] 
Revert "interface: Consume @def in virInterfaceObjNew"

This reverts commit 92840eb3a7e47cdf761e52afccc41d2a35327fbd.

More recent reviews/changes don't have the vir*ObjNew APIs
consuming the @def, so remove from Interface as well. Changes
needed to also deal with conflicts from commit id '46f5eca4'.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agomaint: correct quoting for gl_WARN_ADD
Eric Blake [Thu, 24 Aug 2017 19:36:36 +0000 (14:36 -0500)] 
maint: correct quoting for gl_WARN_ADD

3 out of 4 uses of gl_WARN_ADD() were incorrectly adding "" around
the argument, which in turn resulted in the argument being used
unquoted (configure had gl_positive=""-fstack-protector-all"",
rather than the intended gl_positive="-fstack-protector-all").

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
7 years agodaemon: logging: Fix --verbose option being ignored by the daemon
Erik Skultety [Fri, 25 Aug 2017 14:58:51 +0000 (16:58 +0200)] 
daemon: logging: Fix --verbose option being ignored by the daemon

Commit 94c465d0 refactored the logging setup phase but introduced an
issue, where the daemon ignores verbose mode when there are no outputs
defined and the default must be used. The problem is that the default
output was determined too early, thus ignoring the potential '--verbose'
option taking effect. This patch postpones the creation of the default
output to the very last moment when nothing else can change. Since the
default output is only created during the init phase, it's safe to leave
the pointer as NULL for a while, but it will be set eventually, thus not
affecting runtime.
Patch also adjusts both the other daemons.

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

Signed-off-by: Erik Skultety <eskultet@redhat.com>
7 years agoqemu: Handle host devices not being available better
Andrea Bolognani [Thu, 24 Aug 2017 14:33:29 +0000 (16:33 +0200)] 
qemu: Handle host devices not being available better

We can't retrieve the isolation group of a device that's not present
in the system. However, it's very common for VFs to be created late
in the boot, so they might not be present yet when libvirtd starts,
which would cause the guests using them to disappear.

Moreover, for other architectures and even ppc64 before isolation
groups were introduced, it's considered perfectly fine to configure a
guest to use a device that's not yet (or no longer) available to the
host, with the obvious caveat that such a guest won't be able to
start before the device is available.

In order to be consistent, when a device's isolation group can't be
determined fall back to not isolating it rather than erroring out or,
worse, making the guest disappear.

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agoconf: don't close the source element inside different function
Pavel Hrdina [Thu, 24 Aug 2017 14:46:58 +0000 (16:46 +0200)] 
conf: don't close the source element inside different function

While formatting disk or chardev element they both uses
virDomainDiskSourceDefFormatSeclabel() function which also closes
the source element.  This is not extendable.

Use the new virXMLFormatElement() to properly format the source
element with possible child elements.

As a side effect it fixes a bug in disk source formatting.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoutil: introduce virXMLFormatElement helper
Pavel Hrdina [Thu, 24 Aug 2017 13:08:23 +0000 (15:08 +0200)] 
util: introduce virXMLFormatElement helper

This helper allows you to better structurize the code if some element
may or may not contains attributes and/or child elements.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoutil: introduce virBufferSetChildIndent macro
Pavel Hrdina [Thu, 24 Aug 2017 12:54:56 +0000 (14:54 +0200)] 
util: introduce virBufferSetChildIndent macro

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agomaint: Update to latest gnulib
Erik Skultety [Mon, 28 Aug 2017 10:12:51 +0000 (12:12 +0200)] 
maint: Update to latest gnulib

This pulls in, among other new things, vc-list-files fix to make
syntax-check work with git worktrees.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
7 years agoconf: add virDomainVideoDefNew
Cole Robinson [Wed, 28 Jun 2017 14:24:33 +0000 (10:24 -0400)] 
conf: add virDomainVideoDefNew

To handle setting a default heads value. Convert callers that were
doing it by hand

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
7 years agoqemu: domain: Move some validation out of DeviceDefPostParse
Cole Robinson [Wed, 28 Jun 2017 14:53:23 +0000 (10:53 -0400)] 
qemu: domain: Move some validation out of DeviceDefPostParse

And into DeviceDefValidate which is the expected place

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
7 years agoqemu: parse: drop redundant video config
Cole Robinson [Wed, 28 Jun 2017 13:54:16 +0000 (09:54 -0400)] 
qemu: parse: drop redundant video config

The ram/vram = 0 bits aren't needed, and PostParse will fill in the
needed QXL default

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
7 years agoqemu: Remove remnants of xenner support
Cole Robinson [Sun, 27 Aug 2017 13:29:50 +0000 (09:29 -0400)] 
qemu: Remove remnants of xenner support

Both of these are dead code: qemu_command.c explicitly rejects
VIRT_XEN earlier in the call chain, and qemu_parse_command.c
will never set VIRT_XEN anymore

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
7 years agodocs: document migrate-getmaxdowntime support
Scott Garfinkle [Thu, 17 Aug 2017 22:17:22 +0000 (17:17 -0500)] 
docs: document migrate-getmaxdowntime support

7 years agovirsh: Add support for virDomainMigrateGetMaxDowntime
Scott Garfinkle [Thu, 17 Aug 2017 22:17:21 +0000 (17:17 -0500)] 
virsh: Add support for virDomainMigrateGetMaxDowntime

Implement a migrate-getmaxdowntime command to complement migrate-setmaxdowntime.

7 years agoqemu: Implement virDomainMigrateGetMaxDowntime
Scott Garfinkle [Thu, 17 Aug 2017 22:17:20 +0000 (17:17 -0500)] 
qemu: Implement virDomainMigrateGetMaxDowntime

Add code to support querying maximum allowable downtime during live migration.

7 years agoAdd virDomainMigrateGetMaxDowntime public API
Scott Garfinkle [Thu, 17 Aug 2017 22:17:19 +0000 (17:17 -0500)] 
Add virDomainMigrateGetMaxDowntime public API

Add virDomainMigrateGetMaxDowntime to support querying maximum allowable
downtime during live migration.

7 years agoqemu: Report error on failure to set isolation group
Andrea Bolognani [Thu, 24 Aug 2017 14:07:07 +0000 (16:07 +0200)] 
qemu: Report error on failure to set isolation group

This is more user-friendly because the error will be
displayed directly instead of being buried in the log.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
7 years agovirt-host-validate: Fix warning for IOMMU detection on PPC
Nitesh Konkar [Thu, 17 Aug 2017 13:48:05 +0000 (19:18 +0530)] 
virt-host-validate: Fix warning for IOMMU detection on PPC

Fix the warning generated on PPC by virt-host-validate for IOMMU.
In case of PPC, IOMMU in the host kernel either has it or it's not
compiled in. The /sys/kernel/iommu_groups check is good enough to
verify if it was compiled with the kernel or not.

Modify the error message when "if (sb.st_nlink <= 2)" to indicate
what the problem would be since there would be no @bootarg.

Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
7 years agoRevert "maint: Update to latest gnulib"
Erik Skultety [Thu, 24 Aug 2017 17:07:53 +0000 (19:07 +0200)] 
Revert "maint: Update to latest gnulib"

Revert @f8172388c which broke the build on Centos 6, because of old
autoconf (< 2.63b) not properly quoting arguments for shell.

7 years agolibxl: Avoid a variable named 'stat'
George Dunlap [Thu, 24 Aug 2017 11:34:13 +0000 (12:34 +0100)] 
libxl: Avoid a variable named 'stat'

Using a variable named 'stat' clashes with the system function
'stat()' causing compiler warnings on some platforms:

libxl/libxl_driver.c: In function 'libxlDomainBlockStatsVBD':
libxl/libxl_driver.c:5387: error: declaration of 'stat' shadows a global declaration [-Wshadow]
/usr/include/sys/stat.h:455: error: shadowed declaration is here [-Wshadow]

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
7 years agomaint: Update to latest gnulib
Erik Skultety [Thu, 24 Aug 2017 08:40:06 +0000 (10:40 +0200)] 
maint: Update to latest gnulib

This pulls in, among other new things, vc-list-files fix to make
syntax-check work with git worktrees.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
7 years agovmx: do not treat controllers as implicit devices
Ján Tomko [Mon, 21 Aug 2017 14:44:42 +0000 (16:44 +0200)] 
vmx: do not treat controllers as implicit devices

When parsing the config, we look for the SCSI controllers one by one,
remembering their models, then let virDomainDefAddImplicitDevices
add them if any SCSI disk is using them.

Since these controllers are not really implicit (they are present
in the source config), add them explicitly.

This patch maintains the behavior of not adding a controller
if it was present in the config, but no disk was using it.

This also resolves the memory leak of virVMXParseConfig overwriting
the video device added by calling virDomainDefAddImplicitDevices
before the parsing is finished.

Reported-by: Michal Privoznik <mprivozn@redhat.com>
7 years agovz: build fix
Nikolay Shirokovskiy [Thu, 24 Aug 2017 07:08:35 +0000 (10:08 +0300)] 
vz: build fix

6e6faf6d changed vzDomObjAlloc signature in source but not in header file.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
7 years agoconf: check address type for USB hostdevs
Ján Tomko [Wed, 23 Aug 2017 14:32:28 +0000 (16:32 +0200)] 
conf: check address type for USB hostdevs

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

7 years agoconf: move hostdev address validation to virDomainHostdevDefValidate
Ján Tomko [Wed, 23 Aug 2017 14:27:36 +0000 (16:27 +0200)] 
conf: move hostdev address validation to virDomainHostdevDefValidate

For selected hostdev types, we validate that the address type
matches the subsystem type when parsing the XML.

Move it to the validation phase, to allow extending the checks
to other subsystem types without making existing domains disappear.

7 years agotests: Fix leak in securityselinuxtest
John Ferlan [Wed, 23 Aug 2017 16:32:23 +0000 (12:32 -0400)] 
tests: Fix leak in securityselinuxtest

If we jump to the error: label and @secbuf is allocated, then it's not
free'd at all.

Found by Coverity

7 years agovz: support disabled items in vz boot order
Nikolay Shirokovskiy [Fri, 30 Jun 2017 06:34:27 +0000 (09:34 +0300)] 
vz: support disabled items in vz boot order

At the time the check was written virtuozzo did not use disabled items in boot
order configuration. Boot items were always enabled. Now they can be disabled
as well. Supporting such items is easy - they just should be ignored.

7 years agodocs: Define anchors correctly in pci-hotplug
Andrea Bolognani [Wed, 23 Aug 2017 11:55:01 +0000 (13:55 +0200)] 
docs: Define anchors correctly in pci-hotplug

HTML5 obsoletes the 'name' attribute in favor of 'id',
and our TOC generator apparently follows the recommendation
to the letter, resulting in a broken TOC if you use the
old-school attribute.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agoconf: do not count per-device boot elements when parsing <os><boot>
Ján Tomko [Fri, 18 Aug 2017 15:55:54 +0000 (17:55 +0200)] 
conf: do not count per-device boot elements when parsing <os><boot>

When parsing bootable devices, we maintain a bitmap of used
<boot order=""> elements. Use it in the post-parse function
to figure out whether the user tried to mix per-device and
per-domain boot elements.

This removes the need to count them twice.

7 years agoconf: create a thin wrapper above virDomainDefPostParse
Ján Tomko [Tue, 22 Aug 2017 11:38:35 +0000 (13:38 +0200)] 
conf: create a thin wrapper above virDomainDefPostParse

Rename the original function to virDomainDefPostParseInternal
to allow adding arguments that will be only used by the internal
version.

7 years agoconf: rename virDomain*PostParseInternal to virDomain*PostParseCommon
Ján Tomko [Tue, 22 Aug 2017 11:29:24 +0000 (13:29 +0200)] 
conf: rename virDomain*PostParseInternal to virDomain*PostParseCommon

These functions contain the post-parse steps common for all drivers.
Rename it to use the 'Common' prefix, instead of the vagueness
of 'Internal', leaving 'Internal' available for other vague uses.

7 years agoconf: move chardev validation into virDomainDeviceDefValidateInternal
Pavel Hrdina [Fri, 18 Aug 2017 20:00:12 +0000 (22:00 +0200)] 
conf: move chardev validation into virDomainDeviceDefValidateInternal

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoconf: separate PTY chardev source parsing
Pavel Hrdina [Fri, 18 Aug 2017 16:19:48 +0000 (18:19 +0200)] 
conf: separate PTY chardev source parsing

There is no reason why to share the same code for PTY and other file
based chardev source types.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoconf: move FILE chardev source parsing to separate function
Pavel Hrdina [Fri, 18 Aug 2017 16:17:28 +0000 (18:17 +0200)] 
conf: move FILE chardev source parsing to separate function

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoconf: assign parsed strings directly into chardev source definition
Pavel Hrdina [Fri, 18 Aug 2017 16:12:08 +0000 (18:12 +0200)] 
conf: assign parsed strings directly into chardev source definition

Since the source element is parsed only once for these type of
character devices we don't have to use temporary variable and
check whether the variable was already set.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoconf: move UNIX chardev source parsing to separate function
Pavel Hrdina [Fri, 18 Aug 2017 17:25:11 +0000 (19:25 +0200)] 
conf: move UNIX chardev source parsing to separate function

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>