qemu-kvm/kvm-migration-postcopy-Detect-file-system-on-dest-host.patch
Miroslav Rezanina 6ee9df2871 * Mon May 22 2023 Miroslav Rezanina <mrezanin@redhat.com> - 8.0.0-4
- kvm-migration-Attempt-disk-reactivation-in-more-failure-.patch [bz#2058982]
- kvm-util-mmap-alloc-qemu_fd_getfs.patch [bz#2057267]
- kvm-vl.c-Create-late-backends-before-migration-object.patch [bz#2057267]
- kvm-migration-postcopy-Detect-file-system-on-dest-host.patch [bz#2057267]
- kvm-migration-mark-mixed-functions-that-can-suspend.patch [bz#2057267]
- kvm-postcopy-ram-do-not-use-qatomic_mb_read.patch [bz#2057267]
- kvm-migration-remove-extra-whitespace-character-for-code.patch [bz#2057267]
- kvm-migration-Merge-ram_counters-and-ram_atomic_counters.patch [bz#2057267]
- kvm-migration-Update-atomic-stats-out-of-the-mutex.patch [bz#2057267]
- kvm-migration-Make-multifd_bytes-atomic.patch [bz#2057267]
- kvm-migration-Make-dirty_sync_missed_zero_copy-atomic.patch [bz#2057267]
- kvm-migration-Make-precopy_bytes-atomic.patch [bz#2057267]
- kvm-migration-Make-downtime_bytes-atomic.patch [bz#2057267]
- kvm-migration-Make-dirty_sync_count-atomic.patch [bz#2057267]
- kvm-migration-Make-postcopy_requests-atomic.patch [bz#2057267]
- kvm-migration-Rename-duplicate-to-zero_pages.patch [bz#2057267]
- kvm-migration-Rename-normal-to-normal_pages.patch [bz#2057267]
- kvm-migration-rename-enabled_capabilities-to-capabilitie.patch [bz#2057267]
- kvm-migration-Pass-migrate_caps_check-the-old-and-new-ca.patch [bz#2057267]
- kvm-migration-move-migration_global_dump-to-migration-hm.patch [bz#2057267]
- kvm-spice-move-client_migrate_info-command-to-ui.patch [bz#2057267]
- kvm-migration-Create-migrate_cap_set.patch [bz#2057267]
- kvm-migration-Create-options.c.patch [bz#2057267]
- kvm-migration-Move-migrate_colo_enabled-to-options.c.patch [bz#2057267]
- kvm-migration-Move-migrate_use_compression-to-options.c.patch [bz#2057267]
- kvm-migration-Move-migrate_use_events-to-options.c.patch [bz#2057267]
- kvm-migration-Move-migrate_use_multifd-to-options.c.patch [bz#2057267]
- kvm-migration-Move-migrate_use_zero_copy_send-to-options.patch [bz#2057267]
- kvm-migration-Move-migrate_use_xbzrle-to-options.c.patch [bz#2057267]
- kvm-migration-Move-migrate_use_block-to-options.c.patch [bz#2057267]
- kvm-migration-Move-migrate_use_return-to-options.c.patch [bz#2057267]
- kvm-migration-Create-migrate_rdma_pin_all-function.patch [bz#2057267]
- kvm-migration-Move-migrate_caps_check-to-options.c.patch [bz#2057267]
- kvm-migration-Move-qmp_query_migrate_capabilities-to-opt.patch [bz#2057267]
- kvm-migration-Move-qmp_migrate_set_capabilities-to-optio.patch [bz#2057267]
- kvm-migration-Move-migrate_cap_set-to-options.c.patch [bz#2057267]
- kvm-migration-Move-parameters-functions-to-option.c.patch [bz#2057267]
- kvm-migration-Use-migrate_max_postcopy_bandwidth.patch [bz#2057267]
- kvm-migration-Move-migrate_use_block_incremental-to-opti.patch [bz#2057267]
- kvm-migration-Create-migrate_throttle_trigger_threshold.patch [bz#2057267]
- kvm-migration-Create-migrate_checkpoint_delay.patch [bz#2057267]
- kvm-migration-Create-migrate_max_cpu_throttle.patch [bz#2057267]
- kvm-migration-Move-migrate_announce_params-to-option.c.patch [bz#2057267]
- kvm-migration-Create-migrate_cpu_throttle_initial-to-opt.patch [bz#2057267]
- kvm-migration-Create-migrate_cpu_throttle_increment-func.patch [bz#2057267]
- kvm-migration-Create-migrate_cpu_throttle_tailslow-funct.patch [bz#2057267]
- kvm-migration-Move-migrate_postcopy-to-options.c.patch [bz#2057267]
- kvm-migration-Create-migrate_max_bandwidth-function.patch [bz#2057267]
- kvm-migration-Move-migrate_use_tls-to-options.c.patch [bz#2057267]
- kvm-migration-Move-qmp_migrate_set_parameters-to-options.patch [bz#2057267]
- kvm-migration-Allow-postcopy_ram_supported_by_host-to-re.patch [bz#2057267]
- kvm-block-bdrv-blk_co_unref-for-calls-in-coroutine-conte.patch [bz#2185688]
- kvm-block-Don-t-call-no_coroutine_fns-in-qmp_block_resiz.patch [bz#2185688]
- kvm-iotests-Use-alternative-CPU-type-that-is-not-depreca.patch [bz#2185688]
- kvm-iotests-Test-resizing-image-attached-to-an-iothread.patch [bz#2185688]
- kvm-Enable-Linux-io_uring.patch [bz#1947230]
- Resolves: bz#2058982
  (Qemu core dump if cut off nfs storage during migration)
- Resolves: bz#2057267
  (Migration with postcopy fail when vm set with shared memory)
- Resolves: bz#2185688
  ([qemu-kvm] no response with QMP command block_resize)
- Resolves: bz#1947230
  (Enable QEMU support for io_uring in RHEL9)
2023-05-22 01:24:31 -04:00

118 lines
4.2 KiB
Diff

From 4827d5be5357ab89e0c46f606ad828bf97d36471 Mon Sep 17 00:00:00 2001
From: Peter Xu <peterx@redhat.com>
Date: Wed, 19 Apr 2023 12:17:38 -0400
Subject: [PATCH 04/56] migration/postcopy: Detect file system on dest host
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
RH-Author: Peter Xu <peterx@redhat.com>
RH-MergeRequest: 162: migration: Pretty failures for postcopy on unsupported memory types
RH-Bugzilla: 2057267
RH-Acked-by: Leonardo Brás <leobras@redhat.com>
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
RH-Acked-by: quintela1 <quintela@redhat.com>
RH-Commit: [3/50] 121aeeda8a019f79dba6c077c7018bd1c86f3d71 (peterx/qemu-kvm)
Postcopy requires the memory support userfaultfd to work. Right now we
check it but it's a bit too late (when switching to postcopy migration).
Do that early right at enabling of postcopy.
Note that this is still only a best effort because ramblocks can be
dynamically created. We can add check in hostmem creations and fail if
postcopy enabled, but maybe that's too aggressive.
Still, we have chance to fail the most obvious where we know there's an
existing unsupported ramblock.
Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
(cherry picked from commit ae30b9b2892b85e6c3d5c0b8d1949c4d77a2954a)
Signed-off-by: Peter Xu <peterx@redhat.com>
---
migration/postcopy-ram.c | 34 ++++++++++++++++++++++++++++++----
1 file changed, 30 insertions(+), 4 deletions(-)
diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
index 93f39f8e06..bbb8af61ae 100644
--- a/migration/postcopy-ram.c
+++ b/migration/postcopy-ram.c
@@ -36,6 +36,7 @@
#include "yank_functions.h"
#include "tls.h"
#include "qemu/userfaultfd.h"
+#include "qemu/mmap-alloc.h"
/* Arbitrary limit on size of each discard command,
* keeps them around ~200 bytes
@@ -336,11 +337,12 @@ static bool ufd_check_and_apply(int ufd, MigrationIncomingState *mis)
/* Callback from postcopy_ram_supported_by_host block iterator.
*/
-static int test_ramblock_postcopiable(RAMBlock *rb, void *opaque)
+static int test_ramblock_postcopiable(RAMBlock *rb)
{
const char *block_name = qemu_ram_get_idstr(rb);
ram_addr_t length = qemu_ram_get_used_length(rb);
size_t pagesize = qemu_ram_pagesize(rb);
+ QemuFsType fs;
if (length % pagesize) {
error_report("Postcopy requires RAM blocks to be a page size multiple,"
@@ -348,6 +350,15 @@ static int test_ramblock_postcopiable(RAMBlock *rb, void *opaque)
"page size of 0x%zx", block_name, length, pagesize);
return 1;
}
+
+ if (rb->fd >= 0) {
+ fs = qemu_fd_getfs(rb->fd);
+ if (fs != QEMU_FS_TYPE_TMPFS && fs != QEMU_FS_TYPE_HUGETLBFS) {
+ error_report("Host backend files need to be TMPFS or HUGETLBFS only");
+ return 1;
+ }
+ }
+
return 0;
}
@@ -366,6 +377,7 @@ bool postcopy_ram_supported_by_host(MigrationIncomingState *mis)
struct uffdio_range range_struct;
uint64_t feature_mask;
Error *local_err = NULL;
+ RAMBlock *block;
if (qemu_target_page_size() > pagesize) {
error_report("Target page size bigger than host page size");
@@ -390,9 +402,23 @@ bool postcopy_ram_supported_by_host(MigrationIncomingState *mis)
goto out;
}
- /* We don't support postcopy with shared RAM yet */
- if (foreach_not_ignored_block(test_ramblock_postcopiable, NULL)) {
- goto out;
+ /*
+ * We don't support postcopy with some type of ramblocks.
+ *
+ * NOTE: we explicitly ignored ramblock_is_ignored() instead we checked
+ * all possible ramblocks. This is because this function can be called
+ * when creating the migration object, during the phase RAM_MIGRATABLE
+ * is not even properly set for all the ramblocks.
+ *
+ * A side effect of this is we'll also check against RAM_SHARED
+ * ramblocks even if migrate_ignore_shared() is set (in which case
+ * we'll never migrate RAM_SHARED at all), but normally this shouldn't
+ * affect in reality, or we can revisit.
+ */
+ RAMBLOCK_FOREACH(block) {
+ if (test_ramblock_postcopiable(block)) {
+ goto out;
+ }
}
/*
--
2.39.1