mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-08-12 05:36:52 +00:00
snapshot: set migration caps before savevm-start
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 <s.reiter@proxmox.com>
This commit is contained in:
parent
c89642784d
commit
27a5be5376
@ -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 {
|
||||
|
@ -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");
|
||||
|
@ -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");
|
||||
|
Loading…
Reference in New Issue
Block a user