return $res;
}
+sub create_and_lock_config {
+ my ($class, $vmid, $allow_existing) = @_;
+
+ $class->lock_config_full($vmid, 5, sub {
+ PVE::Cluster::check_vmid_unused($vmid, $allow_existing);
+
+ my $conf = eval { $class->load_config($vmid) } || {};
+ $class->check_lock($conf);
+ $conf->{lock} = 'create';
+ $class->write_config($vmid, $conf);
+ });
+}
+
# Lock config file using flock, run $code with @param, unlock config file.
# $timeout is the maximum time to aquire the flock
# $shared eq 1 creates a non-exclusive ("read") flock