qemu-kvm/kvm-migration-Create-options.c.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

525 lines
13 KiB
Diff

From 282634a835f4711c8b501dd76c344058bc399fbd Mon Sep 17 00:00:00 2001
From: Juan Quintela <quintela@redhat.com>
Date: Wed, 1 Mar 2023 21:18:45 +0100
Subject: [PATCH 23/56] migration: Create options.c
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: [22/50] 10c9be528b9fcfae93f1a12fcd09db1a69e58f64 (peterx/qemu-kvm)
We move there all capabilities helpers from migration.c.
Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
Following David advise:
- looked through the history, capabilities are newer than 2012, so we
can remove that bit of the header.
- This part is posterior to Anthony.
Original Author is Orit. Once there,
I put myself. Peter Xu also did quite a bit of work here.
Anyone else wants/needs to be there? I didn't search too hard
because nobody asked before to be added.
What do you think?
(cherry picked from commit 1f0776f1c03312aad5d6a5f98871240bc3af01e5)
Signed-off-by: Peter Xu <peterx@redhat.com>
---
hw/virtio/virtio-balloon.c | 1 +
migration/block-dirty-bitmap.c | 1 +
migration/block.c | 1 +
migration/colo.c | 1 +
migration/meson.build | 1 +
migration/migration.c | 109 +----------------------------
migration/migration.h | 12 ----
migration/options.c | 124 +++++++++++++++++++++++++++++++++
migration/options.h | 32 +++++++++
migration/postcopy-ram.c | 1 +
migration/ram.c | 1 +
migration/savevm.c | 1 +
migration/socket.c | 1 +
13 files changed, 166 insertions(+), 120 deletions(-)
create mode 100644 migration/options.c
create mode 100644 migration/options.h
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
index 746f07c4d2..43092aa634 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
@@ -32,6 +32,7 @@
#include "qemu/error-report.h"
#include "migration/misc.h"
#include "migration/migration.h"
+#include "migration/options.h"
#include "hw/virtio/virtio-bus.h"
#include "hw/virtio/virtio-access.h"
diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c
index fe73aa94b1..a6ffae0002 100644
--- a/migration/block-dirty-bitmap.c
+++ b/migration/block-dirty-bitmap.c
@@ -79,6 +79,7 @@
#include "qapi/qapi-visit-migration.h"
#include "qapi/clone-visitor.h"
#include "trace.h"
+#include "options.h"
#define CHUNK_SIZE (1 << 10)
diff --git a/migration/block.c b/migration/block.c
index b2497bbd32..4b167fa5cf 100644
--- a/migration/block.c
+++ b/migration/block.c
@@ -28,6 +28,7 @@
#include "migration/vmstate.h"
#include "sysemu/block-backend.h"
#include "trace.h"
+#include "options.h"
#define BLK_MIG_BLOCK_SIZE (1ULL << 20)
#define BDRV_SECTORS_PER_DIRTY_CHUNK (BLK_MIG_BLOCK_SIZE >> BDRV_SECTOR_BITS)
diff --git a/migration/colo.c b/migration/colo.c
index 0716e64689..93b78c9270 100644
--- a/migration/colo.c
+++ b/migration/colo.c
@@ -36,6 +36,7 @@
#include "sysemu/cpus.h"
#include "sysemu/runstate.h"
#include "net/filter.h"
+#include "options.h"
static bool vmstate_loading;
static Notifier packets_compare_notifier;
diff --git a/migration/meson.build b/migration/meson.build
index 0d1bb9f96e..480ff6854a 100644
--- a/migration/meson.build
+++ b/migration/meson.build
@@ -22,6 +22,7 @@ softmmu_ss.add(files(
'migration.c',
'multifd.c',
'multifd-zlib.c',
+ 'options.c',
'postcopy-ram.c',
'savevm.c',
'socket.c',
diff --git a/migration/migration.c b/migration/migration.c
index 18058fb597..66ea55be06 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -63,6 +63,7 @@
#include "sysemu/cpus.h"
#include "yank_functions.h"
#include "sysemu/qtest.h"
+#include "options.h"
#define MAX_THROTTLE (128 << 20) /* Migration transfer speed throttling */
@@ -357,15 +358,6 @@ static void migrate_generate_event(int new_state)
}
}
-static bool migrate_late_block_activate(void)
-{
- MigrationState *s;
-
- s = migrate_get_current();
-
- return s->capabilities[MIGRATION_CAPABILITY_LATE_BLOCK_ACTIVATE];
-}
-
/*
* Send a message on the return channel back to the source
* of the migration.
@@ -2525,56 +2517,11 @@ void qmp_migrate_continue(MigrationStatus state, Error **errp)
qemu_sem_post(&s->pause_sem);
}
-bool migrate_release_ram(void)
-{
- MigrationState *s;
-
- s = migrate_get_current();
-
- return s->capabilities[MIGRATION_CAPABILITY_RELEASE_RAM];
-}
-
-bool migrate_postcopy_ram(void)
-{
- MigrationState *s;
-
- s = migrate_get_current();
-
- return s->capabilities[MIGRATION_CAPABILITY_POSTCOPY_RAM];
-}
-
bool migrate_postcopy(void)
{
return migrate_postcopy_ram() || migrate_dirty_bitmaps();
}
-bool migrate_auto_converge(void)
-{
- MigrationState *s;
-
- s = migrate_get_current();
-
- return s->capabilities[MIGRATION_CAPABILITY_AUTO_CONVERGE];
-}
-
-bool migrate_zero_blocks(void)
-{
- MigrationState *s;
-
- s = migrate_get_current();
-
- return s->capabilities[MIGRATION_CAPABILITY_ZERO_BLOCKS];
-}
-
-bool migrate_postcopy_blocktime(void)
-{
- MigrationState *s;
-
- s = migrate_get_current();
-
- return s->capabilities[MIGRATION_CAPABILITY_POSTCOPY_BLOCKTIME];
-}
-
bool migrate_use_compression(void)
{
MigrationState *s;
@@ -2620,33 +2567,6 @@ int migrate_decompress_threads(void)
return s->parameters.decompress_threads;
}
-bool migrate_dirty_bitmaps(void)
-{
- MigrationState *s;
-
- s = migrate_get_current();
-
- return s->capabilities[MIGRATION_CAPABILITY_DIRTY_BITMAPS];
-}
-
-bool migrate_ignore_shared(void)
-{
- MigrationState *s;
-
- s = migrate_get_current();
-
- return s->capabilities[MIGRATION_CAPABILITY_X_IGNORE_SHARED];
-}
-
-bool migrate_validate_uuid(void)
-{
- MigrationState *s;
-
- s = migrate_get_current();
-
- return s->capabilities[MIGRATION_CAPABILITY_VALIDATE_UUID];
-}
-
bool migrate_use_events(void)
{
MigrationState *s;
@@ -2665,15 +2585,6 @@ bool migrate_use_multifd(void)
return s->capabilities[MIGRATION_CAPABILITY_MULTIFD];
}
-bool migrate_pause_before_switchover(void)
-{
- MigrationState *s;
-
- s = migrate_get_current();
-
- return s->capabilities[MIGRATION_CAPABILITY_PAUSE_BEFORE_SWITCHOVER];
-}
-
int migrate_multifd_channels(void)
{
MigrationState *s;
@@ -2785,24 +2696,6 @@ bool migrate_use_block_incremental(void)
return s->parameters.block_incremental;
}
-bool migrate_background_snapshot(void)
-{
- MigrationState *s;
-
- s = migrate_get_current();
-
- return s->capabilities[MIGRATION_CAPABILITY_BACKGROUND_SNAPSHOT];
-}
-
-bool migrate_postcopy_preempt(void)
-{
- MigrationState *s;
-
- s = migrate_get_current();
-
- return s->capabilities[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT];
-}
-
/* migration thread support */
/*
* Something bad happened to the RP stream, mark an error
diff --git a/migration/migration.h b/migration/migration.h
index 04e0860b4e..a25fed6ef0 100644
--- a/migration/migration.h
+++ b/migration/migration.h
@@ -449,16 +449,7 @@ MigrationState *migrate_get_current(void);
bool migrate_postcopy(void);
-bool migrate_release_ram(void);
-bool migrate_postcopy_ram(void);
-bool migrate_zero_blocks(void);
-bool migrate_dirty_bitmaps(void);
-bool migrate_ignore_shared(void);
-bool migrate_validate_uuid(void);
-
-bool migrate_auto_converge(void);
bool migrate_use_multifd(void);
-bool migrate_pause_before_switchover(void);
int migrate_multifd_channels(void);
MultiFDCompression migrate_multifd_compression(void);
int migrate_multifd_zlib_level(void);
@@ -487,9 +478,6 @@ int migrate_compress_threads(void);
int migrate_compress_wait_thread(void);
int migrate_decompress_threads(void);
bool migrate_use_events(void);
-bool migrate_postcopy_blocktime(void);
-bool migrate_background_snapshot(void);
-bool migrate_postcopy_preempt(void);
/* Sending on the return path - generic and then for each message type */
void migrate_send_rp_shut(MigrationIncomingState *mis,
diff --git a/migration/options.c b/migration/options.c
new file mode 100644
index 0000000000..88a9a45913
--- /dev/null
+++ b/migration/options.c
@@ -0,0 +1,124 @@
+/*
+ * QEMU migration capabilities
+ *
+ * Copyright (c) 2012-2023 Red Hat Inc
+ *
+ * Authors:
+ * Orit Wasserman <owasserm@redhat.com>
+ * Juan Quintela <quintela@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "qemu/osdep.h"
+#include "migration.h"
+#include "options.h"
+
+bool migrate_auto_converge(void)
+{
+ MigrationState *s;
+
+ s = migrate_get_current();
+
+ return s->capabilities[MIGRATION_CAPABILITY_AUTO_CONVERGE];
+}
+
+bool migrate_background_snapshot(void)
+{
+ MigrationState *s;
+
+ s = migrate_get_current();
+
+ return s->capabilities[MIGRATION_CAPABILITY_BACKGROUND_SNAPSHOT];
+}
+
+bool migrate_dirty_bitmaps(void)
+{
+ MigrationState *s;
+
+ s = migrate_get_current();
+
+ return s->capabilities[MIGRATION_CAPABILITY_DIRTY_BITMAPS];
+}
+
+bool migrate_ignore_shared(void)
+{
+ MigrationState *s;
+
+ s = migrate_get_current();
+
+ return s->capabilities[MIGRATION_CAPABILITY_X_IGNORE_SHARED];
+}
+
+bool migrate_late_block_activate(void)
+{
+ MigrationState *s;
+
+ s = migrate_get_current();
+
+ return s->capabilities[MIGRATION_CAPABILITY_LATE_BLOCK_ACTIVATE];
+}
+
+bool migrate_pause_before_switchover(void)
+{
+ MigrationState *s;
+
+ s = migrate_get_current();
+
+ return s->capabilities[MIGRATION_CAPABILITY_PAUSE_BEFORE_SWITCHOVER];
+}
+
+bool migrate_postcopy_blocktime(void)
+{
+ MigrationState *s;
+
+ s = migrate_get_current();
+
+ return s->capabilities[MIGRATION_CAPABILITY_POSTCOPY_BLOCKTIME];
+}
+
+bool migrate_postcopy_preempt(void)
+{
+ MigrationState *s;
+
+ s = migrate_get_current();
+
+ return s->capabilities[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT];
+}
+
+bool migrate_postcopy_ram(void)
+{
+ MigrationState *s;
+
+ s = migrate_get_current();
+
+ return s->capabilities[MIGRATION_CAPABILITY_POSTCOPY_RAM];
+}
+
+bool migrate_release_ram(void)
+{
+ MigrationState *s;
+
+ s = migrate_get_current();
+
+ return s->capabilities[MIGRATION_CAPABILITY_RELEASE_RAM];
+}
+
+bool migrate_validate_uuid(void)
+{
+ MigrationState *s;
+
+ s = migrate_get_current();
+
+ return s->capabilities[MIGRATION_CAPABILITY_VALIDATE_UUID];
+}
+
+bool migrate_zero_blocks(void)
+{
+ MigrationState *s;
+
+ s = migrate_get_current();
+
+ return s->capabilities[MIGRATION_CAPABILITY_ZERO_BLOCKS];
+}
diff --git a/migration/options.h b/migration/options.h
new file mode 100644
index 0000000000..0dfa0af245
--- /dev/null
+++ b/migration/options.h
@@ -0,0 +1,32 @@
+/*
+ * QEMU migration capabilities
+ *
+ * Copyright (c) 2012-2023 Red Hat Inc
+ *
+ * Authors:
+ * Orit Wasserman <owasserm@redhat.com>
+ * Juan Quintela <quintela@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#ifndef QEMU_MIGRATION_OPTIONS_H
+#define QEMU_MIGRATION_OPTIONS_H
+
+/* capabilities */
+
+bool migrate_auto_converge(void);
+bool migrate_background_snapshot(void);
+bool migrate_dirty_bitmaps(void);
+bool migrate_ignore_shared(void);
+bool migrate_late_block_activate(void);
+bool migrate_pause_before_switchover(void);
+bool migrate_postcopy_blocktime(void);
+bool migrate_postcopy_preempt(void);
+bool migrate_postcopy_ram(void);
+bool migrate_release_ram(void);
+bool migrate_validate_uuid(void);
+bool migrate_zero_blocks(void);
+
+#endif
diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
index d7b48dd920..0711500036 100644
--- a/migration/postcopy-ram.c
+++ b/migration/postcopy-ram.c
@@ -37,6 +37,7 @@
#include "tls.h"
#include "qemu/userfaultfd.h"
#include "qemu/mmap-alloc.h"
+#include "options.h"
/* Arbitrary limit on size of each discard command,
* keeps them around ~200 bytes
diff --git a/migration/ram.c b/migration/ram.c
index 229714045a..912ccd89fa 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -57,6 +57,7 @@
#include "qemu/iov.h"
#include "multifd.h"
#include "sysemu/runstate.h"
+#include "options.h"
#include "hw/boards.h" /* for machine_dump_guest_core() */
diff --git a/migration/savevm.c b/migration/savevm.c
index 589ef926ab..ebcf571e37 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -67,6 +67,7 @@
#include "qemu/yank.h"
#include "yank_functions.h"
#include "sysemu/qtest.h"
+#include "options.h"
const unsigned int postcopy_ram_discard_version;
diff --git a/migration/socket.c b/migration/socket.c
index e6fdf3c5e1..ebf9ac41af 100644
--- a/migration/socket.c
+++ b/migration/socket.c
@@ -27,6 +27,7 @@
#include "io/net-listener.h"
#include "trace.h"
#include "postcopy-ram.h"
+#include "options.h"
struct SocketOutgoingArgs {
SocketAddress *saddr;
--
2.39.1