mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-08-11 17:09:56 +00:00
api: create: refactor parameter check logic
In preparation to allow passing along certain parameters together with 'archive'. Moving the parameter checks to after the conflicts-with-'archive' to ensure that the more telling error will trigger first. All check helpers should handle empty params fine, but check first just to make sure and to avoid all the superfluous function calls. Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
This commit is contained in:
parent
3591b62b85
commit
325b32cc40
@ -818,22 +818,7 @@ __PACKAGE__->register_method({
|
|||||||
raise_perm_exc();
|
raise_perm_exc();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$archive) {
|
if ($archive) {
|
||||||
&$resolve_cdrom_alias($param);
|
|
||||||
|
|
||||||
&$check_storage_access($rpcenv, $authuser, $storecfg, $vmid, $param, $storage);
|
|
||||||
|
|
||||||
&$check_vm_modify_config_perm($rpcenv, $authuser, $vmid, $pool, [ keys %$param]);
|
|
||||||
|
|
||||||
&$check_vm_create_serial_perm($rpcenv, $authuser, $vmid, $pool, $param);
|
|
||||||
&$check_vm_create_usb_perm($rpcenv, $authuser, $vmid, $pool, $param);
|
|
||||||
|
|
||||||
&$check_cpu_model_access($rpcenv, $authuser, $param);
|
|
||||||
|
|
||||||
$check_drive_param->($param, $storecfg);
|
|
||||||
|
|
||||||
PVE::QemuServer::add_random_macs($param);
|
|
||||||
} else {
|
|
||||||
my $keystr = join(' ', keys %$param);
|
my $keystr = join(' ', keys %$param);
|
||||||
raise_param_exc({ archive => "option conflicts with other options ($keystr)"}) if $keystr;
|
raise_param_exc({ archive => "option conflicts with other options ($keystr)"}) if $keystr;
|
||||||
|
|
||||||
@ -854,6 +839,23 @@ __PACKAGE__->register_method({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (scalar(keys $param->%*) > 0) {
|
||||||
|
&$resolve_cdrom_alias($param);
|
||||||
|
|
||||||
|
&$check_storage_access($rpcenv, $authuser, $storecfg, $vmid, $param, $storage);
|
||||||
|
|
||||||
|
&$check_vm_modify_config_perm($rpcenv, $authuser, $vmid, $pool, [ keys %$param]);
|
||||||
|
|
||||||
|
&$check_vm_create_serial_perm($rpcenv, $authuser, $vmid, $pool, $param);
|
||||||
|
&$check_vm_create_usb_perm($rpcenv, $authuser, $vmid, $pool, $param);
|
||||||
|
|
||||||
|
&$check_cpu_model_access($rpcenv, $authuser, $param);
|
||||||
|
|
||||||
|
$check_drive_param->($param, $storecfg);
|
||||||
|
|
||||||
|
PVE::QemuServer::add_random_macs($param);
|
||||||
|
}
|
||||||
|
|
||||||
my $emsg = $is_restore ? "unable to restore VM $vmid -" : "unable to create VM $vmid -";
|
my $emsg = $is_restore ? "unable to restore VM $vmid -" : "unable to create VM $vmid -";
|
||||||
|
|
||||||
eval { PVE::QemuConfig->create_and_lock_config($vmid, $force) };
|
eval { PVE::QemuConfig->create_and_lock_config($vmid, $force) };
|
||||||
|
Loading…
Reference in New Issue
Block a user