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) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 546916B3F2 for ; Tue, 16 Mar 2021 17:31:03 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 3EE0A24F8B for ; Tue, 16 Mar 2021 17:30:33 +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) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 0917A24F80 for ; Tue, 16 Mar 2021 17:30:32 +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 C875F42654 for ; Tue, 16 Mar 2021 17:30:31 +0100 (CET) From: Stefan Reiter To: pve-devel@lists.proxmox.com Date: Tue, 16 Mar 2021 17:30:23 +0100 Message-Id: <20210316163023.24534-2-s.reiter@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210316163023.24534-1-s.reiter@proxmox.com> References: <20210316163023.24534-1-s.reiter@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.022 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [qemuserver.pm, qemuconfig.pm, snapshot-test.pm] Subject: [pve-devel] [PATCH qemu-server 2/2] snapshot: set migration caps before savevm-start 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: Tue, 16 Mar 2021 16:31:03 -0000 A "savevm" call (both our async variant and the upstream sync one) use migration code internally. As such, they both expect migration capabilities to be set. This is usually not a problem, as the default set of capabilities is ok, however, it leads to differing snapshot settings if one does a snapshot after a machine has been live-migrated (as the capabilities will persist from that), which could potentially lead to discrepencies in snapshots (currently it seems to be fine, but it still makes sense to set them to safeguard against future changes). Note that we do set the "dirty-bitmaps" capability now (if query-proxmox-support reports true), which has three effects: 1) PBS dirty-bitmaps are preserved in snapshots, enabling fast-incremental backups to work after rollback (as long as no newer backups exist), including for hibernate/resume 2) snapshots taken from now on, with a QEMU version supporting bitmap migration, *might* lead to incompatibility of these snapshots with QEMU versions that don't know about bitmaps at all (i.e. < 5.0 IIRC?) - forward compatibility is still given, and all other capabilities we set go back to very old versions 3) since we now explicitly disable bitmap saving if the version doesn't report support, we avoid crashes even with not-updated QEMU versions Signed-off-by: Stefan Reiter --- PVE/QemuConfig.pm | 1 + PVE/QemuServer.pm | 8 ++++++-- test/snapshot-test.pm | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/PVE/QemuConfig.pm b/PVE/QemuConfig.pm index c58ff19..7ee8876 100644 --- a/PVE/QemuConfig.pm +++ b/PVE/QemuConfig.pm @@ -281,6 +281,7 @@ sub __snapshot_create_vol_snapshots_hook { PVE::Storage::activate_volumes($storecfg, [$snap->{vmstate}]); my $state_storage_id = PVE::Storage::parse_volume_id($snap->{vmstate}); + PVE::QemuServer::set_migration_caps($vmid, 1); mon_cmd($vmid, "savevm-start", statefile => $path); print "saving VM state and RAM using storage '$state_storage_id'\n"; my $render_state = sub { diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index 15100ed..1c0b5c2 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -4330,10 +4330,13 @@ sub qemu_volume_snapshot_delete { } sub set_migration_caps { - my ($vmid) = @_; + my ($vmid, $savevm) = @_; my $qemu_support = eval { mon_cmd($vmid, "query-proxmox-support") }; + my $bitmap_prop = $savevm ? 'pbs-dirty-bitmap-savevm' : 'pbs-dirty-bitmap-migration'; + my $dirty_bitmaps = $qemu_support->{$bitmap_prop} ? 1 : 0; + my $cap_ref = []; my $enabled_cap = { @@ -4342,7 +4345,7 @@ sub set_migration_caps { "x-rdma-pin-all" => 0, "zero-blocks" => 0, "compress" => 0, - "dirty-bitmaps" => $qemu_support->{'pbs-dirty-bitmap-migration'} ? 1 : 0, + "dirty-bitmaps" => $dirty_bitmaps, }; my $supported_capabilities = mon_cmd($vmid, "query-migrate-capabilities"); @@ -5600,6 +5603,7 @@ sub vm_suspend { PVE::Storage::activate_volumes($storecfg, [$vmstate]); eval { + set_migration_caps($vmid, 1); mon_cmd($vmid, "savevm-start", statefile => $path); for(;;) { my $state = mon_cmd($vmid, "query-savevm"); diff --git a/test/snapshot-test.pm b/test/snapshot-test.pm index f65a902..cc04f01 100644 --- a/test/snapshot-test.pm +++ b/test/snapshot-test.pm @@ -380,6 +380,8 @@ sub vm_stop { return; } +sub set_migration_caps {} # ignored + # END redefine PVE::QemuServer methods PVE::Tools::run_command("rm -rf snapshot-working"); -- 2.20.1