fix #6391: restore: fall back to automatic VM state storage if unavailable

Restoring a backup keeps the 'vmstatestorage' option of the backed up
VM. When the backup is restored on another node or cluster, that
storage might not exist there or not be enabled for the node, so that
hibernating the VM or taking a snapshot including RAM fails later on,
for example with "storage 'local-zfs-pve1' does not exist".

If the configured VM state storage is not available on the node the
backup is restored to, drop the option, so that the storage is
selected automatically, like for VMs without it, and log that in the
restore task log.

A 'vmstatestorage' passed explicitly when restoring is applied after
this and is not affected.

Signed-off-by: Michal Fox <me@dualfroz.com>
This commit is contained in:
dualfroz committed 2026-10-03 01:40:02 +02:00
1 parent b2fcf5405f
commit 5ef4888910
10 files changed
+139 -1

No files matched your search

+10
View File
@@ -6697,6 +6697,16 @@ sub restore_update_config_line {
} else {
$res .= $line;
}
} elsif ($line =~ m/^vmstatestorage:\s*(\S+)\s*$/) {
my $storeid = $1;
my $storecfg = PVE::Storage::config();
my $scfg = PVE::Storage::storage_config($storecfg, $storeid, 1);
if ($scfg && PVE::Storage::storage_check_enabled($storecfg, $storeid, undef, 1)) {
$res .= $line;
} else {
print "VM state storage '$storeid' is not available on this node, using"
. " automatic selection instead\n";
}
} elsif (($line =~ m/^vmgenid: (.*)/)) {
my $vmgenid = $1;
if ($vmgenid ne '0') {