Commit Graph

21796 Commits

Author SHA1 Message Date
Jiri Denemark
748246f3f5 qemu: Implement virConnectCompareHypervisorCPU
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-28 15:58:05 +02:00
Jiri Denemark
bbe1ad5b6c remote: Implement virConnectCompareHypervisorCPU
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-28 15:58:05 +02:00
Jiri Denemark
24a41aa643 Introduce virConnectCompareHypervisorCPU public API
This new API compares the given CPU description with the CPU the
specified hypervisor is able to provide on the host. It is a more useful
version of virConnectCompareCPU, which compares the CPU definition with
the host CPU without considering any specific hypervisor and its
abilities.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Collin Walling <walling@linux.ibm.com>
2018-05-28 15:55:17 +02:00
Jiri Denemark
da3bfc9ffc qemu_capabilities: Introduce virQEMUCapsCacheLookupDefault
virConnectGetDomainCapabilities needs to lookup QEMU capabilities
matching a specified binary, architecture, virt type, and machine type
while using default values when any of the parameters are not provided
by the user. Let's extract the lookup code into
virQEMUCapsCacheLookupDefault to make it reusable.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-28 15:54:10 +02:00
Jiri Denemark
95ef9ceea4 Improve documentation of virConnectGetCPUModelNames
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Collin Walling <walling@linux.ibm.com>
Reviewed-by: Kashyap Chamarthy <kchamart@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-28 15:54:10 +02:00
Michal Privoznik
150d0930f8 qemu: Implement virDomainDetachDeviceAlias
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-28 13:08:52 +02:00
Michal Privoznik
5c81c342a7 qemu_hotplug: Allow asynchronous detach
The virDomainDetachDeviceAlias API is designed so that it only
sends detach request to qemu. It's user's responsibility to wait
for DEVICE_DELETED event, not libvirt's. Add @async flag to
qemuDomainDetach*Device() functions so that caller can chose if
detach is semi-synchronous (old virDomainDetachDeviceFlags()) or
fully asynchronous (new virDomainDetachDeviceFlags()).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-28 13:08:52 +02:00
Michal Privoznik
a7837f92cc qemuDomainDetachDeviceLiveAndConfig: Avoid overwriting @ret
The fact that we are overwriting @ret multiple times makes it
difficult to see what is actually happening here. Follow our
traditional pattern where @ret is initialized to -1, and set to 0
only in case we know we succeeded.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-28 13:08:51 +02:00
Michal Privoznik
604f3ff0c0 qemuDomainDetachDeviceLiveAndConfig: Don't use driver->caps directly
Funny, we obtain driver caps at the beginning of the function,
but then for unknown reason access driver->caps directly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-28 13:08:50 +02:00
Michal Privoznik
e73f6b4d66 qemu_hotplug: Use more gotos in qemuDomainDetach*Device
We are overwriting @ret a lot. It makes hard to see what is
actually going on. Use more gotos. Two functions are fixed here:
qemuDomainDetachShmemDevice() and qemuDomainDetachWatchdog().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-28 13:08:49 +02:00
Michal Privoznik
ee87e5de36 qemuDomainDetachWatchdog: Don't release watchdog address twice
On watchdog unplug, when qemu doesn't support DEVICE_DELETED event
(or couple of other reasons) we do two things:

1) release watchdog device address,
2) call qemuDomainRemoveWatchdog() which does 1) again.

This is potentially dangerous.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-28 13:08:45 +02:00
Michal Privoznik
c2fa7e7ffc qemuDomainDetachShmemDevice: Don't release shmem address twice
On shmem unplug, when qemu doesn't support DEVICE_DELETED event
(or couple of other reasons) we do two things:

1) release shmem device address,
2) call qemuDomainRemoveShmemDevice() which does 1) again.

This is potentially dangerous.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-28 13:08:44 +02:00
Michal Privoznik
aac088d998 qemuDomainRemoveChrDevice: Release device address
Instead of releasing address only sometimes in
qemuDomainDetachChrDevice() let's release it whenever the device
is actually removed from the domain definition.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-28 13:08:43 +02:00
Michal Privoznik
18f2e9d500 remote: Implement virDomainDetachDeviceAlias
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-28 13:08:41 +02:00
Michal Privoznik
007f500a23 Introduce virDomainDetachDeviceAlias API
When detaching a device it can be uniquely identified by its
alias. Instead of misusing virDomainDetachDeviceFlags which has
the same signature introduce new function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-28 13:08:38 +02:00
John Ferlan
e288080ae0 disk: Allow settling to occur after reading partitions
https://bugzilla.redhat.com/show_bug.cgi?id=1400475

In order to avoid a possible error as a result of kernel interactions
with the partition helper, let's use virWaitForDevices to force things
to settle down before attempting to open and read the partition. This
is related to https://bugzilla.redhat.com/show_bug.cgi?id=1264719.

Although perhaps overkill to have too many places to settle, since
we know that the act of reading the partitions via libvirt_parthelper
will cause udev activity/events - we just need to ensure udev has
been settled before proceding with usage of the device.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
2018-05-25 08:26:41 -04:00
John Ferlan
0f358fcdca domcaps: Add 'genid' to domain capabilities
Report domaincaps <features><genid supported='yes'/> if the guest
config accepts <genid/> or <genid>$GUID</genid>.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
2018-05-25 08:15:58 -04:00
John Ferlan
87973a45f9 qemu: Add VM Generation ID to qemu command line
https://bugzilla.redhat.com/show_bug.cgi?id=1149445

If the domain requests usage of the genid functionality,
then add the QEMU '-device vmgenid' to the command line
providing either the supplied or generated GUID value.

Add tests for both a generated and supplied GUID value.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
2018-05-25 08:15:58 -04:00
John Ferlan
c445abb52d qemu: Alter VM Generation ID for specific startup/launch transitions
Before we generate the command line for qemu, if the domain about to
be launched desires to utilize the VM Generation ID functionality, then
handle both the regenerating the GUID value for backup recovery (restore
operation) and the startup after snapshot as both require a new GUID to
be generated to allow the guest operating system to recognize the VM
is re-executing something that has already executed before.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
2018-05-25 08:15:47 -04:00
John Ferlan
3005002e0e qemu: Add VM Generation ID device capability
Add the query of the device objects for the vmgenid device

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
2018-05-25 08:04:57 -04:00
John Ferlan
b50efe97ad conf: Add VM Generation ID parse/format support
The VM Generation ID is a mechanism to provide a unique 128-bit,
cryptographically random, and integer value identifier known as
the GUID (Globally Unique Identifier) to the guest OS. The value
is used to help notify the guest operating system when the virtual
machine is executed with a different configuration.

This patch adds support for a new "genid" XML element similar to
the "uuid" element. The "genid" element can have two forms "<genid/>"
or "<genid>$GUID</genid>". If the $GUID is not provided, libvirt
will generate one and save it in the XML.

Since adding support for a generated GUID (or UUID like) value to
be displayed modifying the xml2xml test to include virrandommock.so
is necessary since it will generate a "known" value.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
2018-05-25 08:04:34 -04:00
Peter Krempa
dd943c741e qemu: domain: Use typecasted enum in qemuDomainDeviceDefPostParse
Rather than a lot of checks use a switch statement. This optimizes the
code as if one device is matched the rest will certainly not match.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-24 18:25:30 +02:00
Peter Krempa
43afdc3e3f qemu: domain: Extract panic device def post parse code
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-24 18:25:30 +02:00
Peter Krempa
9647a95c37 qemu: domain: Extract video device def post parse code
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-24 18:25:30 +02:00
Peter Krempa
91779733de qemu: domain: Extract network device def post parse code
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-24 18:25:30 +02:00
Peter Krempa
db4dd58d6c qemu: domain: Extract disk post parse code into a function
Later on, more stuff will be added so prevent the main function growing
out of control.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-24 18:25:30 +02:00
Peter Krempa
c49013f26c qemu: monitor: Remove diskSecretLookup monitor event
After the text monitor was deleted this event can't be triggered.
Remove it and all the unnecessary code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-23 15:44:13 +02:00
Peter Krempa
41f8888619 qemu: monitor: Remove dead code from text monitor
Remove all unused functions and cleanup headers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-23 15:44:13 +02:00
Peter Krempa
01d8a67449 qemu: monitor: Drop calls to text monitor impl where possible
Drop all conditional calls which have JSON variants, now that we
guarantee JSON monitor.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-23 15:44:13 +02:00
Peter Krempa
788d6376da qemu: monitor: Drop JSON versions of savevm/delvm/loadvm
qemu did not QAPIfy these and the design and name will most probably
change. The replacements will not be compatible. Drop the JSON stubs and
annotate that there won't be a replacement.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-23 15:44:10 +02:00
Peter Krempa
10bc01056b qemu: monitor: Drop QEMU_CHECK_MONITOR_JSON... macros
Monitor is now JSON only. Drop the old cruft.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-23 15:43:35 +02:00
Peter Krempa
58be5738fe qemu: monitor: Remove unused qemuMonitor(Add|Remove)HostNetwork
There are no callers for these. Remove them and the monitor
implementations.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-23 15:43:34 +02:00
Peter Krempa
b9571bc61b qemu: monitor: Drop fallback to text monitor for 'send-key' command
The QMP version was added in qemu commit e4c8f004c55d9da3eae3e14 which
is included in v1.3.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-23 15:43:34 +02:00
Peter Krempa
8f829a71b7 qemu: monitor: Drop fallback to text monitor for 'inject-nmi' command
The QMP version was added in qemu commit ab49ab5c488237f3656689 which
is included in v1.1.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-23 15:43:34 +02:00
Roland Schulz
e58739ad46 test driver: Make test capabilities report more hugepages per each NUMA node
Signed-off-by: Roland Schulz <schullzroll@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-05-23 15:27:40 +02:00
Peter Krempa
a8dc146a4d qemu: migration: Add support for transporting NBD over TLS
Implement the secure way to transport non-shared storage data across
migrations. The new approach uses blockdev-add to create the NBD client
so that the TLS secret object can be specified.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-23 13:18:25 +02:00
Peter Krempa
89ed82646c qemu: migration: Extract code responsible for calling drive-mirror
Separate the code relevant for this approach so that we can later add a
second implementation without making the function messy.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-23 13:18:25 +02:00
Peter Krempa
8bad8e7bf0 qemu: migration: Rename NBD migration functions
Drop the mention of 'drive mirror' from the function names and mention
NBD. This will help when adding the 'blockdev mirror' migration code
which will allow using TLS.

Additionally fix some of the function comments to make more sense

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-23 13:18:25 +02:00
Peter Krempa
93a3f9844f qemu: domain: Add private data for NBD migration storage source definition
Allow saving various aspects necessary to do NBD migration via blockdev
by storing a 'virStorageSource' in the disk private data meant to store
the NBD target of migration. Along with this add code to parse and
format it into the status XML.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-23 13:18:25 +02:00
Peter Krempa
35a8487ad9 qemu: domain: Extract parsing of NBD status XML
Extract the NBD portion of the 'job' status XML element parser into a
separate function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-23 13:18:25 +02:00
Peter Krempa
0d6ec712d3 qemu: domain: Extract NBD disk migration private data formatting
We will be adding source data to it so extract it to a separate function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-23 13:18:25 +02:00
Peter Krempa
ceb151b24b qemu: block: Add helpers for hot-adding virStorageSource via blockdev
These helpers add infrastructure which simplifies adding and rolling
back virStorageSources to a running qemu instance. Using of the helper
structure and separate functions allows for a much cleaner code in the
section dealing with the monitor.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-23 13:18:25 +02:00
Peter Krempa
d30fd1fc54 qemu: monitor: Introduce support for blockdev-mirror
drive-mirror allows only file targets. Introduce support for
blockdev-mirror that is able to copy to any BDS described by a node name
in qemu.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-23 13:18:25 +02:00
Peter Krempa
c7b66f2a59 qemu: monitor: Add implementation for blockdev-add and blockdev-del
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-23 13:18:25 +02:00
Peter Krempa
a6178a6610 qemu: monitor: Factor out and document code to format QMP command
Move formatting of the qemu command out of qemuMonitorJSONMakeCommandRaw
to qemuMonitorJSONMakeCommandInternal to allow greater reusability and
document the function better.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-23 13:18:25 +02:00
Peter Krempa
e969af4cec qemu: caps: Add capability for blockdev-add/blockdev-del
The capability also represents that 'blockdev-add' is functional. It's
necessary to detect it via presence of 'blockdev-del' since blockdev-add
did not have the unsupported 'x-blockdev-add' version previously and
thus would be marked as present even if we could not use it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-23 13:18:25 +02:00
Peter Krempa
d4e57c6f04 qemu: migration: Don't access disk members without lock
The initiation of a synchronous block job in the NBD storage migration
code was placed after entering the monitor thus after the lock on the VM
object was unlocked. Thankfully nothing bad could happen in this
situation since the migration job prevents any disk detaches or other
modifications of the domain object.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-23 13:18:23 +02:00
Peter Krempa
082266bf27 conf: domain: Export virDomainStorageSourceParse
It will be used when parsing the migration private data.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-23 13:18:23 +02:00
Peter Krempa
b8240fe704 qemu: block: Don't nest storage layer properties into format layer
Reference the storage via node name rather than inlining it. This is
the approach that will be used with -blockdev/blockdev-add since it
allows more control and is more future proof.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-23 13:18:23 +02:00
Filip Alac
3b8d050911 qemu: capabilities: Add 'hda-output' sound codec to capabilities
Signed-off-by: Filip Alac <filipalac@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2018-05-23 09:51:53 +02:00