restore: check bridge access when actual config is available

This was not only rather inefficient (getting the config from the
archive twice) but also wrong, as we can override options on restore,
so we can do the check only when the backed-up config and override
config got merged.

If this is to late from POV of volume deletion or the like, then the
issue is that those things happen to early, as we can only know what
to do with the actual target config, so destructive actions that
happen before that are wrong by design.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2023-06-08 17:19:43 +02:00
parent d6deb7f6bb
commit 951714ea92
2 changed files with 2 additions and 4 deletions

View File

@ -866,10 +866,6 @@ __PACKAGE__->register_method({
'backup',
);
my $vzdump_conf = PVE::Storage::extract_vzdump_config($storecfg, $archive);
my $backup_conf = PVE::QemuServer::parse_vm_config("restore/qemu-server/$vmid.conf", $vzdump_conf, 1);
PVE::QemuServer::check_bridge_access($rpcenv, $authuser, $backup_conf);
$archive = $parse_restore_archive->($storecfg, $archive);
}
}

View File

@ -7171,6 +7171,7 @@ sub restore_proxmox_backup_archive {
}
my $new_conf = $restore_merge_config->($conffile, $new_conf_raw, $options->{override_conf});
check_bridge_access($rpcenv, $user, $new_conf);
PVE::QemuConfig->write_config($vmid, $new_conf);
eval { rescan($vmid, 1); };
@ -7484,6 +7485,7 @@ sub restore_vma_archive {
}
my $new_conf = $restore_merge_config->($conffile, $new_conf_raw, $opts->{override_conf});
check_bridge_access($rpcenv, $user, $new_conf);
PVE::QemuConfig->write_config($vmid, $new_conf);
eval { rescan($vmid, 1); };