]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
6 years agoremote: check & report OOM in make_nonnull_XXX methods
Daniel P. Berrangé [Mon, 10 Dec 2018 18:48:47 +0000 (18:48 +0000)]
remote: check & report OOM in make_nonnull_XXX methods

The make_nonnull_XXX methods can all fail due to OOM but this was being
silently ignored and thus also not checked by callers. Make the methods
propagate errors and use ATTRIBUTE_RETURN_CHECK to force callers to deal
with it.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoRemove all Author(s): lines from source file headers
Daniel P. Berrangé [Thu, 13 Dec 2018 11:23:42 +0000 (11:23 +0000)]
Remove all Author(s): lines from source file headers

In many files there are header comments that contain an Author:
statement, supposedly reflecting who originally wrote the code.
In a large collaborative project like libvirt, any non-trivial
file will have been modified by a large number of different
contributors. IOW, the Author: comments are quickly out of date,
omitting people who have made significant contribitions.

In some places Author: lines have been added despite the person
merely being responsible for creating the file by moving existing
code out of another file. IOW, the Author: lines give an incorrect
record of authorship.

With this all in mind, the comments are useless as a means to identify
who to talk to about code in a particular file. Contributors will always
be better off using 'git log' and 'git blame' if they need to  find the
author of a particular bit of code.

This commit thus deletes all Author: comments from the source and adds
a rule to prevent them reappearing.

The Copyright headers are similarly misleading and inaccurate, however,
we cannot delete these as they have legal meaning, despite being largely
inaccurate. In addition only the copyright holder is permitted to change
their respective copyright statement.

Reviewed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoqemu: Add check for whether KVM nesting is enabled
John Ferlan [Mon, 12 Nov 2018 19:58:09 +0000 (14:58 -0500)]
qemu: Add check for whether KVM nesting is enabled

Support for nested KVM is handled via a kernel module configuration
parameters values for kvm_intel, kvm_amd, kvm_hv (PPC), or kvm (s390).
While it's possible to fetch the kmod config values via virKModConfig,
unfortunately that is the static value and we need to get the
current/dynamic value from the kernel file system.

So this patch adds a new API virHostKVMSupportsNesting that will
search the 3 kernel modules to get the nesting value and check if
it is 'Y' (or 'y' just in case) to return a true/false whether
the KVM kernel supports nesting.

We need to do this in order to handle cases where adjustments to
the value are made after libvirtd is started to force a refetch of
the latest QEMU capabilities since the correct CPU settings need
to be made for a guest to add the "vmx=on" to/for the guest config.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agosecret: Add check/validation for correct usage when LookupByUUID
John Ferlan [Tue, 4 Dec 2018 20:15:22 +0000 (15:15 -0500)]
secret: Add check/validation for correct usage when LookupByUUID

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

If virSecretGetSecretString is using by secretLookupByUUID,
then it's possible the found sec->usageType doesn't match the
desired @secretUsageType. If this occurs for the encrypted
volume creation processing and a subsequent pool refresh is
executed, then the secret used to create the volume will not
be found by the storageBackendLoadDefaultSecrets which expects
to find secrets by VIR_SECRET_USAGE_TYPE_VOLUME.

Add a check to virSecretGetSecretString to avoid the possibility
along with an error indicating the incorrect matched types.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agorng: Only one secret is in vol instead of zero or more
Han Han [Wed, 12 Dec 2018 02:54:27 +0000 (10:54 +0800)]
rng: Only one secret is in vol instead of zero or more

Referring to commit fab2e49d, it should be one and only secret for encryption.

Signed-off-by: Han Han <hhan@redhat.com>
6 years agostorage: Add tests for logical backend startup
John Ferlan [Tue, 4 Dec 2018 16:12:37 +0000 (11:12 -0500)]
storage: Add tests for logical backend startup

Add the logical storage pool startup validation (xml2argv) tests.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agological: Fix @on argument type
John Ferlan [Tue, 4 Dec 2018 16:03:28 +0000 (11:03 -0500)]
logical: Fix @on argument type

It's only pass as 0 or 1 and used as a bool, let's just use a bool

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agostorage: Rework virStorageBackendFileSystemMountCmd
John Ferlan [Mon, 3 Dec 2018 20:43:00 +0000 (15:43 -0500)]
storage: Rework virStorageBackendFileSystemMountCmd

Let's create helpers for each style of command line created. This
primarily is easier on the eyes rather than the large multi line
if-then-else-else clause used, but may also be useful if in the
future any particular pool needs to add to the command line based
on pool xml format.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agotests: Add storagepool xml test for netfs-auto
John Ferlan [Tue, 4 Dec 2018 15:20:59 +0000 (10:20 -0500)]
tests: Add storagepool xml test for netfs-auto

Cover the case where @netauto would be used to create the command
line in virStorageBackendFileSystemMountCmd. Essentially when the
pool type is "netfs", but the "source.format" is empty, create the
command line properly.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agotests: Introduce tests for storage pool xml to argv checks
John Ferlan [Tue, 4 Dec 2018 11:16:23 +0000 (06:16 -0500)]
tests: Introduce tests for storage pool xml to argv checks

Similar to qemuxml2argv and storagevolxml2argv, let's create some
tests to ensure that the XML generates a consistent command line.

Using the same list of pools as storagepoolxml2xmltest, start with
the file system tests (fs, netfs, netfs-cifs, netfs-gluster).

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agostorage: Move virStorageBackendFileSystemGetPoolSource
John Ferlan [Tue, 4 Dec 2018 11:50:06 +0000 (06:50 -0500)]
storage: Move virStorageBackendFileSystemGetPoolSource

Move into storage_util for reuse by test harness

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agostorage: Move FS backend mount creation command helper
John Ferlan [Tue, 4 Dec 2018 11:34:58 +0000 (06:34 -0500)]
storage: Move FS backend mount creation command helper

Move virStorageBackendFileSystemMountCmd to storage_util so that
it can be used by the test harness.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agostorage: Extract out mount command creation for FS Backend
John Ferlan [Tue, 4 Dec 2018 11:28:34 +0000 (06:28 -0500)]
storage: Extract out mount command creation for FS Backend

Extract out the code that is used to create the MOUNT command
for starting the pool. We can use this for Storage Pool XML
to Argv testing to ensure code changes don't alter how a
storage pool is started.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoqemu: Don't use -mem-prealloc among with .prealloc=yes
Michal Privoznik [Mon, 5 Nov 2018 10:48:16 +0000 (11:48 +0100)]
qemu: Don't use -mem-prealloc among with .prealloc=yes

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

There are two ways to request memory preallocation on cmd line:
-mem-prealloc and .prealloc attribute for a memory-backend-file.
However, as it turns out it's not safe to use both at the same
time. If -mem-prealloc is used then qemu will fully allocate the
memory (this is done by actually touching every page that has
been allocated). Then, if .prealloc=yes is specified,
mbind(flags = MPOL_MF_STRICT | MPOL_MF_MOVE) is called which:

a) has to (possibly) move the memory to a different NUMA node,
b) can have no effect when hugepages are in play (thus ignoring user
request to place memory on desired NUMA nodes).

Prefer -mem-prealloc as it is more backward compatible
compared to switching to "-numa node,memdev=  + -object
memory-backend-file".

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemuBuildMemoryBackendProps: Pass @priv instead of its individual members
Michal Privoznik [Wed, 7 Nov 2018 10:14:14 +0000 (11:14 +0100)]
qemuBuildMemoryBackendProps: Pass @priv instead of its individual members

So far we have two arguments that we are passing to
qemuBuildMemoryBackendProps() and that are taken from domain
private data: @qemuCaps and @autoNodeset. In the next commit I
will use one more item from there. Therefore, instead of having
it as yet another argument to the function, pass pointer to the
private data object.

There is one change in qemuDomainAttachMemory() where previously
@autoNodeset was NULL but now is priv->autoNodeset (which may be
set). This is safe to do as @autoNodeset is advisory only.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoconf: Add check/error for domain supports cold/hotplug
John Ferlan [Fri, 7 Dec 2018 14:46:48 +0000 (09:46 -0500)]
conf: Add check/error for domain supports cold/hotplug

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

Add a check during virDomainDefCompatibleDevice whether the
domain supports cold/hotplug of a memory module even though
this duplicates the qemuDomainDefValidateMemoryHotplug check.

Without this check, the cold/hot plug would fail on the
subsequent mem_memory check (since it's 0). Adding a check
for max_memory > 0 would allow the subsequent hotplug check
to fail, but would cause coldplug to fail with the somewhat
opaque message "no free memory device slot available".

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoconf: Add the size of failed max_memory in error
John Ferlan [Fri, 7 Dec 2018 16:07:32 +0000 (11:07 -0500)]
conf: Add the size of failed max_memory in error

If virDomainDefCompatibleDevice fails because there is insufficient
domain def->mem.max_memory, then let's also print out that value in
the error message.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoconf: domain: gfx: Iterate over graphics devices when doing validation
Erik Skultety [Fri, 7 Dec 2018 13:53:46 +0000 (14:53 +0100)]
conf: domain: gfx: Iterate over graphics devices when doing validation

The QEMU validation code for graphics has been in place for a while, but
because it is only executed from virDomainDeviceInfoIterateInternal, it
was never run, since the iterator expects the device to have boot info
which graphics don't have. The unfortunate side effect of this whole mess
was that a few capabilities were missing from the test suite (as commit
d8266ebe1 demonstrated with graphics-spice-invalid-egl-headless test),
which in turn meant that a few graphics tests which expected a failure
happily accepted any failure the test runtime returned which made them
succeed. The impact of this was that we then allowed to start a domain
with multiple OpenGL-enabled graphics devices.

This patch enables iteration over graphics devices. Unsurprisingly,
a few tests started to fail as a result, so fix those too.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agotests: Introduce negative versions of DO_TEST_CAPS_LATEST
Erik Skultety [Fri, 7 Dec 2018 12:13:58 +0000 (13:13 +0100)]
tests: Introduce negative versions of DO_TEST_CAPS_LATEST

It's fairly easy to forget to add a capability to the list of
capabilities for a negative test case which might yield (for us) very
unfortunate results. Therefore, introduce negative versions of
DO_TEST_CAPS_LATEST macros, so that real QEMU caps can be used with
tests that expect a failure too.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoconf: domain: Introduce virDomainDeviceIterateFlags
Erik Skultety [Fri, 7 Dec 2018 12:13:03 +0000 (13:13 +0100)]
conf: domain: Introduce virDomainDeviceIterateFlags

Validation of domain devices is accomplished via a generic device
iterator which takes a callback, iterates over all kinds of supported
device types and invokes the callback on every single device. However,
there might be cases when we need to alter the behaviour of the
iteration (most notably skip or include a group of devices). Therefore,
this patch introduces iterator flags.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: domain: gfx: Fix shadowing of a function argument in validation
Erik Skultety [Fri, 7 Dec 2018 14:07:37 +0000 (15:07 +0100)]
qemu: domain: gfx: Fix shadowing of a function argument in validation

Since the code was never run, it would have been very hard to spot this
mistake, especially since the compiler can't really warn about it.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agotests: Adding test case to include multiple network definitions.
Julio Faracco [Fri, 30 Nov 2018 12:43:37 +0000 (20:43 +0800)]
tests: Adding test case to include multiple network definitions.

This commit includes a test case for multiple network definitions. It is
useful right now, but it will be more useful when the index used by LXC
version 3.X is implemented to support this new settings. The version 3.X
is using indexes to specify each network settings.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agolxc: Initializing IPv6 and IPv4 gateway to overwrite old settings.
Julio Faracco [Fri, 30 Nov 2018 12:43:36 +0000 (20:43 +0800)]
lxc: Initializing IPv6 and IPv4 gateway to overwrite old settings.

This commit fixes a bug when you have multiple network settings defined.
Basically, if you set an IPv6 or IPv4 gateway, it carries on next
network settings. It is happening because the data is not being
initialized when a new network type is defined. So, the old data still
persists into the pointer. Another way to initialized the data was
introduced using memset() to avoid missing attributes from the struct.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agotools: rename S_ORG to C_ORG in virt-pki-validate
Daniel P. Berrangé [Tue, 11 Dec 2018 14:58:43 +0000 (14:58 +0000)]
tools: rename S_ORG to C_ORG in virt-pki-validate

Rename a variable to make it clear that it holds the client organization
rather than the server organization.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agotools: relax x509 Subject regexes to allow numbers and more
Daniel P. Berrangé [Mon, 10 Dec 2018 16:50:10 +0000 (16:50 +0000)]
tools: relax x509 Subject regexes to allow numbers and more

The virt-pki-validate tool is extracting components in the x509
certificate Subject field. Unfortunately the regex it is is using is far
too strict, and so truncating valid data. It needs to consider ',' as a
field separator, and if that's not there take all data until the EOL.

With the broken regex:

$ echo "  Subject: O=Test,CN=guestHyp1ver"  | sed 's+.*CN=\(.[a-zA-Z \._-]*\).*+\1+'
guestHyp

And with the fixed regex

$ echo "Subject: O=Test,CN=guestHyp1ver"  | sed 's+.*CN=\([^,]*\).*+\1+'
guestHyp1ver

Reported-by: Kashyap Chamarthy <kchamart@redhat.com>
Reviewed-by: Kashyap Chamarthy <kchamart@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agodomain: conf: graphics: Fix picking DRI renderer automatically for SPICE
Erik Skultety [Thu, 6 Dec 2018 15:12:14 +0000 (16:12 +0100)]
domain: conf: graphics: Fix picking DRI renderer automatically for SPICE

Commit 255e0732 introduced a few graphics-related helpers. The problem
is that virDomainGraphicsNeedsAutoRenderNode returns true if it gets
NULL as a response from virDomainGraphicsNeedsAutoRenderNode. That's
okay for egl-headless because that one always needs a DRM render node,
the same is not true for SPICE though, and unless the XML specifies
<gl enable='yes'> for SPICE, there's no need for any renderer.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: disable external snapshot of readonly disk
Nikolay Shirokovskiy [Fri, 9 Nov 2018 07:50:47 +0000 (10:50 +0300)]
qemu: disable external snapshot of readonly disk

Disable external snapshot of a readonly disk for domains as
this operation is not very useful. Such a snapshot is not
possible for active domains but the error message from QEMU
is more cryptic:

     error: internal error: unable to execute QEMU command 'transaction':
                         Could not create file: Permission denied

This error at least makes the error more understandable for
active domains and disallows for inactive domains as well.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agolibxl: handle external domain destroy
Marek Marczykowski-Górecki [Sat, 8 Dec 2018 02:46:00 +0000 (03:46 +0100)]
libxl: handle external domain destroy

If domain is killed with `xl destroy`, libvirt will not notice it and
still report the domain as running. Also trying to destroy the domain
through libvirt will fail. The only way to recover from such a situation
is to restart libvirt daemon. The problem is that even though libxl
report LIBXL_EVENT_TYPE_DOMAIN_DEATH, libvirt ignore it as all the
domain cleanup is done in a function actually destroying the domain. If
destroy is done outside of libvirt, there is no place where it would be
handled.

Fix this by doing domain cleanup in LIBXL_EVENT_TYPE_DOMAIN_DEATH too.
To avoid doing it twice, add a ignoreDeathEvent flag
libxlDomainObjPrivate, set when the domain death is triggered by libvirt
itself.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
6 years agolibxl: add missing cleanup on error path in libxlDomainPMWakeup
Marek Marczykowski-Górecki [Sat, 8 Dec 2018 02:45:59 +0000 (03:45 +0100)]
libxl: add missing cleanup on error path in libxlDomainPMWakeup

Since domain was suspended before and on failed wakeup is destroyed,
send an event.
Also, add missing libxlDomainCleanup.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
6 years agolxc: don't forbid <interface type='direct'>
Laine Stump [Thu, 6 Dec 2018 14:59:59 +0000 (09:59 -0500)]
lxc: don't forbid <interface type='direct'>

Commit 017dfa27d changed a few switch statements in the LXC code to
have all possible enum values, and in the process changed the switch
statement in virLXCControllerGetNICIndexes() to return an error status
for unsupported interface types, but it erroneously put type='direct'
on the list of unsupported types.

type='direct' (implemented with a macvlan interface) is supported on
LXC, but it's interface shouldn't be placed on the list of interfaces
given to CreateMachineWithNetwork() because the interface is put
inside the container, while CreateMachineWithNetwork() only wants to
know about the parent veths of veth pairs (the parent veth remains on
the host side, while the child veth is put into the container).

Resolves: https://bugzilla.redhat.com/1656463
Signed-off-by: Laine Stump <laine@laine.org>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agolxc: check actual type of interface not config type
Laine Stump [Wed, 5 Dec 2018 21:58:08 +0000 (16:58 -0500)]
lxc: check actual type of interface not config type

virLXCControllerGetNICIndexes() was deciding whether or not to add the
ifindex for an interface's ifname to the list of ifindexes sent to
CreateMachineWithNetwork based on the interface type stored in the
config. This would be incorrect in the case of <interface
type='network'> where the network was giving out macvlan interfaces
tied to a physical device (i.e. when the actual interface type was
"direct").

Instead of checking the setting of "net->type", we should be checking
the setting of virDomainNetGetActualType(net).

I don't think this caused any actual misbehavior, it was just
technically wrong.

Signed-off-by: Laine Stump <laine@laine.org>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: fix dry run handling in network firewall test
Daniel P. Berrangé [Thu, 1 Nov 2018 11:42:56 +0000 (11:42 +0000)]
tests: fix dry run handling in network firewall test

The networkxml2firewalltest sets virCommand to dry run mode but doesn't
provide a callback to fill in stdout/stderr. As a result when the
firewall code queries rules it gets a NULL output and so never triggers
the callback to process output.

This trivial change just returns an empty string for the command output
in order to ensure the callback gets triggered. It has no effect right
now, but in future patches this will trigger greater test coverage.

Reviewed-by: Laine Stump <laine@laine.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agotests: remove duplicated test case in networkxml2firewalltest
Daniel P. Berrangé [Thu, 1 Nov 2018 10:30:42 +0000 (10:30 +0000)]
tests: remove duplicated test case in networkxml2firewalltest

Reviewed-by: Laine Stump <laine@laine.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoutil: refactor iptables APIs to share more code
Daniel P. Berrangé [Wed, 31 Oct 2018 18:51:34 +0000 (18:51 +0000)]
util: refactor iptables APIs to share more code

Most of the iptables APIs share code for the add/delete paths, but a
couple were separated. Merge the remaining APIs to facilitate future
changes.

Reviewed-by: Laine Stump <laine@laine.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agonews: Mention Xen support for openvswitch
Jim Fehlig [Fri, 16 Nov 2018 22:20:04 +0000 (15:20 -0700)]
news: Mention Xen support for openvswitch

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoxenconfig: add support for openvswitch configuration
Jim Fehlig [Fri, 16 Nov 2018 20:08:23 +0000 (13:08 -0700)]
xenconfig: add support for openvswitch configuration

Add support for converting openvswitch interface configuration
to/from libvirt domXML and xl.cfg(5). The xl config syntax for
virtual interfaces is described in detail in the
xl-network-configuration(5) man page. The Xen Networking wiki
also contains information and examples for using openvswitch
in xl.cfg config format

https://wiki.xenproject.org/wiki/Xen_Networking#Open_vSwitch

Tests are added to check conversions of openvswitch tagged and
trunked VLAN configuration.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agolibxl: support openvswitch interfaces
Jim Fehlig [Tue, 28 Jun 2016 20:20:02 +0000 (14:20 -0600)]
libxl: support openvswitch interfaces

It is currently possible to use <interface>s of type openvswitch
with the libxl driver in a non-standard way, e.g.

  <interface type='bridge'>
    <source bridge='ovsbr0'/>
    <mac address='00:16:3e:7a:35:ce'/>
    <script path='vif-openvswitch'/>
  </interface>

This patch adds support for openvswitch <interface>s specified
in typical libvirt config

  <interface type='bridge'>
    <source bridge='ovsbr0'/>
    <mac address='00:16:3e:7a:35:ce'/>
    <virtualport type='openvswitch'/>
  </interface>

VLAN tags and trunking are also supported using the extended
syntax for specifying an openvswitch bridge in libxl

   BRIDGE_NAME[.VLAN][:TRUNK:TRUNK]

See Xen's networking wiki for more details on openvswitch support

https://wiki.xenproject.org/wiki/Xen_Networking#Open_vSwitch

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoqemu: Don't fail stats collection due to IOThread capability
John Ferlan [Tue, 27 Nov 2018 15:12:56 +0000 (10:12 -0500)]
qemu: Don't fail stats collection due to IOThread capability

Commit 212dc9286 made a generic qemuDomainGetIOThreadsMon which
would fail if the QEMU_CAPS_OBJECT_IOTHREAD didn't exist. Then
commit d1eac927 used that helper for the collection of all domain
stats. However, if the capability doesn't exist, then the entire
stats collection fails. Since the IOThread stats were meant to be
if available only, thus rather than failing if the capability
doesn't exist, let's just not collect the stats. Restore the caps
failure logic for qemuDomainGetIOThreadsLive.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: Save qemuDomainGetStats error
John Ferlan [Tue, 27 Nov 2018 15:08:53 +0000 (10:08 -0500)]
qemu: Save qemuDomainGetStats error

During qemuConnectGetAllDomainStats if qemuDomainGetStats causes
a failure, then when collecting more than one domain's worth of
statistics the loop in virDomainStatsRecordListFree would call
virDomainFree which would call virResetLastError effectively wiping
out the reason we failed leaving the caller with no idea why the
collection failed.

To fix this, let's Preserve the error and Restore it prior to return
so that a caller such as 'virsh domstats' doesn't get the generic
"error: An error occurred, but the cause is unknown".

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: qemuxml2argv: Remove disks from few tests which don't need them
Peter Krempa [Wed, 28 Nov 2018 12:52:40 +0000 (13:52 +0100)]
tests: qemuxml2argv: Remove disks from few tests which don't need them

Remove the disk from tests focusing on other aspects so that change to
-blockdev will touch less tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: snapshot: Remove file format check from parser
Peter Krempa [Tue, 4 Sep 2018 13:48:48 +0000 (15:48 +0200)]
conf: snapshot: Remove file format check from parser

We already have a way stricter check in the code which is doing the
snapshot so duplicating it in the parser does not make much sense. Also
gets rid of an ugly ternary operator.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: domain: Initialize proper element in qemuDomainPrepareStorageSourceBlockdev
Peter Krempa [Tue, 9 Oct 2018 08:55:00 +0000 (10:55 +0200)]
qemu: domain: Initialize proper element in qemuDomainPrepareStorageSourceBlockdev

We are preparing a certain disk source passed in as '@src' so the
individual functions should use that rather than disk->src which
corresponds to the top level element of the chain only.

Without this change TLS and persistent reservations would not work for
backing images of a chain when using -blockdev.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: xml: Always consume args of virXMLFormatElement
Peter Krempa [Fri, 30 Nov 2018 11:26:30 +0000 (12:26 +0100)]
util: xml: Always consume args of virXMLFormatElement

The function clears and frees the passed buffers on success, but not in
one case of failure. Modify the control flow that the args are always
consumed, record it in the docs and remove few pointless cleanup paths
in callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: qemuxml2xml: Add few debug statements for status XML testing
Peter Krempa [Mon, 3 Dec 2018 08:51:25 +0000 (09:51 +0100)]
tests: qemuxml2xml: Add few debug statements for status XML testing

Add markers for allowing test debugging if one of the steps fails
without setting a proper error.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemuDomainRemoveRNGDevice: Remove associated chardev too
Michal Privoznik [Tue, 4 Dec 2018 13:30:37 +0000 (14:30 +0100)]
qemuDomainRemoveRNGDevice: Remove associated chardev too

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

An RNG device can consists of more devices than RND device
itself. For instance, in case of EGD there is a chardev that
connects to EGD daemon and feeds the qemu with random data. When
doing RNG device removal we have to remove the associated chardev
as well.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoFix minor typos in messages and docs
Yuri Chornoivan [Tue, 4 Dec 2018 17:08:14 +0000 (19:08 +0200)]
Fix minor typos in messages and docs

Signed-off-by: Yuri Chornoivan <yurchor@ukr.net>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemuBuildRNGBackendChrdevStr: Fix formatting
Michal Privoznik [Tue, 4 Dec 2018 13:15:33 +0000 (14:15 +0100)]
qemuBuildRNGBackendChrdevStr: Fix formatting

The way that the code is currently written makes my eyes hurt.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: Fix the build on MinGW because of missing DT_CHR dirent type
Erik Skultety [Tue, 4 Dec 2018 08:58:10 +0000 (09:58 +0100)]
util: Fix the build on MinGW because of missing DT_CHR dirent type

Caused by commit 39480969

Signed-off-by: Erik Skultety <eskultet@redhat.com>
6 years agosyncNicRxFilterMultiMode: Fix indentation
Michal Privoznik [Tue, 4 Dec 2018 07:48:05 +0000 (08:48 +0100)]
syncNicRxFilterMultiMode: Fix indentation

The indentation of the code in this function is a bit off.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agosyncNicRxFilterMultiMode: Check for helper's retval properly
Michal Privoznik [Tue, 4 Dec 2018 07:45:15 +0000 (08:45 +0100)]
syncNicRxFilterMultiMode: Check for helper's retval properly

There are two functions called from syncNicRxFilterMultiMode:
virNetDevSetRcvAllMulti() and virNetDevSetRcvMulti(). Both of
them return 0 on success and -1 on error. However, currently
their return value is checked for != 0 which conflicts with our
assumptions on retvals: a positive value is still considered
success but with current check it would lead to failure.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agodocs: Provide news update for libvirt being able to pick a DRI device
Erik Skultety [Thu, 22 Nov 2018 16:36:10 +0000 (17:36 +0100)]
docs: Provide news update for libvirt being able to pick a DRI device

Signed-off-by: Erik Skultety <eskultet@redhat.com>
6 years agoqemu: command: gfx: egl-headless: Add 'rendernode' option to the cmdline
Erik Skultety [Thu, 15 Nov 2018 10:38:00 +0000 (11:38 +0100)]
qemu: command: gfx: egl-headless: Add 'rendernode' option to the cmdline

Depending on whether QEMU actually supports the option, we can put the
'rendernode' on the '-display egl-headless' cmdline.

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

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agosecurity: dac: gfx: egl-headless: Relabel the DRI device
Erik Skultety [Fri, 16 Nov 2018 07:44:08 +0000 (08:44 +0100)]
security: dac: gfx: egl-headless: Relabel the DRI device

Just like for SPICE, we need to change the permissions on the DRI device
used as the @rendernode for egl-headless graphics type.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: cgroup: gfx: egl-headless: Add the DRI device into the cgroup list
Erik Skultety [Thu, 22 Nov 2018 15:12:40 +0000 (16:12 +0100)]
qemu: cgroup: gfx: egl-headless: Add the DRI device into the cgroup list

Just like for SPICE, we need to put the render node DRI device into the
device cgroup list so that users don't need to add it manually via
qemu.conf file.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: domain: egl-headless: Add the DRI device into the namespace
Erik Skultety [Thu, 22 Nov 2018 11:05:06 +0000 (12:05 +0100)]
qemu: domain: egl-headless: Add the DRI device into the namespace

Just like for SPICE, we need to put the DRI device into the namespace,
otherwise it will be left out from the DAC relabeling process.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: gfx: egl-headless: Introduce a new <gl> subelement
Erik Skultety [Tue, 27 Nov 2018 07:23:13 +0000 (08:23 +0100)]
conf: gfx: egl-headless: Introduce a new <gl> subelement

Unlike with SPICE and SDL which use the <gl> subelement to enable OpenGL
acceleration, specifying egl-headless graphics in the XML has
essentially the same meaning, thus in case of egl-headless we don't have
a need for the 'enable' element attribute and we'll only be interested
in the 'rendernode' one further down the road.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: gfx: Add egl-headless as a member to virDomainGraphicsDef struct
Erik Skultety [Thu, 15 Nov 2018 10:37:00 +0000 (11:37 +0100)]
conf: gfx: Add egl-headless as a member to virDomainGraphicsDef struct

Since we need to specify the rendernode option onto QEMU cmdline, we
need this union member to retain consistency in how we build the
cmdline.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: caps: Introduce QEMU_EGL_HEADLESS_RENDERNODE capability
Erik Skultety [Wed, 21 Nov 2018 13:07:01 +0000 (14:07 +0100)]
qemu: caps: Introduce QEMU_EGL_HEADLESS_RENDERNODE capability

Now that we have QAPI introspection of display types in QEMU upstream,
we can check whether the 'rendernode' option is supported with
egl-headless display type.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: command: Introduce qemuBuildGraphicsEGLHeadlessCommandLine helper
Erik Skultety [Thu, 15 Nov 2018 08:33:04 +0000 (09:33 +0100)]
qemu: command: Introduce qemuBuildGraphicsEGLHeadlessCommandLine helper

We're going to need a bit more logic for egl-headless down the road so
prepare a helper just like for the other display types.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: process: spice: Pick the first available DRM render node
Erik Skultety [Wed, 14 Nov 2018 15:48:27 +0000 (16:48 +0100)]
qemu: process: spice: Pick the first available DRM render node

Up until now, we formatted 'rendernode=' onto QEMU cmdline only if the
user specified it in the XML, otherwise we let QEMU do it for us. This
causes permission issues because by default the /dev/dri/renderDX
permissions are as follows:

crw-rw----. 1 root video

There's literally no reason why it shouldn't be libvirt picking the DRM
render node instead of QEMU, that way (and because we're using
namespaces by default), we can safely relabel the device within the
namespace.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Introduce virDomainGraphics-related helpers
Erik Skultety [Mon, 26 Nov 2018 10:07:42 +0000 (11:07 +0100)]
conf: Introduce virDomainGraphics-related helpers

A few simple helpers that allow us to determine whether a graphics can
and will need to make use of a DRM render node.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: Introduce virHostGetDRMRenderNode helper
Erik Skultety [Thu, 8 Nov 2018 10:47:09 +0000 (11:47 +0100)]
util: Introduce virHostGetDRMRenderNode helper

This is the first step towards libvirt picking the first available
render node instead of QEMU. It also makes sense for us to be able to do
that, since we allow specifying the node directly for SPICE, so if
there's no render node specified by the user, we should pick the first
available one. The algorithm used for that is essentially the same as
the one QEMU uses.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: handle multicast overflow on macvtap NIC_RX_FILTER_CHANGED
Jason Baron [Fri, 30 Nov 2018 17:50:26 +0000 (12:50 -0500)]
qemu: handle multicast overflow on macvtap NIC_RX_FILTER_CHANGED

Guest network devices can set 'overflow' when there are a number of multicast
ips configured. For virtio_net, the limit is only 64. In this case, the list
of mac addresses is empty and the 'overflow' condition is set. Thus, the guest
will currently receive no multicast traffic in this state.

When 'overflow' is set in the guest, let's turn this into ALLMULTI on the host.

Signed-off-by: Jason Baron <jbaron@akamai.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoNews: Add armv6l Support as guest
Stefan Schallenberg [Wed, 28 Nov 2018 21:45:16 +0000 (21:45 +0000)]
News: Add armv6l Support as guest

Signed-off-by: Stefan Schallenberg <infos@nafets.de>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemu: Add Default PCI Device for armv6l versatilepb guests
Stefan Schallenberg [Wed, 28 Nov 2018 21:45:15 +0000 (21:45 +0000)]
qemu: Add Default PCI Device for armv6l versatilepb guests

Signed-off-by: Stefan Schallenberg <infos@nafets.de>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoAdd armv6l Support as guest
Stefan Schallenberg [Wed, 28 Nov 2018 21:45:14 +0000 (21:45 +0000)]
Add armv6l Support as guest

Support for armv6l qemu guests has been added.
Tested with arm1176 CPU on x86.

Signed-off-by: Stefan Schallenberg <infos@nafets.de>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agonews: Fix version number
Andrea Bolognani [Mon, 3 Dec 2018 13:17:41 +0000 (14:17 +0100)]
news: Fix version number

The schema expects it to match the pattern

  v[0-9]+\.[0-9]+\.[0-9]+

which "5.0.0" clearly doesn't, causing the build to fail.

Reported-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 years agomaint: Post-release version bump to 5.0.0
Andrea Bolognani [Mon, 3 Dec 2018 13:12:59 +0000 (14:12 +0100)]
maint: Post-release version bump to 5.0.0

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 years agoRelease of libvirt-4.10.0
Daniel Veillard [Mon, 3 Dec 2018 12:15:36 +0000 (13:15 +0100)]
Release of libvirt-4.10.0

* docs/news.xml: updated for release

Signed-off-by: Daniel Veillard <veillard@redhat.com>
6 years agotests: Sync qemucaps2xml with qemucapabilities
Andrea Bolognani [Thu, 29 Nov 2018 13:29:51 +0000 (14:29 +0100)]
tests: Sync qemucaps2xml with qemucapabilities

Commits d7434ae8009f and 9c4afbda3456 added replies files for
QEMU 3.0.0 on s390x and QEMU 3.1.0 on x86_64 respectively, but
only enabled the corresponding test in qemucapabilities and not
in qemucaps2xml.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 years agovirsh: Strip XML declaration when extracting CPU XMLs
Jiri Denemark [Thu, 22 Nov 2018 15:28:56 +0000 (16:28 +0100)]
virsh: Strip XML declaration when extracting CPU XMLs

Since commit v4.3.0-336-gc84726fbdd all
{hypervisor-,}cpu-{baseline,compare} commands use a generic
vshExtractCPUDefXMLs helper for extracting individual CPU definitions
from the provided input file. The helper wraps the input file in a
<container> element so that several independent elements can be easily
parsed from the file. This works fine except when the file starts with
XML declaration (<?xml version="1.0" ... ?>) because the XML declaration
cannot be put inside any element. In fact it has to be at the very
beginning of the XML document without any preceding white space
characters. We can just simply skip the XML declaration.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: Fix post-copy migration on the source
Jiri Denemark [Thu, 15 Nov 2018 10:16:43 +0000 (11:16 +0100)]
qemu: Fix post-copy migration on the source

Post-copy migration has been broken on the source since commit
v3.8.0-245-g32c29f10db which implemented support for
pause-before-switchover QEMU migration capability.

Even though the migration itself went well, the source did not really
know when it switched to the post-copy mode despite the messages logged
by MIGRATION event handler. As a result of this, the events emitted by
source libvirtd were not accurate and statistics of the completed
migration would cover only the pre-copy part of migration. Moreover, if
migration failed during the post-copy phase for some reason, the source
libvirtd would just happily resume the domain, which could lead to disk
corruption.

With the pause-before-switchover capability enabled, the order of events
emitted by QEMU changed:

                    pause-before-switchover
           disabled                        enabled
    MIGRATION, postcopy-active      STOP
    STOP                            MIGRATION, pre-switchover
                                    MIGRATION, postcopy-active

The STOP even handler checks the migration status (postcopy-active) and
sets the domain state accordingly. Which is sufficient when
pause-before-switchover is disabled, but once we enable it, the
migration status is still active when we get STOP from QEMU. Thus the
domain state set in the STOP handler has to be corrected once we are
notified that migration changed to postcopy-active.

This results in two SUSPENDED events to be emitted by the source
libvirtd during post-copy migration. The first one with
VIR_DOMAIN_EVENT_SUSPENDED_MIGRATED detail, while the second one reports
the corrected VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY detail. This is
inevitable because we don't know whether migration will eventually
switch to post-copy at the time we emit the first event.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotest: caps: Add capabilities for QEMU 3.1.0
Erik Skultety [Wed, 28 Nov 2018 11:14:20 +0000 (12:14 +0100)]
test: caps: Add capabilities for QEMU 3.1.0

These are based on QEMU v3.1.0-rc2-41-g4822f1ee9e.

Acked-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
6 years agoRefresh translations from zanata
Daniel P. Berrangé [Wed, 28 Nov 2018 17:25:02 +0000 (17:25 +0000)]
Refresh translations from zanata

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agovsh-table: Get rid of trailing spaces
Simon Kobyda [Tue, 27 Nov 2018 09:07:32 +0000 (10:07 +0100)]
vsh-table: Get rid of trailing spaces

Get rid of trailing spaces which can be found after last column in tables.

Signed-off-by: Simon Kobyda <skobyda@redhat.com>
6 years agonews: Document nested-hv feature
Andrea Bolognani [Tue, 20 Nov 2018 16:35:36 +0000 (17:35 +0100)]
news: Document nested-hv feature

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemu: Format nested-hv feature on the command line
Andrea Bolognani [Tue, 20 Nov 2018 16:23:09 +0000 (17:23 +0100)]
qemu: Format nested-hv feature on the command line

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 years agoconf: Parse and format nested-hv feature
Andrea Bolognani [Tue, 20 Nov 2018 13:57:27 +0000 (14:57 +0100)]
conf: Parse and format nested-hv feature

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemu: Introduce QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV
Andrea Bolognani [Tue, 20 Nov 2018 12:56:38 +0000 (13:56 +0100)]
qemu: Introduce QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 years agotests: Add capabilities data for QEMU 3.1.0 on ppc64
Andrea Bolognani [Tue, 20 Nov 2018 13:00:09 +0000 (14:00 +0100)]
tests: Add capabilities data for QEMU 3.1.0 on ppc64

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemu: Drop duplicated code from qemuDomainDefValidateFeatures()
Andrea Bolognani [Tue, 20 Nov 2018 14:15:54 +0000 (15:15 +0100)]
qemu: Drop duplicated code from qemuDomainDefValidateFeatures()

Both VIR_DOMAIN_FEATURE_HPT and VIR_DOMAIN_FEATURE_HTM are
handled in the exact same way, so we can remove some duplicated
code without losing any functionality.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 years agodocs: Updated news.xml for CMT
Wang Huaqiang [Mon, 26 Nov 2018 17:56:17 +0000 (01:56 +0800)]
docs: Updated news.xml for CMT

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: Report cache occupancy (CMT) with domstats
Wang Huaqiang [Mon, 26 Nov 2018 17:56:16 +0000 (01:56 +0800)]
qemu: Report cache occupancy (CMT) with domstats

Adding the interface in qemu to report CMT statistic information
through command 'virsh domstats --cpu-total'.

Below is a typical output:

         # virsh domstats 1 --cpu-total
         Domain: 'ubuntu16.04-base'
           ...
           cpu.cache.monitor.count=2
           cpu.cache.monitor.0.name=vcpus_1
           cpu.cache.monitor.0.vcpus=1
           cpu.cache.monitor.0.bank.count=2
           cpu.cache.monitor.0.bank.0.id=0
           cpu.cache.monitor.0.bank.0.bytes=4505600
           cpu.cache.monitor.0.bank.1.id=1
           cpu.cache.monitor.0.bank.1.bytes=5586944
           cpu.cache.monitor.1.name=vcpus_4-6
           cpu.cache.monitor.1.vcpus=4,5,6
           cpu.cache.monitor.1.bank.count=2
           cpu.cache.monitor.1.bank.0.id=0
           cpu.cache.monitor.1.bank.0.bytes=17571840
           cpu.cache.monitor.1.bank.1.id=1
           cpu.cache.monitor.1.bank.1.bytes=29106176

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoutil: Introduce virResctrlMonitorFreeStats
Wang Huaqiang [Mon, 26 Nov 2018 17:56:15 +0000 (01:56 +0800)]
util: Introduce virResctrlMonitorFreeStats

The call of virResctrlMonitorGetStats will allocate the memory for
holding cache occupancy or memory bandwidth statistics.

This patch adds the function virResctrlMonitorFreeStats as the
opposing action of virResctrlMonitorGetStats to free the memory.

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoutil: Return a list of pointer in virResctrlMonitorGetStats
Wang Huaqiang [Mon, 26 Nov 2018 17:56:14 +0000 (01:56 +0800)]
util: Return a list of pointer in virResctrlMonitorGetStats

Return a list of virResctrlMonitorStatsPtr instead of
a virResctrlMonitorStats array in virResctrlMonitorGetStats.

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agonews: Mention support for Xen's PVH machine type
Marek Marczykowski-Górecki [Mon, 26 Nov 2018 19:34:41 +0000 (20:34 +0100)]
news: Mention support for Xen's PVH machine type

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
6 years agoxenconfig: add support for type="pvh"
Marek Marczykowski-Górecki [Mon, 26 Nov 2018 19:34:40 +0000 (20:34 +0100)]
xenconfig: add support for type="pvh"

Handle PVH domain type in both directions (xen-xl->xml, xml->xen-xl).
And add a test for it.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
6 years agoxenconfig: add support for parsing type= xl config entry
Marek Marczykowski-Górecki [Mon, 26 Nov 2018 19:34:39 +0000 (20:34 +0100)]
xenconfig: add support for parsing type= xl config entry

builder="hvm" is deprecated since Xen 4.10, new syntax is type="hvm" (or
type="pv", which is default). Since the old one is still supported,
still use it when writing native config, so the config will work on
older Xen too (and will also not complicate tests).

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
6 years agotests: add basic Xen PVH test
Marek Marczykowski-Górecki [Mon, 26 Nov 2018 19:34:38 +0000 (20:34 +0100)]
tests: add basic Xen PVH test

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
6 years agolibxl: add support for PVH
Marek Marczykowski-Górecki [Mon, 26 Nov 2018 19:34:37 +0000 (20:34 +0100)]
libxl: add support for PVH

Since this is something between PV and HVM, it makes sense to put the
setting in place where domain type is specified.
To enable it, use <os><type machine="xenpvh">xenpvh</type></os>. It is
also included in capabilities.xml, for every supported HVM guest type - it
doesn't seems to be any other requirement (besides new enough Xen).

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
6 years agolibxl: reorder libxlMakeDomBuildInfo for upcoming PVH support
Marek Marczykowski-Górecki [Mon, 26 Nov 2018 19:34:36 +0000 (20:34 +0100)]
libxl: reorder libxlMakeDomBuildInfo for upcoming PVH support

Make it easier to share HVM and PVH code where relevant. No functional
change.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
6 years agotest: Convert testDriver to virObjectLockable
Marc Hartmayer [Tue, 20 Nov 2018 13:54:16 +0000 (14:54 +0100)]
test: Convert testDriver to virObjectLockable

The test driver state (@testDriver) uses it's own reference counting
and locking implementation. Instead of doing that, convert @testDriver
into a virObjectLockable and use the provided functionalities.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
6 years agoutil: netdevbridge: fall back to ioctl from sysfs
Christian Ehrhardt [Tue, 20 Nov 2018 07:55:49 +0000 (08:55 +0100)]
util: netdevbridge: fall back to ioctl from sysfs

There are certain cases e.g. containers where the sysfs path might
exists, but might fail. Unfortunately the exact restrictions are only
known to libvirt when trying to write to it so we need to try it.

But in case it fails there is no need to fully abort, in those cases try
to fall back to the older ioctl interface which can still work.

That makes setting up a bridge in unprivileged LXD containers work.

Fixes: https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1802906
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
Reported-by: Brian Candler <b.candler@pobox.com>
6 years agoqemuMigrationSrcConfirm: Don't remove domain config if confirm phase fails
Michal Privoznik [Thu, 22 Nov 2018 13:12:14 +0000 (14:12 +0100)]
qemuMigrationSrcConfirm: Don't remove domain config if confirm phase fails

If migration is cancelled or confirm phase fails the domain
should be kept on the source even if VIR_MIGRATE_UNDEFINE_SOURCE
was requested.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
6 years agoqemuMigrationDstPrepareAny: Parse cookie before adding domain onto list
Michal Privoznik [Thu, 22 Nov 2018 10:31:00 +0000 (11:31 +0100)]
qemuMigrationDstPrepareAny: Parse cookie before adding domain onto list

There are some checks done when parsing a migration cookie. For
instance, one of the checks ensures that the domain is not being
migrated onto the same host. If that is the case, then we are in
big trouble because the @vm is the same domain object used by
source and it has some jobs sets and everything so recovering
from failed cookie parsing would be needlessly hard.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
6 years agoqemuMigrationEatCookie: Pass virDomainDef instead of virDomainObj
Michal Privoznik [Thu, 22 Nov 2018 10:24:03 +0000 (11:24 +0100)]
qemuMigrationEatCookie: Pass virDomainDef instead of virDomainObj

The function currently takes virDomainObjPtr because it's using
both: the domain definition and domain private data.
Unfortunately, this means that in prepare phase we can't parse
migration cookie before putting incoming domain def onto domain
objects list (addressed in the very next commit). Change the
arguments so that virDomainDef and private data are passed
instead of virDomainObjPtr.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
6 years agoqemuMigrationDstPrepareAny: Don't overwrite error in cleanup path
Michal Privoznik [Wed, 21 Nov 2018 08:01:59 +0000 (09:01 +0100)]
qemuMigrationDstPrepareAny: Don't overwrite error in cleanup path

There are several functions called in the cleanup path. Some of
them do report error (e.g. qemuDomainRemoveInactiveJob()) which
may result in overwriting an error reported earlier with some
less useful message.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
6 years agosecurity: aa-helper: Fix static defined vfio MDEVs
Christian Ehrhardt [Thu, 22 Nov 2018 12:55:02 +0000 (13:55 +0100)]
security: aa-helper: Fix static defined vfio MDEVs

virt-aa-helper needs to grant QEMU access to VFIO MDEV devices.

This extends commit 74e86b6b which only covered PCI hostdevs for VFIO-PCI
assignment by now also covering vfio MDEVs.
It has still the same limitations regarding the device lifecycle, IOW we're
unable to predict the actual VFIO device being created, thus we need
wildcards.

Also note that the hotplug case, where apparmor is able to detect the actual
VFIO device during runtime, is already covered by commit 606afafb.

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
6 years agoutil: Fix a bug in virResctrlMonitorGetStats
Wang Huaqiang [Tue, 20 Nov 2018 02:10:39 +0000 (10:10 +0800)]
util: Fix a bug in virResctrlMonitorGetStats

The path argument of virFileIsDir should be a full name
of file, pathname and filename. Fixed it by passing the
full path name to virFileIsDir.

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoutil: Fix virDoes*Exist return type
Martin Kletzander [Mon, 19 Nov 2018 21:31:01 +0000 (22:31 +0100)]
util: Fix virDoes*Exist return type

Since the functions only return 0 or 1, they should return bool.  I missed the
change when "refactoring" the first commit.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>