Commit Graph

6815 Commits

Author SHA1 Message Date
Andrea Bolognani
b0f1c291a0 qemu: Add QEMU_CAPS_DEVICE_ISA_SERIAL
All serial devices shoule have an associated capability.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-11-28 15:51:33 +01:00
Pino Toscano
220c1f70dc qemu: switch s390/s390x default console back to serial
Now that <serial> and <console> on s390/s390x behave a bit more like the
other architectures, remove this extra differentation, and use sclp
console by default for new guests.  New virtio consoles can still be
added, and it is actually needed because of the limited number of
instances for sclp and sclplm.

This reverts commit b1c88c1476, whose
reasons are not totally clear.

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
2017-11-28 15:48:59 +01:00
Pino Toscano
21332bf658 conf: add VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP
Introduce specific a target types with two models for the console
devices (sclp and sclplm) used in s390 and s390x guests, so isa-serial
is no more used for them.

This makes <serial> usable on s390 and s390x guests, with at most only
a single sclpconsole and one sclplmconsole devices usable in a single
guest (due to limitations in QEMU, which will enforce already at
runtime).

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

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-11-28 15:46:34 +01:00
Andrea Bolognani
eccdcb81fc conf: Add target type and model for pl011
We can finally introduce a specific target model for the pl011 device
used by mach-virt guests, which means isa-serial will no longer show
up to confuse users.

We make sure migration works in both directions by interpreting the
isa-serial target type, or the lack of target type, appropriately
when parsing the guest XML, and skipping the newly-introduced type
when formatting if for migration. We also verify that pl011 is not
used for non-mach-virt guests and add a bunch of test cases.

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-11-28 15:46:34 +01:00
Andrea Bolognani
b342e94399 qemu: Support usb-serial and pci-serial on pSeries
The existing implementation set the address type for all serial
devices to spapr-vio, which made it impossible to use other devices
such as usb-serial and pci-serial; moreover, some decisions were
made based on the address type rather than the device type.

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-11-28 15:46:33 +01:00
Andrea Bolognani
c498a8921e conf: Add target type and model for spapr-vty
We can finally introduce a specific target model for the spapr-vty
device used by pSeries guests, which means isa-serial will no longer
show up to confuse users.

We make sure migration works in both directions by interpreting the
isa-serial target type, or the lack of target type, appropriately
when parsing the guest XML, and skipping the newly-introduced type
when formatting if for migration. We also verify that spapr-vty is
not used for non-pSeries guests and add a bunch of test cases.

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

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-11-28 15:46:33 +01:00
Andrea Bolognani
fa96d35242 qemu: Remove redundancy in qemuBuildSerialChrDeviceStr()
Instead duplicating the capability check for each possible target
model, introduce a small helper that matches the target model with
the corresponding capability and collapse all existing checks into
a single one.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-11-28 15:46:33 +01:00
Andrea Bolognani
7c76c30465 qemu: Format targetModel for serial devices
Now that we've created a distinction between target type and target
model, with the latter being the concrete device name, it's time to
switch to formatting the model instead of the type.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-11-28 15:46:33 +01:00
Andrea Bolognani
a9254a2d6e qemu: Validate target model for serial devices
Target model and target type must agree for the configuration
to make sense, so check that's actually the case and error out
otherwise.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-11-28 15:46:33 +01:00
Andrea Bolognani
72bf21f233 qemu: Set targetModel based on targetType for serial devices
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-11-28 15:46:33 +01:00
Andrea Bolognani
9ae116eadf qemu: Improve qemuDomainChrTargetDefValidate()
Instead of validating each target type / address type combination
separately, create a small helper to perform the matching and
collapse all existing checks into a single one.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-11-28 15:46:33 +01:00
Andrea Bolognani
81e14caf60 qemu: Introduce qemuDomainChrTargetDefValidate()
Instead of waiting until we get to command line generation, we can
validate the target for a char device much earlier.

Move all the checks out of qemuBuildSerialChrDeviceStr() and into
the new fuction. This will later allow us to validate the target
for platform devices.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-11-28 15:46:32 +01:00
Andrea Bolognani
6385c8c142 conf: Introduce VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE
This is the first step in getting rid of the assumption that
isa-serial is the default target type for serial devices.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-11-28 15:46:32 +01:00
Andrea Bolognani
f4b50cc1b9 qemu: Introduce qemuDomainChrDefPostParse()
Having a separate function for char device handling is better than
adding even more code to qemuDomainDeviceDefPostParse().

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
2017-11-28 15:46:31 +01:00
John Ferlan
c5c96545c7 qemu: Use secret objects to pass iSCSI passwords
https://bugzilla.redhat.com/show_bug.cgi?id=1425757

The blockdev-add code provides a mechanism to sanely provide user
and password-secret arguments for iscsi without placing them on the
command line to be viewable by a 'ps -ef' type command or needing
to create separate -iscsi devices for each disk/volume found.

So modify the iSCSI command line building to check for the presence
of the capability in order properly setup and use the domain master
secret object to encrypt the password in a secret object and alter
the parameters for the command line to utilize.

Modify the xml2argvtest to exhibit the syntax for both disk and
hostdev configurations.
2017-11-24 11:47:26 -05:00
John Ferlan
4f44b8b5ae qemu: Get capabilities to use iscsi password-secret argument
Detect the capability via the query-qmp-schema for blockdev-add
to find the 'password-secret' parameter that will allow the iSCSI
code to use the master secret object to encrypt the secret for an
and only need to provide the object id of the secret on the command
line thus obsfuscating the passphrase.
2017-11-24 11:47:26 -05:00
John Ferlan
8001c2f3e4 qemu: Refactor qemuBuildSCSIiSCSIHostdevDrvStr slightly
Rather than building the "file" string in qemuBuildSCSIHostdevDrvStr
build it in the called helper.
2017-11-24 11:47:26 -05:00
John Ferlan
1d9108cf16 qemu: Remove private hostdev
Since it's not longer used to shuttle the @secinfo, let's remove
the private hostdev completely.
2017-11-24 11:47:26 -05:00
John Ferlan
16eef5c2b4 qemu: Use private storage source for iscsi instead of private hostdev
Rather than placing/using privateData about secinfo in the hostdev,
let's use the virStorageSource private data instead.
2017-11-24 11:47:26 -05:00
John Ferlan
626ea2d596 conf,qemu: Replace iscsisrc fields with virStorageSourcePtr
Rather than picking apart the two pieces we need/want (path, hosts,
and auth)- let's allocate/use a virStorageSourcePtr for iSCSI storage.

The end result is that qemuBuildSCSIiSCSIHostdevDrvStr doesn't need
to "fake" one for the qemuBuildNetworkDriveStr call.
2017-11-24 11:47:26 -05:00
Ján Tomko
2814f66f28 qemu: Properly label and create evdev on input device hotplug
Utilize all the newly introduced function to create the evdev node
and label it on hotplug and destroy it on hotunplug.

This was forgotten in commits bc9ffaf and 67486bb.

https://bugzilla.redhat.com/show_bug.cgi?id=1509866
2017-11-24 17:38:51 +01:00
Ján Tomko
c4c7a18c4b qemu: functions for dealing with input device namespaces and labels
Introudce functions that will let us create the evdevs in namespaces
and label the devices on input device hotplug/hotunplug.
2017-11-24 17:38:51 +01:00
Ján Tomko
f29612fd35 qemu: Introduce functions for input device cgroup manipulation
Export qemuSetupInputCgroup and introduce qemuTeardownInputCgroup
for hotunplug.
2017-11-24 17:38:51 +01:00
Ján Tomko
cbf4242db7 Introduce virDomainInputDefGetPath
Use it to denadify qemuDomainSetupInput.
2017-11-24 17:38:51 +01:00
Jason J. Herne
74fc32a955 s390: qemu-capabilities: Avoid error message when missing non-kvm host cpu info
Libvirt prints an error on startup when it is missing host cpu model
information for any queried qemu binary. On s390 we only have host cpu model
information for kvm enabled qemu instances. So when virt type is not kvm, this
is actually not an error on s390.

This patch adds virt type as a parameter to virQEMUCapsInitCPUModelS390, and a
new return code 2 for virQEMUCapsInitCPUModel and virQEMUCapsInitCPUModelS390.
If the virt type is not kvm then we skip printing the scary error message
and return 2 because this case is actually expected behavior. The new return
code is meant to differentiate between the failure case and the case where we
simply expect the cpu model information to be unattainable.

Signed-off-by: Jason J. Herne <jjherne@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-11-24 16:53:56 +01:00
Peter Krempa
1455a91b33 qemu: command: Properly format disk 'debug' attribute
Move the setup of the disk attribute to the disk source prepare function
which will allow proper usage with JSON props and move the fallback
(legacy) generating code into the block which is executed with legacy
options.

As a side-effect of this change we can clean up propagation of 'cfg'
into the command generator.

Also it's nice to see that the test output is the same even when the
value is generated in a different place.
2017-11-23 18:50:04 +01:00
Peter Krempa
be50137aa0 qemu: domain: Unify disk source prepare steps
Aggregate setup of various aspects of a disk source (secrets, TLS, ...)
into one function so that we don't need to call multiple across the code
base.
2017-11-23 18:50:04 +01:00
Peter Krempa
7aa8a9a621 qemu: hotplug: Rename qemuDomainPrepareDisk to qemuHotplugPrepareDiskAccess
Match the prefix of the file and choose a name which better describes
what happens.
2017-11-23 18:50:04 +01:00
Peter Krempa
eeaf6657f7 qemu: block: Add support for formatting gluster debug level via JSON
Improve the formatter so that we can use the 'debug' property straight
away when using json.
2017-11-23 18:50:04 +01:00
Peter Krempa
6197d5726b qemu: command: Inject password-secret only when not using JSON props
The 'file.password-secret' injection should be used only if we are using
the old formatter. When formatting the source string from the JSON
properties, the property should be added there.

Also drop the comment which refers to stuff that will not be used in
libvirt since -blockdev is the way to go.
2017-11-23 18:50:04 +01:00
Peter Krempa
28907b0043 qemu: command: Mark <shared/> disks as such in qemu
Qemu has now an internal mechanism for locking images to fix specific
cases of disk corruption. This requires libvirt to mark the image as
shared so that qemu lifts certain restrictions.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1378242
2017-11-23 18:26:48 +01:00
Peter Krempa
860a3c4bea qemu: caps: Add capability for 'share-rw' disk option
'share-rw' for the disk device configures qemu to allow concurrent
access to the backing storage.

The capability is checked in various supported disk frontend buses since
it does not make sense to partially backport it.
2017-11-23 18:26:48 +01:00
Peter Krempa
2b41c86294 qemu: Disallow pivot of shared disks to unsupported storage
Pivoting to a unsupported storage type might break the assumption that
shared disks will not corrupt metadata.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1511480
2017-11-23 18:26:48 +01:00
Peter Krempa
9b2fbfa6f6 qemu: snapshot: Disallow snapshot of unsupported shared disks
Creating a snapshot would introduce a possibly unsupported member for
sharing into the backing chain. Add a check to prevent that from
happening.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1511480
2017-11-23 18:26:48 +01:00
Peter Krempa
3b03a27cd0 qemu: domain: Reject shared disk access if backing format does not support it
Disk sharing between two VMs may corrupt the images if the format driver
does not support it. Check that the user declared use of a supported
storage format when they want to share the disk.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1511480
2017-11-23 18:26:25 +01:00
Peter Krempa
1fc3cd8731 qemu: block: Add function to check if storage source allows concurrent access
Storage source format backing a shared device (e.g. running a cluster
filesystem) needs to support the sharing so that metadata are not
corrupted. Add a central function for checking this.
2017-11-23 18:26:25 +01:00
Peter Krempa
85b0e2f126 qemu: domain: Refactor domain device validation function
Use a style that will discourage from adding inline checks.
2017-11-23 18:26:25 +01:00
Peter Krempa
ab948b6299 qemu: domain: Move video device validation into separate function 2017-11-23 18:26:25 +01:00
Peter Krempa
a6936ec098 qemu: domain: Move hostdev validation into separate function 2017-11-23 18:26:25 +01:00
Peter Krempa
577ccd07c3 qemu: domain: Despaghettify qemuDomainDeviceDefValidate
Move network device validation into a separate function.
2017-11-23 18:26:14 +01:00
Peter Krempa
8ffdeed455 qemu: Move snapshot disk validation functions into one
Move the code so that both the new image and old image can be verified
in the same function.
2017-11-23 18:22:19 +01:00
Michal Privoznik
97a051f0f8 qemu: Support setting NUMA distances
Since we already have such support for libxl all we need is qemu
driver adjustment. And a test case.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-11-23 14:54:32 +01:00
Michal Privoznik
13e148ebda qemu_capabilities: Introcude QEMU_CAPS_NUMA_DIST
This capability says if qemu is capable of specifying distances
between NUMA nodes on the command line. Unfortunately, there's no
real way to check this and thus we have to go with version check.
QEMU introduced this in 0f203430dd8 (and friend) which was
released in 2.10.0.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-11-23 14:54:31 +01:00
Jiri Denemark
96f7a045e9 qemu: Use the end of QEMU log for reporting errors
When QEMU dies, we read its output stored in a log file and use it for
reporting a hopefully useful error. However, virReportError will trim
the message to (VIR_ERROR_MAX_LENGTH - 1) characters, which means the
end of the log (which likely contains the error message we want to
report) may get lost. We should trim the beginning of the log instead.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-11-23 14:06:40 +01:00
Jiri Denemark
7e0cd26db4 qemu: Properly skip "char device redirected to" in QEMU log
When reading QEMU log for reporting it as an error message, we want to
skip "char device redirected to" line. However, this string is not
printed at the beginning of a line, which means STRPREFIX will never
find it.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-11-23 14:06:40 +01:00
Peter Krempa
9baf50c414 qemu: command: Anotate formatting of the frontend attributes with -drive
Explain that certain attributes formatted with -drive are in fact
attributes of the drive itself and not the storage backing it.
2017-11-22 20:37:36 +01:00
Peter Krempa
1bf4dfc02a qemu: command: Move formatting of disk io error policy from -drive
That's a disk frontend attribute. Move the code to a separate function
since it's non-trivial and call it from the frontend attribute
formatter.
2017-11-22 20:37:36 +01:00
Peter Krempa
3443fddfea qemu: command: Move disk trhottling argument building into a separate function
Isolate it from the other code.
2017-11-22 20:37:36 +01:00
Peter Krempa
55a5d71825 qemu: command: Refactor logic when formatting -drive
Move all logic depending on whether we are solely formatting -drive (no
-device along with it) into one block.
2017-11-22 20:37:36 +01:00
Peter Krempa
b9dfed787d qemu: command: Move around order of generating -drive arguments
Move together sections which are conditionaly executed depending on
whether -device will be used together with the -drive.
2017-11-22 20:37:36 +01:00