Commit Graph

30533 Commits

Author SHA1 Message Date
Peter Krempa
50edca1331 qemu: monitor: Add the 'query-nodes' argument for query-blockstats
The 'query-blockstats' command does not return statistics for the
explicitly named nodes unless the new argument is specified. Add
infrastrucuture that will allow us to use the new approach if desired.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-20 15:41:38 +02:00
Peter Krempa
f78033c4f2 qemu: command: use qemuDomainDiskGetBackendAlias in commandline building
Use the proper backend for the block device both when using -drive and
when -blockdev will be used for disk drives and floppy disks.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-20 15:41:38 +02:00
Peter Krempa
8abbc72bd2 qemu: domain: Add helper for getting the disk backend alias
The disk backend alias was historically the alias of the -drive backing
the storage. For setups with -blockdev this will become more complex as
it will depend on other configs and generally will differ.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-20 15:41:33 +02:00
Peter Krempa
b05a48c0d2 qemu: domain: Move out clearing of backing chain in qemuDomainDetermineDiskChain
In some cases backing chain needs to be cleared prior to re-detection.
Move this step out of qemuDomainDetermineDiskChain as only certain
places need it and the function itself is able to skip to the end of the
chain to perform detection.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-20 15:33:20 +02:00
Peter Krempa
055c918b37 qemu: driver: Reuse qemuDomainBlocksStatsGather in qemuDomainGetBlockInfo
Allow updating capacity for the block devices returned by
qemuDomainBlocksStatsGather and replace the open-coded call to
qemuMonitorGetAllBlockStatsInfo by the helper.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-20 15:33:20 +02:00
Peter Krempa
4a0835364e utils: storage: Add copying of PR definition to virStorageSource
Despite the warning that virStorageSourceCopy needs to be populated on
additions to the structure commit 687730540e neglected to implement the
copy function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-20 14:40:59 +02:00
Peter Krempa
4fbe2295db qemu: hotplug: Add/remove managed PR objects on media change
When changing cdrom media we did not handle the managed PR objects thus
we'd either have a stale PR object left behind or the media change would
fail.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-20 14:23:09 +02:00
Peter Krempa
83fe11e950 qemu: hotplug: Make qemuHotplugWaitForTrayEject reusable
Remove the issue of the monitor command to the caller so that the
function can be used with the modern approach.

Additionally improve the error message.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-20 14:23:09 +02:00
Peter Krempa
22480cf950 qemu: hotplug: Extract legacy disk media changing bits
Prepare for the -blockdev implementation of ejectable media changing by
splitting up the old bits.

Additionally since both callers make sure that the device is a cdrom or
floppy the check is no longer necessary.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-20 14:23:09 +02:00
Peter Krempa
36e9b1ec50 qemu: hotplug: Refactor/simplify PR managed addition to VM
Similarly to qemuDomainDiskRemoveManagedPR make it enter monitor on
its own so that it can be reused. Future users will be in the snapshot
code and in removable media change code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-20 14:23:09 +02:00
Peter Krempa
8498a1e222 qemu: hotplug: Simplify removal of managed PR infrastructure on unplug
Extract the (possible) removal of the PR backend and daemon into a
separate helper which enters monitor on its own. This simplifies the
code and allows reuse of this function in the future e.g. for blockjobs
where removing a image with PR may result into PR not being necessary.

Since the PR is not used often the overhead of entering monitor again
should be negligible.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-20 14:23:09 +02:00
Peter Krempa
e417c23d39 qemu: hotplug: Reuse qemuHotplugDiskSourceRemove for disk backend removal
Add code which will convert a disk definition into
qemuHotplugDiskSourceData and then reuse qemuHotplugDiskSourceRemove to
remove all the backend related objects.

This unifies the detach code as much as possible with the already
existing helpers and will allow reuse this infrastructure when changing
removable disk media.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-20 14:23:09 +02:00
Peter Krempa
ee46360b43 qemu: hotplug: Don't leak 'disk' if VM crashes during unplug finishing
qemuDomainRemoveDiskDevice would leak the disk to be removed if the VM
crashed since it was removed from the definition but not freed.

Broken in commit 105bcdde76 which moved the removal from the definition
earlier.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-20 14:23:09 +02:00
Peter Krempa
d3f9dda2c9 qemu: hotplug: Prepare for multiple backing chain member hotplug
Similarly to how we've intergrated data belonging to a single
virStorageSource for purposes of attaching it to a qemu instance we will
need to agregate data relevant for the whole disk. With blockdev there
will be some disk-wide backing chain members such as the copy-on-read
handler.

Introduce qemuHotplugDiskSourceData which agregates the backing chain
and other data relevant for the disk and functions which generate it
and apply and rollback it.

In addition to disk hotplug this will also be reused for media changing
where we need to exchange the full disk backend.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-20 14:23:09 +02:00
Peter Krempa
13f763fcdd qemu: hotplug: Don't format NULL in %s in qemuHotplugPrepareDiskAccess
The warning messages which include the disk source could potentially
format NULL using %s as virDomainDiskGetSource may return NULL for e.g.
NBD disks. As most of the APIs are NOOP for remote disks the usage of
the source string only should be fine for now.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-20 14:23:09 +02:00
Peter Krempa
f952dccb8f qemu: hotplug: Remove pointless variable
Now that there's only one use of it, replace it directly by the code
filling it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-20 14:23:08 +02:00
Peter Krempa
539f74e885 qemu: hotplug: Reuse qemuHotplugPrepareDiskAccess in qemuDomainRemoveDiskDevice
qemuHotplugPrepareDiskAccess can be used to tear down disk access so we
can replace the open-coded version collecting the same function calls.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-20 14:23:08 +02:00
John Ferlan
313eaae3b5 tools: Fix typo generating adapter_wwpn field
https://bugzilla.redhat.com/show_bug.cgi?id=1601377

Fix typo from commit id d45bee449 for the parent_wwpn field
resulting in parent_wwnn being printed twice.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2018-07-20 07:45:42 -04:00
Peter Krempa
2f259d598a qemu: monitor: Remove old code for dual handling of 'transaction' data
Now that we use only the separate function for creating data for the
'transaction' command we can remove all the boilerplate which was
necessary before.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-20 13:39:45 +02:00
Peter Krempa
42f3bbb15e qemu: monitor: Remove old external snapshot code
Remove the dual mode code which allowed to create snapshots without
support for 'transaction'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-20 13:39:45 +02:00
Peter Krempa
bed681d7b5 qemu: block: Create helper for creating data for legacy snapshots
With 'transaction' support we don't need to keep around the multipurpose
code which would create the snapshot if 'transaction' is not supported.

To simplify this add a new helper that just wraps the arguments for
'blockdev-snapshot-sync' operation in 'transaction' and use it instead
of qemuBlockSnapshotAddLegacy.

Additionally this allows to format the arguments prior to creating the
file for simpler cleanup.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-20 13:39:44 +02:00
Peter Krempa
faf769d862 qemu: monitor: Add API to help creating 'transaction' arguments
Add a new helper that will be solely used to create arguments for the
transaction command. Later on this will make it possible to remove the
overloading which was caused by the fact that snapshots were created
without transaction and also will help in blockdevification of snapshots.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-20 13:39:44 +02:00
Peter Krempa
936ef573f1 qemu: snapshot: Audit actual disk snapshot creation
Currently we'd audit that we managed to format the data for the
'transaction' command rather than the (un)successful attempt to create
the snapshot.

Move the auditing code so that it can actually audit the result of the
'transaction' command.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-20 13:39:44 +02:00
Peter Krempa
c5dc734403 qemu: snapshot: Unify conditions checking whether snapshot needs to be taken
In the cleanup path we already checked whether a snapshot needed to be
taken by looking into the collected data. Use the same approach when
creating the snapshot command data and when committing the changes to the
domain definition.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-20 13:39:44 +02:00
Peter Krempa
d5d02aa900 qemu: snapshot: Remove monitor code now that 'transaction' is always used
Since we now always do the snapshot via the 'transaction' command we can
drop the code which would enter monitor for individual disk snapshots.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-20 13:39:44 +02:00
Peter Krempa
aa65f0f2f1 qemu: snapshot: Require support of 'transaction' command for external snapshots
While qemu supports the 'transaction' command since v1.1.0
(52e7c241ac766406f05fa) and the 'blockdev-snapshot-sync' command since
v0.14.0-rc0 we need to keep the capability bits present since some qemu
downstreams (RHEL/CentOS 7 for example) chose to cripple qemu by
arbitrarily compiling out some stuff which was already present at that
time.

To simplify the crazy code just require both commands to be present at
the beginning of an external snapshot so that we can remove the case when
'transaction' would not be supported.

This also allows to drop any logic connected to the
VIR_DOMAIN_SNAPSHOT_CREATE_ATOMIC flag since snapshots are atomic with
the 'transaction' command.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-20 13:39:44 +02:00
Han Han
a47d053720 virt-xml-validate: Add schema for nwfilterbinding
https://bugzilla.redhat.com/show_bug.cgi?id=1600330

Add nwfilterbinding schema in virt-xml-validate for autoprobing.
Add document of nwfilterbinding schema in tools/virt-xml-validate.pod.

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-07-19 16:16:57 -04:00
John Ferlan
09c67432f3 build: Fix accidental revert of .gnulib update
Commit id 1bff5bbe25 accidentally
reverted .gnulib back to d6397dde2e127e246e3eeb5254a21f42cac783c8
which was two updates ago.

Update to the latest 68df637b5f1b5c10370f6981d2a43a5cf74368df
which includes three changes since the previous fetch of
cdbf3d385a32ff904c96f20c26f3470bd8345248.

> autoupdate
> hard-locale: simplify by removing hard-locale.m4
> gnulib-tool: limit line length for git send-email

Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-07-19 16:15:51 -04:00
Cole Robinson
a33e20c734 test: Implement virConnectListAllInterfaces
This adds some generic virinterfaceobj code, roughly matching what
is used by other stateful drivers like network, storage, etc.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2018-07-19 09:47:01 -04:00
Julio Faracco
359b938b8b qemu: Fix broken autostart symlink after renaming domain
If a domain is configured to start on boot, it has a symlink to the
domain definition inside the autostart directory. If you rename this
domain, the definition is renamed too. The symlink need to be pointed to
this renamed file. This commit recreates the symlink after renaming the
XML file.

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

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
2018-07-19 11:22:28 +02:00
Nikolay Shirokovskiy
1bff5bbe25 util: set OOM in virCopyLastError if error is not set
virCopyLastError is intended to be used after last error is set.
However due to virLastErrorObject failures (very unlikely though
as thread local error is allocated on first use) we can have zero
fields in a copy as a result. In particular code field can be set
to VIR_ERR_OK.

In some places (qemu monitor, qemu agent and qemu migaration code
for example) we use copy result as a flag and this leads to bugs.

Let's set OOM-like error in copy in case of virLastErrorObject failures.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2018-07-19 10:49:46 +03:00
Daniel P. Berrangé
36d426a611 locking: don't create qemu-sanlock.conf file when QEMU isn't enabled
The test targets result in the qemu-sanlock.conf file being created
when sanlock is enabled, even if QEMU is not enabled. As a result it
never gets cleaned up when distclean is run, breaking distcheck.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-07-18 18:46:32 +01:00
Erik Skultety
2e7965735a docs: news: Provide an update about the video type 'none'
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
2018-07-18 18:23:51 +02:00
Erik Skultety
d48813e81a conf: Introduce new video type 'none'
Historically, we've always enabled an emulated video device every time we
see that graphics should be supported with a guest. With the appearance
of mediated devices which can support QEMU's vfio-display capability,
users might want to use such a device as the only video device.
Therefore introduce a new, effectively a 'disable', type for video
device.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
2018-07-18 18:23:51 +02:00
Erik Skultety
32b52ed838 docs: Rephrase the mediated devices hostdev section a bit
Currently it reads:
Refer MDEV to create a mediated device on the host

...even though it resembles English, it's not a proper English.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
2018-07-18 18:23:48 +02:00
Erik Skultety
5a33bcb838 docs: Update news about the VNC console enablement for mdevs
Signed-off-by: Erik Skultety <eskultet@redhat.com>
Acked-by: Michal Privoznik <mprivozn@redhat.com>
2018-07-18 18:16:08 +02:00
Erik Skultety
c0ca6dcf42 qemu: command: Enable formatting vfio-pci.display option onto cmdline
Since QEMU 2.12, QEMU understands a new vfio-pci device option 'display'
which can be used to turn on display capabilities on vgpu-enabled
mediated devices, IOW emulated GPU devices like QXL will no longer be
needed with vgpu-enable mdevs.
QEMU defaults to 'auto' for the 'display' attribute, which is not
foolproof, so we need to play it safe here and default to display='off'
if this attribute wasn't provided in the XML explicitly.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
2018-07-18 18:16:08 +02:00
Erik Skultety
d54e45b6ed conf: Introduce new <hostdev> attribute 'display'
QEMU 2.12 introduced a new type of display for mediated devices using
vfio-pci backend which allows a mediated device to be used as a VGA
compatible device as an alternative to an emulated video device. QEMU
exposes this feature via a vfio device property 'display' with supported
values 'on/off/auto' (libvirt will default to 'off').

This patch adds the necessary bits to domain config handling in order to
expose this feature. Since there's no convenient way for libvirt to come
up with usable defaults for the display setting, simply because libvirt
is not able to figure out which of the display implementations - dma-buf
which requires OpenGL support vs vfio regions which doesn't need OpenGL
(works with OpenGL enabled too) - the underlying mdev uses.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
2018-07-18 18:16:08 +02:00
Erik Skultety
f1f6f48582 conf: Replace 'error' with 'cleanup' in virDomainHostdevDefParseXMLSubsys
The exit path is the same for both success and failure, so the label
should be called cleanup.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-18 18:16:08 +02:00
Erik Skultety
425329181f conf: Introduce virDomainGraphicsDefHasOpenGL helper
A simple helper which will loop through all the graphics elements and
checks whether at least one of them enables OpenGL support, either by
containing <gl enable='yes'/> or being of type 'egl-headless'.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Acked-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-18 18:16:08 +02:00
Erik Skultety
11c7bdac6d qemu: caps: Add vfio-pci.display capability
QEMU 2.12 introduced a new vfio-pci device option 'display=on/off/auto'.
This patch introduces the necessary capability.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-18 18:16:07 +02:00
Erik Skultety
d8266ebe16 qemu: Introduce a new graphics display type 'headless'
Since 2.10 QEMU supports a new display type egl-headless which uses the
drm nodes for OpenGL rendering copying back the rendered bits back to
QEMU into a dma-buf which can be accessed by standard "display" apps
like VNC or SPICE. Although this display type can be used on its own,
for any practical use case it makes sense to pair it with either VNC or
SPICE display. The clear benefit of this display is that VNC gains
OpenGL support, which it natively doesn't have, and SPICE gains remote
OpenGL support (native OpenGL support only works locally through a UNIX
socket, i.e. listen type=socket/none).

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
2018-07-18 18:16:07 +02:00
Erik Skultety
7ab7d0ed49 qemu: caps: Introduce a capability for egl-headless
Since QEMU 2.10, it's possible to use a new type of display -
egl-headless which uses drm nodes to provide OpenGL support. This patch
adds a capability for that. However, since QEMU doesn't provide a QMP
command to probe it, we have to base the capability on specific QEMU
version.

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
2018-07-18 18:15:58 +02:00
Erik Skultety
3b61f333ac qemu: qemuBuildHostdevCommandLine: Use a helper variable mdevsrc
Decrease the number of accessors we have to use.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
2018-07-18 18:15:03 +02:00
Ján Tomko
4dd6054000 m4: Introduce STABLE_ORDERING_JANSSON
Add a second check for Jansson >= 2.8, which includes
fixes to preserve ordering of object keys.

Use this constant to guard tests that depend on stable ordering.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-07-18 17:54:18 +02:00
Ján Tomko
01ce04375c build: require Jansson if QEMU driver is enabled
If the QEMU driver was requested, require Jansson, since we need to use
the JSON monitor to probe capabilities for all QEMU version supported
by libvirt.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-07-18 17:54:18 +02:00
Ján Tomko
c5ae8e0c2b build: switch --with-qemu default from yes to check
Unless explicitly requested, enable the QEMU driver
only if the Jansson library is present.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-07-18 17:54:18 +02:00
Ján Tomko
8f802c6d86 Remove virJSONValueNewStringLen
It is no longer used.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-07-18 17:54:18 +02:00
Ján Tomko
1caf844160 build: remove references to WITH_YAJL for SETUID_RPC_CLIENT
We no longer allow building WITH_YAJL, remove the remaining
uses of the macro.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-07-18 17:54:18 +02:00
Ján Tomko
bf114decb3 Remove functions using yajl
We no longer support building WITH_YAJL, remove the dead code
as well as the virJSONParser structures that are no longer used.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-07-18 17:54:18 +02:00