Commit Graph

8062 Commits

Author SHA1 Message Date
Cole Robinson
0ba9786d8a qemu: Move <rng> validation out of qemu_command.c
Move the rng->model == VIRTIO check to parse time. This also
allows us to remove similar checks throughout the qemu driver

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-01-24 18:59:38 -05:00
Cole Robinson
6427bfc8b3 qemu: Move <memballoon> validation out of qemu_command.c
If we validate that memballoon is NONE|VIRTIO at parse time,
we can drop similar checks elsewhere in the qemu driver

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-01-24 18:59:38 -05:00
Cole Robinson
ea72bc65df conf: Add virDomainNetIsVirtioModel
This will be extended in the future, so let's simplify things by
centralizing the checks.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-01-24 18:59:38 -05:00
Eric Blake
7b6116fb89 qemu: improve compile-time check of qemuBlockjobState mapping
Asserting the value we set four lines earlier in qemuBlockjobState
doesn't buy us any safety (if the public header adds a value, we end
up skipping that value without the compiler warning us of our gap);
what we really want is to assert that the value auto-assigned by the
compiler matches the actual last value in the public headers (as was
done below for qemuBlockJobType).  Add useful comments while at it.

Signed-off-by: Eric Blake <eblake@redhat.com>
ACKed-by: Peter Krempa <pkrempa@redhat.com>
2019-01-23 16:20:25 -06:00
Peter Krempa
ab5d49d46c qemu: process: Handle all failure values for dimms in qemuProcessHandleAcpiOstInfo
Hanlde all the possible failure codes as per ACPI standard documented in
the function header.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-01-23 10:30:09 +01:00
Peter Krempa
f2f14e3f45 qemu: process: Improve documentation of values handled by qemuProcessHandleAcpiOstInfo
We forgot to document the specific fields for the 0x103 and 0x200
sources which are tied to device removal and device hotplug
respectively.

The value description is based on the ACPI 6.2A standard Table 6-207 and
Table 6-208. At the time of writing of this patch the standard can be
accessed e.g. at:

https://www.uefi.org/sites/default/files/resources/ACPI%206_2_A_Sept29.pdf

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-01-23 10:30:09 +01:00
Radoslaw Biernacki
8fac64db5e util: Fix for NULL dereference
The device xml parser code does not set "model" while parsing the
following XML:

  <interface type='hostdev'>
    <source>
      <address type='pci' domain='0x0002' bus='0x01' slot='0x00' function='0x2'/>
    </source>
  </interface>

The net->model can be NULL and therefore must be compared using
STREQ_NULLABLE instead of plain STREQ.

Fixes: ac47e4a622 (qemu: replace "def->nets[i]" with "net" and "def->sounds[i]" with "sound")
Fixes: c7fc151eec (qemu: assign virtio devices to PCIe slot when appropriate)
Signed-off-by: Radoslaw Biernacki <radoslaw.biernacki@linaro.org>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2019-01-23 10:18:36 +01:00
Ján Tomko
4fb769f5e0 qemu: error out when vnc vncTLSx509secretUUID is unsupported
Add a capability check to qemuDomainDefValidate and refuse to start
a domain with VNC graphics if the TLS secret was set in qemu.conf
and it's not supported.

Note that qemuDomainSecretGraphicsPrepare does not generate any
secret data if the capability is not present and qemuBuildTLSx509BackendProps
is not called at all.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2019-01-22 12:18:28 +01:00
Ján Tomko
2e2b0d69a9 qemu: add support for encrypted VNC TLS keys
Use the password stored in the secret driver under
the uuid specified by the vnc_tls_x509_secret_uuid
option in qemu.conf.

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2019-01-22 12:18:28 +01:00
Ján Tomko
2c5dd1ee4c qemu.conf: add vnc_tls_x509_secret_uuid
Add an option that lets the user specify the secret
that unlocks the server TLS key.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2019-01-22 12:18:28 +01:00
Ján Tomko
0b3fc37e61 qemu_process: fix debug message
Be generic instead of trying to enumerate all the involved
device types.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2019-01-22 12:18:28 +01:00
Ján Tomko
2c7791a869 qemu: prepare secret for the graphics upfront
Instead of hardcoding the TLS creds alias in
qemuBuildGraphicsVNCCommandLine, store it
in the domain private data.

Given that we only support one VNC graphics
and thus have only one alias per-domain,
this is overengineered, but it will allow us
to prepare the secret upfront when we start
supporting encrypted server TLS keys.

Note that the alias is not formatted anywhere
since we won't need to access it after domain
startup.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2019-01-22 12:18:28 +01:00
Ján Tomko
ea3c3f8846 qemu: add qemuDomainGraphicsPrivate data with a tlsAlias
Also introduce the necessary callbacks.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2019-01-22 12:18:28 +01:00
Ján Tomko
5de4d410a2 virQEMUDriverConfigLoadSWTPMEntry: use VIR_AUTOFREE
Switch the function to use VIR_AUTOFREE and VIR_AUTOPTR macros
to get rid of the cleanup section.

Requested-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-01-21 17:14:29 +01:00
Ján Tomko
784e690ecb virQEMUDriverConfigLoadSecurityEntry: use VIR_AUTOFREE
Switch the function to use VIR_AUTOFREE and VIR_AUTOPTR macros
to get rid of the cleanup section.

Requested-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-01-21 17:14:29 +01:00
Ján Tomko
2a33dc41bb virQEMUDriverConfigLoadNVRAMEntry: use VIR_AUTOFREE
Switch the function to use VIR_AUTOFREE and VIR_AUTOPTR macros
to get rid of the cleanup section.

Requested-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-01-21 17:14:29 +01:00
Ján Tomko
92e601d08c virQEMUDriverConfigLoadProcessEntry: use VIR_AUTOFREE
Switch the function to use VIR_AUTOFREE and VIR_AUTOPTR macros
to get rid of the cleanup section.

Requested-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-01-21 17:14:29 +01:00
Peter Krempa
f80eae8c2a qemu: command: Don't format image properties for empty -drive
If a -drive has no image, using image properties makes qemu whine that
they should not be used.

This patch stops formating cache/readonly/... for empty drives
for the pre-blockdev syntax. Unfortunately those parameters can't be
added later when inserting media, but on the other hand qemu will start
with an empty drive.

Since we already were able to start a VM with such config previously due
to qemu ignoring them I've opted just to skip formatting them.
Additionally with -blockdev support it will work as expected as the
image properties will be formatted when adding the image itself which is
not possible without it.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2019-01-21 17:04:26 +01:00
Laine Stump
40136bd316 qemu: fix i6300esb watchdog hotplug on Q35
When commit 361c8dc17 added support for hotplugging the i6300esb
watchdog device (first in libvirt-3.9.0), it accidentally contstructed
the commandline for the device_add command before allocating a PCI
address for the device. With no PCI address specified in the command,
the watchdog would simply be placed at the lowest unused PCI slot.

On a 440fx guest, this doesn't cause a problem, because libvirt's PCI
address allocation algorithm would most likely give the same address
anyway (usually a slot on pci-root), so nobody noticed the omission of
address from the command.

But on a Q35 guest, the lowest unused PCI slot is on pcie-root, which
doesn't support hotplug; libvirt knows enough to assign a PCI address
that is on a pcie-to-pci-bridge (because its slots *do* support
hotplug), but qemu doesn't, so if there is no PCI address in the
command, qemu just tries to plug the new device into pcie-root, and
fails because it doesn't support hotplug, e.g.:

  error: Failed to attach device from watchdog.xml
  error: internal error: unable to execute QEMU command 'device_add':
  Bus 'pcie.0' does not support hotplugging

The solution is simply to build the command string after assigning a
PCI address, not before.

Resolves: https://bugzilla.redhat.com/1666559
Signed-off-by: Laine Stump <laine@laine.org>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2019-01-18 14:12:02 -05:00
Wang Yechao
01ca4010d8 qemu: Assign device addresses earlier in qemuDomainAttachNetDevice
If code in the @actualType switch needs to have/know which PCI
Address is being used, then we must assign it earlier. In particular
a vhost-user device needs to call qemuDomainSupportsNicdev which
requires an address to be defined.

Signed-off-by: Wang Yechao <wang.yechao255@zte.com.cn>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2019-01-18 10:11:50 -05:00
Ján Tomko
e6df863294 qemu_conf: rename checkdefaultTLSx509certdir
Use defaultTLSx509certdirPresent for consistencty.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2019-01-18 12:55:07 +01:00
Ján Tomko
4079f47677 qemu_conf: split out virQEMUDriverConfigLoadDefaultTLSEntry
Split out parts of the config parsing code to make
the parent function easier to read.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2019-01-18 12:55:07 +01:00
Ján Tomko
cfe99a336d qemu_conf: split out virQEMUDriverConfigLoadVNCEntry
Split out parts of the config parsing code to make
the parent function easier to read.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2019-01-18 12:55:07 +01:00
Ján Tomko
53680aa379 qemu_conf: split out virQEMUDriverConfigLoadNographicsEntry
Split out parts of the config parsing code to make
the parent function easier to read.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2019-01-18 12:55:07 +01:00
Ján Tomko
da3dc5a382 qemu_conf: split out virQEMUDriverConfigLoadSPICEEntry
Split out parts of the config parsing code to make
the parent function easier to read.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2019-01-18 12:55:07 +01:00
Ján Tomko
a0ac0b913e qemu_conf: split out virQEMUDriverConfigLoadSpecificTLS
Split out parts of the config parsing code to make
the parent function easier to read.

This is the only patch that mixes various augeas entry
groups in one function.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2019-01-18 12:55:07 +01:00
Ján Tomko
de100ceddb qemu_conf: split out virQEMUDriverConfigLoadRemoteDisplayEntry
Split out parts of the config parsing code to make
the parent function easier to read.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2019-01-18 12:55:07 +01:00
Ján Tomko
1195e10b98 qemu_conf: split out virQEMUDriverConfigLoadSaveEntry
Split out parts of the config parsing code to make
the parent function easier to read.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2019-01-18 12:55:06 +01:00
Ján Tomko
0ebe4e60e6 qemu_conf: split out virQEMUDriverConfigLoadProcessEntry
Split out parts of the config parsing code to make
the parent function easier to read.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2019-01-18 12:55:06 +01:00
Ján Tomko
00063c2c95 qemu_conf: split out virQEMUDriverConfigLoadDeviceEntry
Split out parts of the config parsing code to make
the parent function easier to read.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2019-01-18 12:55:06 +01:00
Ján Tomko
e79e0cacc5 qemu_conf: split out virQEMUDriverConfigLoadRPCEntry
Split out parts of the config parsing code to make
the parent function easier to read.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2019-01-18 12:55:06 +01:00
Ján Tomko
a780ee8ab5 qemu_conf: split out virQEMUDriverConfigLoadNetworkEntry
Split out parts of the config parsing code to make
the parent function easier to read.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2019-01-18 12:55:06 +01:00
Ján Tomko
f78c3dde57 qemu_conf: split out virQEMUDriverConfigLoadLogEntry
Split out parts of the config parsing code to make
the parent function easier to read.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2019-01-18 12:55:06 +01:00
Ján Tomko
627595641d qemu_conf: split out virQEMUDriverConfigLoadNVRAMEntry
Split out parts of the config parsing code to make
the parent function easier to read.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2019-01-18 12:55:06 +01:00
Ján Tomko
fad7036ad4 qemu_conf: split out virQEMUDriverConfigLoadGlusterDebugEntry
Split out parts of the config parsing code to make
the parent function easier to read.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2019-01-18 12:55:05 +01:00
Ján Tomko
632dab43b4 qemu_conf: split out virQEMUDriverConfigLoadSecurityEntry
Split out parts of the config parsing code to make
the parent function easier to read.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2019-01-18 12:55:05 +01:00
Ján Tomko
6427aca725 qemu_conf: split out virQEMUDriverConfigLoadMemoryEntry
Split out parts of the config parsing code to make
the parent function easier to read.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2019-01-18 12:55:05 +01:00
Ján Tomko
d447293893 qemu_conf: split out virQEMUDriverConfigLoadSWTPMEntry
Split out parts of the config parsing code to make
the parent function easier to read.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2019-01-18 12:55:05 +01:00
Peter Krempa
b70fb35d81 qemu: process: Use enum belonging to correct type
GCC was unhappy about comparison between two distinct enum types. Use
the correct value instead.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2019-01-18 08:39:40 +01:00
Peter Krempa
4ab8447af7 qemu: blockjob: Add job name into the data
Currently the job name corresponds to the disk the job belongs to. For
jobs which will not correspond to disks we'll need to track the name
separately.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-01-17 17:12:51 +01:00
Peter Krempa
dfe11a705c qemu: blockjob: Convert qemuBlockJobSyncEndDisk to take job instead of disk
And rename it in accordance with the change.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-01-17 17:12:50 +01:00
Peter Krempa
e5f704c971 qemu: migration: Don't call qemuBlockJobSyncEndDisk when block job has terminated
Now that the data is per-job, we don't really need to bother with
finishing the synchronous job handling if the job is already terminated.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-01-17 17:12:50 +01:00
Peter Krempa
a54acc8570 qemu: Allocate diskPriv->blockjob only when there's a blockjob
Rather than storing the presence of the blockjob in a flag we can bind
together the lifecycle of the job with the lifecycle of the object which
is tracking the data for it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-01-17 17:12:50 +01:00
Peter Krempa
103a4245ae qemu: blockjob: Pass job into qemuBlockJobUpdateDisk and rename it
Instead of passing in the disk information, pass in the job and name the
function accordingly.

Few callers needed to be modified to have the job pointer handy.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-01-17 17:12:50 +01:00
Peter Krempa
c257352797 qemu: blockjob: Consume new block job state in the processing function
The processing function modifies the job state so it should make sure
that the variable holding the new state is cleared properly and not the
caller. The caller should only deal with the job state and not the
transition that happened.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-01-17 17:12:50 +01:00
Peter Krempa
8ca9fcec24 qemu: blockjob: Remove error propagation from qemuBlockJobUpdateDisk
The job error can be safely accessed in the job structure, so we don't
need to propagate it through qemuBlockJobUpdateDisk.

Drop the propagation and refactor any caller that pased non-NULL error.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-01-17 17:12:50 +01:00
Peter Krempa
10c99feb05 qemu: migration: Extract reporting of disk migration error
The same message is reported in 3 distinct places. Move it out into a
single function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-01-17 17:12:50 +01:00
Peter Krempa
d1a44634ac qemu: blockjob: Track current state of blockjob
Add a field tracking the current state of job so that it can be queried
later. Until now the job state e.g. that the job is _READY for
finalizing was tracked only for mirror jobs. Add tracking of state for
all jobs.

Similarly to 'qemuBlockJobType' this maps the existing states of the
blockjob from virConnectDomainEventBlockJobStatus to
'qemuBlockJobState' so that we can track some internal states as well.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-01-17 17:12:50 +01:00
Peter Krempa
728830be9b qemu: blockjob: Convert qemuBlockJobSyncBeginDisk to work with the job
Modify qemuBlockJobSyncBeginDisk to operate on qemuBlockt sJobDataPtr and
rename it accordingly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-01-17 17:12:50 +01:00
Peter Krempa
0ba9afc6b2 qemu: blockjob: Pass in job to qemuBlockJobEventProcessLegacy
Don't split out individual fields, just pass in the job.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-01-17 17:12:50 +01:00