Commit Graph

46030 Commits

Author SHA1 Message Date
Jiri Denemark
8ede853a9f qemu: Introduce qemuMigrationDstFinishFresh
Refactors qemuMigrationDstFinish by moving some parts to a dedicated
function for easier introduction of postcopy resume code without
duplicating common parts of the Finish phase. The goal is to have the
following call graph:

    - qemuMigrationDstFinish
        - qemuMigrationDstFinishOffline
        - qemuMigrationDstFinishActive
            - qemuMigrationDstFinishFresh
            - qemuMigrationDstFinishResume

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2022-06-07 17:40:20 +02:00
Jiri Denemark
3865596cf9 qemu: Preserve error in qemuMigrationDstFinish
We want to prevent our error path that can potentially kill the domain
on the destination host from overwriting an error reported earlier, but
we were only doing so in one specific path when starting vCPUs fails.
Let's do it in all paths.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2022-06-07 17:40:20 +02:00
Jiri Denemark
ea08483e7d qemu: Drop obsolete comment in qemuMigrationDstFinish
The comment about QEMU < 0.10.6 has been irrelevant for years.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-06-07 17:40:20 +02:00
Jiri Denemark
c41edf420b qemu: Make final part of migration Finish phase reusable
By separating it into a dedicated qemuMigrationDstComplete function
which can be later called in other places.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2022-06-07 17:40:20 +02:00
Jiri Denemark
c542432357 qemu: Generate migration cookie in Finish phase earlier
The final part of Finish phase will be refactored into a dedicated
function and we don't want to generate the cookie there.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2022-06-07 17:40:20 +02:00
Jiri Denemark
6bb40ef6b1 qemu: Rename "endjob" label in qemuMigrationDstFinish
Let's call it "error" so that it's clear the label is only used in
failure path.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2022-06-07 17:40:20 +02:00
Jiri Denemark
5eb956e284 qemu: Separate success and failure path in qemuMigrationDstFinish
Most of the code in "endjob" label is executed only on failure. Let's
duplicate the rest so that the label can be used only in error path
making the success path easier to follow and refactor.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2022-06-07 17:40:20 +02:00
Jiri Denemark
4cd9b5cdb8 qemu: Move success-only code out of endjob in qemuMigrationDstFinish
Code executed only when dom != NULL can be moved before "endjob" label,
to the only place where dom is set.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2022-06-07 17:40:20 +02:00
Jiri Denemark
b85eed31a5 qemu: Create domain object at the end of qemuMigrationDstFinish
We don't need the object until we get to the "endjob" label.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2022-06-07 17:40:20 +02:00
Jiri Denemark
73b81fc55f qemu: Add support for postcopy-recover QEMU migration state
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-06-07 17:40:20 +02:00
Jiri Denemark
5dd2d11ec0 qemu: Handle 'postcopy-paused' migration state
When connection breaks during post-copy migration, QEMU enters
'postcopy-paused' state. We need to handle this state and make the
situation visible to upper layers.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-06-07 17:40:20 +02:00
Jiri Denemark
458fa0e2bf qemu: Use switch in qemuProcessHandleMigrationStatus
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-06-07 17:40:20 +02:00
Jiri Denemark
425886ea99 qemu: Fetch paused migration stats
Even though a migration is paused, we still want to see the amount of
data transferred so far and that the migration is indeed not progressing
any further.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2022-06-07 17:40:20 +02:00
Jiri Denemark
918c14ee06 qemu: Don't wait for migration job when migration is running
Migration is a job which takes some time and if it succeeds, there's
nothing to call another migration on. If a migration fails, it might
make sense to rerun it with different arguments, but this would only be
done once the first migration fails rather than while it is still
running.

If this was not enough, the migration job now stays active even if
post-copy migration fails and anyone possibly retrying the migration
would be waiting for the job timeout just to get a suboptimal error
message.

So let's special case getting a migration job when another one is
already active.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2022-06-07 17:40:20 +02:00
Jiri Denemark
96db9dcfe9 qemu: Drop forward declarations in migration code
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2022-06-07 17:40:20 +02:00
Jiri Denemark
7c36e5004c qemu: Restore async job start timestamp on reconnect
Jobs that are supposed to remain active even when libvirt daemon
restarts were reported as started at the time the daemon was restarted.
This is not very helpful, we should restore the original timestamp.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-06-07 17:40:20 +02:00
Jiri Denemark
013d3091e0 qemu: Restore failed migration job on reconnect
Since we keep the migration job active when post-copy migration fails,
we need to restore it when reconnecting to running domains.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2022-06-07 17:40:20 +02:00
Jiri Denemark
c2f6a6a726 qemu: Abort failed post-copy when we haven't called Finish yet
When migration fails after it already switched to post-copy phase on the
source, but early enough that we haven't called Finish on the
destination yet, we know the vCPUs were not started on the destination
and the source host still has a complete state of the domain. Thus we
can just ignore the fact post-copy phase started and normally abort the
migration and resume vCPUs on the source.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2022-06-07 17:40:20 +02:00
Jiri Denemark
88a59fbbf3 qemu: Keep migration job active after failed post-copy
When post-copy migration fails, we can't just abort the migration and
resume the domain on the source host as it is already running on the
destination host and no host has a complete state of the domain memory.
Instead of the current approach of just marking the domain on both ends
as paused/running with a post-copy failed sub state, we will keep the
migration job active (even though the migration API will return failure)
so that the state is more visible and we can better control what APIs
can be called on the domains and even allow for resuming the migration.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2022-06-07 17:40:20 +02:00
Jiri Denemark
6637880b3c qemu: Add qemuDomainObjRestoreAsyncJob
The code for setting up a previously active backup job in
qemuProcessRecoverJob is generalized into a dedicated function so that
it can be later reused in other places.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2022-06-07 17:40:20 +02:00
Jiri Denemark
d6d1c4980d qemu: Rename qemuDomainObjRestoreJob as qemuDomainObjPreserveJob
It is used for saving job out of domain object. Just like
virErrorPreserveLast is used for errors. Let's make the naming
consistent as Restore would suggest different semantics.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2022-06-07 17:40:20 +02:00
Jiri Denemark
7c1840fa37 qemu: Introduce qemuProcessCleanupMigrationJob
The function can be used as a callback for qemuDomainCleanupAdd to
automatically clean up a migration job when a domain is destroyed.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2022-06-07 17:40:20 +02:00
Jiri Denemark
83ccd3a3d1 conf: Introduce virDomainObjIsPostcopy helper
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2022-06-07 17:40:20 +02:00
Jiri Denemark
efe95fb878 conf: Introduce virDomainObjIsFailedPostcopy helper
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2022-06-07 17:40:20 +02:00
Jiri Denemark
6ca0ff90ac qemu: Make qemuDomainCleanupAdd return void
The function never returns anything but zero.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2022-06-07 17:40:20 +02:00
Jiri Denemark
3abe9c496c qemu: Explicitly emit events on post-copy failure
The events would normally be triggered only if we're changing domain
state. But most of the time the domain is already in the right state and
we're just changing its substate from {PAUSED,RUNNING}_POSTCOPY to
*_POSTCOPY_FAILED. Let's emit lifecycle events explicitly when post-copy
migration fails to make the failure visible without polling.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2022-06-07 17:40:20 +02:00
Jiri Denemark
13b43c22b7 qemu: Keep domain running on dst on failed post-copy migration
There's no need to artificially pause a domain when post-copy fails
from our point of view unless QEMU connection is broken too as migration
may still be progressing well.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-06-07 17:40:20 +02:00
Jiri Denemark
aab9d64d4d Introduce VIR_DOMAIN_RUNNING_POSTCOPY_FAILED
This new "post-copy failed" reason for the running state will be used on
the destination host when post-copy migration fails while the domain is
already running there.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-06-07 17:40:20 +02:00
Jiri Denemark
8cd5edfdfe qemumonitorjsontest: Test more migration capabilities
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2022-06-07 17:40:19 +02:00
Jiri Denemark
8d00f3e801 qemu: Add debug messages to job recovery code
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2022-06-07 17:40:19 +02:00
Göran Uddeborg
fe67380b20 Translated using Weblate (Swedish)
Currently translated at 34.5% (3601 of 10431 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/sv/

Translated using Weblate (Swedish)

Currently translated at 34.1% (3561 of 10431 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/sv/

Co-authored-by: Göran Uddeborg <goeran@uddeborg.se>
Signed-off-by: Göran Uddeborg <goeran@uddeborg.se>
2022-06-07 16:50:32 +02:00
Peng Liang
b2297edc05 storage_file: Remove unused includes
Signed-off-by: Peng Liang <tcx4c70@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-06-07 16:16:48 +02:00
Peng Liang
32b11c49e6 security: Remove unused includes
Signed-off-by: Peng Liang <tcx4c70@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-06-07 16:07:00 +02:00
Peng Liang
c701575d8b secret: Remove unused includes
Signed-off-by: Peng Liang <tcx4c70@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-06-07 16:07:00 +02:00
Peng Liang
c666bb7929 nwfilter: Remove unused includes
Signed-off-by: Peng Liang <tcx4c70@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-06-07 16:04:21 +02:00
Peng Liang
72593eac93 interface: Remove unused includes
Signed-off-by: Peng Liang <tcx4c70@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-06-07 16:04:21 +02:00
Ján Tomko
4539530034 docs: contact: recommend the TLS port for IRC
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-06-07 15:22:32 +02:00
Peter Krempa
0e3f42b834 qemucapabilitiestest: Update latest caps to 'v7.0.0-1512-gca127b3fc2'
Notable changes:

 - Icelake-Client cpu model family removed:
     "Icelake-Client-noTSX-x86_64-cpu"
     "Icelake-Client-v1-x86_64-cpu"
     "Icelake-Client-v2-x86_64-cpu"
     "Icelake-Client-v3-x86_64-cpu"
     "Icelake-Client-x86_64-cpu"

 - 'zero-copy-send' migration feature added

 - display 'sdl' qapified

 - 'arch-lbr' cpu feature added

 - new HyperV enlightenments:
     'hv-tlbflush-ext'
     'hv-tlbflush-direct'
     'hv-emsr-bitmap'
     'hv-xmm-input'

 - 'none-machine' has two new properties:
     - "boot" described as "Boot configuration"
     - "memory" described as "Memory size configuration"

 - 'igd-passthrough-isa-bridge' is now Xen-only

 - CXL: Compute eXpress Link related devices:
      "CXL"
      "cxl-rp",
      "cxl-type3",
      "pxb-cxl",
      "pxb-cxl-bus",
      "pxb-cxl-host",

 - 'dma-translation' feature of 'intel-iommu'

 - 'vmcb-clean' cpu feature now migratable:
     - possibly due to host kernel upgrade
     - changes commandline generated for the 'cpu-host-model' case of
       qemuxml2argvtest

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-06-07 13:00:56 +02:00
Peter Krempa
95bd137216 qemu: Fix crash in qemuBuildDeviceCommandlineHandleOverrides
'STREQ' is used to compare the override alias with the device alias.
While the parser ensures that the override alias is non-NULL, the device
alias may be NULL and STREQ doesn't handle that.

Fixes: 38ab5c9ead
Resolves: https://gitlab.com/libvirt/libvirt/-/issues/321
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-06-06 10:41:38 +02:00
Peter Krempa
8d3a807a4a qemu: fd: Fix monitor usage of qemuFDPassDirectGetPath
We need to use the 'name' variable and just overwrite it with the FD
number when FDs are passed on the monitor. Otherwise we will read NULL
path if the FD is accessed before being passed on the monitor. The idea
of this helper is to simplify the monitor code so it would be
counterproductive to have other behaviour.

Fixes the following symptom:

 $ virsh attach-interface cd network default --model virtio
 error: Failed to attach interface
 error: internal error: unable to execute QEMU command 'netdev_add': File descriptor named '(null)' has not been found

Fixes: bca9047906
Resolves: https://gitlab.com/libvirt/libvirt/-/issues/318
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2092856
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-06-06 09:42:58 +02:00
Peter Krempa
a939d4d869 util: json: Add modifier for adding non-negative long values to JSON objects
Similarly to the 'k' modifier for integers introduce 'K' for long
integers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2022-06-03 10:09:04 +02:00
Göran Uddeborg
b0f473f49e Translated using Weblate (Swedish)
Currently translated at 33.3% (3481 of 10431 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/sv/

Co-authored-by: Göran Uddeborg <goeran@uddeborg.se>
Signed-off-by: Göran Uddeborg <goeran@uddeborg.se>
2022-06-02 22:18:44 +02:00
Michal Privoznik
8d2567bccf qemu: Restore label to temp file in qemuDomainScreenshot()
Obtaining a screenshot via virDomainScreenshot() works like this:
  1) we create a temp file, label it, then
  2) tell QEMU to store the screenshot into it, and
  3) finally, open the file for transfer via virStream

Since the file is just temporary and even explicitly unlinked at
the end, no seclabel restoration is done. This makes perfect
sense for security models which attach a label to file itself
(DAC, SELinux) because the label is gone with the file. However,
for models where a list of files and allowed actions is kept on a
side (AppArmor) this approach means we just append files into the
profile and never remove them. In turn, the file grows and policy
update takes longer with each entry.

Restore the seclabel for AppArmor's sake.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2022-06-02 17:03:43 +02:00
Michal Privoznik
215b2466cd virStorageSourceGetActualType: Change type of retval
The virStorageSourceGetActualType() function returns either
virStorageSource->type (which is of type virStorageType), or
virStorageSourcePoolDef->type, which really stores a value of the
same enum. Thus, the latter struct can be changed so that the
virStorageSourceGetActualType() function can return correct type
instead of generic int.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
2022-06-01 14:54:59 +02:00
Michal Privoznik
2307f06cb2 Drop needless typecast to virStorageType enum
There are three places (two in domain_conf.c and one in
qemu_migration.c) where a virStorageSource->type is typecasted to
virStorageType (for the purpose of catching missing enum member
in a switch() statement at compile time). This is needless,
because as of v8.2.0-rc1~120 the struct member is of proper type.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
2022-06-01 14:54:59 +02:00
Peter Krempa
0c4bdd835c schemas: Allow 'manual' snapshot mode in domain definition
Commit a1465e661e added the 'manual' disk snapshot mode documentation
but didn't allow it in the schema as default snapshot mode for a disk.

Add the needed value into the schema.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-06-01 12:27:10 +02:00
Peter Krempa
3299e00298 docs: domain: Remove extraneous quotes
Certain documentation bits tried to put a reference of a value into
quotes, but that's not needed for both the pure view of the rST source
and the rendered output.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-06-01 12:27:10 +02:00
Peter Krempa
24049c06d9 virNetMessageEncodePayloadEmpty: Replace by virNetMessageEncodePayloadRaw(msg, NULL, 0)
Replace the two outstanding invocations and remove the function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Claudio Fontana <cfontana@suse.de>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-06-01 12:27:10 +02:00
Peter Krempa
9a86592c4e virNetMessageEncodePayloadRaw: Tolerate empty 'data'
'virNetMessageEncodePayloadRaw' is not supposed to be called with 'NULL'
data, but the code path from 'virNetClientStreamSendPacket' does so.

Now 'virNetMessageEncodePayloadEmpty' is intended for such case, but
since it's just a sub-set of steps from 'virNetMessageEncodePayloadRaw'
it's more straightforward to add NULL-tolerance to 'virNetMessageEncodePayloadRaw'
and subsequently remove 'virNetMessageEncodePayloadEmpty'.

Closes: https://gitlab.com/libvirt/libvirt/-/issues/308
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Claudio Fontana <cfontana@suse.de>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-06-01 12:27:10 +02:00
Peter Krempa
00509d2d6a glibcompat: Provide proper override for 'g_hash_table_steal_extended'
We've emulated the function in virHashSteal, with a note pointing to use
the proper version. Move the code to glibcomapt.c and make it such that
builds using newer glib already use the new function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-06-01 12:27:10 +02:00