From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 511DD66295 for ; Thu, 5 Nov 2020 19:40:53 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 47A5D1B845 for ; Thu, 5 Nov 2020 19:40:53 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 167A41B83B for ; Thu, 5 Nov 2020 19:40:52 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id D6D8E46040 for ; Thu, 5 Nov 2020 19:40:51 +0100 (CET) From: Thomas Lamprecht To: pve-devel@lists.proxmox.com Date: Thu, 5 Nov 2020 19:40:46 +0100 Message-Id: <20201105184046.576179-1-t.lamprecht@proxmox.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.115 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] applied: [PATCH qemu] fix dirty-bitmap state migration freeze X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Nov 2020 18:40:53 -0000 The idea in general is to migrate all the state, which is small for us, in a single step once. But, QEMU only calls save state if we return active true. Hardcoding is-active to return true, like done initially, makes the migration freeze, as QEMU thinks this is never done, and only stops calling us and finishes after a few seconds. So, add a state with an "active" boolean, set to true when initializing a migration, and set it to false when the state was saved. Signed-off-by: Thomas Lamprecht --- ...igrate-dirty-bitmap-state-via-savevm.patch | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/debian/patches/pve/0055-PVE-Migrate-dirty-bitmap-state-via-savevm.patch b/debian/patches/pve/0055-PVE-Migrate-dirty-bitmap-state-via-savevm.patch index 5a2e29e..b1eca48 100644 --- a/debian/patches/pve/0055-PVE-Migrate-dirty-bitmap-state-via-savevm.patch +++ b/debian/patches/pve/0055-PVE-Migrate-dirty-bitmap-state-via-savevm.patch @@ -15,11 +15,11 @@ Signed-off-by: Stefan Reiter --- include/migration/misc.h | 3 ++ migration/Makefile.objs | 1 + - migration/pbs-state.c | 92 ++++++++++++++++++++++++++++++++++++++++ + migration/pbs-state.c | 97 ++++++++++++++++++++++++++++++++++++++++ pve-backup.c | 1 + qapi/block-core.json | 9 +++- softmmu/vl.c | 1 + - 6 files changed, 106 insertions(+), 1 deletion(-) + 6 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 migration/pbs-state.c diff --git a/include/migration/misc.h b/include/migration/misc.h @@ -48,10 +48,10 @@ index 0fc619e380..20b3792599 100644 common-obj-$(CONFIG_RDMA) += rdma.o diff --git a/migration/pbs-state.c b/migration/pbs-state.c new file mode 100644 -index 0000000000..165895b488 +index 0000000000..c711498c3e --- /dev/null +++ b/migration/pbs-state.c -@@ -0,0 +1,92 @@ +@@ -0,0 +1,97 @@ +/* + * PBS (dirty-bitmap) state migration + */ @@ -63,6 +63,12 @@ index 0000000000..165895b488 +#include "migration/register.h" +#include "proxmox-backup-qemu.h" + ++typedef struct PBSState { ++ bool active; ++} PBSState; ++ ++static PBSState pbs_state; ++ +static void pbs_state_save_pending(QEMUFile *f, void *opaque, + uint64_t max_size, + uint64_t *res_precopy_only, @@ -70,9 +76,6 @@ index 0000000000..165895b488 + uint64_t *res_postcopy_only) +{ + /* we send everything in save_setup, so nothing is ever pending */ -+ *res_precopy_only = 0; -+ *res_compatible = 0; -+ *res_postcopy_only = 0; +} + +/* receive PBS state via f and deserialize, called on target */ @@ -106,20 +109,21 @@ index 0000000000..165895b488 + qemu_put_buffer(f, buf, buf_size); + + proxmox_free_state_buf(buf); ++ pbs_state.active = false; + return 0; +} + +static bool pbs_state_is_active(void *opaque) +{ -+ /* always active, i.e. we do our job for every migration, since there's no -+ * harm done if we just copy an empty buffer */ -+ return true; ++ // we need to be return active once, else .save_setup is never called, but, ++ // if we'd just would return true, we'd freeze the migration for ~ 5 - 10s ++ return pbs_state.active; +} + +static bool pbs_state_is_active_iterate(void *opaque) +{ + /* we don't iterate, everything is sent in save_setup */ -+ return false; ++ return pbs_state_is_active(opaque); +} + +static bool pbs_state_has_postcopy(void *opaque) @@ -140,9 +144,10 @@ index 0000000000..165895b488 + +void pbs_state_mig_init(void) +{ ++ pbs_state.active = true; + register_savevm_live("pbs-state", 0, 1, + &savevm_pbs_state_handlers, -+ NULL); ++ &pbs_state); +} diff --git a/pve-backup.c b/pve-backup.c index 1a2647e7a5..c12ff8bb61 100644 -- 2.20.1