Machine states that were created on snapshots with memory could not be restored on rollback. The state volume was not activated so KVM couldn't load the state.
This patch moves the path generation into vm_start and de-/activates the state volume. Signed-off-by: Alwin Antreich <a.antre...@proxmox.com> --- PVE/QemuConfig.pm | 3 +-- PVE/QemuServer.pm | 10 +++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/PVE/QemuConfig.pm b/PVE/QemuConfig.pm index edbf1a7..e9796a3 100644 --- a/PVE/QemuConfig.pm +++ b/PVE/QemuConfig.pm @@ -359,8 +359,7 @@ sub __snapshot_rollback_vm_start { my ($class, $vmid, $vmstate, $data) = @_; my $storecfg = PVE::Storage::config(); - my $statefile = PVE::Storage::path($storecfg, $vmstate); - PVE::QemuServer::vm_start($storecfg, $vmid, $statefile, undef, undef, undef, $data->{forcemachine}); + PVE::QemuServer::vm_start($storecfg, $vmid, $vmstate, undef, undef, undef, $data->{forcemachine}); } sub __snapshot_rollback_get_unused { diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index 8376260..39315b3 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -5420,6 +5420,7 @@ sub vm_start { my ($cmd, $vollist, $spice_port) = config_to_command($storecfg, $vmid, $conf, $defaults, $forcemachine); + my $migrate_port = 0; my $migrate_uri; if ($statefile) { @@ -5466,7 +5467,12 @@ sub vm_start { push @$cmd, '-S'; } else { - push @$cmd, '-loadstate', $statefile; + my $sfile = $statefile; + if (!-e $statefile) { + PVE::Storage::activate_volumes($storecfg, [$statefile]); + $sfile = PVE::Storage::path($storecfg, $statefile); + } + push @$cmd, '-loadstate', $sfile; } } elsif ($paused) { push @$cmd, '-S'; @@ -5622,6 +5628,8 @@ sub vm_start { PVE::Storage::deactivate_volumes($storecfg, [$vmstate]); PVE::Storage::vdisk_free($storecfg, $vmstate); PVE::QemuConfig->write_config($vmid, $conf); + } elsif ($statefile && (!-e $statefile)) { + PVE::Storage::deactivate_volumes($storecfg, [$statefile]); } PVE::GuestHelpers::exec_hookscript($conf, $vmid, 'post-start'); -- 2.20.1 _______________________________________________ pve-devel mailing list pve-devel@pve.proxmox.com https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel