mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-07-09 12:52:13 +00:00
migrate: check storage permissions and content type
both where previously missing. the existing 'check_storage_access' helper is not applicable here since it operates on a full set of VM config options, not just storage IDs. Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
parent
bf8fc5a307
commit
aea447bb9d
@ -3453,15 +3453,27 @@ __PACKAGE__->register_method({
|
|||||||
my $storecfg = PVE::Storage::config();
|
my $storecfg = PVE::Storage::config();
|
||||||
|
|
||||||
if (my $targetstorage = $param->{targetstorage}) {
|
if (my $targetstorage = $param->{targetstorage}) {
|
||||||
|
my $check_storage = sub {
|
||||||
|
my ($target_sid) = @_;
|
||||||
|
PVE::Storage::storage_check_node($storecfg, $target_sid, $target);
|
||||||
|
$rpcenv->check($authuser, "/storage/$target_sid", ['Datastore.AllocateSpace']);
|
||||||
|
my $scfg = PVE::Storage::storage_config($storecfg, $target_sid);
|
||||||
|
raise_param_exc({ targetstorage => "storage '$target_sid' does not support vm images"})
|
||||||
|
if !$scfg->{content}->{images};
|
||||||
|
};
|
||||||
|
|
||||||
my $storagemap = eval { PVE::JSONSchema::parse_idmap($targetstorage, 'pve-storage-id') };
|
my $storagemap = eval { PVE::JSONSchema::parse_idmap($targetstorage, 'pve-storage-id') };
|
||||||
raise_param_exc({ targetstorage => "failed to parse targetstorage map: $@" })
|
raise_param_exc({ targetstorage => "failed to parse targetstorage map: $@" })
|
||||||
if $@;
|
if $@;
|
||||||
|
|
||||||
|
$rpcenv->check_vm_perm($authuser, $vmid, undef, ['VM.Config.Disk'])
|
||||||
|
if !defined($storagemap->{identity});
|
||||||
|
|
||||||
foreach my $source (keys %{$storagemap->{entries}}) {
|
foreach my $source (keys %{$storagemap->{entries}}) {
|
||||||
PVE::Storage::storage_check_node($storecfg, $storagemap->{entries}->{$source}, $target);
|
$check_storage->($storagemap->{entries}->{$source});
|
||||||
}
|
}
|
||||||
|
|
||||||
PVE::Storage::storage_check_node($storecfg, $storagemap->{default}, $target)
|
$check_storage->($storagemap->{default})
|
||||||
if $storagemap->{default};
|
if $storagemap->{default};
|
||||||
|
|
||||||
PVE::QemuServer::check_storage_availability($storecfg, $conf, $target)
|
PVE::QemuServer::check_storage_availability($storecfg, $conf, $target)
|
||||||
|
Loading…
Reference in New Issue
Block a user