Commit Graph

7609 Commits

Author SHA1 Message Date
Katerina Koukiou
74b5634b77 qemu: Fix setting global_period cputune element
When VIR_DOMAIN_SCHEDULER_GLOBAL_PERIOD is matched "cputune.global_period"
should be updated and not "cputune.period".

Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com>

https://bugzilla.redhat.com/show_bug.cgi?id=1600427
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-07-16 15:26:15 +02:00
Katerina Koukiou
611b038fb6 qemu: hotplug: report error when changing rom enabled attr for net iface
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1599513

Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-16 10:46:19 +02:00
Katerina Koukiou
f7b55665cc qemu: hotplug: don't overwrite error message in qemuDomainAttachNetDevice
Since commit f14c37, virDomainConfVMNWFilterTeardown is reporting errors
thus any previously reported error gets overwritten.
We need to save the errors in qemuDomainAttachNetDevice before calling
this function when we are in cleanup code.

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

Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2018-07-16 10:41:44 +02:00
Michal Privoznik
8d2a9f0994 qemu_cgroup: Allow/disallow devmapper control iff available
https://bugzilla.redhat.com/show_bug.cgi?id=1591732

On kernels without device mapper support there won't be
/dev/mapper/control. Therefore it doesn't make much sense to
put it into devices CGroup.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-13 16:01:16 +02:00
John Ferlan
7406ab691f qemu: Fix ATTRIBUTE_NONNULL for qemuMonitorAddObject
Commit id fac0dacd was trying to make things more robust;
however, the ATTRIBUTE_NONNULL(1) would be for the @mon,
not the intended (2) and the @props argument as described
in the commit message.

Found by Coverity build.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-07-12 15:52:05 -04:00
Peter Krempa
fac0dacd54 qemu: monitor: Make qemuMonitorAddObject more robust against programming errors
Document and check that @props contains a pointer to a json object and
check that both necessary fields are present. Also mark @props as
NONNULL.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-10 17:32:58 +02:00
Peter Krempa
62ef8227e2 qemu: hotplug: Do not try to add secret object for TLS if it does not exist
The check whether the object holding secret for decryption of the TLS
environment was wrong and would always attempt to add the object. This
lead to a crash due to recent refactors.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-10 17:32:58 +02:00
Michal Privoznik
ab435a4be4 qemu: Fetch pr-helper process info on reconnect
If qemu-pr-helper process died while libvirtd was not running no
event is emitted. Therefore, when reconnecting to the monitor we
must check the qemu-pr-helper process status and act accordingly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-07-10 14:56:22 +02:00
Michal Privoznik
5f085862e8 qemu_monitor: Introduce qemuMonitorJSONGetPRManagerInfo
This function fetches status of all pr-managers. So far, qemu
reports only a single attribute "connected" but that fits our
needs.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-07-10 14:56:22 +02:00
Michal Privoznik
6fbda83330 qemu: Wire up PR_MANAGER_STATUS_CHANGED event
This event is emitted on the monitor if one of pr-managers lost
connection to its pr-helper process. What libvirt needs to do is
restart the pr-helper process iff it corresponds to managed
pr-manager.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-07-10 14:56:22 +02:00
Michal Privoznik
900403a3b2 qemuDomainValidateStorageSource: Relax PR validation
Rather than rejecting the user provided path and alias for the
managed PR reservation we will ignore the provided path. The
reason is that migration XML does contain path even for managed
reservations.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-07-10 14:56:22 +02:00
Michal Privoznik
dd1d58cabc qemuProcessStartPRDaemonHook: Try to set NS iff domain was started with one
Users have possibility to disable qemu namespace feature (e.g.
because they are running on *BSD which lacks Linux NS support).
If that's the case we should not try to move qemu-pr-helper into
the same namespace as qemu is in.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-07-10 14:56:22 +02:00
Peter Krempa
bb4f3543bb qemu: command: Format rerror/werror with -device instead of -drive
Use the new proper location for the read/write error policy selection.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-10 13:37:51 +02:00
Peter Krempa
a087a8e60a qemu: capabilities: Add capability for werror/rerror for 'usb-device' frontend
Support for specifying it with the -device frontend was added recently.
Add a capability for it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-10 13:37:51 +02:00
Peter Krempa
1cb98a1fb3 qemu: block: Add support for RBD authentication for blockdev
To allow using -blockdev with RBD we need to support the recently added
RBD authentication.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-10 13:37:51 +02:00
Peter Krempa
ad8da38e0a qemu: command: Rename qemuBuildDriveDevStr to qemuBuildDiskDeviceStr
It builds the string for '-device' from a virDomainDiskDef.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-10 13:32:54 +02:00
Peter Krempa
192cf8ce00 qemu: command: Refactor floppy controller command formatting
Aggregate the code for the two separate formats used according to the
machine type and add some supporting code so that the function is
actually readable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-10 13:32:54 +02:00
Peter Krempa
6236b61443 qemu: command: Don't generate disk drive alias manually for floppies
qemuBulildFloppyCommandLineOptions built its own version of the -drive
alias. Replace it by qemuAliasDiskDriveFromDisk.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-10 13:32:54 +02:00
Peter Krempa
35582d1125 qemu: command: Split out formatting of disk source commandline
Further split qemuBuildDiskCommandLine to separate formatting of the
source part.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-10 13:32:54 +02:00
Peter Krempa
48c643f47c qemu: hotplug: Add warning regarding SD hotplug
SD card hotplug should not be implemented until they can be used via
-blockdev.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-10 13:32:54 +02:00
Peter Krempa
aa624c3bfb qemu: command: Rename and export qemuDiskBusNeedsDeviceArg
Change the semantics to exactly opposite and rename it to
qemuDiskBusNeedsDriveArg. This will be necessary as some devices can't
be used with -blockdev.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-10 13:32:54 +02:00
Peter Krempa
d7eeafaa4c qemu: domain: Reject copy_on_read for read-only disks
The sectors read from the backing image need to be written to the top
level image. If a disk is marked read-only the image can't be written.

QEMU handled that by disabling copy_on_read and reporting a warning:

-drive file=/var/lib/libvirt/images/c,format=qcow2,if=none,
    id=drive-scsi0-0-1,readonly=on,copy-on-read=on:
    warning: disabling copy-on-read on read-only drive

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-10 13:32:53 +02:00
Peter Krempa
9ac3ea5cf8 qemu: domain: Remove code assuming disk format probing
After commit c95f50cb02 we always set a disk format in the
post parse callback so the code that mandates use of explicit format for
shareable disks no longer makes sense.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-10 13:32:53 +02:00
Erik Skultety
767f9e1449 qemu: validate: Enforce compile time switch type checking for videos
There wasn't an explicit type case to the video type enum in
qemuDomainDeviceDefValidateVideo, _TYPE_GOP was also missing from the
switch.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-07-09 18:59:24 +02:00
Erik Skultety
3e90bd67a2 qemu: address: Handle all the video devices within a single loop
Since 133fb140 moved the validation of a video device into a separate
function, the code handling PCI slot assignment for video devices has
been the same for both the primary device and the secondary devices.
Let's merge these and thus handle all the devices within the existing
'for' loop.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-07-09 18:59:02 +02:00
Erik Skultety
ff767f083f qemu: command: Fix building of the SDL display command line
QEMU uses a shorthand '-sdl' which maps to '-display sdl'. However, if
there are any options to be passed to SDL, the full command version must
be used. Everything seemingly worked for us until commit 5038b30043
introduced OpenGL support for SDL and added ',gl=on/off' option which as
mentioned above could have never worked with the shorthand version of
the command. Indeed starting a domain with an SDL display and OpenGL
enabled, QEMU produces a rather cryptic error:

-sdl: Could not open 'gl=on': No such file or directory

This patch provides fixes to both the SDL cmdline generation and the
test suite.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-07-09 17:45:19 +02:00
Erik Skultety
9f26814afd qemu: command: Add virReportEnumRangeError to BuildHostdevCommandline
Adding the 'default' case to our enum-typecasted switches is the current
safety trend, so add it here for mdevs too.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-07-09 17:45:19 +02:00
Erik Skultety
afc107c20f qemu: command: Move graphics iteration to its own function
It should be the command line helper who takes care of the iteration
rather than the caller.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-07-09 17:45:19 +02:00
Boris Fiuczynski
78eb8895eb qemu: Fix typo in qemu_command.c
Rename qemuBulildFloppyCommandLineOptions into
qemuBuildFloppyCommandLineOptions.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
2018-07-09 16:36:18 +02:00
Peter Krempa
902f4bce09 qemu: monitor: Use 'target' instead of 'arch' in reply of 'query-cpus-fast'
qemu changed the output field name for the architecture from 'arch' to
'target'. Note the change and fix the code so that the arch-specific
extraction works.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-07-09 16:18:53 +02:00
Peter Krempa
1e65d35b04 qemu: monitor: Remove qemuMonitorJSONExtractCPUArchInfo wrapper
The wraper is quite pointless and also the 'arch' field may depend on
whether query-cpus-fast is used.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-07-09 16:18:53 +02:00
Michal Privoznik
87d80b50c6 qemuBuildSCSIiSCSIHostdevDrvStr: Don't leak @netsource and @srcprops
After 6b770f9a3b both @netsource and @srcprops are leaked
because of early return introduced in the commit.

==1812== 644 bytes in 4 blocks are definitely lost in loss record 835 of 885
==1812==    at 0x4C2F12F: realloc (vg_replace_malloc.c:785)
==1812==    by 0x8846393: xmlSaveUriRealloc (in /usr/lib64/libxml2.so.2.9.8)
==1812==    by 0x8846B1C: xmlSaveUri (in /usr/lib64/libxml2.so.2.9.8)
==1812==    by 0x5DDA619: virURIFormat (viruri.c:256)
==1812==    by 0x56E941B: qemuBuildNetworkDriveURI (qemu_command.c:781)
==1812==    by 0x56E979A: qemuBuildNetworkDriveStr (qemu_command.c:859)
==1812==    by 0x56F3A0B: qemuBuildSCSIiSCSIHostdevDrvStr (qemu_command.c:4664)
==1812==    by 0x56F3D1F: qemuBuildSCSIHostdevDrvStr (qemu_command.c:4732)
==1812==    by 0x56F57F7: qemuBuildHostdevCommandLine (qemu_command.c:5337)
==1812==    by 0x570303A: qemuBuildCommandLine (qemu_command.c:10376)
==1812==    by 0x57604EE: qemuProcessCreatePretendCmd (qemu_process.c:6649)
==1812==    by 0x11352A: testCompareXMLToArgv (qemuxml2argvtest.c:566)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-07-09 13:07:30 +02:00
Daniel P. Berrangé
1bc1a7e320 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>
2018-07-06 14:08:05 +01:00
Daniel P. Berrangé
ed5aa85f37 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>
2018-07-06 10:07:47 +01:00
Daniel P. Berrangé
0140d4c59b 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>
2018-07-06 10:07:47 +01:00
Daniel P. Berrangé
4c76266bac 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>
2018-07-06 10:07:47 +01:00
Michal Privoznik
2647a36367 qemuDomainNestedJobAllowed: Allow QEMU_JOB_NONE
https://bugzilla.redhat.com/show_bug.cgi?id=1598084

When creating a snapshot with --quiesce an async job is grabbed
and just before executing guest fs-freeze command an agent job is
grabbed. This is achieved by calling

  qemuDomainObjBeginJobInternal(job = QEMU_JOB_NONE,
                                agentJob = QEMU_AGENT_JOB_MODIFY);

Since there already is an async job set on the domain (by the
same thread) qemuDomainNestedJobAllowed(priv, job) is consulted
if @job is allowed by job mask. But this function returns false
(meaning sync @job is not allowed) which leads to a deadlock.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2018-07-04 13:56:29 +02:00
Anya Harter
7bdd06b4e1 qemu: move qemuDomainCCWAddrSetCreateFromDomain
from src/qemu/qemu_domain_address.c to src/conf/domain_addr.c
and rename to virDomainCCWAddressSetCreateFromDomain

(rename to have Address in full instead of Addr to follow
the naming convention of other virDomainCCWAddress functions)

Signed-off-by: Anya Harter <aharter@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-07-03 15:37:32 -04:00
Daniel P. Berrangé
b340c6c614 qemu: format serial and geometry on frontend disk device
Currently we format the serial, geometry and error policy on the -drive
backend argument.

QEMU added the ability to set serial and geometry on the frontend in
the 1.2 release deprecating use of -drive, with support being deleted
from -drive in 3.0.

We keep formatting error policy on -drive for now, because we don't
ahve support for that with -device for usb-storage just yet.

Note that some disk buses (sd) still don't support -device. Although
QEMU allowed these properties to be set on -drive for if=sd, they
have been ignored so we now report an error in this case.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-07-03 16:32:42 +01:00
Peter Krempa
33a475056f qemu: hotplug: Don't access srcPriv when it's not allocated
The private data of a virStorageSource which is backing an iSCSI hostdev
may be NULL if no authentication is present. The code handling the
hotplug would attempt to extract the authentication info stored in
'secinfo' without checking if it is allocated which resulted in a crash.

Here we opt the easy way to check if srcPriv is not NULL so that we
don't duplicate all the logic which selects whether the disk source has
a secret.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-07-03 16:42:14 +02:00
Michal Privoznik
8677a476c7 qemu: Remove unused bypassSecurityDriver from qemuOpenFileAs
This argument is not used anymore. The only function that is
passing non-NULL (qemuDomainSaveMemory) does not actually care
for the value (after 23087cfdb) and every other caller just
passes NULL anyway.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-07-03 15:09:08 +02:00
Daniel P. Berrangé
7ac08cc929 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>
2018-07-03 10:19:26 +01:00
Andrea Bolognani
d4c1117107 qemu: Format the HTM pSeries feature
This makes the feature fully operational.

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-07-03 09:47:01 +02:00
Andrea Bolognani
9f3b9100f3 conf: Parse and format the HTM pSeries feature
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-07-03 09:46:59 +02:00
Andrea Bolognani
755a5765ac qemu: Add capability for the HTM pSeries feature
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-07-03 09:46:52 +02:00
Peter Krempa
d802eb6ad1 qemu: domain: update only newly detected images in qemuDomainDetermineDiskChain
The processing code which prepares images should be executed really only
for the images which were detected. The code actually tried to update
the last user-specified layer as well. Thankfully we don't do anything
that would be a problem at this point.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-07-03 06:16:42 +02:00
Michal Privoznik
a6fbbce73e qemuDomainDeviceDefValidateNetwork: Check for range only if IP prefix set
https://bugzilla.redhat.com/show_bug.cgi?id=1515533

The @prefix attribute to <ip/> element for interface type user is
optional. Therefore, if left out it has value of zero in which
case we should not check whether it falls into <4, 27> range.
Otherwise we fail parsing domain XML for no good reason.

Broken by commit b62b8090b2.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-07-03 04:56:29 +02:00
Jiri Denemark
5f99821911 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>
2018-07-02 11:53:21 +02:00
Jiri Denemark
e05ed21623 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>
2018-07-02 11:52:30 +02:00
Michal Privoznik
cb7a4ac4fb 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>
2018-06-28 17:06:52 +02:00