diff --git a/migration-Extand-the-fdtable-in-the-incoming-phase-o.patch b/migration-Extand-the-fdtable-in-the-incoming-phase-o.patch new file mode 100644 index 0000000000000000000000000000000000000000..4d5084fca5efd23537021a67ec9372c6e7309247 --- /dev/null +++ b/migration-Extand-the-fdtable-in-the-incoming-phase-o.patch @@ -0,0 +1,72 @@ +From 7702ed79f226c7b42adfc9e741395c6af447a1d9 Mon Sep 17 00:00:00 2001 +From: libai +Date: Wed, 2 Apr 2025 20:14:10 +0800 +Subject: [PATCH] migration:Extand the fdtable in the incoming phase of + migration + +Perform the fdtable extension in advance to avoid time consumption +caused by triggering the fdtable extension during the migration downtime. + +Signed-off-by: libai +Signed-off-by: huangchengfei +--- + migration/migration.c | 29 +++++++++++++++++++++++++++++ + 1 file changed, 29 insertions(+) + +diff --git a/migration/migration.c b/migration/migration.c +index 3da2ed37f3..353b7c9a09 100644 +--- a/migration/migration.c ++++ b/migration/migration.c +@@ -121,6 +121,8 @@ + #define DEFAULT_MIGRATE_VCPU_DIRTY_LIMIT_PERIOD 1000 /* milliseconds */ + #define DEFAULT_MIGRATE_VCPU_DIRTY_LIMIT 1 /* MB/s */ + ++#define DEFAULT_FD_MAX 4096 ++ + static NotifierList migration_state_notifiers = + NOTIFIER_LIST_INITIALIZER(migration_state_notifiers); + +@@ -2196,6 +2198,31 @@ void migrate_del_blocker(Error *reason) + migration_blockers = g_slist_remove(migration_blockers, reason); + } + ++/* ++ * Kernel will expand the fatable allocated to the qemu process when ++ * the number of fds held by qemu process exceeds a power of 2 (starting from 64). ++ * Each expansion introduces tens of ms of latency due to RCU synchronization. ++ * The expansion is completed during qemu process initialization to avoid ++ * triggering this action during the migration downtime phase. ++ */ ++static void qemu_pre_extend_fdtable(void) ++{ ++ int buffer[DEFAULT_FD_MAX] = {0}; ++ int i; ++ ++ /* expand fdtable */ ++ for (i = 0; i < DEFAULT_FD_MAX; i++) { ++ buffer[i] = qemu_dup(STDIN_FILENO); ++ } ++ ++ /* close tmp fd */ ++ for (i = 0; i < DEFAULT_FD_MAX; i++) { ++ if (buffer[i] > 0) { ++ (void)qemu_close(buffer[i]); ++ } ++ } ++} ++ + void qmp_migrate_incoming(const char *uri, Error **errp) + { + Error *local_err = NULL; +@@ -2214,6 +2241,8 @@ void qmp_migrate_incoming(const char *uri, Error **errp) + return; + } + ++ qemu_pre_extend_fdtable(); ++ + qemu_start_incoming_migration(uri, &local_err); + + if (local_err) { +-- +2.41.0.windows.1 + diff --git a/qemu.spec b/qemu.spec index 18d10688a1022d00dcebc3c8ab0c6a21d0e2db81..0d466da64e2cc97d01857989d5406b56afcee97d 100644 --- a/qemu.spec +++ b/qemu.spec @@ -3,7 +3,7 @@ Name: qemu Version: 6.2.0 -Release: 108 +Release: 109 Epoch: 10 Summary: QEMU is a generic and open source machine emulator and virtualizer License: GPLv2 and BSD and MIT and CC-BY-SA-4.0 @@ -1183,6 +1183,8 @@ Patch1168: qapi-qom-Define-cache-enumeration-and-properties-for.patch Patch1169: hw-core-machine-smp-Initialize-caches_bitmap-before-.patch Patch1170: qemu-Support-specifying-the-cache-size-presented-to-.patch Patch1171: vdpa-Fix-dirty-page-bitmap-synchronization-not-done-.patch +Patch1172: qemu6.2.0-Add-trace-to-measure-hot-migrate-downtime.patch +Patch1173: migration-Extand-the-fdtable-in-the-incoming-phase-o.patch BuildRequires: flex BuildRequires: gcc @@ -1781,6 +1783,10 @@ getent passwd qemu >/dev/null || \ %endif %changelog +* Thu May 22 2025 - 10:6.2.0-109 +- migration:Extand the fdtable in the incoming phase of migration +- qemu6.2.0: Add trace to measure hot migrate downtime + * Wed May 14 2025 - 10:6.2.0-108 - vdpa:Fix dirty page bitmap synchronization not done after suspend for vdpa devices diff --git a/qemu6.2.0-Add-trace-to-measure-hot-migrate-downtime.patch b/qemu6.2.0-Add-trace-to-measure-hot-migrate-downtime.patch new file mode 100644 index 0000000000000000000000000000000000000000..06a1ea658ed57a9324dc5a669dedc6aca9e14f0d --- /dev/null +++ b/qemu6.2.0-Add-trace-to-measure-hot-migrate-downtime.patch @@ -0,0 +1,50 @@ +From fa02520b850839ece3c1df016f714db812c8b89e Mon Sep 17 00:00:00 2001 +From: Chengfei Huang +Date: Mon, 19 May 2025 18:44:01 +0800 +Subject: [PATCH] qemu6.2.0: Add trace to measure hot migrate downtime + +Add trace to measure hot migrate downtime + +Signed-off-by: Chengfei Huang +--- + softmmu/cpus.c | 3 +++ + softmmu/trace-events | 2 ++ + 2 files changed, 5 insertions(+) + +diff --git a/softmmu/cpus.c b/softmmu/cpus.c +index 3f61a3c31d..38bae59024 100644 +--- a/softmmu/cpus.c ++++ b/softmmu/cpus.c +@@ -259,6 +259,8 @@ static int do_vm_stop(RunState state, bool send_stop) + runstate_set(state); + cpu_disable_ticks(); + pause_all_vcpus(); ++ trace_all_vcpus_paused(); ++ + vm_state_notify(0, state); + if (send_stop) { + qapi_event_send_stop(); +@@ -694,6 +696,7 @@ int vm_prepare_start(void) + cpu_enable_ticks(); + runstate_set(RUN_STATE_RUNNING); + vm_state_notify(1, RUN_STATE_RUNNING); ++ trace_all_vcpus_prepared(); + return 0; + } + +diff --git a/softmmu/trace-events b/softmmu/trace-events +index 22606dc27b..998d870fe2 100644 +--- a/softmmu/trace-events ++++ b/softmmu/trace-events +@@ -23,6 +23,8 @@ global_dirty_changed(unsigned int bitmask) "bitmask 0x%"PRIx32 + + # softmmu.c + vm_stop_flush_all(int ret) "ret %d" ++all_vcpus_paused(void) "" ++all_vcpus_prepared(void) "" + + # vl.c + vm_state_notify(int running, int reason, const char *reason_str) "running %d reason %d (%s)" +-- +2.41.0.windows.1 +