mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-08-06 00:23:54 +00:00
update_vm api : add optionnal revert option
Signed-off-by: Alexandre Derumier <aderumier@odiso.com> Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
This commit is contained in:
parent
81d95ae1a8
commit
d3df8cf350
@ -824,9 +824,11 @@ my $update_vm_api = sub {
|
||||
|
||||
my $delete_str = extract_param($param, 'delete');
|
||||
|
||||
my $revert_str = extract_param($param, 'revert');
|
||||
|
||||
my $force = extract_param($param, 'force');
|
||||
|
||||
die "no options specified\n" if !$delete_str && !scalar(keys %$param);
|
||||
die "no options specified\n" if !$delete_str && !$revert_str && !scalar(keys %$param);
|
||||
|
||||
my $storecfg = PVE::Storage::config();
|
||||
|
||||
@ -836,13 +838,31 @@ my $update_vm_api = sub {
|
||||
|
||||
# now try to verify all parameters
|
||||
|
||||
my $revert = {};
|
||||
foreach my $opt (PVE::Tools::split_list($revert_str)) {
|
||||
if (!PVE::QemuServer::option_exists($opt)) {
|
||||
raise_param_exc({ revert => "unknown option '$opt'" });
|
||||
}
|
||||
|
||||
raise_param_exc({ delete => "you can't use '-$opt' and " .
|
||||
"-revert $opt' at the same time" })
|
||||
if defined($param->{$opt});
|
||||
|
||||
$revert->{$opt} = 1;
|
||||
}
|
||||
|
||||
my @delete = ();
|
||||
foreach my $opt (PVE::Tools::split_list($delete_str)) {
|
||||
$opt = 'ide2' if $opt eq 'cdrom';
|
||||
|
||||
raise_param_exc({ delete => "you can't use '-$opt' and " .
|
||||
"-delete $opt' at the same time" })
|
||||
if defined($param->{$opt});
|
||||
|
||||
raise_param_exc({ revert => "you can't use '-delete $opt' and " .
|
||||
"-revert $opt' at the same time" })
|
||||
if $revert->{$opt};
|
||||
|
||||
if (!PVE::QemuServer::option_exists($opt)) {
|
||||
raise_param_exc({ delete => "unknown option '$opt'" });
|
||||
}
|
||||
@ -878,6 +898,14 @@ my $update_vm_api = sub {
|
||||
|
||||
PVE::QemuServer::check_lock($conf) if !$skiplock;
|
||||
|
||||
foreach my $opt (keys %$revert) {
|
||||
if (defined($conf->{$opt})) {
|
||||
$param->{$opt} = $conf->{$opt};
|
||||
} elsif (defined($conf->{pending}->{$opt})) {
|
||||
push @delete, $opt;
|
||||
}
|
||||
}
|
||||
|
||||
if ($param->{memory} || defined($param->{balloon})) {
|
||||
my $maxmem = $param->{memory} || $conf->{pending}->{memory} || $conf->{memory} || $defaults->{memory};
|
||||
my $balloon = defined($param->{balloon}) ? $param->{balloon} : $conf->{pending}->{balloon} || $conf->{balloon};
|
||||
|
Loading…
Reference in New Issue
Block a user