]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
6 years agolibxl: implement virDomainPM* functions
Marek Marczykowski-Górecki [Fri, 7 Sep 2018 19:29:55 +0000 (21:29 +0200)]
libxl: implement virDomainPM* functions

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
6 years agolibxl: send lifecycle event on suspend
Marek Marczykowski-Górecki [Fri, 7 Sep 2018 19:29:54 +0000 (21:29 +0200)]
libxl: send lifecycle event on suspend

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
6 years agoqemu: Fix indentation in virDomainDefFormatInternal
Jiri Denemark [Thu, 6 Sep 2018 15:43:17 +0000 (17:43 +0200)]
qemu: Fix indentation in virDomainDefFormatInternal

Broken by v3.10.0-68-gaed3d038a6.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agodocs: update domain schema for machine attribute
Marek Marczykowski-Górecki [Sun, 5 Aug 2018 21:48:45 +0000 (23:48 +0200)]
docs: update domain schema for machine attribute

Replace the long dead 'xenner' with 'xenfv'.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
6 years agoqemu: remove leftover property probing
Ján Tomko [Fri, 7 Sep 2018 12:59:00 +0000 (14:59 +0200)]
qemu: remove leftover property probing

Previous commits removed all capabilities from per-device property
probing for:

  pci-assign
  kvm-pci-assign
  usb-host
  scsi-generic

Remove them from the virQEMUCapsDeviceProps list and get rid of the
redundant device-list-properties QMP calls.

Note that 'pci-assign' was already useless, because the QMP version
of the device is called 'kvm-pci-assign', see libvirt commit 7257480
from 2012.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemu: always assume QEMU_CAPS_DEVICE_SCSI_GENERIC_BOOTINDEX
Ján Tomko [Fri, 7 Sep 2018 12:53:02 +0000 (14:53 +0200)]
qemu: always assume QEMU_CAPS_DEVICE_SCSI_GENERIC_BOOTINDEX

Introduced by QEMU commit 28b77657 in v1.0-rc4~21^2~8.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemu: always assume QEMU_CAPS_VFIO_PCI_BOOTINDEX
Ján Tomko [Fri, 7 Sep 2018 12:46:26 +0000 (14:46 +0200)]
qemu: always assume QEMU_CAPS_VFIO_PCI_BOOTINDEX

Introduced by QEMU commit c29029d which was included in 1.5.0

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemu: always assume QEMU_CAPS_USB_HOST_BOOTINDEX
Ján Tomko [Fri, 7 Sep 2018 12:37:34 +0000 (14:37 +0200)]
qemu: always assume QEMU_CAPS_USB_HOST_BOOTINDEX

Added by QEMU commit 65bb3a5 contained in v1.1.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemu: always assume QEMU_CAPS_USB_REDIR_BOOTINDEX
Ján Tomko [Fri, 7 Sep 2018 12:37:34 +0000 (14:37 +0200)]
qemu: always assume QEMU_CAPS_USB_REDIR_BOOTINDEX

Added by QEMU commit 65bb3a5 contained in v1.1.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemu: always assume QEMU_CAPS_PCI_BOOTINDEX
Ján Tomko [Fri, 7 Sep 2018 11:31:23 +0000 (13:31 +0200)]
qemu: always assume QEMU_CAPS_PCI_BOOTINDEX

At the time of the addition of 'pci-assign' in QEMU commit
v1.3.0-rc0~572^2 the bootindex argument was already supported.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemu: always assume QEMU_CAPS_PCI_CONFIGFD
Ján Tomko [Fri, 7 Sep 2018 11:31:23 +0000 (13:31 +0200)]
qemu: always assume QEMU_CAPS_PCI_CONFIGFD

At the time of the addition of 'pci-assign' in QEMU commit
v1.3.0-rc0~572^2 the configfd argument was already supported.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemu: drop unused QEMU_CAPS_DEVICE_USB_NET
Ján Tomko [Fri, 7 Sep 2018 12:28:50 +0000 (14:28 +0200)]
qemu: drop unused QEMU_CAPS_DEVICE_USB_NET

Added by commit fc66c1603c and not used since.

Also, the device was present in QEMU 1.5.0 so this capability
will not be needed if we ever decide to implement usb-net support.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemuProcessBuildDestroyMemoryPathsImpl: Don't overwrite error
Michal Privoznik [Fri, 7 Sep 2018 12:04:54 +0000 (14:04 +0200)]
qemuProcessBuildDestroyMemoryPathsImpl: Don't overwrite error

The qemuSecurityDomainSetPathLabel() function reports perfect
error itself. Do not overwrite it to something less meaningful.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Fix check for chardev source path
Andrea Bolognani [Thu, 6 Sep 2018 15:51:10 +0000 (17:51 +0200)]
conf: Fix check for chardev source path

Attempting to use a chardev definition like

  <serial type='unix'>
    <target type='isa-serial'/>
  </serial>

correctly results in an error being reported, since the source
path - a required piece of information - is missing; however,
the very similar

  <serial type='unix'>
    <target type='pci-serial'/>
  </serial>

was happily accepted by libvirt, only to result in libvirtd
crashing as soon as the guest was started.

The issue was caused by checking the chardev's targetType
against whitelisted values from virDomainChrChannelTargetType
without first checking the chardev's deviceType to make sure
it is actually a channel, for which the check makes sense,
rather than a different type of chardev.

The only reason this wasn't spotted earlier is that the
whitelisted values just so happen to correspond to USB and
PCI serial devices and Xen and UML consoles respectively,
all of which are fairly uncommon.

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: fix args naming of virDomainChrSourceDefCopy
Ján Tomko [Thu, 6 Sep 2018 11:10:20 +0000 (13:10 +0200)]
conf: fix args naming of virDomainChrSourceDefCopy

Since its introduction in commit 2e37bf42 the naming of the arguments
between the prototype and the definition does not match.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Renamed 'controlBuf' to 'childrenBuf'
Wang Huaqiang [Mon, 27 Aug 2018 11:23:04 +0000 (19:23 +0800)]
conf: Renamed 'controlBuf' to 'childrenBuf'

To add CMT/MBM feature and let code be consistent in later patches,
renaming variable name from 'controlBuf' to 'childrenBuf', locates
in functions 'virCapabilitiesFormatCaches' and
'virCapabilitiesFormatMemoryBandwidth'.

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoutil: netlink: Replace virNetDevPutExtraHeader with nlmsg_append
Shi Lei [Fri, 7 Sep 2018 08:14:46 +0000 (16:14 +0800)]
util: netlink: Replace virNetDevPutExtraHeader with nlmsg_append

nlmsg_append from the libnl library provides exactly the same
functionality, so we should rely on that instead. This also allows us to
drop the aforementioned function completely.

Signed-off-by: Shi Lei <shi_lei@massclouds.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: netdevip: Fix a memleak in virNetDevIPRouteAdd
Shi Lei [Fri, 7 Sep 2018 08:27:39 +0000 (16:27 +0800)]
util: netdevip: Fix a memleak in virNetDevIPRouteAdd

@resp is allocated by virNetlinkCommand and the caller is responsible
for freeing the buffer. Since we already converted this module to use
VIR_AUTO{FREE,PTR} macros, let's resolve the problem by using them.

Signed-off-by: Shi Lei <shi_lei@massclouds.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agosecurity_dac: Fix const correctness
Michal Privoznik [Wed, 22 Aug 2018 13:57:08 +0000 (15:57 +0200)]
security_dac: Fix const correctness

These two functions (virSecurityDACSetOwnership and
virSecurityDACRestoreFileLabelInternal) do not really change
@src. Make it const.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agosecurity_dac: Pass virSecurityManagerPtr to virSecurityDACRestoreFileLabelInternal
Michal Privoznik [Wed, 22 Aug 2018 13:19:11 +0000 (15:19 +0200)]
security_dac: Pass virSecurityManagerPtr to virSecurityDACRestoreFileLabelInternal

This function is going call security manager APIs and therefore
it needs pointer to it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agosecurity_dac: Pass virSecurityManagerPtr to virSecurityDACSetOwnership
Michal Privoznik [Wed, 22 Aug 2018 13:09:16 +0000 (15:09 +0200)]
security_dac: Pass virSecurityManagerPtr to virSecurityDACSetOwnership

This function is going call security manager APIs and therefore
it needs pointer to it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemuDomainNamespaceTeardownHostdev: Drop useless check
Michal Privoznik [Thu, 6 Sep 2018 16:14:55 +0000 (18:14 +0200)]
qemuDomainNamespaceTeardownHostdev: Drop useless check

There is no need to check if @npaths is not zero. Let's
qemuDomainNamespaceUnlinkPaths() handle that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agonwfilter: Check for filter presence before open connect during teardown
John Ferlan [Mon, 27 Aug 2018 14:39:39 +0000 (10:39 -0400)]
nwfilter: Check for filter presence before open connect during teardown

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

Instantiation of an nwfilter binding is only allowed when
the net->filter is defined for the network; however, the
teardown of the binding does not make this check. This
leaves open the possibility that the teardown could be
called during guest shutdown/teardown in session mode
resulting in the following error being logged:

    error : nwfilterConnectOpen:383 : internal error: unexpected
    nwfilter URI path '/session', try nwfilter:///system

So before going through the teardown processing, let's
be sure the network had a filter and then attempt to
get a connection. For session mode it's not even possible
create an nwfilter binding.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agonwfilter: Disallow binding creation in session mode
John Ferlan [Mon, 27 Aug 2018 14:41:35 +0000 (10:41 -0400)]
nwfilter: Disallow binding creation in session mode

Similar to nwfilterDefineXML, let's be sure the a filter binding
creation is not attempted in session mode and generate the proper
error message.

Failure to open nwfilter in session mode (nwfilterConnectOpen)
fails already, but that doesn't stop the free thinker from using
a different connection in order to attempt to attempt to create
the binding. Although even doing that would result in a failure:

$ virsh nwfilter-binding-create QEMUGuest1-binding.xml
error: Failed to create network filter from QEMUGuest1-binding.xml
error: internal error: Could not get access to ACL tech driver 'ebiptables'

$

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoqemu: Unify generation of command line for virtio devices
Andrea Bolognani [Wed, 5 Sep 2018 16:24:55 +0000 (18:24 +0200)]
qemu: Unify generation of command line for virtio devices

A virtio device such as

  <controller type='scsi' model='virtio-scsi'/>

will be translated to one of four different QEMU devices
based on the address type. This behavior is the same for
all virtio devices, but unfortunately we have separate
ad-hoc code dealing with each and every one of them: not
only this is pointless duplication, but it turns out
that most of that code is not robust against new address
types being introduced and some of it is outright buggy.

Introduce a new function, qemuBuildVirtioDevStr(), which
deals with the issue in a generic fashion, and rewrite
all existing code to use it.

This fixes a bunch of issues such as virtio-serial-pci
being used with virtio-mmio addresses and virtio-gpu
not being usable at all with virtio-mmio addresses.

It also introduces a couple of minor regressions,
namely no longer erroring out when attempting to
use virtio-balloon and virtio-input devices with
virtio-s390 addresses; that said, virtio-s390 has
been superseded by virtio-ccw such a long time ago
that recent QEMU releases have dropped support for
the former entirely, so re-implementing such
device-specific validation is not worth it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: Check for virtio-input capabilities at validate time
Andrea Bolognani [Wed, 5 Sep 2018 15:52:38 +0000 (17:52 +0200)]
qemu: Check for virtio-input capabilities at validate time

The appropriate time to ensure the required capabilities are
present is validate rather than command line generation: add
a new qemuDomainDeviceDefValidateInput() function and move
all existing checks there.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: Always format iothread for virtio-blk
Andrea Bolognani [Wed, 5 Sep 2018 15:24:19 +0000 (17:24 +0200)]
qemu: Always format iothread for virtio-blk

So far we've only formatted it for virtio-blk-pci and
virtio-blk-ccw, but other virtio-blk devices also support
the corresponding option; moreover, we've always formatted
it for all virtio-scsi devices.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: Remove duplicated option formatting for virtio devices
Andrea Bolognani [Wed, 5 Sep 2018 15:32:10 +0000 (17:32 +0200)]
qemu: Remove duplicated option formatting for virtio devices

There are several functions where we pointlessly duplicate
parts of the format string and pass the same arguments:
refactor them so that the common parts are formatted separately
from the variable parts.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: Check type range for virtio-input devices
Andrea Bolognani [Wed, 5 Sep 2018 15:26:52 +0000 (17:26 +0200)]
qemu: Check type range for virtio-input devices

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: Add missing virtio-input capabilities
Andrea Bolognani [Wed, 5 Sep 2018 15:51:24 +0000 (17:51 +0200)]
tests: Add missing virtio-input capabilities

A few qemuxml2xml tests for virtio-input devices are
missing the capabilities used for the corresponding
qemuxml2argv tests: this wasn't a problem until now
because capabilities were only checked at command line
generation time, but we're going to change that later.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemuBuildMemPathStr: Produce -mem-path more frequently
Michal Privoznik [Thu, 30 Aug 2018 11:43:33 +0000 (13:43 +0200)]
qemuBuildMemPathStr: Produce -mem-path more frequently

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

If a domain is configured to use <source type='file'/> under
<memoryBacking/> we have to honour that setting and produce
-mem-path on the command line. We are not doing so if domain has
no guest NUMA nodes nor hugepages.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agodocs: Typo fix in virDomainGetJobStats
Eric Blake [Wed, 5 Sep 2018 19:26:06 +0000 (14:26 -0500)]
docs: Typo fix in virDomainGetJobStats

Signed-off-by: Eric Blake <eblake@redhat.com>
6 years agoqemu: unlink the error report from VIR_STRDUP.
Julio Faracco [Wed, 5 Sep 2018 04:20:56 +0000 (01:20 -0300)]
qemu: unlink the error report from VIR_STRDUP.

The function to retrieve the file system info using QEMU-GA is using
some conditionals to retrieve the info. This is wrong because the error
of some conditionals will be raised if VIR_STRDUP return errors and not
if some problem occurred with JSON.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agodocs: Add QEMU-GA get hostname feature into news.xml
Julio Faracco [Wed, 5 Sep 2018 04:20:55 +0000 (01:20 -0300)]
docs: Add QEMU-GA get hostname feature into news.xml

QEMU-GA supports get geust hostname command. This commit includes a
specific entry to inform this new feature for QEMU driver to 4.8.0
release.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: adding domainGetHostname support for QEMU
Julio Faracco [Wed, 5 Sep 2018 04:20:54 +0000 (01:20 -0300)]
qemu: adding domainGetHostname support for QEMU

This commit adds support to use the function qemuAgentGetHostname()
to obtain the domain hostname using QEMU-GA command.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: implementing qemuAgentGetHostname() function.
Julio Faracco [Wed, 5 Sep 2018 04:20:53 +0000 (01:20 -0300)]
qemu: implementing qemuAgentGetHostname() function.

This commit implements the function qemuAgentGetHostname() that uses
the QEMU guest agent command 'guest-get-host-name' to retrieve the
guest hostname of virtual machine running the QEMU-GA.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agotests: Add simple headless guests using latest caps
Andrea Bolognani [Wed, 5 Sep 2018 11:38:34 +0000 (13:38 +0200)]
tests: Add simple headless guests using latest caps

The new tests use DO_TEST_CAPS_ARCH_LATEST() with an input
XML describing a very simple headless guest and cover most
architectures and machine types we care about.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: Prepare to use DO_TEST_CAPS_ARCH_LATEST() more
Andrea Bolognani [Wed, 5 Sep 2018 11:04:08 +0000 (13:04 +0200)]
tests: Prepare to use DO_TEST_CAPS_ARCH_LATEST() more

We can add aarch64, ppc64 and riscv64 to the list of
supported architectures for the macro, since we have
capabilities data for all of them.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: Fix use of virtio-serial for aarch64/virt
Andrea Bolognani [Thu, 30 Aug 2018 16:03:58 +0000 (18:03 +0200)]
tests: Fix use of virtio-serial for aarch64/virt

virtio-serial is an alias for virtio-serial-pci, which
should not have been used for a PCIe-less aarch64/virt
guest but it ended up being used anyway because the
virtio-mmio capability was missing and the algorithm
is buggy.

Fix the test case so that we can fix the algorithm next.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: Drop virPCIGetAddrString()
Andrea Bolognani [Tue, 4 Sep 2018 17:05:46 +0000 (19:05 +0200)]
util: Drop virPCIGetAddrString()

There's a single user for it which takes an existing
virPCIDeviceAddress, passes its various bits to the
function which in turn constructs a virPCIDevice and
then copies the string representation for the caller
to use: we can use virPCIDeviceAddressAsString()
instead and avoid creating the virPCIDevice in the
first place. Since the function ends up having no
users after the change, we can just drop it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
6 years agoconf: Rename virDomainPCIAddressAsString()
Andrea Bolognani [Tue, 4 Sep 2018 16:50:32 +0000 (18:50 +0200)]
conf: Rename virDomainPCIAddressAsString()

The struct is called virPCIDeviceAddress and the
functions operating on it should be named accordingly.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
6 years agoconf: Move virDomainPCIAddressAsString() to util/virpci
Andrea Bolognani [Tue, 4 Sep 2018 16:32:38 +0000 (18:32 +0200)]
conf: Move virDomainPCIAddressAsString() to util/virpci

It's a better fit than conf/domain_conf.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
6 years agovirLockManagerLockDaemonAddResource: Switch to cleanup label rather than error
Michal Privoznik [Wed, 22 Aug 2018 07:56:07 +0000 (09:56 +0200)]
virLockManagerLockDaemonAddResource: Switch to cleanup label rather than error

This will help in future expansions of the code when it is be
harder to track if @newName and/or @newLockspace were already
allocated or not and thus whether it is safe to 'return' or we
need to 'goto error'. By using the 'cleanup' label those two
cases merge into a single one.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agolocking: Don't leak private data in virLockManagerLockDaemonNew
Michal Privoznik [Wed, 22 Aug 2018 06:58:32 +0000 (08:58 +0200)]
locking: Don't leak private data in virLockManagerLockDaemonNew

If drvNew callback fails, nobody calls drvFree and thus private
data of the driver might leak.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovirLockManagerSanlockAddResource: Do not ignore unknown resource types
Michal Privoznik [Wed, 22 Aug 2018 09:59:45 +0000 (11:59 +0200)]
virLockManagerSanlockAddResource: Do not ignore unknown resource types

Currently, there are only two types of resource. So effectively
this is a dead code. However, that assumption can change and we
shouldn't just silently ignore the error.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovirLockManagerLockDaemonAcquire: Drop useless check
Michal Privoznik [Wed, 22 Aug 2018 07:51:30 +0000 (09:51 +0200)]
virLockManagerLockDaemonAcquire: Drop useless check

The if() is completely useless since args.path is set to NULL in
the line just above.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agolock_driver_lockd: Don't leak lockspace dirs
Michal Privoznik [Tue, 21 Aug 2018 12:06:44 +0000 (14:06 +0200)]
lock_driver_lockd: Don't leak lockspace dirs

On daemon deinit only fileLockSpaceDir is freed. The other two
(scsiLockSpaceDir and lvmLockSpaceDir) are missing even though
they are allocated in virLockManagerLockDaemonLoadConfig().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agolock_daemon: Fix some memleaks
Michal Privoznik [Sun, 26 Aug 2018 06:48:47 +0000 (08:48 +0200)]
lock_daemon: Fix some memleaks

28 bytes in 1 blocks are definitely lost in loss record 26 of 66
   at 0x4C2CF0F: malloc (vg_replace_malloc.c:299)
   by 0x7A02719: strdup (strdup.c:42)
   by 0x197DC1: virStrdup (virstring.c:961)
   by 0x12B478: virLockDaemonConfigFilePath (lock_daemon_config.c:44)
   by 0x12A759: main (lock_daemon.c:1270)

62 (32 direct, 30 indirect) bytes in 1 blocks are definitely lost in loss record 41 of 66
   at 0x4C2EF26: calloc (vg_replace_malloc.c:711)
   by 0x151B61: virAlloc (viralloc.c:144)
   by 0x12B56C: virLockDaemonConfigNew (lock_daemon_config.c:71)
   by 0x12A491: main (lock_daemon.c:1262)

13 bytes in 1 blocks are definitely lost in loss record 21 of 70
   at 0x4C2CF0F: malloc (vg_replace_malloc.c:299)
   by 0x7A02719: strdup (strdup.c:42)
   by 0x197E3F: virStrdup (virstring.c:961)
   by 0x12C86B: virLockSpaceProtocolDispatchRegister (lock_daemon_dispatch.c:291)
   by 0x12BB73: virLockSpaceProtocolDispatchRegisterHelper (lock_daemon_dispatch_stubs.h:152)
   by 0x1336AA: virNetServerProgramDispatchCall (virnetserverprogram.c:437)
   by 0x13320D: virNetServerProgramDispatch (virnetserverprogram.c:304)
   by 0x139E3E: virNetServerProcessMsg (virnetserver.c:144)
   by 0x13A1A2: virNetServerDispatchNewMessage (virnetserver.c:230)
   by 0x1350F5: virNetServerClientDispatchMessage (virnetserverclient.c:343)
   by 0x137680: virNetServerClientDispatchEvent (virnetserverclient.c:1498)
   by 0x147704: virNetSocketEventHandle (virnetsocket.c:2140)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovirSecurityManagerNewStack: Don't ignore virSecurityStackAddNested retval
Michal Privoznik [Tue, 21 Aug 2018 12:54:52 +0000 (14:54 +0200)]
virSecurityManagerNewStack: Don't ignore virSecurityStackAddNested retval

The virSecurityStackAddNested() can fail in which case
virSecurityManagerNewStack() should fail too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovirSecurityManagerNewDriver: Fix code pattern
Michal Privoznik [Tue, 21 Aug 2018 11:46:18 +0000 (13:46 +0200)]
virSecurityManagerNewDriver: Fix code pattern

Use 'error' label to free allocated memory.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agotests: rewrite socket to do something sensible and reliable
Daniel P. Berrangé [Tue, 1 May 2018 10:55:02 +0000 (11:55 +0100)]
tests: rewrite socket to do something sensible and reliable

The current socket test is rather crazy in that it sets up a server
listening for sockets and then runs a client connect call, relying on
the fact that the kernel will accept this despite the application
not having called accept() yet. It then closes the client socket and
calls accept() on the server. On Linux accept() will always see that
the client has gone and so skip the rest of the code. On FreeBSD,
however, the accept sometimes succeeds, causing us to then go into
code that attempts to read and write to the client which will fail
aborting the test. The accept() never succeeds on FreeBSD guests
with a single CPU, but as you add more CPUs, accept() becomes more and
more likely to succeed, giving a 100% failure rate for the test when
using 8 CPUs.

This completely rewrites the test so that it is avoids this designed in
race condition. We simply spawn a background thread to act as the
client, which will read a byte from the server and write it back again.
The main thread can now properly listen and accept the client in a
synchronous manner avoiding any races.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agotests: merge code for UNIX and TCP socket testing
Daniel P. Berrangé [Tue, 1 May 2018 10:34:51 +0000 (11:34 +0100)]
tests: merge code for UNIX and TCP socket testing

The test code for UNIX and TCP sockets will need to be rewritten and
extended later, and will benefit from code sharing.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agotests: skip qemublocktest if building without YAJL
Daniel P. Berrangé [Tue, 4 Sep 2018 11:00:14 +0000 (12:00 +0100)]
tests: skip qemublocktest if building without YAJL

If no JSON parser is available qemublocktest fails, so skip its execution.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agotests: skip some unicode tests if expected output won't match
Daniel P. Berrangé [Tue, 4 Sep 2018 10:26:03 +0000 (11:26 +0100)]
tests: skip some unicode tests if expected output won't match

The expected output strings from the vshtabletest.c are created on a
modern Linux host where unicode printing support is very good. On older
Linux platforms, or non-Linux platforms, some unicode characters will
not be considered printable. While the vsh table alignment code will
stil do the right thing with escaping & aligning in this case, the
result will not match the test's expected output.

Since we know the code is working correctly, do a check with iswprint()
to validate the platform's quality and skip the test if it fails. This
fixes the test on FreeBSD platforms.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoconf: Move *AddressParseXML() to device_conf
Andrea Bolognani [Wed, 29 Aug 2018 17:14:24 +0000 (19:14 +0200)]
conf: Move *AddressParseXML() to device_conf

The corresponding structs are declared there.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Change return type of *AddressIsValid() to bool
Andrea Bolognani [Wed, 29 Aug 2018 16:29:41 +0000 (18:29 +0200)]
conf: Change return type of *AddressIsValid() to bool

These are simple predicates, which makes bool a more
appropriate return type than int.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Move virDomainDeviceAddressIsValid() to device_conf
Andrea Bolognani [Wed, 29 Aug 2018 16:19:15 +0000 (18:19 +0200)]
conf: Move virDomainDeviceAddressIsValid() to device_conf

The function is called on a virDomainDeviceInfo, so it
should be declared along with it.

Moving this function requires moving and making public
virDomainDeviceCCWAddressIsValid() as well, but that's
perfectly fine since the same reasoning above also
applies to it, due to virDomainDeviceCCWAddress being
(correctly) declared in device_conf.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Move virDomainDeviceAddressType to device_conf
Andrea Bolognani [Wed, 29 Aug 2018 15:59:20 +0000 (17:59 +0200)]
conf: Move virDomainDeviceAddressType to device_conf

It's used in virDomainDeviceInfo, which makes
domain_conf the wrong place to declare it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: Properly reset mocked CPU model
Jiri Denemark [Tue, 28 Aug 2018 14:04:13 +0000 (16:04 +0200)]
tests: Properly reset mocked CPU model

When switching the host architecture to something for which we do not
have any host CPU model defined, the mocked
virQEMUCapsProbeHostCPUForEmulator would just return the previous CPU
model resulting in strange combinations, such as "core2duo" host CPU
model in QEMU capabilities for "AArch64" architecture. It currently
doesn't break any test case, but we should fix it anyway to avoid future
surprises which would be quite hard to debug.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agovirDomainDetachDeviceFlags: Clarify update semantics
Michal Privoznik [Mon, 27 Aug 2018 13:40:33 +0000 (15:40 +0200)]
virDomainDetachDeviceFlags: Clarify update semantics

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

When users want to update a path to a CDROM they tend to
construct a very minimal XML and feed the API with it. This is
not a good practice as it breaks the assumptions the API is built
on. Most notably, leaving an element out should be treated as a
request for removal of the corresponding setting. Just like
leaving out <bandwidth/> clears out any QoS previously set.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agotests: pass ULLONG_MAX to qemuMonitorJSONGetBalloonInfo
Ján Tomko [Fri, 24 Aug 2018 11:30:17 +0000 (13:30 +0200)]
tests: pass ULLONG_MAX to qemuMonitorJSONGetBalloonInfo

Test that we correctly accept 64-bit unsigned numbers for QEMU.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoTest parsing of large numbers in JSON
Ján Tomko [Wed, 22 Aug 2018 13:12:47 +0000 (15:12 +0200)]
Test parsing of large numbers in JSON

We expect to get numbers as big as ULLONG_MAX from QEMU,
add a test for them.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agovirjsontest: use the test name in AddRemove test
Ján Tomko [Fri, 1 Jun 2018 07:09:46 +0000 (09:09 +0200)]
virjsontest: use the test name in AddRemove test

Instead of printing the whole JSON in error messages,
print just the test name.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agovirjsontest: use name instead of doc for deflatten test
Ján Tomko [Fri, 1 Jun 2018 11:00:12 +0000 (13:00 +0200)]
virjsontest: use name instead of doc for deflatten test

This test gets its JSON docs from files.

Now that we have a 'name' field in testInfo, use it instead
of abusing the 'doc' field.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agovirjsontest: store name in testInfo
Ján Tomko [Thu, 31 May 2018 17:20:13 +0000 (19:20 +0200)]
virjsontest: store name in testInfo

Give the testing function access to the test name instead of only
passing it to virTestRun.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoqemuDomainAttachNetDevice: use only one virErrorPtr variable
Ján Tomko [Tue, 21 Aug 2018 13:28:18 +0000 (15:28 +0200)]
qemuDomainAttachNetDevice: use only one virErrorPtr variable

Commit f7b5566 added 'save_error' even though the function
already has 'originalError' used in the 'try_remove' section.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agostorage_driver: Release pool object lock for some long running jobs
Michal Privoznik [Sun, 19 Aug 2018 06:26:04 +0000 (08:26 +0200)]
storage_driver: Release pool object lock for some long running jobs

As advertised in previous commit, there are three APIs that might
run for quite some time (because they read/write data from/to a
volume) and these three are: downloadVol, uploadVol, wipeVol.
Release pool object lock and reacquire it later to allow more
concurrency.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agostorage_driver: Mark volume as 'in use' for some operations
Michal Privoznik [Sat, 18 Aug 2018 16:42:07 +0000 (18:42 +0200)]
storage_driver: Mark volume as 'in use' for some operations

There are few operations in the storage driver that read/write
data onto volumes. Such operations can take very long time to
finish. During that time the storage pool object is locked which
has bad performance impacts (other threads can't fetch its XML
for instance). This commit prepares the storage driver for
releasing the lock during those operations (downloadVol,
uploadVol, wipeVol).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovirstorageobj: Check for source duplicates from virStoragePoolObjAssignDef
Michal Privoznik [Fri, 17 Aug 2018 13:07:01 +0000 (15:07 +0200)]
virstorageobj: Check for source duplicates from virStoragePoolObjAssignDef

Just like a few commits earlier, checking for pool source
duplicates and unlocking pools list afterwards is a buggy
pattern. The check must go into virStoragePoolObjAssignDef.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovirStoragePoolObjSourceFindDuplicate: Drop @conn argument
Michal Privoznik [Fri, 17 Aug 2018 13:14:31 +0000 (15:14 +0200)]
virStoragePoolObjSourceFindDuplicate: Drop @conn argument

The @conn argument is needed only to do some source matching in
case of iSCSI source. Anyway, it's used just for node device
driver and as such can be replaced with virGetConnectNodeDev().

At the same time, the @conn struct member is dropped from
_virStoragePoolObjFindDuplicateData.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovirstorageobj: Move virStoragePoolObjSourceFindDuplicate and friends up
Michal Privoznik [Fri, 17 Aug 2018 12:50:59 +0000 (14:50 +0200)]
virstorageobj: Move virStoragePoolObjSourceFindDuplicate and friends up

This function is going to be made static in used in
virStoragePoolObjAssignDef(). Therefore move it and all the
static functions it calls a few lines up.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovirstorageobj: Check for duplicates from virStoragePoolObjAssignDef
Michal Privoznik [Fri, 17 Aug 2018 10:30:08 +0000 (12:30 +0200)]
virstorageobj: Check for duplicates from virStoragePoolObjAssignDef

Even though we do some checking it is not as thorough as it
should be. We already have virStoragePoolObjIsDuplicate but the
way we use it is a typical TOCTOU. Imagine two threads trying to
define two pools with the same name but different UUIDs. With the
current code neither of them finds a duplicate and thus proceed
to virStoragePoolObjAssignDef where only names are compared.
Therefore both threads succeed which is obviously wrong.

We should check for duplicates where we care for them.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovirstorageobj: Move virStoragePoolObjIsDuplicate up
Michal Privoznik [Fri, 17 Aug 2018 10:14:41 +0000 (12:14 +0200)]
virstorageobj: Move virStoragePoolObjIsDuplicate up

This function is going to be made static in used in
virStoragePoolObjAssignDef(). Therefore move it a few lines up.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agostorage_backend_rbd: Drop ATTRIBUTE_UNUSED for arguments that are used
Michal Privoznik [Sat, 18 Aug 2018 16:53:13 +0000 (18:53 +0200)]
storage_backend_rbd: Drop ATTRIBUTE_UNUSED for arguments that are used

In two places the passed pool object argument is marked as
ATTRIBUTE_UNUSED even though it's used right away.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovirDomainNetDefCheckABIStability: Check for MTU change too
Michal Privoznik [Thu, 30 Aug 2018 12:11:36 +0000 (14:11 +0200)]
virDomainNetDefCheckABIStability: Check for MTU change too

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

Changing MTU on a running guest is not possible and trying to do
so made us face many problems. That's why we forbid it in
5f44d7e357f61f7. However, there is still one possible path where
users can sneak in change: migration XML.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agovirDomainDefCompatibleDevice: Relax alias change check
Michal Privoznik [Wed, 29 Aug 2018 12:08:59 +0000 (14:08 +0200)]
virDomainDefCompatibleDevice: Relax alias change check

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

When introducing this check back in 4ad54a417a1 my mindset was
that if an element is missing in update XML then user is
requesting for removal of the corresponding setting. For
instance, if <bandwidth/> is not present in update XML any QoS
previously set on <interface/> is cleared out. Well this
assumption is correct but only to some extent.

Turns out, we have some users who when updating path to ISO
image construct very minimalistic disk XML and pass it to device
update API. Such XML is lacking a lot of information, and alias
is one of them. This triggers error in
virDomainDefCompatibleDevice() because we think that user is
requesting to remove the alias. Well, they are not.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: Don't overwrite stats in qemuDomainBlocksStatsGather
Peter Krempa [Thu, 30 Aug 2018 08:30:09 +0000 (10:30 +0200)]
qemu: Don't overwrite stats in qemuDomainBlocksStatsGather

The size/capacity stats gathered in qemuDomainBlocksStatsGather when
using -blockdev would be overwritten by assigning/copying the transfered
data statistics at the end. Fix it by moving the assignment prior to
fetching the capacity data.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoPost-release version bump to 4.8.0
Peter Krempa [Tue, 4 Sep 2018 06:07:17 +0000 (08:07 +0200)]
Post-release version bump to 4.8.0

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
6 years agoRelease of libvirt-4.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
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>