optional => 1,
description => 'If set, suspends the VM to disk. Will be resumed on next VM start.',
},
+ statestorage => get_standard_option('pve-storage-id', {
+ description => "The storage for the VM state",
+ requires => 'todisk',
+ optional => 1,
+ completion => \&PVE::Storage::complete_storage_enabled,
+ }),
},
},
returns => {
my $todisk = extract_param($param, 'todisk') // 0;
+ my $statestorage = extract_param($param, 'statestorage');
+
my $skiplock = extract_param($param, 'skiplock');
raise_param_exc({ skiplock => "Only root may use this option." })
if $skiplock && $authuser ne 'root@pam';
syslog('info', "suspend VM $vmid: $upid\n");
- PVE::QemuServer::vm_suspend($vmid, $skiplock, $todisk);
+ PVE::QemuServer::vm_suspend($vmid, $skiplock, $todisk, $statestorage);
return;
};
}
sub __snapshot_save_vmstate {
- my ($class, $vmid, $conf, $snapname, $storecfg, $suspend) = @_;
+ my ($class, $vmid, $conf, $snapname, $storecfg, $statestorage, $suspend) = @_;
# first, use explicitly configured storage
- my $target = $conf->{vmstatestorage};
+ # either directly via API, or via conf
+ my $target = $statestorage // $conf->{vmstatestorage};
if (!$target) {
my ($shared, $local);
}
sub vm_suspend {
- my ($vmid, $skiplock, $includestate) = @_;
+ my ($vmid, $skiplock, $includestate, $statestorage) = @_;
my $conf;
my $path;
$conf->{lock} = 'suspending';
my $date = strftime("%Y-%m-%d", localtime(time()));
$storecfg = PVE::Storage::config();
- $vmstate = PVE::QemuConfig->__snapshot_save_vmstate($vmid, $conf, "suspend-$date", $storecfg, 1);
+ $vmstate = PVE::QemuConfig->__snapshot_save_vmstate($vmid, $conf, "suspend-$date", $storecfg, $statestorage, 1);
$path = PVE::Storage::path($storecfg, $vmstate);
PVE::QemuConfig->write_config($vmid, $conf);
} else {