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

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

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

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

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

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

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

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

Forbid it on read-only connections.

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

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agologging: restrict sockets to mode 0600
Daniel P. Berrangé [Tue, 30 Apr 2019 16:27:41 +0000 (17:27 +0100)] 
logging: restrict sockets to mode 0600

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

Fixes CVE-2019-10132

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

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

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

Fixes CVE-2019-10132

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

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

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

Fixes CVE-2019-10132

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

7 years agovirDomainConfNWFilterInstantiate: initialize @xml to avoid random crash
Luyao Huang [Thu, 5 Jul 2018 04:34:11 +0000 (12:34 +0800)] 
virDomainConfNWFilterInstantiate: initialize @xml to avoid random crash

If the code jump to the cleanup before assigning value to @xml
libvirtd may crash when it tries to free an uninitialized pointer.

backtrace:

0  0x00007ffff428d59c in free () from /lib64/libc.so.6
1  0x00007ffff721314a in virFree (ptrptr=ptrptr@entry=0x7fffc67f1b00) at util/viralloc.c:582
2  0x00007ffff7345ac4 in virDomainConfNWFilterInstantiate (vmname=<optimized out>,
   vmuuid=vmuuid@entry=0x7fffc0181ca8 "߉\237\\۔H\262\206z\340\302f\265\233z", net=<optimized out>,
   ignoreExists=ignoreExists@entry=true) at conf/domain_nwfilter.c:122
3  0x00007fffca5a77f6 in qemuProcessFiltersInstantiate (ignoreExists=true, def=0x7fffc0181ca0) at qemu/qemu_process.c:3028
4  qemuProcessReconnect (opaque=<optimized out>) at qemu/qemu_process.c:7653
5  0x00007ffff72c4895 in virThreadHelper (data=<optimized out>) at util/virthread.c:206
6  0x00007ffff45dcdd5 in start_thread () from /lib64/libpthread.so.0
7  0x00007ffff4305ead in clone () from /lib64/libc.so.6

Signed-off-by: Luyao Huang <lhuang@redhat.com>
(cherry picked from commit d7557f5f6f51264c1b5623e97f7b4d5259d4d3b6)

7 years agoqemu: fix UNIX socket chardevs operating in client mode
Daniel P. Berrangé [Fri, 6 Jul 2018 10:00:11 +0000 (11:00 +0100)] 
qemu: fix UNIX socket chardevs operating in client mode

When support was adding for passing a pre-opened listener socket to UNIX
chardevs, it accidentally passed the listener socket for client mode
chardevs too with predictable amounts of fail resulting. This affects
libvirt when using QEMU >= 2.12

Expand the unit test coverage to validate that we are only doing FD
passing when operating in server mode.

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

Tested-by: Richard W.M. Jones <rjones@redhat.com>
Reported-by: Richard W.M. Jones <rjones@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit 1bc1a7e3205f7ef75ebd8fd1ef7653f8e181e3d2)

7 years agoqemu: don't use chardev FD passing for vhostuser backend
Daniel P. Berrangé [Wed, 4 Jul 2018 13:28:14 +0000 (14:28 +0100)] 
qemu: don't use chardev FD passing for vhostuser backend

QEMU chardevs have a bug which makes the vhostuser backend complain
about lack of support for FD passing when validating the chardev.
While this is ultimately QEMU's responsibility to fix, libvirt needs to
avoid tickling the bug.

Simply disabling chardev FD passing just for vhostuser's chardev is
the most prudent approach, avoiding need for a QEMU version number
check.

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

7 years agoqemu: consolidate parameters of qemuBuildChrChardevStr into flags
Daniel P. Berrangé [Wed, 4 Jul 2018 13:20:40 +0000 (14:20 +0100)] 
qemu: consolidate parameters of qemuBuildChrChardevStr into flags

There are two boolean parameters passed to qemuBuildChrChardevStr,
and soon there will be a third. It will be clearer to understand
from callers' POV if we use named flags instead.

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

7 years agoqemu: remove chardevStdioLogd param from vhostuser code path
Daniel P. Berrangé [Thu, 5 Jul 2018 10:59:22 +0000 (11:59 +0100)] 
qemu: remove chardevStdioLogd param from vhostuser code path

The vhostuser network backend is only supported with the UNIX domain
socket chardev backend, so passing around chardevStdioLogd is not
required.

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

7 years agoqemu: don't use chardev FD passing with standalone args
Daniel P. Berrangé [Thu, 28 Jun 2018 11:49:12 +0000 (12:49 +0100)] 
qemu: don't use chardev FD passing with standalone args

When using domxml-to-native, we must generate CLI args that can be used
in a standalone scenario. This means no FD passing can be used. To
achieve this we must clear the QEMU_CAPS_CHARDEV_FD_PASS capability bit.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit 7ac08cc929dc512e8682fbfcc5d33518058f20e4)

7 years agoRelease of libvirt-4.5.0 v4.5.0
Daniel Veillard [Mon, 2 Jul 2018 20:11:33 +0000 (22:11 +0200)] 
Release of libvirt-4.5.0

- docs/news.xml: updated for the release

Signed-off-by: Daniel Veillard <veillard@redhat.com>
7 years agonews: Update for 4.5.0 release
Andrea Bolognani [Mon, 2 Jul 2018 14:43:54 +0000 (16:43 +0200)] 
news: Update for 4.5.0 release

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agoqemu_migration: Check for active domain after talking to remote daemon
Jiri Denemark [Thu, 28 Jun 2018 09:38:52 +0000 (11:38 +0200)] 
qemu_migration: Check for active domain after talking to remote daemon

Once we called qemuDomainObjEnterRemote to talk to the destination
daemon during a peer to peer migration, the vm lock is released and we
only hold an async job. If the source domain dies at this point the
monitor EOF callback is allowed to do its job and (among other things)
clear all private data irrelevant for stopped domain. Thus when we call
qemuDomainObjExitRemote, the domain may already be gone and we should
avoid touching runtime private data (such as current job info).

In other words after acquiring the lock in qemuDomainObjExitRemote, we
need to check the domain is still alive. Unless we're doing offline
migration.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoqemu_migration: Rename 'offline' variable in SrcPerformPeer2Peer
Jiri Denemark [Thu, 28 Jun 2018 12:09:47 +0000 (14:09 +0200)] 
qemu_migration: Rename 'offline' variable in SrcPerformPeer2Peer

The variable is used to store the offline migration capability of the
destination daemon. Let's call it 'dstOffline' so that we can later use
'offline' to indicate whether we were asked to do offline migration.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoqemu: Allow cachetune only for KVM domains v4.5.0-rc2
Michal Privoznik [Thu, 28 Jun 2018 09:37:09 +0000 (11:37 +0200)] 
qemu: Allow cachetune only for KVM domains

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

In TCG mode, there are no vCPU threads and thus there's nothing
to be placed into resctrl group. Forbid such configuration.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agoqemu: Report error on unexpected job stats type
Jiri Denemark [Fri, 1 Jun 2018 08:22:30 +0000 (10:22 +0200)] 
qemu: Report error on unexpected job stats type

If we ever fail to properly set jobinfo->statsType,
qemuDomainJobInfoToParams would return -1 without setting an error.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agosecurity: Add swtpm paths to the domain's AppArmor profile
Stefan Berger [Sat, 19 May 2018 03:33:46 +0000 (23:33 -0400)] 
security: Add swtpm paths to the domain's AppArmor profile

This patch extends the AppArmor domain profile with file paths
the swtpm accesses for state, log, pid, and socket files.

Both, QEMU and swtpm, use this AppArmor profile.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Cc: Christian Ehrhardt <christian.ehrhardt@canonical.com>
7 years agonwfilter: variable 'obj' must be initialized inside nwfilterBindingCreateXML().
Julio Faracco [Wed, 27 Jun 2018 02:47:53 +0000 (23:47 -0300)] 
nwfilter: variable 'obj' must be initialized inside nwfilterBindingCreateXML().

The function nwfilterBindingCreateXML() is failing to compile due to a
conditional branch which leads to an undefined 'obj' variable. So 'obj'
must have an initial value to avoid compilation errors. See the problem:

  CC       nwfilter/libvirt_driver_nwfilter_impl_la-nwfilter_driver.lo
nwfilter/nwfilter_driver.c:752:9: error: variable 'obj' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
    if (virNWFilterBindingCreateXMLEnsureACL(conn, def) < 0)
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
nwfilter/nwfilter_driver.c:779:10: note: uninitialized use occurs here
    if (!obj)
         ^~~
nwfilter/nwfilter_driver.c:752:5: note: remove the 'if' if its condition is always false
    if (virNWFilterBindingCreateXMLEnsureACL(conn, def) < 0)
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
nwfilter/nwfilter_driver.c:742:33: note: initialize the variable 'obj' to silence this warning
    virNWFilterBindingObjPtr obj;
                                ^
                                 = NULL

This commit initialized 'obj' with NULL to fix the error properly.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoconf: Forbid device alias change on device-update
Michal Privoznik [Tue, 12 Jun 2018 14:05:10 +0000 (16:05 +0200)] 
conf: Forbid device alias change on device-update

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

When updating a live device users might pass different alias than
the one the device has. Currently, this is silently ignored which
goes against our behaviour for other parts of the device where we
explicitly allow only certain changes and error out loudly on
anything else.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoconf: Reintroduce action to virDomainDefCompatibleDevice
Michal Privoznik [Tue, 26 Jun 2018 08:37:27 +0000 (10:37 +0200)] 
conf: Reintroduce action to virDomainDefCompatibleDevice

This was lost in c57f3fd2f8999d17e01. But now we are going to
need it again (except the DETACH action where checking for device
compatibility does not make much sense anyway).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemuDomainUpdateDeviceFlags: Parse device as live if needed
Michal Privoznik [Tue, 12 Jun 2018 14:04:30 +0000 (16:04 +0200)] 
qemuDomainUpdateDeviceFlags: Parse device as live if needed

When updating device it's worth parsing live info too as users
might want to update it as well.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agospec: list new nwfilter schema files v4.5.0-rc1
Pavel Hrdina [Wed, 27 Jun 2018 08:42:52 +0000 (10:42 +0200)] 
spec: list new nwfilter schema files

Commit <41d619e99c2015eab2d56bea874e23ba9f52f829> introduced new RNG
schema files for nwfilter but forgot to update spec file.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agosyms: Fix placement of virDomainGetBlkioParametersAssignFromDef
Cole Robinson [Tue, 26 Jun 2018 19:53:30 +0000 (15:53 -0400)] 
syms: Fix placement of virDomainGetBlkioParametersAssignFromDef

It's in the domain_addr.h section, but should be in the
domain_conf.h section

Signed-off-by: Cole Robinson <crobinso@redhat.com>
7 years agoqemu: hotplug: fix mdev attach for vfio-ccw
Bjoern Walk [Tue, 26 Jun 2018 11:47:39 +0000 (13:47 +0200)] 
qemu: hotplug: fix mdev attach for vfio-ccw

Mediated devices of model 'vfio-ccw' are using CCW addresses, so make
sure to call the correct address preparation code for the model.

Reviewed-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Signed-off-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agodocs: Add news article for volume encryption modifications
John Ferlan [Wed, 20 Jun 2018 22:37:15 +0000 (18:37 -0400)] 
docs: Add news article for volume encryption modifications

Include both the domain and storage modifications in a "Removed
features" section as well as describing the improvement to allow
using a raw input volume to create the luks encrypted volume.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
7 years agostorage: Add support for using inputvol for encryption
John Ferlan [Wed, 20 Jun 2018 19:51:47 +0000 (15:51 -0400)] 
storage: Add support for using inputvol for encryption

Starting with QEMU 2.9, encryption convert processing requires
a multi-step process in order to generate an encrypted image from
some non encrypted raw image.

Processing requires to first create an encrypted image using the
sizing parameters from the input source and second to use the
--image-opts, -n, and --target-image-opts options along with inline
driver options to describe the input and output files, generating
two commands such as:

  $ qemu-img create -f luks \
      --object secret,id=demo.img_encrypt0,file=/path/to/secretFile \
      -o key-secret=demo.img_encrypt0 \
      demo.img 500K
  Formatting 'demo.img', fmt=luks size=512000 key-secret=demo.img_encrypt0
  $ qemu-img convert --image-opts -n --target-image-opts \
      --object secret,id=demo.img_encrypt0,file=/path/to/secretFile \
      driver=raw,file.filename=sparse.img \
      driver=luks,file.filename=demo.img,key-secret=demo.img_encrypt0
  $

This patch handles the convert processing by running the processing
in a do..while loop essentially reusing the existing create logic and
arguments to create the target vol from the inputvol and then converting
the inputvol using new arguments.

This then allows the following virsh command to work properly:

  virsh vol-create-from default encrypt1-luks.xml data.img --inputpool default

where encrypt1-luks.xml would provided the path and secret for
the new image, while data.img would be the source image.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
7 years agostorage: Remove storageBackendGenerateSecretData
John Ferlan [Tue, 19 Jun 2018 15:56:21 +0000 (11:56 -0400)] 
storage: Remove storageBackendGenerateSecretData

Since we no longer support creating qcow2 encryption format
volumes, we no longer have to possibly create some secret and
have no real need for the function, so move the remaining
functionality to build the secret path back into the caller
storageBackendCreateQemuImg.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
7 years agostorage: Clean up storageBackendCreateQemuImgOpts
John Ferlan [Tue, 19 Jun 2018 23:19:23 +0000 (19:19 -0400)] 
storage: Clean up storageBackendCreateQemuImgOpts

Since we only generate the @encinfo when there's a secret object
and thus we need to reference it in the options,

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
7 years agostorage: Clean up storageBackendCreateQemuImgCheckEncryption
John Ferlan [Wed, 20 Jun 2018 21:15:03 +0000 (17:15 -0400)] 
storage: Clean up storageBackendCreateQemuImgCheckEncryption

Remove the checks for qcow encryption since both callers (create
and resize) would have already disallowed usage.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
7 years agostorage: Disallow create/resize of qcow2 encrypted images
John Ferlan [Wed, 20 Jun 2018 20:21:50 +0000 (16:21 -0400)] 
storage: Disallow create/resize of qcow2 encrypted images

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

Since commit c4eedd793 disallowed qcow2 encrypted images to be
used for domains, it no longer makes sense to allow a qcow2
encrypted volume to be created or resized.

Add a test that will exhibit the failure of creation as well
as the xml2xml validation of the format still being correct.

Update the documentation to note the removal of the capability
to create and use qcow/default encrypted volumes.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
7 years agotests: Remove qcow2 encryption from storagevol tests
John Ferlan [Wed, 20 Jun 2018 19:52:30 +0000 (15:52 -0400)] 
tests: Remove qcow2 encryption from storagevol tests

We're about to disallow creation of a qcow2 encrypted storage
volume, so let's remove the qcow encryption element from the
tests which are testing whether other format='qcow2' related
features work properly.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
7 years agostorage: Rename encryption info variable for clarity
John Ferlan [Tue, 19 Jun 2018 23:15:43 +0000 (19:15 -0400)] 
storage: Rename encryption info variable for clarity

Change from @enc to @encinfo leaving @enc for the vol->target.encryption
in the storageBackendCreateQemuImgSetOptions code path.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
7 years agotests: Add luks creation examples to storagevolxml2argvtest
John Ferlan [Tue, 19 Jun 2018 14:59:48 +0000 (10:59 -0400)] 
tests: Add luks creation examples to storagevolxml2argvtest

Add the storagevolxml2xmltest "luks" and "luks-cipher" tests
to the storagevolxml2argvtest.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
7 years agostorage: Don't allow encryption secretPath to be NULL
John Ferlan [Tue, 19 Jun 2018 16:05:31 +0000 (12:05 -0400)] 
storage: Don't allow encryption secretPath to be NULL

Allowing a NULL @secretPath for virStorageBackendCreateQemuImgCmdFromVol
would result in a generated command line with a dangling "file=" output.
So let's make sure the @secretPath exists before processing.

This means we should pass a dummy path from the storage test.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
7 years agodomain_addr: Fix weird comment format
Cole Robinson [Tue, 26 Jun 2018 15:49:54 +0000 (11:49 -0400)] 
domain_addr: Fix weird comment format

Signed-off-by: Cole Robinson <crobinso@redhat.com>
7 years agonwfilter: convert virt drivers to use public API for nwfilter bindings
Daniel P. Berrangé [Fri, 11 May 2018 17:39:27 +0000 (18:39 +0100)] 
nwfilter: convert virt drivers to use public API for nwfilter bindings

Remove the callbacks that the nwfilter driver registers with the domain
object config layer. Instead make the current helper methods call into
the public API for creating/deleting nwfilter bindings.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agonwfilter: wire up new APIs for creating and deleting nwfilter bindings
Daniel P. Berrangé [Fri, 11 May 2018 15:59:51 +0000 (16:59 +0100)] 
nwfilter: wire up new APIs for creating and deleting nwfilter bindings

This allows the virsh commands nwfilter-binding-create and
nwfilter-binding-delete to be used.

Note using these commands lets you delete filters that were
previously created automatically by the virt drivers, or add
filters for VM nics that were not there before. Generally it
is expected these new APIs will only be used by virt drivers.
It is the admin's responsibility to not shoot themselves in
the foot.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agonwfilter: wire up new APIs for listing and querying filter bindings
Daniel P. Berrangé [Thu, 10 May 2018 13:12:40 +0000 (14:12 +0100)] 
nwfilter: wire up new APIs for listing and querying filter bindings

Wire up the ListAll, LookupByPortDev and GetXMLDesc APIs to allow the
virsh nwfilter-binding-list & nwfilter-binding-dumpxml commands to
work.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agonwfilter: remove virt driver callback layer for rebuilding filters
Daniel P. Berrangé [Fri, 27 Apr 2018 12:25:10 +0000 (13:25 +0100)] 
nwfilter: remove virt driver callback layer for rebuilding filters

Now that the nwfilter driver keeps a list of bindings that it has
created, there is no need for the complex virt driver callbacks. It is
possible to simply iterate of the list of recorded filter bindings.

This means that rebuilding filters no longer has to acquire any locks on
the virDomainObj objects, as they're never touched.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agonwfilter: keep track of active filter bindings
Daniel P. Berrangé [Thu, 26 Apr 2018 17:34:33 +0000 (18:34 +0100)] 
nwfilter: keep track of active filter bindings

Currently the nwfilter driver does not keep any record of what filter
bindings it has active. This means that when it needs to recreate
filters, it has to rely on triggering callbacks provided by the virt
drivers. This introduces a hash table recording the virNWFilterBinding
objects so the driver has a record of all active filters.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agovirsh: add manpage docs for nwfilter-binding commands.
Daniel P. Berrangé [Fri, 22 Jun 2018 10:53:39 +0000 (11:53 +0100)] 
virsh: add manpage docs for nwfilter-binding commands.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agoqemu: Escape commas for qemuBuildSCSIiSCSIHostdevDrvStr
Anya Harter [Wed, 20 Jun 2018 13:17:00 +0000 (09:17 -0400)] 
qemu: Escape commas for qemuBuildSCSIiSCSIHostdevDrvStr

Add comma escaping for netsource. This is done here because
qemuBuildNetworkDriveStr has other external callers which
may not expect an escaped comma; however, this particular
command building path needs to perform the escaping for the
hostdev command line, so we do it now to ensure src->path
and src->host->name are covered.

Signed-off-by: Anya Harter <aharter@redhat.com>
7 years agoqemu: use virBuffer in qemuBuildSCSIiSCSIHostdevDrvStr
Anya Harter [Wed, 20 Jun 2018 13:16:59 +0000 (09:16 -0400)] 
qemu: use virBuffer in qemuBuildSCSIiSCSIHostdevDrvStr

Instead of source to enable use of virBuffer functions in
string construction.

Signed-off-by: Anya Harter <aharter@redhat.com>
7 years agoqemuDomainObjBeginJobInternal: Report agent job in error message
Michal Privoznik [Wed, 20 Jun 2018 12:17:45 +0000 (14:17 +0200)] 
qemuDomainObjBeginJobInternal: Report agent job in error message

If a thread is unable to acquire a job (e.g. because of timeout)
an error is reported and the error message contains reference to
the other thread holding the job. Well, the error message should
report agent job too as it is yet another source of possible
failure.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoset-lifecycle-action: add description of type and action
Chen Hanxiao [Thu, 21 Jun 2018 11:28:55 +0000 (19:28 +0800)] 
set-lifecycle-action: add description of type and action

In [1], <type> are described as "on_poweroff", "on_reboot",
"on_crash". but we accept "poweroff", "reboot" and "crash".
This patch adds documentation for them.

[1]: https://libvirt.org/formatdomain.html#elementsEvents

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoconf: introduce a virNWFilterBindingObjListPtr struct
Daniel P. Berrangé [Thu, 10 May 2018 14:29:46 +0000 (15:29 +0100)] 
conf: introduce a virNWFilterBindingObjListPtr struct

Introduce a new struct to act as the manager of a collection of
virNWFilterBindingObjPtr objects.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agoconf: introduce a virNWFilterBindingObjPtr struct
Daniel P. Berrangé [Thu, 10 May 2018 16:21:24 +0000 (17:21 +0100)] 
conf: introduce a virNWFilterBindingObjPtr struct

Introduce a new struct to act as the stateful owner of the
virNWFilterBindingDefPtr objects.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agoconf: report an error if nic needs filtering by no driver is present
Daniel P. Berrangé [Thu, 26 Apr 2018 13:05:10 +0000 (14:05 +0100)] 
conf: report an error if nic needs filtering by no driver is present

If a <interface> includes a filter name but the nwfilter driver is not
present we silently do nothing. This is very bad, because an application
that thinks it is protected by malicious guest traffic will in fact be
vulnerable. Reporting an error gives the administrator the ability to
know there is a problem and fix it.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agonwfilter: convert DHCP address snooping code to virNWFilterBindingDefPtr
Daniel P. Berrangé [Thu, 26 Apr 2018 11:45:29 +0000 (12:45 +0100)] 
nwfilter: convert DHCP address snooping code to virNWFilterBindingDefPtr

Use the virNWFilterBindingDefPtr struct in the DHCP address snooping code
directly.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agonwfilter: convert IP address learning code to virNWFilterBindingDefPtr
Daniel P. Berrangé [Thu, 26 Apr 2018 11:45:29 +0000 (12:45 +0100)] 
nwfilter: convert IP address learning code to virNWFilterBindingDefPtr

Use the virNWFilterBindingDefPTr struct in the IP address learning code
directly.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agonwfilter: convert the gentech driver code to use virNWFilterBindingDefPtr
Daniel P. Berrangé [Thu, 26 Apr 2018 11:26:51 +0000 (12:26 +0100)] 
nwfilter: convert the gentech driver code to use virNWFilterBindingDefPtr

Use the virNWFilterBindingDefPtr struct in the gentech driver code
directly.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agovirsh: add nwfilter binding commands
Daniel P. Berrangé [Wed, 9 May 2018 16:44:35 +0000 (17:44 +0100)] 
virsh: add nwfilter binding commands

$ virsh nwfilter-binding-list
 Port Dev                              Filter
------------------------------------------------------------------
 vnet0                 clean-traffic
 vnet1                 clean-traffic

$ virsh nwfilter-binding-dumpxml vnet1
<filterbinding>
  <owner>
    <name>f25arm7</name>
    <uuid>12ac8b8c-4f23-4248-ae42-fdcd50c400fd</uuid>
  </owner>
  <portdev name='vnet1'/>
  <mac address='52:54:00:9d:81:b1'/>
  <filterref filter='clean-traffic'>
    <parameter name='MAC' value='52:54:00:9d:81:b1'/>
  </filterref>
</filterbinding>

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agoremote: add support for nwfilter binding objects
Daniel P. Berrangé [Wed, 9 May 2018 16:18:58 +0000 (17:18 +0100)] 
remote: add support for nwfilter binding objects

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agoaccess: add nwfilter binding object permissions
Daniel P. Berrangé [Wed, 9 May 2018 16:19:55 +0000 (17:19 +0100)] 
access: add nwfilter binding object permissions

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agonwfilter: export port binding concept in the public API
Daniel P. Berrangé [Wed, 9 May 2018 11:21:25 +0000 (12:21 +0100)] 
nwfilter: export port binding concept in the public API

When the daemons are split there will need to be a way for the virt
drivers and/or network driver to create and delete bindings between
network ports and network filters. This defines a set of public APIs
that are suitable for managing this facility.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agoschemas: add schema for nwfilter binding XML document
Daniel P. Berrangé [Tue, 15 May 2018 17:00:16 +0000 (18:00 +0100)] 
schemas: add schema for nwfilter binding XML document

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agoconf: add support for parsing/formatting virNWFilterBindingDefPtr
Daniel P. Berrangé [Thu, 10 May 2018 12:37:53 +0000 (13:37 +0100)] 
conf: add support for parsing/formatting virNWFilterBindingDefPtr

A typical XML representation of the virNWFilterBindingDefPtr struct
looks like this:

  <filterbinding>
    <owner>
      <name>f25arm7</name>
      <uuid>12ac8b8c-4f23-4248-ae42-fdcd50c400fd</uuid>
    </owner>
    <portdev name='vnet1'/>
    <mac address='52:54:00:9d:81:b1'/>
    <filterref filter='clean-traffic'>
      <parameter name='MAC' value='52:54:00:9d:81:b1'/>
    </filterref>
  </filterbinding>

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agoconf: move virNWFilterBindingDefPtr into its own files
Daniel P. Berrangé [Thu, 10 May 2018 13:30:42 +0000 (14:30 +0100)] 
conf: move virNWFilterBindingDefPtr into its own files

There's no code sharing between virNWFilterDef and
virNWFilterBindingDefPtr types, so it is clearer if they live in
separate source files and headers.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agoconf: add missing virxml.h include for nwfilter_params.h
Daniel P. Berrangé [Thu, 10 May 2018 13:29:58 +0000 (14:29 +0100)] 
conf: add missing virxml.h include for nwfilter_params.h

The nwfilter_params.h header references the xmlNodePtr type, so must
include the virxml.h header to get the libxml2 types defined.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agoconf: change virNWFilterBindingPtr to virNWFilterBindingDefPtr
Daniel P. Berrangé [Tue, 8 May 2018 12:45:26 +0000 (13:45 +0100)] 
conf: change virNWFilterBindingPtr to virNWFilterBindingDefPtr

We are going to want to expose the NWFilter binding concept in the
public API, so the virNWFilterBindingPtr type needs to be used there.
Our internal type will shortly gain an XML representation, so rename
it to virNWFilterBindingDefPtr which follows our normal conventions.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agospec: Move SASL configuration file from -libs to -daemon
Andrea Bolognani [Thu, 21 Jun 2018 14:14:48 +0000 (16:14 +0200)] 
spec: Move SASL configuration file from -libs to -daemon

SASL authentication is configured server-side, so the sample
configuration file should be shipped along with the daemon
rather than with the libraries.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agonews: Update for HPT maxpagesize feature
Andrea Bolognani [Mon, 25 Jun 2018 16:56:23 +0000 (18:56 +0200)] 
news: Update for HPT maxpagesize feature

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agoqemu: Format HPT maxpagesize on the command line
Andrea Bolognani [Wed, 23 May 2018 16:18:02 +0000 (18:18 +0200)] 
qemu: Format HPT maxpagesize on the command line

This makes the feature fully functional.

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agoconf: Parse and format HPT maxpagesize
Andrea Bolognani [Wed, 23 May 2018 16:18:01 +0000 (18:18 +0200)] 
conf: Parse and format HPT maxpagesize

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agoconf: Tweak HPT feature parsing and formatting
Andrea Bolognani [Wed, 23 May 2018 16:17:58 +0000 (18:17 +0200)] 
conf: Tweak HPT feature parsing and formatting

This doesn't seem very useful at the moment, but it will make
sense once we introduce another HPT-related setting.

The output XML is decoupled from the input XML in preparation
of future changes as well; while doing so, we can shave a few
lines off the latter.

This commit is best viewed with 'git show -w'.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agoconf: Reintroduce virDomainDef::hpt_resizing
Andrea Bolognani [Wed, 23 May 2018 16:17:57 +0000 (18:17 +0200)] 
conf: Reintroduce virDomainDef::hpt_resizing

We're going to introduce a second HPT-related setting soon,
at which point using a single location to store everything is
no longer going to cut it.

This mostly, but not completely, reverts 3dd1eb3b2650.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agoqemu: Add capability for the HPT maxpagesize feature
Andrea Bolognani [Tue, 19 Jun 2018 11:51:05 +0000 (13:51 +0200)] 
qemu: Add capability for the HPT maxpagesize feature

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agotests: Add replies for QEMU 3.0.0 on ppc64
Andrea Bolognani [Mon, 25 Jun 2018 11:58:09 +0000 (13:58 +0200)] 
tests: Add replies for QEMU 3.0.0 on ppc64

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agoutil: fix mount issue by moving NULL value to "none" in syscall.
Julio Faracco [Tue, 26 Jun 2018 03:18:21 +0000 (00:18 -0300)] 
util: fix mount issue by moving NULL value to "none" in syscall.

After running libvirt daemon with valgrind tools, some errors are
appearing when you try to start a domain. One example:

==18012== Syscall param mount(type) points to unaddressable byte(s)
==18012==    at 0x6FEE3CA: mount (syscall-template.S:78)
==18012==    by 0x531344D: virFileMoveMount (virfile.c:3828)
==18012==    by 0x27FE7675: qemuDomainBuildNamespace (qemu_domain.c:11501)
==18012==    by 0x2800C44E: qemuProcessHook (qemu_process.c:2870)
==18012==    by 0x52F7E1D: virExec (vircommand.c:726)
==18012==    by 0x52F7E1D: virCommandRunAsync (vircommand.c:2477)
==18012==    by 0x52F4EDD: virCommandRun (vircommand.c:2309)
==18012==    by 0x2800A731: qemuProcessLaunch (qemu_process.c:6235)
==18012==    by 0x2800D6B4: qemuProcessStart (qemu_process.c:6569)
==18012==    by 0x28074876: qemuDomainObjStart (qemu_driver.c:7314)
==18012==    by 0x280522EB: qemuDomainCreateWithFlags (qemu_driver.c:7367)
==18012==    by 0x55484BF: virDomainCreate (libvirt-domain.c:6531)
==18012==    by 0x12CDBD: remoteDispatchDomainCreate (remote_daemon_dispatch_stubs.h:4350)
==18012==    by 0x12CDBD: remoteDispatchDomainCreateHelper (remote_daemon_dispatch_stubs.h:4326)
==18012==  Address 0x0 is not stack'd, malloc'd or (recently) free'd

Some documentation recommends to use "none" when you don't have a
filesystem type to use. Specially, for bind and move actions.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
7 years agosnapshots: Clarify comments on snapshot role
Eric Blake [Tue, 26 Jun 2018 00:16:04 +0000 (19:16 -0500)] 
snapshots: Clarify comments on snapshot role

Give some more details on what a snapshot is good for, to make
it easier to distinguish from the role of upcoming additions for
incremental backups.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agodocs: schema: Add missing <interleave> to devices
Han Han [Fri, 22 Jun 2018 05:24:02 +0000 (13:24 +0800)] 
docs: schema: Add missing <interleave> to devices

For input,hub,redirdev devices, their sub-elements should be interleaved.

input device: interleave for <driver>, <alias>, <address>
hub device: interleave for <alias>, <address>
redirdev device: interleave for <source>, <alias>, <address>, <boot>

Signed-off-by: Han Han <hhan@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoqemu: Fix memory leak in qemuDomainBlockJobSetSpeed()
w00251574 [Mon, 25 Jun 2018 14:15:36 +0000 (22:15 +0800)] 
qemu: Fix memory leak in qemuDomainBlockJobSetSpeed()

fix 'device' leak in qemuDomainBlockJobSetSpeed

Signed-off-by: Jie Wang <wangjie88.huawei.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoqemu: monitor: Fix memory leak in qemuMonitorJSONNBDServerStart()
w00251574 [Mon, 25 Jun 2018 13:48:50 +0000 (21:48 +0800)] 
qemu: monitor: Fix memory leak in qemuMonitorJSONNBDServerStart()

Exiting early through the return path did result in 'port_str'
being leaked.

Signed-off-by: Jie Wang <wangjie88.huawei.com>
7 years agoqemu: ensure FDs passed to QEMU for chardevs have correct SELinux labels
Daniel P. Berrangé [Thu, 7 Jun 2018 15:55:07 +0000 (16:55 +0100)] 
qemu: ensure FDs passed to QEMU for chardevs have correct SELinux labels

The UNIX socket FDs were we passing to QEMU inherited a label based on
libvirtd's context. QEMU is thus denied ability to access the UNIX
socket. We need to use the security manager to change our current
context temporarily when creating the UNIX socket FD.

Reviewed-by: Laine Stump <laine@laine.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agodocs: formatdomain: Mention that 'urandom' is the recommended RNG backend
Kashyap Chamarthy [Fri, 22 Jun 2018 10:09:39 +0000 (12:09 +0200)] 
docs: formatdomain: Mention that 'urandom' is the recommended RNG backend

Since libvirt 1.3.4, any RNG source is accepted for the 'random'
backend.  However, '/dev/urandom' is the _recommended_ source of
entropy. Therefore we should mention that in the docs.

Suggested-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Kashyap Chamarthy <kchamart@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
7 years agoqemuDomainObjBeginJobInternal: Log agent job too
Michal Privoznik [Wed, 20 Jun 2018 12:15:42 +0000 (14:15 +0200)] 
qemuDomainObjBeginJobInternal: Log agent job too

If a thread is unable to start a job (e.g. because of timeout)
a warning is printed into the logs. So far, the message does not
contain agent job info. Add it as it might help future debugging.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
7 years agonews: Document recent agent job change
Michal Privoznik [Thu, 21 Jun 2018 13:37:38 +0000 (15:37 +0200)] 
news: Document recent agent job change

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
7 years agovirDomainSnapshotDefParse: Prefer VIR_STEAL_PTR
Michal Privoznik [Thu, 21 Jun 2018 10:11:29 +0000 (12:11 +0200)] 
virDomainSnapshotDefParse: Prefer VIR_STEAL_PTR

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
7 years agoqemu: fix msg could be a wild pointer in qemuMonitorIOProcess()
Weilun Zhu [Wed, 20 Jun 2018 08:45:27 +0000 (16:45 +0800)] 
qemu: fix msg could be a wild pointer in qemuMonitorIOProcess()

As qemuMonitorJSONIOProcess will call qemuMonitorJSONIOProcessEvent
which unlocks the monitor mutex, there is some extreme situation,
eg qemu send message to monitor twice in a short time, where the
local viriable 'msg' of qemuMonitorIOProcess could be a wild point:

1. qemuMonitorSend() assign mon->msg to parameter 'msg', which is alse a
local variable of its caller qemuMonitorJSONCommandWithFd(), cause
eventloop to send message to monitor, then wait condition.
2. qemu send message to monitor for the first time immediately.
3. qemuMonitorIOProcess() is called, then wake up the qemuMonitorSend()
thread, but the qemuMonitorSend() thread stuck for a while as cpu pressure
or some other reasons, which means the qemu monitor is still unlocked.
4. qemu send event message to monitor for the second time,
such as RTC_CHANGE event
5. qemuMonitorIOProcess() is called again, the local viriable 'msg' is
assigned to mon->msg.
6. qemuMonitorIOProcess() call qemuMonitorJSONIOProcess() to deal with
the qemu event.
7. qemuMonitorJSONIOProcess() unlock the qemu monitor in the macro
'QEMU_MONITOR_CALLBACK', then qemuMonitorSend() thread get the mutex
and free the mon->msg, assign mon->msg to NULL.

Signed-off-by: Weilun Zhu <zhuweilun@huawei.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
7 years agovmx: allow an odd number of vCPUs
Pino Toscano [Thu, 14 Jun 2018 13:34:25 +0000 (15:34 +0200)] 
vmx: allow an odd number of vCPUs

Most probably this was a limitation in older ESX versions, and it seems
it does not exist anymore in more recent versions; see the following
thread:
https://www.redhat.com/archives/libvir-list/2018-May/msg02159.html
https://www.redhat.com/archives/libvir-list/2018-June/msg00043.html

Hence, allow an odd number (greater than 1) of vCPUs, since most
probably older versions of ESXi will error out anyway.

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

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoqemu: Escape commas for qemuBuildDiskThrottling
Anya Harter [Tue, 19 Jun 2018 16:20:18 +0000 (12:20 -0400)] 
qemu: Escape commas for qemuBuildDiskThrottling

Add comma escaping for disk->blkdeviotune.group_name.

Signed-off-by: Anya Harter <aharter@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agonews: add cmdDomblkinfo --all option
Chen Hanxiao [Tue, 19 Jun 2018 10:01:26 +0000 (18:01 +0800)] 
news: add cmdDomblkinfo --all option

Update news for cmdDomblkinfo --all option.

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agocmdDomblkinfo: add --all to show all block devices info
Chen Hanxiao [Tue, 19 Jun 2018 10:01:24 +0000 (18:01 +0800)] 
cmdDomblkinfo: add --all to show all block devices info

This patch introduces --all to show all block devices info
of guests like:

virsh # domblkinfo w08 --all
Target     Capacity        Allocation      Physical
---------------------------------------------------
hda        42949672960     9878110208      9878110208
vda        10737418240     10736439296     10737418240

Target     Capacity        Allocation      Physical
---------------------------------------------------
hda        40.000 GiB      9.200 GiB       9.200 GiB
vda        10.000 GiB      9.999 GiB       10.000 GiB

For inactive domains using networked storage, a "-" will
be printed instead of the value since it's not possible
to determine the value without the storage connection.

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agocmdDomblkinfo: introduce helper cmdDomblkinfoPrint
Chen Hanxiao [Tue, 19 Jun 2018 10:01:23 +0000 (18:01 +0800)] 
cmdDomblkinfo: introduce helper cmdDomblkinfoPrint

Introduce helper cmdDomblkinfoPrint for printing.

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoschema: allow a <rule> element with no subelements in a nwfilter
Laine Stump [Thu, 21 Jun 2018 06:07:17 +0000 (02:07 -0400)] 
schema: allow a <rule> element with no subelements in a nwfilter

This is a regression in behavior caused by commit 37359814. It was
intended to limit the schema to allow only a single subelement of
<rule>, but it is also acceptable for <rule> to have no subelement at
all.

To prevent the same error from reoccurring in the future, the
examples/xml/nwfilter directory was added to the list of nwfilter
schema test directories.

Resolves: https://bugzilla.redhat.com/1593549

Signed-off-by: Laine Stump <laine@laine.org>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
7 years agohyperv: erase "generated files" sentinel during make maintainer-clean
Laine Stump [Thu, 21 Jun 2018 07:42:32 +0000 (03:42 -0400)] 
hyperv: erase "generated files" sentinel during make maintainer-clean

Re-generating of generated source files in the hyperv directory
depends on src/.hyperv_wmi_generator.stamp not existing, or having a
timestamp older than src/hyperv/hyperv_wmi_generator.py. "make
maintainer-clean" erases the generated files, but not this sentinel
file, so the erased files aren't regenerated during the next
make. Once we add it to the list of MAINTAINERCLEANFILES, it gets
deleted at the same time as the generated files, so make is able to
understand they need regeneration.

Signed-off-by: Laine Stump <laine@laine.org>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
7 years agohyperv: fix typo in Makefile.am.inc
Laine Stump [Thu, 21 Jun 2018 06:19:45 +0000 (02:19 -0400)] 
hyperv: fix typo in Makefile.am.inc

The problem has been around for quite awhile - the misspelling was
faithfully copied from src/Makefile.am to src/hyperv/Makefile.am.inc
in commit 253b528c.

Signed-off-by: Laine Stump <laine@laine.org>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoqemu: Don't use asyncJob after stop during snapshot revert
John Ferlan [Tue, 19 Jun 2018 22:54:19 +0000 (18:54 -0400)] 
qemu: Don't use asyncJob after stop during snapshot revert

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

Attempting to use the FORCE flag for snapshot-revert was resulting
in failures because qemuProcessStart and qemuProcessStartCPUs were
using QEMU_ASYNC_JOB_START after a qemuProcessStop resulting in an
error when entering the monitor:

error: internal error: unexpected async job 6 type expected 0

So create a local @jobType, initialize to QEMU_ASYNC_JOB_START, and
change to QEMU_ASYNC_JOB_NONE if we end up in the --force path
where the qemuProcessStop is run before a Start and StartCPUs.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoqemu: Unset the genid start change flag for revert force
John Ferlan [Tue, 19 Jun 2018 22:54:18 +0000 (18:54 -0400)] 
qemu: Unset the genid start change flag for revert force

If the the snapshot revert involves a forced revert option, then
let's not cause startup to change the genid flag in order to signify
that we're still running the same/previous guest and not some
snapshot reversion.

Related to:
https://bugzilla.redhat.com/show_bug.cgi?id=1149445

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoqemu: Use start_flags for RUNNING and PAUSED transitions
John Ferlan [Tue, 19 Jun 2018 22:54:17 +0000 (18:54 -0400)] 
qemu: Use start_flags for RUNNING and PAUSED transitions

Use and set the @start_flags at the top of the RUNNING and PAUSED
transitions to GEN_VMID | PAUSED.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoqemu: Promote start_flags in qemuDomainRevertToSnapshot
John Ferlan [Tue, 19 Jun 2018 22:54:16 +0000 (18:54 -0400)] 
qemu: Promote start_flags in qemuDomainRevertToSnapshot

Promote the @start_flags to the top of the function, a
subsequent patch needs to use it.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoqemu: Adjust async job failure message
John Ferlan [Tue, 19 Jun 2018 22:54:15 +0000 (18:54 -0400)] 
qemu: Adjust async job failure message

Make it clearer what asyncJob type was passed and what was expected.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoqemu_command: vhost: cleanup error reporting
Cole Robinson [Tue, 19 Jun 2018 16:26:25 +0000 (12:26 -0400)] 
qemu_command: vhost: cleanup error reporting

- Switch to cleanup: label and share free calls
- Don't overwrite qemuBuildNicDevStr error

Signed-off-by: Cole Robinson <crobinso@redhat.com>
7 years agoqemu_command: replace vlan= with netdev= for legacy nic
Cole Robinson [Tue, 19 Jun 2018 15:42:37 +0000 (11:42 -0400)] 
qemu_command: replace vlan= with netdev= for legacy nic

VMs with hardcoded platform network devices are forced to use old
style '-net nic' command line config. Current we use qemu's vlan
option to hook this with the '-netdev' host side of things.

However since qemu 1.2 there is '-net nic,netdev=X' option for
explicitly referencing a netdev ID, which is more inline with
typical VM commandlines, so let's switch to that

Signed-off-by: Cole Robinson <crobinso@redhat.com>
7 years agoqemu_command: remove unused LegacyNicStr arg 'prefix'
Cole Robinson [Tue, 19 Jun 2018 15:35:32 +0000 (11:35 -0400)] 
qemu_command: remove unused LegacyNicStr arg 'prefix'

Hardcode the only string that's passed in

Signed-off-by: Cole Robinson <crobinso@redhat.com>
7 years agoqemu_command: Rename BuildNicStr to BuildLegacyNicStr
Cole Robinson [Tue, 19 Jun 2018 15:31:37 +0000 (11:31 -0400)] 
qemu_command: Rename BuildNicStr to BuildLegacyNicStr

Makes it less ambiguous

Signed-off-by: Cole Robinson <crobinso@redhat.com>
7 years agoqemu_command: Make qemuBuildNicStr static
Cole Robinson [Tue, 19 Jun 2018 15:30:52 +0000 (11:30 -0400)] 
qemu_command: Make qemuBuildNicStr static

It doesn't have any external callers

Signed-off-by: Cole Robinson <crobinso@redhat.com>