+ my $code = sub {
+
+ $config = PVE::APIClient::Config->load(); # reload
+
+ # check again (file is locked now)
+ die "Remote '$remote' already exists\n"
+ if $config->{ids}->{$remote};
+
+ my $opts = $plugin->check_config($remote, $param, 1, 1);
+
+ $config->{ids}->{$remote} = $opts;
+
+ PVE::APIClient::Config->save($config);
+ };
+
+ PVE::APIClient::Config->lock_config(undef, $code);