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 DAC1C96BDE for ; Thu, 26 Jan 2023 14:46:19 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id AF866238B4 for ; Thu, 26 Jan 2023 14:46:19 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Thu, 26 Jan 2023 14:46:17 +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 AE1B946565 for ; Thu, 26 Jan 2023 14:46:17 +0100 (CET) From: Fiona Ebner To: pve-devel@lists.proxmox.com Date: Thu, 26 Jan 2023 14:46:13 +0100 Message-Id: <20230126134614.117709-1-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 2.507 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_HI -5 Sender listed at https://www.dnswl.org/, high trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [meson.build] Subject: [pve-devel] [PATCH qemu 1/2] fix #4476: savevm-async: avoid looping without progress 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, 26 Jan 2023 13:46:19 -0000 when pend_postcopy is large. By definition, pend_postcopy won't decrease when iterating, so a value larger than the cutoff of 400000 would lead to essentially empty iterations, filling up the state file until only 30 MiB + pending_size remain and the second half of the check would trigger. Avoid this, by not considering pend_postcopy for the cutoff to enter the final phase. Signed-off-by: Fiona Ebner --- Many thanks to Fabian for discussing the issue with me! ...vevm-async-for-background-state-snapshots.patch | 14 ++++++++------ ...-PVE-add-optional-buffer-size-to-QEMUFile.patch | 6 +++--- ...async-register-yank-before-migration_inco.patch | 4 ++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/debian/patches/pve/0017-PVE-add-savevm-async-for-background-state-snapshots.patch b/debian/patches/pve/0017-PVE-add-savevm-async-for-background-state-snapshots.patch index fcbe4bc..91d4710 100644 --- a/debian/patches/pve/0017-PVE-add-savevm-async-for-background-state-snapshots.patch +++ b/debian/patches/pve/0017-PVE-add-savevm-async-for-background-state-snapshots.patch @@ -24,7 +24,8 @@ Signed-off-by: Wolfgang Bumiller [improve aborting] Signed-off-by: Stefan Reiter [FE: further improve aborting - adapt to removal of QEMUFileOps] + adapt to removal of QEMUFileOps + improve condition for entering final stage] Signed-off-by: Fiona Ebner --- hmp-commands-info.hx | 13 + @@ -32,13 +33,13 @@ Signed-off-by: Fiona Ebner include/migration/snapshot.h | 2 + include/monitor/hmp.h | 5 + migration/meson.build | 1 + - migration/savevm-async.c | 531 +++++++++++++++++++++++++++++++++++ + migration/savevm-async.c | 532 +++++++++++++++++++++++++++++++++++ monitor/hmp-cmds.c | 57 ++++ qapi/migration.json | 34 +++ qapi/misc.json | 32 +++ qemu-options.hx | 12 + softmmu/vl.c | 10 + - 11 files changed, 730 insertions(+) + 11 files changed, 731 insertions(+) create mode 100644 migration/savevm-async.c diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx @@ -154,10 +155,10 @@ index 8cac83c06c..0842d00cd2 100644 ), gnutls) diff --git a/migration/savevm-async.c b/migration/savevm-async.c new file mode 100644 -index 0000000000..05d394c0e2 +index 0000000000..4a4e91a26d --- /dev/null +++ b/migration/savevm-async.c -@@ -0,0 +1,531 @@ +@@ -0,0 +1,532 @@ +#include "qemu/osdep.h" +#include "migration/channel-savevm-async.h" +#include "migration/migration.h" @@ -415,7 +416,8 @@ index 0000000000..05d394c0e2 + + maxlen = blk_getlength(snap_state.target) - 30*1024*1024; + -+ if (pending_size > 400000 && snap_state.bs_pos + pending_size < maxlen) { ++ /* Note that there is no progress for pend_postcopy when iterating */ ++ if (pending_size - pend_postcopy > 400000 && snap_state.bs_pos + pending_size < maxlen) { + ret = qemu_savevm_state_iterate(snap_state.file, false); + if (ret < 0) { + save_snapshot_error("qemu_savevm_state_iterate error %d", ret); diff --git a/debian/patches/pve/0018-PVE-add-optional-buffer-size-to-QEMUFile.patch b/debian/patches/pve/0018-PVE-add-optional-buffer-size-to-QEMUFile.patch index 5cf894b..956a09d 100644 --- a/debian/patches/pve/0018-PVE-add-optional-buffer-size-to-QEMUFile.patch +++ b/debian/patches/pve/0018-PVE-add-optional-buffer-size-to-QEMUFile.patch @@ -192,10 +192,10 @@ index fa13d04d78..914f1a63a8 100644 int qemu_fclose(QEMUFile *f); diff --git a/migration/savevm-async.c b/migration/savevm-async.c -index 05d394c0e2..bafe6ae5eb 100644 +index 4a4e91a26d..20aae335ca 100644 --- a/migration/savevm-async.c +++ b/migration/savevm-async.c -@@ -367,7 +367,7 @@ void qmp_savevm_start(bool has_statefile, const char *statefile, Error **errp) +@@ -368,7 +368,7 @@ void qmp_savevm_start(bool has_statefile, const char *statefile, Error **errp) QIOChannel *ioc = QIO_CHANNEL(qio_channel_savevm_async_new(snap_state.target, &snap_state.bs_pos)); @@ -204,7 +204,7 @@ index 05d394c0e2..bafe6ae5eb 100644 if (!snap_state.file) { error_set(errp, ERROR_CLASS_GENERIC_ERROR, "failed to open '%s'", statefile); -@@ -500,7 +500,8 @@ int load_snapshot_from_blockdev(const char *filename, Error **errp) +@@ -501,7 +501,8 @@ int load_snapshot_from_blockdev(const char *filename, Error **errp) blk_op_block_all(be, blocker); /* restore the VM state */ diff --git a/debian/patches/pve/0049-PVE-savevm-async-register-yank-before-migration_inco.patch b/debian/patches/pve/0049-PVE-savevm-async-register-yank-before-migration_inco.patch index b25c9fc..746b735 100644 --- a/debian/patches/pve/0049-PVE-savevm-async-register-yank-before-migration_inco.patch +++ b/debian/patches/pve/0049-PVE-savevm-async-register-yank-before-migration_inco.patch @@ -11,7 +11,7 @@ Signed-off-by: Thomas Lamprecht 1 file changed, 5 insertions(+) diff --git a/migration/savevm-async.c b/migration/savevm-async.c -index bafe6ae5eb..da3634048f 100644 +index 20aae335ca..94c5ae1c81 100644 --- a/migration/savevm-async.c +++ b/migration/savevm-async.c @@ -20,6 +20,7 @@ @@ -22,7 +22,7 @@ index bafe6ae5eb..da3634048f 100644 /* #define DEBUG_SAVEVM_STATE */ -@@ -514,6 +515,10 @@ int load_snapshot_from_blockdev(const char *filename, Error **errp) +@@ -515,6 +516,10 @@ int load_snapshot_from_blockdev(const char *filename, Error **errp) dirty_bitmap_mig_before_vm_start(); qemu_fclose(f); -- 2.30.2