mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-05-04 13:02:03 +00:00
cleanup update_vm - move param checks to start of function
This commit is contained in:
parent
a0d1b1a2fe
commit
0532bc6391
@ -614,10 +614,24 @@ __PACKAGE__->register_method({
|
|||||||
raise_param_exc({ skiplock => "Only root may use this option." })
|
raise_param_exc({ skiplock => "Only root may use this option." })
|
||||||
if $skiplock && $authuser ne 'root@pam';
|
if $skiplock && $authuser ne 'root@pam';
|
||||||
|
|
||||||
my $delete = extract_param($param, 'delete');
|
my $delete_str = extract_param($param, 'delete');
|
||||||
|
|
||||||
my $force = extract_param($param, 'force');
|
my $force = extract_param($param, 'force');
|
||||||
|
|
||||||
die "no options specified\n" if !$delete && !scalar(keys %$param);
|
die "no options specified\n" if !$delete_str && !scalar(keys %$param);
|
||||||
|
|
||||||
|
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});
|
||||||
|
|
||||||
|
if (!PVE::QemuServer::option_exists($opt)) {
|
||||||
|
raise_param_exc({ delete => "unknown option '$opt'" });
|
||||||
|
}
|
||||||
|
push @delete, $opt;
|
||||||
|
}
|
||||||
|
|
||||||
my $storecfg = PVE::Storage::config();
|
my $storecfg = PVE::Storage::config();
|
||||||
|
|
||||||
@ -635,15 +649,7 @@ __PACKAGE__->register_method({
|
|||||||
PVE::Cluster::log_msg('info', $authuser, "update VM $vmid: " . join (' ', @paramarr));
|
PVE::Cluster::log_msg('info', $authuser, "update VM $vmid: " . join (' ', @paramarr));
|
||||||
|
|
||||||
#delete
|
#delete
|
||||||
foreach my $opt (PVE::Tools::split_list($delete)) {
|
foreach my $opt (@delete) {
|
||||||
|
|
||||||
$opt = 'ide2' if $opt eq 'cdrom';
|
|
||||||
die "you can't use '-$opt' and '-delete $opt' at the same time\n"
|
|
||||||
if defined($param->{$opt});
|
|
||||||
|
|
||||||
if (!PVE::QemuServer::option_exists($opt)) {
|
|
||||||
raise_param_exc({ delete => "unknown option '$opt'" });
|
|
||||||
}
|
|
||||||
|
|
||||||
next if !defined($conf->{$opt});
|
next if !defined($conf->{$opt});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user