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

These APIs can be used to execute arbitrary emulators.
Forbid them on read-only connections.

Fixes: CVE-2019-10168
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit bf6c2830b6c338b1f5699b095df36f374777b291)
Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agoapi: disallow virConnectGetDomainCapabilities on read-only connections
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>
6 years agologging: restrict sockets to mode 0600
Daniel P. Berrangé [Tue, 30 Apr 2019 16:27:41 +0000 (17:27 +0100)] 
logging: restrict sockets to mode 0600

The virtlogd daemon's only intended client is the libvirtd daemon. As
such it should never allow clients from other user accounts to connect.
The code already enforces this and drops clients from other UIDs, but
we can get earlier (and thus stronger) protection against DoS by setting
the socket permissions to 0600

Fixes CVE-2019-10132

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit e37bd65f9948c1185456b2cdaa3bd6e875af680f)

6 years agolocking: restrict sockets to mode 0600
Daniel P. Berrangé [Tue, 30 Apr 2019 15:51:37 +0000 (16:51 +0100)] 
locking: restrict sockets to mode 0600

The virtlockd daemon's only intended client is the libvirtd daemon. As
such it should never allow clients from other user accounts to connect.
The code already enforces this and drops clients from other UIDs, but
we can get earlier (and thus stronger) protection against DoS by setting
the socket permissions to 0600

Fixes CVE-2019-10132

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit f111e09468693909b1f067aa575efdafd9a262a1)

6 years agoadmin: reject clients unless their UID matches the current UID
Daniel P. Berrangé [Tue, 30 Apr 2019 16:26:13 +0000 (17:26 +0100)] 
admin: reject clients unless their UID matches the current UID

The admin protocol RPC messages are only intended for use by the user
running the daemon. As such they should not be allowed for any client
UID that does not match the server UID.

Fixes CVE-2019-10132

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit 96f41cd765c9e525fe28ee5abbfbf4a79b3720c7)

6 years agocpu_map: Define md-clear CPUID bit
Jiri Denemark [Tue, 9 Apr 2019 10:35:52 +0000 (12:35 +0200)] 
cpu_map: Define md-clear CPUID bit

CVE-2018-12126, CVE-2018-12127, CVE-2018-12130, CVE-2019-11091

The bit is set when microcode provides the mechanism to invoke a flush
of various exploitable CPU buffers by invoking the VERW instruction.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit 538d873571d7a682852dc1d70e5f4478f4d64e85)

Conflicts:
        src/cpu_map/x86_features.xml
            - missing pconfig feature

        tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-guest.xml
        tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-host.xml
            - test data missing downstream

        tests/cputestdata/x86_64-cpuid-Xeon-E3-1225-v5-guest.xml
        tests/cputestdata/x86_64-cpuid-Xeon-E3-1225-v5-host.xml
            - intel-pt feature is missing
    - stibp feature is missing

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agocputest: Add data for Intel(R) Xeon(R) CPU E3-1225 v5
Jiri Denemark [Fri, 5 Apr 2019 09:19:30 +0000 (11:19 +0200)] 
cputest: Add data for Intel(R) Xeon(R) CPU E3-1225 v5

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
(cherry picked from commit 5cd9db3ac11e88846cbcf95fad9f6fae9d880dee)

CVE-2018-12126, CVE-2018-12127, CVE-2018-12130, CVE-2019-11091

Conflicts:
tests/cputestdata/x86_64-cpuid-Xeon-E3-1225-v5-guest.xml
tests/cputestdata/x86_64-cpuid-Xeon-E3-1225-v5-host.xml
            - intel-pt feature is missing
    - stibp feature is missing

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoqemu: Don't cache microcode version
Jiri Denemark [Fri, 12 Apr 2019 19:21:05 +0000 (21:21 +0200)] 
qemu: Don't cache microcode version

My earlier commit be46f61326 was incomplete. It removed caching of
microcode version in the CPU driver, which means the capabilities XML
will see the correct microcode version. But it is also cached in the
QEMU capabilities cache where it is used to detect whether we need to
reprobe QEMU. By missing the second place, the original commit
be46f61326 made the situation even worse since libvirt would report
correct microcode version while still using the old host CPU model
(visible in domain capabilities XML).

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 673c62a3b7855a0685d8f116e227c402720b9ee9)

Conflicts:
        src/qemu/qemu_capabilities.c
            - virQEMUCapsCacheLookupByArch refactoring (commits
              7948ad4129a and 1a3de67001c) are missing

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agocpu_x86: Do not cache microcode version
Jiri Denemark [Fri, 5 Apr 2019 09:33:32 +0000 (11:33 +0200)] 
cpu_x86: Do not cache microcode version

The microcode version checks are used to invalidate cached CPU data we
get from QEMU. To minimize /proc/cpuinfo parsing the microcode version
was only read when libvirtd started and cached for the daemon's
lifetime. However, the CPU microcode can change anytime (updating the
microcode package can automatically upload it to the CPU) and we need to
stop caching it to avoid using stale CPU model data.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit be46f613261d3b655a1f15afd635087e68a9c39b)

6 years agoRelease of libvirt-4.7.0 v4.7.0
Daniel Veillard [Mon, 3 Sep 2018 17:20:30 +0000 (19:20 +0200)] 
Release of libvirt-4.7.0

* docs/news.xml: updated for release

Signed-off-by: Daniel Veillard <veillard@redhat.com>
6 years agonews: Update for 4.7.0 release
Andrea Bolognani [Mon, 3 Sep 2018 11:55:22 +0000 (13:55 +0200)] 
news: Update for 4.7.0 release

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
6 years agovirsh: Drop dead variables
Eric Blake [Fri, 31 Aug 2018 22:10:57 +0000 (17:10 -0500)] 
virsh: Drop dead variables

The helper function virshSnapshotCreate (formerly vshSnapshotCreate)
has had dead variables since commit a00c37f2 (Sep 2011).

Signed-off-by: Eric Blake <eblake@redhat.com>
6 years agoqemu: mdev: Use vfio-pci 'display' property only with vfio-pci mdevs
Farhan Ali [Thu, 30 Aug 2018 17:07:34 +0000 (13:07 -0400)] 
qemu: mdev: Use vfio-pci 'display' property only with vfio-pci mdevs

S390 is aware of both vfio-pci and vfio-ccw devices, so
on S390 the capability QEMU_CAPS_VFIO_PCI_DISPLAY will be
available. Add an extra check to make sure we only set the
display to off for vfio-pci mediated devices. Otherwise we
add display for vfio-ccw device and this breaks vfio-ccw
device qemu command line.

Fixes: d54e45b6e conf: Introduce new <hostdev> attribute 'display'
Signed-off-by: Farhan Ali <alifm@linux.ibm.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agostorage: Fix mention of disk pool default
Eric Blake [Wed, 29 Aug 2018 22:15:43 +0000 (17:15 -0500)] 
storage: Fix mention of disk pool default

The default disk storage pool type in XML is 'dos', not 'msdos'.
But tweak wording to keep the term 'msdos' in the text for the
sake of grep searches.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: Validate memory access during validate domain config v4.7.0-rc2
Luyao Huang [Mon, 20 Aug 2018 09:48:33 +0000 (17:48 +0800)] 
qemu: Validate memory access during validate domain config

Commit 6534b3c4 tried to raise an error when there is no numa
nodes by setting access='shared' in the domain config, but added
a helper called from qemuDomainDeviceDefValidate instead of a
helper called from qemuDomainDefValidate for XML:

  <memoryBacking>
    <hugepages/>
    <access mode='shared'/>
  </memoryBacking>

Since there are no memory devices in the test XML, there would
be no validation failure, but the test added was still failing.
Investigating that it turns out that unnecessary XML elements
were causing the failure (no need for <video>, <graphics>,
<pm>, usb controller model "piix3-uhci", disk attribute for
"discard='unmap'", <serial>, <console>, <channel> and a
memballoon model). Removing all those before moving the method
caused the test to succeed.

So this patch moves the validation to the right place and
removes all the unnecessary XML pieces that were causing
a false validation failure.

https://bugzilla.redhat.com/show_bug.cgi?id=1448149#c14

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovsh-table: Fix broken build on centos and rhel
Simon Kobyda [Wed, 29 Aug 2018 07:48:10 +0000 (09:48 +0200)] 
vsh-table: Fix broken build on centos and rhel

The reason of broken build was that centos and rhel use older version of
glibc. These versions of glibc on these platforms cannot work with newer
unicodes, thus causing functions iswprint() and wcwidth() return
unexpected values causing the vshtabletest to fail. Therefore, let's
replace the new unicode characters causing issues with some older ones
to fix the test suite, as the issue would still persist during runtime.

Signed-off-by: Simon Kobyda <skobyda@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agovirDomainObjListAddLocked: fix double free
Marc Hartmayer [Mon, 27 Aug 2018 13:20:13 +0000 (15:20 +0200)] 
virDomainObjListAddLocked: fix double free

If @vm has flagged as "to be removed" virDomainObjListFindByNameLocked
returns NULL (although the definition actually exists). Therefore, the
possibility exits that "virHashAddEntry" will raise the error
"Duplicate key" => virDomainObjListAddObjLocked fails =>
virDomainObjEndAPI(&vm) is called and this leads to a freeing of @def
since @def is already assigned to vm->def. But actually this leads to
a double free since the common usage pattern is that the caller of
virDomainObjListAdd(Locked) is responsible for freeing @def in case of
an error.

Let's fix this by setting vm->def to NULL in case of an error.

Backtrace:

   ➤  bt
   #0  virFree (ptrptr=0x7575757575757575)
   #1  0x000003ffb5b25b3e in virDomainResourceDefFree
   #2  0x000003ffb5b37c34 in virDomainDefFree
   #3  0x000003ff9123f734 in qemuDomainDefineXMLFlags
   #4  0x000003ff9123f7f4 in qemuDomainDefineXML
   #5  0x000003ffb5cd2c84 in virDomainDefineXML
   #6  0x000000011745aa82 in remoteDispatchDomainDefineXML
   ...

Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
6 years agoqemu: Add more defaults for RISC-V virt guests
Andrea Bolognani [Tue, 28 Aug 2018 15:40:27 +0000 (17:40 +0200)] 
qemu: Add more defaults for RISC-V virt guests

We would have used virtio for networking anyway, but it's
better to be explicit; for graphics, none of the existing
models work right now but virtio is the only one which
has a non-PCI variant, so it's as good a default as any

Spotted-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: Introduce 16550A serial console model
Andrea Bolognani [Mon, 27 Aug 2018 08:25:17 +0000 (10:25 +0200)] 
qemu: Introduce 16550A serial console model

None of the existing models is suitable for use with
RISC-V virt guests, and we don't want information about
the serial console to be missing from the XML.

The name is based on comments in qemu/hw/riscv/virt.c:

  RISC-V machine with 16550a UART and VirtIO MMIO

and in qemu/hw/char/serial.c:

  QEMU 16550A UART emulation

along with the output of dmesg in the guest:

  Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
  10000000.uart: ttyS0 at MMIO 0x10000000 (irq = 13,
    base_baud= 230400) is a 16550A

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: Don't use legacy USB for RISC-V guests
Andrea Bolognani [Fri, 24 Aug 2018 11:09:32 +0000 (13:09 +0200)] 
qemu: Don't use legacy USB for RISC-V guests

The architecture is new enough that we don't need to
concern ourselves with backwards compatibility in any
capacity.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: no USB by default on RISC-V machines
Lubomir Rintel [Thu, 14 Jun 2018 20:32:27 +0000 (22:32 +0200)] 
qemu: no USB by default on RISC-V machines

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agodocs: api_extension: Update paths in the examples
Peter Krempa [Thu, 23 Aug 2018 08:48:37 +0000 (10:48 +0200)] 
docs: api_extension: Update paths in the examples

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: qemumonitorjson: Add test case for 'blockdev-mirror'
Peter Krempa [Thu, 16 Aug 2018 16:42:12 +0000 (18:42 +0200)] 
tests: qemumonitorjson: Add test case for 'blockdev-mirror'

Add the generated testcase to test the generated command against the
QMP schema.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: qemumonitorjson: Change values which would be omitted
Peter Krempa [Thu, 16 Aug 2018 14:36:41 +0000 (16:36 +0200)] 
tests: qemumonitorjson: Change values which would be omitted

Many of the parameters are omitted for NULL/0 situations. Change the
values for these cases so all the arguments are schema-checked.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: qemumonitorjson: Add test for 'block-stream' command
Peter Krempa [Wed, 15 Aug 2018 13:42:22 +0000 (15:42 +0200)] 
tests: qemumonitorjson: Add test for 'block-stream' command

Test the generated command against the schema.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemuargv2xmltest: Fix caps loading in VPATH build
Jiri Denemark [Tue, 28 Aug 2018 12:24:10 +0000 (14:24 +0200)] 
qemuargv2xmltest: Fix caps loading in VPATH build

Broken by v4.7.0-rc1-9-g6700062fb0.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
6 years agoutil: json: Allow converting a virTristate(Bool|Switch) into JSON
Peter Krempa [Thu, 16 Aug 2018 14:19:22 +0000 (16:19 +0200)] 
util: json: Allow converting a virTristate(Bool|Switch) into JSON

Add a new modifier letter for virJSONValueObjectAddVArgs which will add
a boolean value with our tristate semantics. The value is omitted when
the _ABSENT value is used.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoxml: report the filename (if any) when parsing files
Daniel P. Berrangé [Thu, 16 Aug 2018 12:08:52 +0000 (13:08 +0100)] 
xml: report the filename (if any) when parsing files

A generic "failed to parse xml document" message without telling us
which XML file failed is quite unhelpful.

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agocpu: split x86 map data into separate files
Daniel P. Berrangé [Mon, 30 Jul 2018 16:17:21 +0000 (17:17 +0100)] 
cpu: split x86 map data into separate files

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agocpu: split PPC64 map data into separate files
Daniel P. Berrangé [Mon, 30 Jul 2018 16:17:21 +0000 (17:17 +0100)] 
cpu: split PPC64 map data into separate files

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agocpu: move the CPU map data files into a src/cpu_map directory
Daniel P. Berrangé [Thu, 16 Aug 2018 11:39:39 +0000 (12:39 +0100)] 
cpu: move the CPU map data files into a src/cpu_map directory

In preparation for splitting up the CPU map data file, move it into a
dedicated directory of its own.

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agocpu: simplify failure cleanup paths
Daniel P. Berrangé [Thu, 16 Aug 2018 10:59:44 +0000 (11:59 +0100)] 
cpu: simplify failure cleanup paths

Get rid of the separate 'error:' label, so all code paths jump straight
to the 'cleanup:' label.

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agocpu: push more parsing logic into common code
Daniel P. Berrangé [Mon, 30 Jul 2018 16:08:38 +0000 (17:08 +0100)] 
cpu: push more parsing logic into common code

The x86 and ppc impls both duplicate some logic when parsing CPU
features. Change the callback signature so that this duplication can be
pushed up a level to common code.

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agocpu: fix cleanup when signature parsing fails
Daniel P. Berrangé [Thu, 16 Aug 2018 10:28:54 +0000 (11:28 +0100)] 
cpu: fix cleanup when signature parsing fails

Two pieces of code accidentally jumped to the wrong label when they
failed causing incorrect cleanup, returning a partially initialized
CPU model struct.

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agocpu: allow include files for CPU definition
Daniel P. Berrangé [Mon, 30 Jul 2018 15:35:57 +0000 (16:35 +0100)] 
cpu: allow include files for CPU definition

Allow for syntax

    <include filename="subdir/fooo.xml"/>

to reference other files in the CPU database directory

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoconf: report enum errors in virDomainInputDefValidate
Ján Tomko [Tue, 21 Aug 2018 12:53:55 +0000 (14:53 +0200)] 
conf: report enum errors in virDomainInputDefValidate

Commit deb057f added a switch without a default case.
Add it and call virReportEnumRangeError for _LAST too.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemu: initialize variables in qemuParseCommandLine
Ján Tomko [Tue, 28 Aug 2018 10:53:25 +0000 (12:53 +0200)] 
qemu: initialize variables in qemuParseCommandLine

Commit 6700062 introduced a jump to error which skipped the
initialization of def:

qemu/qemu_parse_command.c:1870:9: error: variable 'def' is
used uninitialized whenever 'if' condition is true
      [-Werror,-Wsometimes-uninitialized]
    if (!(qemuCaps = virQEMUCapsCacheLookup(capsCache, progargv[0])))

Initialize def to fix this warning and qemuCaps, to prevent
a future error like this.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: fix default machine for argv -> xml convertor
Daniel P. Berrangé [Mon, 13 Aug 2018 11:42:01 +0000 (12:42 +0100)] 
qemu: fix default machine for argv -> xml convertor

Historically the argv -> xml convertor wanted the same default machine
as we'd set when parsing xml. The latter has now changed, however, to
use a default defined by libvirt. The former needs fixing to again
honour the default QEMU machine.

This exposed a bug in handling for the aarch64 target, as QEMU does not
define any default machine. Thus we should not having been accepting
argv without a -machine provided.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoqemu: rename method for getting preferred machine type
Daniel P. Berrangé [Fri, 10 Aug 2018 14:06:38 +0000 (15:06 +0100)] 
qemu: rename method for getting preferred machine type

The virQEMUCapsGetDefaultMachine() method doesn't get QEMU's default
machine any more, instead it gets the historical default that libvirt
prefers for each arch. Rename it, so that the old name can be used for
getting QEMU's default.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoqemu: record the QEMU default machine in capabilities
Daniel P. Berrangé [Fri, 10 Aug 2018 12:18:27 +0000 (13:18 +0100)] 
qemu: record the QEMU default machine in capabilities

We don't honour the QEMU default machine type anymore, always using the
libvirt chosen default instead. The QEMU argv parser, however, will need
to know the exacty QEMU default, so we must record that info.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agotests: qemuxml2argv: Remove 'args' for tests only used in xml2xmltest
Peter Krempa [Mon, 27 Aug 2018 16:06:20 +0000 (18:06 +0200)] 
tests: qemuxml2argv: Remove 'args' for tests only used in xml2xmltest

'metadata' and 'leases' are features internal to libvirt and thus don't
influence the generated QEMU command line. As they are not tested we
don't need the output files.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agotests: qemuxml2argv: Remove the 'no-shutdown' test completely
Peter Krempa [Mon, 27 Aug 2018 16:05:04 +0000 (18:05 +0200)] 
tests: qemuxml2argv: Remove the 'no-shutdown' test completely

Now we assume the flag always so there's no use for this test. Probably
a leftover from the cleanup of the capability.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agotests: qemuxml2argv: Make use of 'vram64' QXL device tests
Peter Krempa [Mon, 27 Aug 2018 15:59:26 +0000 (17:59 +0200)] 
tests: qemuxml2argv: Make use of 'vram64' QXL device tests

The test files were unused, but we don't have any other test for this
feature. Make use of the existing files by removing disks and using
DO_TEST_CAPS_LATEST to execute them. The legacy output files will be
dropped.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agotests: qemuxml2argv: Remove 'args' files for tests expecting failure
Peter Krempa [Mon, 27 Aug 2018 15:54:50 +0000 (17:54 +0200)] 
tests: qemuxml2argv: Remove 'args' files for tests expecting failure

Output file does not make sense for those.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoconf: Move some device_conf predicates
Andrea Bolognani [Fri, 17 Aug 2018 13:35:19 +0000 (15:35 +0200)] 
conf: Move some device_conf predicates

Turn

  virPCIDeviceAddressIsEmpty()
  virDeviceInfoPCIAddressIsWanted()
  virDeviceInfoPCIAddressIsPresent()

from inline functions to regular functions.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoconf: Rename some device_conf predicates
Andrea Bolognani [Fri, 17 Aug 2018 13:12:42 +0000 (15:12 +0200)] 
conf: Rename some device_conf predicates

The affected functions are

  virDeviceInfoPCIAddressWanted()
  virDeviceInfoPCIAddressPresent()

which get renamed to

  virDeviceInfoPCIAddressIsWanted()
  virDeviceInfoPCIAddressIsPresent()

to comply with the naming convention used for other
predicates.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovsh: Fix broken build on mingw v4.7.0-rc1
Simon Kobyda [Mon, 27 Aug 2018 15:44:29 +0000 (17:44 +0200)] 
vsh: Fix broken build on mingw

The function wcwidth() doesn't exist on mingw. However, it does exist in
gnulib, so we can rely on that.

Signed-off-by: Simon Kobyda <skobyda@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agovircgroup: Remove obsolete sa_assert
Pavel Hrdina [Sun, 19 Aug 2018 09:04:35 +0000 (11:04 +0200)] 
vircgroup: Remove obsolete sa_assert

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: Simplify if conditions in virCgroupMakeGroup
Pavel Hrdina [Sun, 19 Aug 2018 09:04:52 +0000 (11:04 +0200)] 
vircgroup: Simplify if conditions in virCgroupMakeGroup

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: Call virCgroupRemove inside virCgroupMakeGroup
Pavel Hrdina [Fri, 17 Aug 2018 13:00:44 +0000 (15:00 +0200)] 
vircgroup: Call virCgroupRemove inside virCgroupMakeGroup

This fixes virCgroupEnableMissingControllers where virCgroupRemove
was not called in case virCgroupMakeGroup failed.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: Split virCgroupPathOfController into two functions
Pavel Hrdina [Wed, 15 Aug 2018 15:21:47 +0000 (17:21 +0200)] 
vircgroup: Split virCgroupPathOfController into two functions

The case where we need path of any controller is only for internal use
so move it out to a different function.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: Extract placement validation into function
Pavel Hrdina [Fri, 24 Aug 2018 11:54:18 +0000 (13:54 +0200)] 
vircgroup: Extract placement validation into function

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: Extract controller detection into function
Pavel Hrdina [Wed, 15 Aug 2018 14:14:12 +0000 (16:14 +0200)] 
vircgroup: Extract controller detection into function

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: Duplicate string before modifying
Pavel Hrdina [Wed, 15 Aug 2018 13:59:08 +0000 (15:59 +0200)] 
vircgroup: Duplicate string before modifying

The 'mntDir' is part of 'struct mntent' as a result of getmntent_r
therefore we should not mangle with it.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agotests: qemuxml2argv: Drop some unused args files
Peter Krempa [Mon, 27 Aug 2018 15:01:10 +0000 (17:01 +0200)] 
tests: qemuxml2argv: Drop some unused args files

aarch64-acpi-nouefi and hostdev-scsi-boot are unused. Noticed when
checking whether '-nodefconfig' is still used by libvirt.

Unused since their introduction in commit deb38c4 and bab6ee6
respectively.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: qemuDomainChangeNet: validity checks should be done before XML autocompletion
Katerina Koukiou [Fri, 24 Aug 2018 10:28:41 +0000 (12:28 +0200)] 
qemu: qemuDomainChangeNet: validity checks should be done before XML autocompletion

This patch ensures that changes in attributes of interfaces will emit
errors except if they are missing from the XML.
Previously we were falsely reporting successful updates, because some
changed attributes got overwritten before the validity checks.

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

Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoapparmor: fix ptrace rules with kernel 4.18
Christian Ehrhardt [Fri, 24 Aug 2018 06:07:39 +0000 (08:07 +0200)] 
apparmor: fix ptrace rules with kernel 4.18

Due to kernel upstream change 338d0be4 ("apparmor: fix ptrace read check")
libvirt now hits apparmor denies like:
  apparmor="DENIED" operation="ptrace" profile="/usr/sbin/libvirtd"
  pid=4409 comm="libvirtd" requested_mask="read" denied_mask="read"
  peer="libvirt-14e92a75-7668-4b97-8f92-322fc1b9c78a"

Extend the ptrace rule to also allow 'ptrace (read)' for libvirtd to work
with these newer kernels.

Fixes: https://bugs.launchpad.net/bugs/1788603
Reported-by: Thadeu Lima de Souza Cascardo <thadeu.cascardo@canonical.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Acked-by: Jamie Strandboge <jamie@canonical.com>
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
6 years agoqemu: Start domain on a node without cpu affinity
Roman Bolshakov [Thu, 23 Aug 2018 08:49:48 +0000 (11:49 +0300)] 
qemu: Start domain on a node without cpu affinity

qemuProcessInitCpuAffinity prevents a VM from getting started on a
platform that uses cpu affinity wrapper stubs e.g. macOS.

The patch adds qemuProcessInitCpuAffinity stub on all platforms without
HAVE_SCHED_GETAFFINITY or HAVE_BSD_CPU_AFFINITY.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoutil: eventpoll: Survive EBADF on macOS
Roman Bolshakov [Thu, 23 Aug 2018 08:49:32 +0000 (11:49 +0300)] 
util: eventpoll: Survive EBADF on macOS

Fixes:
https://www.redhat.com/archives/libvir-list/2017-January/msg00978.html

QEMU is probed through monitor fd to check capabilities during libvirtd init.
The monitor fd is closed after probing by virQEMUCapsInitQMPCommandFree
that calls virQEMUCapsInitQMPCommandAbort that calls qemuMonitorClose,
the latter one notifies the event loop via an interrupt handle in
qemuMonitorUnregister and after then closes monitor fd.

There could be a case when interrupt is sent after eventLoop is unlocked
but before virEventPollRunOnce blocks in poll, shortly before file
descriptor is closed by qemuMonitorClose. Then poll receives closed monitor
fd in fdset and returns EBADF.

EBADF is not mentioned as a valid errno on macOS poll man-page but such
behaviour can appear release-to-release, according to cpython:
https://github.com/python/cpython/blob/master/Modules/selectmodule.c#L1161

The change also fixes the issue in qemucapabilitiestest. It returns
Bad file descriptor message 25 times without the fix.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agodocs: api_extension: Don't encourage other tools than git
Peter Krempa [Thu, 23 Aug 2018 08:46:39 +0000 (10:46 +0200)] 
docs: api_extension: Don't encourage other tools than git

Save us hassle in the list if anybody would read this.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agodocs: api_extension: Remove example patches
Peter Krempa [Thu, 23 Aug 2018 08:23:46 +0000 (10:23 +0200)] 
docs: api_extension: Remove example patches

Now that they are not linked any more remove them.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agodocs: api_extension: Remove links to the stale example patches
Peter Krempa [Thu, 23 Aug 2018 08:21:03 +0000 (10:21 +0200)] 
docs: api_extension: Remove links to the stale example patches

The patches used as an example for the api_extension manual don't hold
up to the current standards any more. Carefully remove links and
mentions of the patches from the docs.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: capabilities: Always assume QEMU_CAPS_ADD_FD
Peter Krempa [Fri, 24 Aug 2018 13:38:59 +0000 (15:38 +0200)] 
qemu: capabilities: Always assume QEMU_CAPS_ADD_FD

The capability was usable since qemu 1.3 so we can remove all the
detection code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agotests: qemuxml2argv: modernize TPM passthrough tests
Peter Krempa [Tue, 14 Aug 2018 11:50:01 +0000 (13:50 +0200)] 
tests: qemuxml2argv: modernize TPM passthrough tests

All supported qemus support FD passing so modify the tests to test the
proper code path.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: command: Extract opening of TPM backend FDs for mocking purposes
Peter Krempa [Tue, 14 Aug 2018 12:17:52 +0000 (14:17 +0200)] 
qemu: command: Extract opening of TPM backend FDs for mocking purposes

Allow mocking of the file descriptor numbers used for the TPM
passthrough mode by extracting the relevant code into an exported
function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agotests: qemuxml2argvmock: Allow 'safe' file descriptors in mocked virCommandPassFD
Peter Krempa [Tue, 14 Aug 2018 13:02:56 +0000 (15:02 +0200)] 
tests: qemuxml2argvmock: Allow 'safe' file descriptors in mocked virCommandPassFD

Allow FDs which are marked as safe for FD passing.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: capabilities: Detect active block commit via QMP schema probing if possible
Peter Krempa [Tue, 14 Aug 2018 15:53:05 +0000 (17:53 +0200)] 
qemu: capabilities: Detect active block commit via QMP schema probing if possible

For versions where we can probe that the arguments are optional we can
perform the probing by a schema query rather than sending a separate
command to do so.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: qapi: Allow selecting specifically optional schema entries in virQEMUQAPISchema...
Peter Krempa [Wed, 15 Aug 2018 06:51:01 +0000 (08:51 +0200)] 
qemu: qapi: Allow selecting specifically optional schema entries in virQEMUQAPISchemaTraverse

Add a new modifier character '*' which will select given schema entry
only when it is optional (denoted by the presence of the 'default' key).

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: qapi: Split up virQEMUQAPISchemaObjectGetType
Peter Krempa [Wed, 15 Aug 2018 06:39:19 +0000 (08:39 +0200)] 
qemu: qapi: Split up virQEMUQAPISchemaObjectGetType

Split it into a function that returns the whole schema entry so that we
can do additional checks and a helper getting the type string from the
schema entry.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: qapi: Simplify value handling in virQEMUQAPISchemaTraverse
Peter Krempa [Wed, 15 Aug 2018 06:32:04 +0000 (08:32 +0200)] 
qemu: qapi: Simplify value handling in virQEMUQAPISchemaTraverse

Introduce a few variables so that we can easily access the modifier
character and also don't have to do pointer arithmetic when selecting
the schema entries. This will simplify adding of new modifier
characters.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agostorage: Add --shrink to qemu-img command when shrinking vol
John Ferlan [Fri, 17 Aug 2018 19:53:29 +0000 (15:53 -0400)] 
storage: Add --shrink to qemu-img command when shrinking vol

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

When shrinking the capacity of a qcow2 or luks volume using
the qemu-img program, the --shrink qualifier must be added.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agonwfilter: Add extra verbiage for binding create/delete
John Ferlan [Wed, 22 Aug 2018 22:01:41 +0000 (18:01 -0400)] 
nwfilter: Add extra verbiage for binding create/delete

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

Add some cautionary words related to the create and delete
NWFilter Binding use cases and possible issues that may result
to the virsh nwfilter-binding-{create|delete} descriptions
and the virNWFilterBinding{CreateXML|Delete) API descriptions.

Essentially summarizing commit 2d9318b6c without using the
shoot yourself in the foot wording.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoaccess: Fix nwfilter-binding ACL access API name generation
John Ferlan [Tue, 21 Aug 2018 19:58:29 +0000 (15:58 -0400)] 
access: Fix nwfilter-binding ACL access API name generation

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

Generation of the ACL API policy is a "automated process"
based on this perl script which "worked" with the changes to
add nwfilter binding API's because they had the "nwfilter"
prefix; however, the generated output name was incorrect
based on the remote protocol algorithm which expected to
generate names such as 'nwfilter-binding.action' instead
of 'nwfilter.binding-action'.

This effectively changes src/access/org.libvirt.api.policy entries:

  org.libvirt.api.nwfilter.binding-create ==>
      org.libvirt.api.nwfilter-binding.create

  org.libvirt.api.nwfilter.binding-delete ==>
      org.libvirt.api.nwfilter-binding.delete

  org.libvirt.api.nwfilter.binding-getattr ==>
      org.libvirt.api.nwfilter-binding.getattr

  org.libvirt.api.nwfilter.binding-read ==>
      org.libvirt.api.nwfilter-binding.read

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoqemu: monitor: Separate probing for active block commit
Peter Krempa [Tue, 14 Aug 2018 13:52:01 +0000 (15:52 +0200)] 
qemu: monitor: Separate probing for active block commit

Extract the code used to probe for the functionality so that it does not
litter the code used for actual work.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: monitor: Rename 'device' argument for block job control APIs
Peter Krempa [Tue, 14 Aug 2018 11:11:05 +0000 (13:11 +0200)] 
qemu: monitor: Rename 'device' argument for block job control APIs

Starting from qemu 2.7 the 'device' argument is in fact a name of the
job itself. Change our APIs accordingly and adjust the error message.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: monitor: Use qemuMonitorJSONBlockJobError in qemuMonitorJSONDrivePivot
Peter Krempa [Tue, 14 Aug 2018 11:04:18 +0000 (13:04 +0200)] 
qemu: monitor: Use qemuMonitorJSONBlockJobError in qemuMonitorJSONDrivePivot

The API deals with a block job so use the common error reporting
function for it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: monitor: Move qemuMonitorJSONDrivePivot together with block-job APIs
Peter Krempa [Tue, 14 Aug 2018 11:02:43 +0000 (13:02 +0200)] 
qemu: monitor: Move qemuMonitorJSONDrivePivot together with block-job APIs

Move all relevant APIs dealing with existing jobs together.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: monitor: Use qemuMonitorJSONCheckError in qemuMonitorJSONBlockStream
Peter Krempa [Tue, 14 Aug 2018 10:54:16 +0000 (12:54 +0200)] 
qemu: monitor: Use qemuMonitorJSONCheckError in qemuMonitorJSONBlockStream

The API does not report any special job-related error so the generic
error function should be used.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: monitor: Remove temporary variables
Peter Krempa [Tue, 14 Aug 2018 10:51:15 +0000 (12:51 +0200)] 
qemu: monitor: Remove temporary variables

Now that the job name is used in single place in the respective
functions remove the temporary strings.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: monitor: Use qemuMonitorJSONCheckError in qemuMonitorJSONBlockJobError
Peter Krempa [Tue, 14 Aug 2018 10:47:05 +0000 (12:47 +0200)] 
qemu: monitor: Use qemuMonitorJSONCheckError in qemuMonitorJSONBlockJobError

Report the generic errors using the existing function so that we don't
reimplement the same functionality multiple times.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: monitor: Remove error classes not conforming to QAPI schema
Peter Krempa [Tue, 14 Aug 2018 10:29:10 +0000 (12:29 +0200)] 
qemu: monitor: Remove error classes not conforming to QAPI schema

Both were removed prior to qemu v1.2.0-rc0 when switching to the new
error format where almost all error types were converted to GenericError.

Relevant qemu commits are <de253f14912e> and <df1e608a01eb0>

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agonews: Add a mention of RISC-V guest support
Lubomir Rintel [Wed, 22 Aug 2018 09:15:28 +0000 (11:15 +0200)] 
news: Add a mention of RISC-V guest support

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agotests: Add RISC-V guest
Lubomir Rintel [Wed, 22 Aug 2018 09:15:27 +0000 (11:15 +0200)] 
tests: Add RISC-V guest

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agotests: Add RISC-V architectures
Lubomir Rintel [Wed, 22 Aug 2018 09:15:27 +0000 (11:15 +0200)] 
tests: Add RISC-V architectures

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemu: assign addresses to virtio devices on RISC-V
Lubomir Rintel [Wed, 22 Aug 2018 09:15:26 +0000 (11:15 +0200)] 
qemu: assign addresses to virtio devices on RISC-V

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemu: add qemuDomainAssignVirtioMMIOAddresses()
Lubomir Rintel [Wed, 22 Aug 2018 09:15:25 +0000 (11:15 +0200)] 
qemu: add qemuDomainAssignVirtioMMIOAddresses()

We're going to need to assign virtio-mmio addresses to non-ARM
guests soon, so let's create a generic wrapper that calls to
the architecture-specific implementation.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemu: add qemuDomainIsRISCVVirt() and qemuDomainMachineIsRISCVVirt()
Lubomir Rintel [Wed, 22 Aug 2018 09:15:24 +0000 (11:15 +0200)] 
qemu: add qemuDomainIsRISCVVirt() and qemuDomainMachineIsRISCVVirt()

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemu: RISC-V machines have no PCI
Lubomir Rintel [Wed, 22 Aug 2018 09:15:23 +0000 (11:15 +0200)] 
qemu: RISC-V machines have no PCI

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoutil: add RISC-V architectures
Lubomir Rintel [Wed, 22 Aug 2018 09:15:22 +0000 (11:15 +0200)] 
util: add RISC-V architectures

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemu: Rename qemuDomain*IsVirt() to qemuDomain*IsARMVirt()
Lubomir Rintel [Wed, 22 Aug 2018 09:15:20 +0000 (11:15 +0200)] 
qemu: Rename qemuDomain*IsVirt() to qemuDomain*IsARMVirt()

They're ARM specific.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agovsh: Added tests
Simon Kobyda [Thu, 23 Aug 2018 15:53:43 +0000 (17:53 +0200)] 
vsh: Added tests

For now, there are 9 test cases
- testVshTableNew: Creating table with empty header
- testVshTableHeader: Printing table with/without header
- testVshTableRowAppend: Appending row with various number of cells.
  Only row with same number of cells as in header is accepted.
- testUnicode: Printing table with unicode characters.
  Checking correct alignment.
- testUnicodeArabic: test opposite (right to left) writing
- testUnicodeZeroWidthChar
- testUnicodeCombiningChar
- testUnicodeNonPrintableChar,
- testNTables: Create and print varios types of tables - one column,
  one row table, table without content, standart table...

Signed-off-by: Simon Kobyda <skobyda@redhat.com>
6 years agovirsh: Implement new table API for virsh list
Simon Kobyda [Thu, 23 Aug 2018 15:53:42 +0000 (17:53 +0200)] 
virsh: Implement new table API for virsh list

Instead of printing it straight in virsh, it creates table struct
which is filled with header and rows(domains). It allows us to know
more about table before printing to calculate alignment right.

Signed-off-by: Simon Kobyda <skobyda@redhat.com>
6 years agovsh: Add API for printing tables.
Simon Kobyda [Thu, 23 Aug 2018 15:53:41 +0000 (17:53 +0200)] 
vsh: Add API for printing tables.

It solves problems with alignment of columns. Width of each column
is calculated by its biggest cell. Should solve unicode bug.
In future, it may be implemented in virsh, virt-admin...

This API has 5 public functions:
- vshTableNew - adds new table and defines its header
- vshTableRowAppend - appends new row (for same number of columns as in
header)
- vshTablePrintToStdout
- vshTablePrintToString
- vshTableFree

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

Signed-off-by: Simon Kobyda <skobyda@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoqemu: Make sure preferredMachines is not missing any entry
Andrea Bolognani [Thu, 23 Aug 2018 16:46:52 +0000 (18:46 +0200)] 
qemu: Make sure preferredMachines is not missing any entry

With the current implementation, adding a new architecture
and not updating preferredMachines accordingly will not
cause a build failure, making it very likely that subtle
bugs will be introduced in the process. Rework the code
so that such issues will be caught by the compiler.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agostorage: fix the error message when encrypted raw volume resize
Shivaprasad G Bhat [Mon, 20 Aug 2018 06:27:13 +0000 (11:57 +0530)] 
storage: fix the error message when encrypted raw volume resize

The vol-dumpxml shows the volume target format type as raw for
encrypted volumes. The error message when attempting to resize
with prealloc is confusing here.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: fix error message on directory creation
Eric Blake [Wed, 22 Aug 2018 21:21:51 +0000 (16:21 -0500)] 
qemu: fix error message on directory creation

Minor copy-and-paste bug present since commit 462c74c3, in Apr 2010.

Signed-off-by: Eric Blake <eblake@redhat.com>
6 years agoqemu: monitor: Fix device matching in qemuMonitorJSONBlockIoThrottleInfo
Peter Krempa [Wed, 22 Aug 2018 11:20:52 +0000 (13:20 +0200)] 
qemu: monitor: Fix device matching in qemuMonitorJSONBlockIoThrottleInfo

We should compare the alias/qdev id only when it was provided by the
caller and when it was found in the reply. Otherwise we could
dereference a NULL pointer. STRNEQ_NULLABLE is not appropriate since
it would return 'true' if the string was not present in the JSON output.

Found by Coverity.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: hotplug: Don't leak 'nodename' in qemuDomainChangeMediaBlockdev
Peter Krempa [Wed, 22 Aug 2018 11:09:50 +0000 (13:09 +0200)] 
qemu: hotplug: Don't leak 'nodename' in qemuDomainChangeMediaBlockdev

qemuDomainDiskGetBackendAlias allocates a copy of the nodename string so
we need to free it at the end.

Found by Coverity.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>