From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] applied: [PATCH qemu] fix dirty-bitmap state migration freeze
Date: Thu, 5 Nov 2020 19:40:46 +0100 [thread overview]
Message-ID: <20201105184046.576179-1-t.lamprecht@proxmox.com> (raw)
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 <t.lamprecht@proxmox.com>
---
...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 <s.reiter@proxmox.com>
---
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
reply other threads:[~2020-11-05 18:40 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201105184046.576179-1-t.lamprecht@proxmox.com \
--to=t.lamprecht@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox