]> git.proxmox.com Git - pve-container.git/blob - src/PVE/API2/LXC.pm
restore: fix simple with non-volume mps
[pve-container.git] / src / PVE / API2 / LXC.pm
1 package PVE::API2::LXC;
2
3 use strict;
4 use warnings;
5
6 use PVE::SafeSyslog;
7 use PVE::Tools qw(extract_param run_command);
8 use PVE::Exception qw(raise raise_param_exc);
9 use PVE::INotify;
10 use PVE::Cluster qw(cfs_read_file);
11 use PVE::AccessControl;
12 use PVE::Firewall;
13 use PVE::Storage;
14 use PVE::RESTHandler;
15 use PVE::RPCEnvironment;
16 use PVE::LXC;
17 use PVE::LXC::Create;
18 use PVE::LXC::Migrate;
19 use PVE::API2::LXC::Config;
20 use PVE::API2::LXC::Status;
21 use PVE::API2::LXC::Snapshot;
22 use PVE::HA::Env::PVE2;
23 use PVE::HA::Config;
24 use PVE::JSONSchema qw(get_standard_option);
25 use base qw(PVE::RESTHandler);
26
27 use Data::Dumper; # fixme: remove
28
29 __PACKAGE__->register_method ({
30 subclass => "PVE::API2::LXC::Config",
31 path => '{vmid}/config',
32 });
33
34 __PACKAGE__->register_method ({
35 subclass => "PVE::API2::LXC::Status",
36 path => '{vmid}/status',
37 });
38
39 __PACKAGE__->register_method ({
40 subclass => "PVE::API2::LXC::Snapshot",
41 path => '{vmid}/snapshot',
42 });
43
44 __PACKAGE__->register_method ({
45 subclass => "PVE::API2::Firewall::CT",
46 path => '{vmid}/firewall',
47 });
48
49 __PACKAGE__->register_method({
50 name => 'vmlist',
51 path => '',
52 method => 'GET',
53 description => "LXC container index (per node).",
54 permissions => {
55 description => "Only list CTs where you have VM.Audit permissons on /vms/<vmid>.",
56 user => 'all',
57 },
58 proxyto => 'node',
59 protected => 1, # /proc files are only readable by root
60 parameters => {
61 additionalProperties => 0,
62 properties => {
63 node => get_standard_option('pve-node'),
64 },
65 },
66 returns => {
67 type => 'array',
68 items => {
69 type => "object",
70 properties => {},
71 },
72 links => [ { rel => 'child', href => "{vmid}" } ],
73 },
74 code => sub {
75 my ($param) = @_;
76
77 my $rpcenv = PVE::RPCEnvironment::get();
78 my $authuser = $rpcenv->get_user();
79
80 my $vmstatus = PVE::LXC::vmstatus();
81
82 my $res = [];
83 foreach my $vmid (keys %$vmstatus) {
84 next if !$rpcenv->check($authuser, "/vms/$vmid", [ 'VM.Audit' ], 1);
85
86 my $data = $vmstatus->{$vmid};
87 $data->{vmid} = $vmid;
88 push @$res, $data;
89 }
90
91 return $res;
92
93 }});
94
95 __PACKAGE__->register_method({
96 name => 'create_vm',
97 path => '',
98 method => 'POST',
99 description => "Create or restore a container.",
100 permissions => {
101 user => 'all', # check inside
102 description => "You need 'VM.Allocate' permissions on /vms/{vmid} or on the VM pool /pool/{pool}. " .
103 "For restore, it is enough if the user has 'VM.Backup' permission and the VM already exists. " .
104 "You also need 'Datastore.AllocateSpace' permissions on the storage.",
105 },
106 protected => 1,
107 proxyto => 'node',
108 parameters => {
109 additionalProperties => 0,
110 properties => PVE::LXC::Config->json_config_properties({
111 node => get_standard_option('pve-node'),
112 vmid => get_standard_option('pve-vmid', { completion => \&PVE::Cluster::complete_next_vmid }),
113 ostemplate => {
114 description => "The OS template or backup file.",
115 type => 'string',
116 maxLength => 255,
117 completion => \&PVE::LXC::complete_os_templates,
118 },
119 password => {
120 optional => 1,
121 type => 'string',
122 description => "Sets root password inside container.",
123 minLength => 5,
124 },
125 storage => get_standard_option('pve-storage-id', {
126 description => "Default Storage.",
127 default => 'local',
128 optional => 1,
129 completion => \&PVE::Storage::complete_storage_enabled,
130 }),
131 force => {
132 optional => 1,
133 type => 'boolean',
134 description => "Allow to overwrite existing container.",
135 },
136 restore => {
137 optional => 1,
138 type => 'boolean',
139 description => "Mark this as restore task.",
140 },
141 pool => {
142 optional => 1,
143 type => 'string', format => 'pve-poolid',
144 description => "Add the VM to the specified pool.",
145 },
146 'ignore-unpack-errors' => {
147 optional => 1,
148 type => 'boolean',
149 description => "Ignore errors when extracting the template.",
150 },
151 'ssh-public-keys' => {
152 optional => 1,
153 type => 'string',
154 description => "Setup public SSH keys (one key per line, " .
155 "OpenSSH format).",
156 },
157 }),
158 },
159 returns => {
160 type => 'string',
161 },
162 code => sub {
163 my ($param) = @_;
164
165 my $rpcenv = PVE::RPCEnvironment::get();
166
167 my $authuser = $rpcenv->get_user();
168
169 my $node = extract_param($param, 'node');
170
171 my $vmid = extract_param($param, 'vmid');
172
173 my $ignore_unpack_errors = extract_param($param, 'ignore-unpack-errors');
174
175 my $basecfg_fn = PVE::LXC::Config->config_file($vmid);
176
177 my $same_container_exists = -f $basecfg_fn;
178
179 # 'unprivileged' is read-only, so we can't pass it to update_pct_config
180 my $unprivileged = extract_param($param, 'unprivileged');
181
182 my $restore = extract_param($param, 'restore');
183
184 if ($restore) {
185 # fixme: limit allowed parameters
186
187 }
188
189 my $force = extract_param($param, 'force');
190
191 if (!($same_container_exists && $restore && $force)) {
192 PVE::Cluster::check_vmid_unused($vmid);
193 } else {
194 my $conf = PVE::LXC::Config->load_config($vmid);
195 PVE::LXC::Config->check_protection($conf, "unable to restore CT $vmid");
196 }
197
198 my $password = extract_param($param, 'password');
199
200 my $ssh_keys = extract_param($param, 'ssh-public-keys');
201 PVE::Tools::validate_ssh_public_keys($ssh_keys) if defined($ssh_keys);
202
203 my $pool = extract_param($param, 'pool');
204
205 if (defined($pool)) {
206 $rpcenv->check_pool_exist($pool);
207 $rpcenv->check_perm_modify($authuser, "/pool/$pool");
208 }
209
210 if ($rpcenv->check($authuser, "/vms/$vmid", ['VM.Allocate'], 1)) {
211 # OK
212 } elsif ($pool && $rpcenv->check($authuser, "/pool/$pool", ['VM.Allocate'], 1)) {
213 # OK
214 } elsif ($restore && $force && $same_container_exists &&
215 $rpcenv->check($authuser, "/vms/$vmid", ['VM.Backup'], 1)) {
216 # OK: user has VM.Backup permissions, and want to restore an existing VM
217 } else {
218 raise_perm_exc();
219 }
220
221 PVE::LXC::check_ct_modify_config_perm($rpcenv, $authuser, $vmid, $pool, $param, []);
222
223 my $storage = extract_param($param, 'storage') // 'local';
224
225 my $storage_cfg = cfs_read_file("storage.cfg");
226
227 my $ostemplate = extract_param($param, 'ostemplate');
228
229 my $archive;
230
231 if ($ostemplate eq '-') {
232 die "pipe requires cli environment\n"
233 if $rpcenv->{type} ne 'cli';
234 die "pipe can only be used with restore tasks\n"
235 if !$restore;
236 $archive = '-';
237 die "restore from pipe requires rootfs parameter\n" if !defined($param->{rootfs});
238 } else {
239 $rpcenv->check_volume_access($authuser, $storage_cfg, $vmid, $ostemplate);
240 $archive = PVE::Storage::abs_filesystem_path($storage_cfg, $ostemplate);
241 }
242
243 my $check_and_activate_storage = sub {
244 my ($sid) = @_;
245
246 my $scfg = PVE::Storage::storage_check_node($storage_cfg, $sid, $node);
247
248 raise_param_exc({ storage => "storage '$sid' does not support container directories"})
249 if !$scfg->{content}->{rootdir};
250
251 $rpcenv->check($authuser, "/storage/$sid", ['Datastore.AllocateSpace']);
252
253 PVE::Storage::activate_storage($storage_cfg, $sid);
254 };
255
256 my $conf = {};
257
258 my $no_disk_param = {};
259 my $mp_param = {};
260 my $storage_only_mode = 1;
261 foreach my $opt (keys %$param) {
262 my $value = $param->{$opt};
263 if ($opt eq 'rootfs' || $opt =~ m/^mp\d+$/) {
264 # allow to use simple numbers (add default storage in that case)
265 if ($value =~ m/^\d+(\.\d+)?$/) {
266 $mp_param->{$opt} = "$storage:$value";
267 } else {
268 $mp_param->{$opt} = $value;
269 }
270 $storage_only_mode = 0;
271 } elsif ($opt =~ m/^unused\d+$/) {
272 warn "ignoring '$opt', cannot create/restore with unused volume\n";
273 delete $param->{$opt};
274 } else {
275 $no_disk_param->{$opt} = $value;
276 }
277 }
278
279 die "mountpoints configured, but 'rootfs' not set - aborting\n"
280 if !$storage_only_mode && !defined($mp_param->{rootfs});
281
282 # check storage access, activate storage
283 my $delayed_mp_param = {};
284 PVE::LXC::Config->foreach_mountpoint($mp_param, sub {
285 my ($ms, $mountpoint) = @_;
286
287 my $volid = $mountpoint->{volume};
288 my $mp = $mountpoint->{mp};
289
290 if ($mountpoint->{type} ne 'volume') { # bind or device
291 die "Only root can pass arbitrary filesystem paths.\n"
292 if $authuser ne 'root@pam';
293 } else {
294 my ($sid, $volname) = PVE::Storage::parse_volume_id($volid);
295 &$check_and_activate_storage($sid);
296 }
297 });
298
299 # check/activate default storage
300 &$check_and_activate_storage($storage) if !defined($mp_param->{rootfs});
301
302 PVE::LXC::Config->update_pct_config($vmid, $conf, 0, $no_disk_param);
303
304 $conf->{unprivileged} = 1 if $unprivileged;
305
306 my $check_vmid_usage = sub {
307 if ($force) {
308 die "can't overwrite running container\n"
309 if PVE::LXC::check_running($vmid);
310 } else {
311 PVE::Cluster::check_vmid_unused($vmid);
312 }
313 };
314
315 my $code = sub {
316 &$check_vmid_usage(); # final check after locking
317 my $old_conf;
318
319 my $config_fn = PVE::LXC::Config->config_file($vmid);
320 if (-f $config_fn) {
321 die "container exists" if !$restore; # just to be sure
322 $old_conf = PVE::LXC::Config->load_config($vmid);
323 } else {
324 eval {
325 # try to create empty config on local node, we have an flock
326 PVE::LXC::Config->write_config($vmid, {});
327 };
328
329 # another node was faster, abort
330 die "Could not reserve ID $vmid, already taken\n" if $@;
331 }
332
333 PVE::Cluster::check_cfs_quorum();
334 my $vollist = [];
335
336 eval {
337 if ($storage_only_mode) {
338 if ($restore) {
339 (undef, $mp_param) = PVE::LXC::Create::recover_config($archive);
340 die "rootfs configuration could not be recovered, please check and specify manually!\n"
341 if !defined($mp_param->{rootfs});
342 PVE::LXC::Config->foreach_mountpoint($mp_param, sub {
343 my ($ms, $mountpoint) = @_;
344 my $type = $mountpoint->{type};
345 if ($type eq 'volume') {
346 die "unable to detect disk size - please specify $ms (size)\n"
347 if !defined($mountpoint->{size});
348 my $disksize = $mountpoint->{size} / (1024 * 1024 * 1024); # create_disks expects GB as unit size
349 delete $mountpoint->{size};
350 $mountpoint->{volume} = "$storage:$disksize";
351 $mp_param->{$ms} = PVE::LXC::Config->print_ct_mountpoint($mountpoint, $ms eq 'rootfs');
352 } else {
353 my $type = $mountpoint->{type};
354 die "restoring rootfs to $type mount is only possible by specifying -rootfs manually!\n"
355 if ($ms eq 'rootfs');
356
357 if ($mountpoint->{backup}) {
358 warn "WARNING - unsupported configuration!\n";
359 warn "backup was enabled for $type mountpoint $ms ('$mountpoint->{mp}')\n";
360 warn "mountpoint configuration will be restored after archive extraction!\n";
361 warn "contained files will be restored to wrong directory!\n";
362 }
363 delete $mp_param->{$ms}; # actually delay bind/dev mps
364 $delayed_mp_param->{$ms} = PVE::LXC::Config->print_ct_mountpoint($mountpoint, $ms eq 'rootfs');
365 }
366 });
367 } else {
368 $mp_param->{rootfs} = "$storage:4"; # defaults to 4GB
369 }
370 }
371
372 $vollist = PVE::LXC::create_disks($storage_cfg, $vmid, $mp_param, $conf);
373
374 if (defined($old_conf)) {
375 # destroy old container volumes
376 PVE::LXC::destroy_lxc_container($storage_cfg, $vmid, $old_conf, {});
377 }
378
379 eval {
380 my $rootdir = PVE::LXC::mount_all($vmid, $storage_cfg, $conf, 1);
381 PVE::LXC::Create::restore_archive($archive, $rootdir, $conf, $ignore_unpack_errors);
382
383 if ($restore) {
384 PVE::LXC::Create::restore_configuration($vmid, $rootdir, $conf);
385 } else {
386 my $lxc_setup = PVE::LXC::Setup->new($conf, $rootdir); # detect OS
387 PVE::LXC::Config->write_config($vmid, $conf); # safe config (after OS detection)
388 $lxc_setup->post_create_hook($password, $ssh_keys);
389 }
390 };
391 my $err = $@;
392 PVE::LXC::umount_all($vmid, $storage_cfg, $conf, $err ? 1 : 0);
393 PVE::Storage::deactivate_volumes($storage_cfg, PVE::LXC::Config->get_vm_volumes($conf));
394 die $err if $err;
395 # set some defaults
396 $conf->{hostname} ||= "CT$vmid";
397 $conf->{memory} ||= 512;
398 $conf->{swap} //= 512;
399 foreach my $mp (keys %$delayed_mp_param) {
400 $conf->{$mp} = $delayed_mp_param->{$mp};
401 }
402 PVE::LXC::Config->write_config($vmid, $conf);
403 };
404 if (my $err = $@) {
405 PVE::LXC::destroy_disks($storage_cfg, $vollist);
406 PVE::LXC::destroy_config($vmid);
407 die $err;
408 }
409 PVE::AccessControl::add_vm_to_pool($vmid, $pool) if $pool;
410 };
411
412 my $realcmd = sub { PVE::LXC::Config->lock_config($vmid, $code); };
413
414 &$check_vmid_usage(); # first check before locking
415
416 return $rpcenv->fork_worker($restore ? 'vzrestore' : 'vzcreate',
417 $vmid, $authuser, $realcmd);
418
419 }});
420
421 __PACKAGE__->register_method({
422 name => 'vmdiridx',
423 path => '{vmid}',
424 method => 'GET',
425 proxyto => 'node',
426 description => "Directory index",
427 permissions => {
428 user => 'all',
429 },
430 parameters => {
431 additionalProperties => 0,
432 properties => {
433 node => get_standard_option('pve-node'),
434 vmid => get_standard_option('pve-vmid'),
435 },
436 },
437 returns => {
438 type => 'array',
439 items => {
440 type => "object",
441 properties => {
442 subdir => { type => 'string' },
443 },
444 },
445 links => [ { rel => 'child', href => "{subdir}" } ],
446 },
447 code => sub {
448 my ($param) = @_;
449
450 # test if VM exists
451 my $conf = PVE::LXC::Config->load_config($param->{vmid});
452
453 my $res = [
454 { subdir => 'config' },
455 { subdir => 'status' },
456 { subdir => 'vncproxy' },
457 { subdir => 'vncwebsocket' },
458 { subdir => 'spiceproxy' },
459 { subdir => 'migrate' },
460 { subdir => 'clone' },
461 # { subdir => 'initlog' },
462 { subdir => 'rrd' },
463 { subdir => 'rrddata' },
464 { subdir => 'firewall' },
465 { subdir => 'snapshot' },
466 { subdir => 'resize' },
467 ];
468
469 return $res;
470 }});
471
472
473 __PACKAGE__->register_method({
474 name => 'rrd',
475 path => '{vmid}/rrd',
476 method => 'GET',
477 protected => 1, # fixme: can we avoid that?
478 permissions => {
479 check => ['perm', '/vms/{vmid}', [ 'VM.Audit' ]],
480 },
481 description => "Read VM RRD statistics (returns PNG)",
482 parameters => {
483 additionalProperties => 0,
484 properties => {
485 node => get_standard_option('pve-node'),
486 vmid => get_standard_option('pve-vmid'),
487 timeframe => {
488 description => "Specify the time frame you are interested in.",
489 type => 'string',
490 enum => [ 'hour', 'day', 'week', 'month', 'year' ],
491 },
492 ds => {
493 description => "The list of datasources you want to display.",
494 type => 'string', format => 'pve-configid-list',
495 },
496 cf => {
497 description => "The RRD consolidation function",
498 type => 'string',
499 enum => [ 'AVERAGE', 'MAX' ],
500 optional => 1,
501 },
502 },
503 },
504 returns => {
505 type => "object",
506 properties => {
507 filename => { type => 'string' },
508 },
509 },
510 code => sub {
511 my ($param) = @_;
512
513 return PVE::Cluster::create_rrd_graph(
514 "pve2-vm/$param->{vmid}", $param->{timeframe},
515 $param->{ds}, $param->{cf});
516
517 }});
518
519 __PACKAGE__->register_method({
520 name => 'rrddata',
521 path => '{vmid}/rrddata',
522 method => 'GET',
523 protected => 1, # fixme: can we avoid that?
524 permissions => {
525 check => ['perm', '/vms/{vmid}', [ 'VM.Audit' ]],
526 },
527 description => "Read VM RRD statistics",
528 parameters => {
529 additionalProperties => 0,
530 properties => {
531 node => get_standard_option('pve-node'),
532 vmid => get_standard_option('pve-vmid'),
533 timeframe => {
534 description => "Specify the time frame you are interested in.",
535 type => 'string',
536 enum => [ 'hour', 'day', 'week', 'month', 'year' ],
537 },
538 cf => {
539 description => "The RRD consolidation function",
540 type => 'string',
541 enum => [ 'AVERAGE', 'MAX' ],
542 optional => 1,
543 },
544 },
545 },
546 returns => {
547 type => "array",
548 items => {
549 type => "object",
550 properties => {},
551 },
552 },
553 code => sub {
554 my ($param) = @_;
555
556 return PVE::Cluster::create_rrd_data(
557 "pve2-vm/$param->{vmid}", $param->{timeframe}, $param->{cf});
558 }});
559
560 __PACKAGE__->register_method({
561 name => 'destroy_vm',
562 path => '{vmid}',
563 method => 'DELETE',
564 protected => 1,
565 proxyto => 'node',
566 description => "Destroy the container (also delete all uses files).",
567 permissions => {
568 check => [ 'perm', '/vms/{vmid}', ['VM.Allocate']],
569 },
570 parameters => {
571 additionalProperties => 0,
572 properties => {
573 node => get_standard_option('pve-node'),
574 vmid => get_standard_option('pve-vmid', { completion => \&PVE::LXC::complete_ctid_stopped }),
575 },
576 },
577 returns => {
578 type => 'string',
579 },
580 code => sub {
581 my ($param) = @_;
582
583 my $rpcenv = PVE::RPCEnvironment::get();
584
585 my $authuser = $rpcenv->get_user();
586
587 my $vmid = $param->{vmid};
588
589 # test if container exists
590 my $conf = PVE::LXC::Config->load_config($vmid);
591
592 my $storage_cfg = cfs_read_file("storage.cfg");
593
594 PVE::LXC::Config->check_protection($conf, "can't remove CT $vmid");
595
596 die "unable to remove CT $vmid - used in HA resources\n"
597 if PVE::HA::Config::vm_is_ha_managed($vmid);
598
599 my $running_error_msg = "unable to destroy CT $vmid - container is running\n";
600
601 die $running_error_msg if PVE::LXC::check_running($vmid); # check early
602
603 my $code = sub {
604 # reload config after lock
605 $conf = PVE::LXC::Config->load_config($vmid);
606 PVE::LXC::Config->check_lock($conf);
607
608 die $running_error_msg if PVE::LXC::check_running($vmid);
609
610 PVE::LXC::destroy_lxc_container($storage_cfg, $vmid, $conf);
611 PVE::AccessControl::remove_vm_access($vmid);
612 PVE::Firewall::remove_vmfw_conf($vmid);
613 };
614
615 my $realcmd = sub { PVE::LXC::Config->lock_config($vmid, $code); };
616
617 return $rpcenv->fork_worker('vzdestroy', $vmid, $authuser, $realcmd);
618 }});
619
620 my $sslcert;
621
622 __PACKAGE__->register_method ({
623 name => 'vncproxy',
624 path => '{vmid}/vncproxy',
625 method => 'POST',
626 protected => 1,
627 permissions => {
628 check => ['perm', '/vms/{vmid}', [ 'VM.Console' ]],
629 },
630 description => "Creates a TCP VNC proxy connections.",
631 parameters => {
632 additionalProperties => 0,
633 properties => {
634 node => get_standard_option('pve-node'),
635 vmid => get_standard_option('pve-vmid'),
636 websocket => {
637 optional => 1,
638 type => 'boolean',
639 description => "use websocket instead of standard VNC.",
640 },
641 },
642 },
643 returns => {
644 additionalProperties => 0,
645 properties => {
646 user => { type => 'string' },
647 ticket => { type => 'string' },
648 cert => { type => 'string' },
649 port => { type => 'integer' },
650 upid => { type => 'string' },
651 },
652 },
653 code => sub {
654 my ($param) = @_;
655
656 my $rpcenv = PVE::RPCEnvironment::get();
657
658 my $authuser = $rpcenv->get_user();
659
660 my $vmid = $param->{vmid};
661 my $node = $param->{node};
662
663 my $authpath = "/vms/$vmid";
664
665 my $ticket = PVE::AccessControl::assemble_vnc_ticket($authuser, $authpath);
666
667 $sslcert = PVE::Tools::file_get_contents("/etc/pve/pve-root-ca.pem", 8192)
668 if !$sslcert;
669
670 my ($remip, $family);
671
672 if ($node ne PVE::INotify::nodename()) {
673 ($remip, $family) = PVE::Cluster::remote_node_ip($node);
674 } else {
675 $family = PVE::Tools::get_host_address_family($node);
676 }
677
678 my $port = PVE::Tools::next_vnc_port($family);
679
680 # NOTE: vncterm VNC traffic is already TLS encrypted,
681 # so we select the fastest chipher here (or 'none'?)
682 my $remcmd = $remip ?
683 ['/usr/bin/ssh', '-t', $remip] : [];
684
685 my $conf = PVE::LXC::Config->load_config($vmid, $node);
686 my $concmd = PVE::LXC::get_console_command($vmid, $conf);
687
688 my $shcmd = [ '/usr/bin/dtach', '-A',
689 "/var/run/dtach/vzctlconsole$vmid",
690 '-r', 'winch', '-z', @$concmd];
691
692 my $realcmd = sub {
693 my $upid = shift;
694
695 syslog ('info', "starting lxc vnc proxy $upid\n");
696
697 my $timeout = 10;
698
699 my $cmd = ['/usr/bin/vncterm', '-rfbport', $port,
700 '-timeout', $timeout, '-authpath', $authpath,
701 '-perm', 'VM.Console'];
702
703 if ($param->{websocket}) {
704 $ENV{PVE_VNC_TICKET} = $ticket; # pass ticket to vncterm
705 push @$cmd, '-notls', '-listen', 'localhost';
706 }
707
708 push @$cmd, '-c', @$remcmd, @$shcmd;
709
710 run_command($cmd);
711
712 return;
713 };
714
715 my $upid = $rpcenv->fork_worker('vncproxy', $vmid, $authuser, $realcmd);
716
717 PVE::Tools::wait_for_vnc_port($port);
718
719 return {
720 user => $authuser,
721 ticket => $ticket,
722 port => $port,
723 upid => $upid,
724 cert => $sslcert,
725 };
726 }});
727
728 __PACKAGE__->register_method({
729 name => 'vncwebsocket',
730 path => '{vmid}/vncwebsocket',
731 method => 'GET',
732 permissions => {
733 description => "You also need to pass a valid ticket (vncticket).",
734 check => ['perm', '/vms/{vmid}', [ 'VM.Console' ]],
735 },
736 description => "Opens a weksocket for VNC traffic.",
737 parameters => {
738 additionalProperties => 0,
739 properties => {
740 node => get_standard_option('pve-node'),
741 vmid => get_standard_option('pve-vmid'),
742 vncticket => {
743 description => "Ticket from previous call to vncproxy.",
744 type => 'string',
745 maxLength => 512,
746 },
747 port => {
748 description => "Port number returned by previous vncproxy call.",
749 type => 'integer',
750 minimum => 5900,
751 maximum => 5999,
752 },
753 },
754 },
755 returns => {
756 type => "object",
757 properties => {
758 port => { type => 'string' },
759 },
760 },
761 code => sub {
762 my ($param) = @_;
763
764 my $rpcenv = PVE::RPCEnvironment::get();
765
766 my $authuser = $rpcenv->get_user();
767
768 my $authpath = "/vms/$param->{vmid}";
769
770 PVE::AccessControl::verify_vnc_ticket($param->{vncticket}, $authuser, $authpath);
771
772 my $port = $param->{port};
773
774 return { port => $port };
775 }});
776
777 __PACKAGE__->register_method ({
778 name => 'spiceproxy',
779 path => '{vmid}/spiceproxy',
780 method => 'POST',
781 protected => 1,
782 proxyto => 'node',
783 permissions => {
784 check => ['perm', '/vms/{vmid}', [ 'VM.Console' ]],
785 },
786 description => "Returns a SPICE configuration to connect to the CT.",
787 parameters => {
788 additionalProperties => 0,
789 properties => {
790 node => get_standard_option('pve-node'),
791 vmid => get_standard_option('pve-vmid'),
792 proxy => get_standard_option('spice-proxy', { optional => 1 }),
793 },
794 },
795 returns => get_standard_option('remote-viewer-config'),
796 code => sub {
797 my ($param) = @_;
798
799 my $vmid = $param->{vmid};
800 my $node = $param->{node};
801 my $proxy = $param->{proxy};
802
803 my $authpath = "/vms/$vmid";
804 my $permissions = 'VM.Console';
805
806 my $conf = PVE::LXC::Config->load_config($vmid);
807
808 die "CT $vmid not running\n" if !PVE::LXC::check_running($vmid);
809
810 my $concmd = PVE::LXC::get_console_command($vmid, $conf);
811
812 my $shcmd = ['/usr/bin/dtach', '-A',
813 "/var/run/dtach/vzctlconsole$vmid",
814 '-r', 'winch', '-z', @$concmd];
815
816 my $title = "CT $vmid";
817
818 return PVE::API2Tools::run_spiceterm($authpath, $permissions, $vmid, $node, $proxy, $title, $shcmd);
819 }});
820
821
822 __PACKAGE__->register_method({
823 name => 'migrate_vm',
824 path => '{vmid}/migrate',
825 method => 'POST',
826 protected => 1,
827 proxyto => 'node',
828 description => "Migrate the container to another node. Creates a new migration task.",
829 permissions => {
830 check => ['perm', '/vms/{vmid}', [ 'VM.Migrate' ]],
831 },
832 parameters => {
833 additionalProperties => 0,
834 properties => {
835 node => get_standard_option('pve-node'),
836 vmid => get_standard_option('pve-vmid', { completion => \&PVE::LXC::complete_ctid }),
837 target => get_standard_option('pve-node', {
838 description => "Target node.",
839 completion => \&PVE::Cluster::complete_migration_target,
840 }),
841 online => {
842 type => 'boolean',
843 description => "Use online/live migration.",
844 optional => 1,
845 },
846 force => {
847 type => 'boolean',
848 description => "Force migration despite local bind / device" .
849 " mounts. WARNING: identical bind / device mounts need to ".
850 " be available on the target node.",
851 optional => 1,
852 },
853 },
854 },
855 returns => {
856 type => 'string',
857 description => "the task ID.",
858 },
859 code => sub {
860 my ($param) = @_;
861
862 my $rpcenv = PVE::RPCEnvironment::get();
863
864 my $authuser = $rpcenv->get_user();
865
866 my $target = extract_param($param, 'target');
867
868 my $localnode = PVE::INotify::nodename();
869 raise_param_exc({ target => "target is local node."}) if $target eq $localnode;
870
871 PVE::Cluster::check_cfs_quorum();
872
873 PVE::Cluster::check_node_exists($target);
874
875 my $targetip = PVE::Cluster::remote_node_ip($target);
876
877 my $vmid = extract_param($param, 'vmid');
878
879 # test if VM exists
880 PVE::LXC::Config->load_config($vmid);
881
882 # try to detect errors early
883 if (PVE::LXC::check_running($vmid)) {
884 die "can't migrate running container without --online\n"
885 if !$param->{online};
886 }
887
888 if (PVE::HA::Config::vm_is_ha_managed($vmid) && $rpcenv->{type} ne 'ha') {
889
890 my $hacmd = sub {
891 my $upid = shift;
892
893 my $service = "ct:$vmid";
894
895 my $cmd = ['ha-manager', 'migrate', $service, $target];
896
897 print "Executing HA migrate for CT $vmid to node $target\n";
898
899 PVE::Tools::run_command($cmd);
900
901 return;
902 };
903
904 return $rpcenv->fork_worker('hamigrate', $vmid, $authuser, $hacmd);
905
906 } else {
907
908 my $realcmd = sub {
909 my $upid = shift;
910
911 PVE::LXC::Migrate->migrate($target, $targetip, $vmid, $param);
912
913 return;
914 };
915
916 return $rpcenv->fork_worker('vzmigrate', $vmid, $authuser, $realcmd);
917 }
918 }});
919
920 __PACKAGE__->register_method({
921 name => 'vm_feature',
922 path => '{vmid}/feature',
923 method => 'GET',
924 proxyto => 'node',
925 protected => 1,
926 description => "Check if feature for virtual machine is available.",
927 permissions => {
928 check => ['perm', '/vms/{vmid}', [ 'VM.Audit' ]],
929 },
930 parameters => {
931 additionalProperties => 0,
932 properties => {
933 node => get_standard_option('pve-node'),
934 vmid => get_standard_option('pve-vmid'),
935 feature => {
936 description => "Feature to check.",
937 type => 'string',
938 enum => [ 'snapshot' ],
939 },
940 snapname => get_standard_option('pve-lxc-snapshot-name', {
941 optional => 1,
942 }),
943 },
944 },
945 returns => {
946 type => "object",
947 properties => {
948 hasFeature => { type => 'boolean' },
949 #nodes => {
950 #type => 'array',
951 #items => { type => 'string' },
952 #}
953 },
954 },
955 code => sub {
956 my ($param) = @_;
957
958 my $node = extract_param($param, 'node');
959
960 my $vmid = extract_param($param, 'vmid');
961
962 my $snapname = extract_param($param, 'snapname');
963
964 my $feature = extract_param($param, 'feature');
965
966 my $conf = PVE::LXC::Config->load_config($vmid);
967
968 if($snapname){
969 my $snap = $conf->{snapshots}->{$snapname};
970 die "snapshot '$snapname' does not exist\n" if !defined($snap);
971 $conf = $snap;
972 }
973 my $storage_cfg = PVE::Storage::config();
974 #Maybe include later
975 #my $nodelist = PVE::LXC::shared_nodes($conf, $storage_cfg);
976 my $hasFeature = PVE::LXC::Config->has_feature($feature, $conf, $storage_cfg, $snapname);
977
978 return {
979 hasFeature => $hasFeature,
980 #nodes => [ keys %$nodelist ],
981 };
982 }});
983
984 __PACKAGE__->register_method({
985 name => 'template',
986 path => '{vmid}/template',
987 method => 'POST',
988 protected => 1,
989 proxyto => 'node',
990 description => "Create a Template.",
991 permissions => {
992 description => "You need 'VM.Allocate' permissions on /vms/{vmid}",
993 check => [ 'perm', '/vms/{vmid}', ['VM.Allocate']],
994 },
995 parameters => {
996 additionalProperties => 0,
997 properties => {
998 node => get_standard_option('pve-node'),
999 vmid => get_standard_option('pve-vmid', { completion => \&PVE::LXC::complete_ctid_stopped }),
1000 experimental => {
1001 type => 'boolean',
1002 description => "The template feature is experimental, set this " .
1003 "flag if you know what you are doing.",
1004 default => 0,
1005 },
1006 },
1007 },
1008 returns => { type => 'null'},
1009 code => sub {
1010 my ($param) = @_;
1011
1012 my $rpcenv = PVE::RPCEnvironment::get();
1013
1014 my $authuser = $rpcenv->get_user();
1015
1016 my $node = extract_param($param, 'node');
1017
1018 my $vmid = extract_param($param, 'vmid');
1019
1020 my $updatefn = sub {
1021
1022 my $conf = PVE::LXC::Config->load_config($vmid);
1023 PVE::LXC::Config->check_lock($conf);
1024
1025 die "unable to create template, because CT contains snapshots\n"
1026 if $conf->{snapshots} && scalar(keys %{$conf->{snapshots}});
1027
1028 die "you can't convert a template to a template\n"
1029 if PVE::LXC::Config->is_template($conf);
1030
1031 die "you can't convert a CT to template if the CT is running\n"
1032 if PVE::LXC::check_running($vmid);
1033
1034 my $realcmd = sub {
1035 PVE::LXC::template_create($vmid, $conf);
1036 };
1037
1038 $conf->{template} = 1;
1039
1040 PVE::LXC::Config->write_config($vmid, $conf);
1041 # and remove lxc config
1042 PVE::LXC::update_lxc_config($vmid, $conf);
1043
1044 return $rpcenv->fork_worker('vztemplate', $vmid, $authuser, $realcmd);
1045 };
1046
1047 PVE::LXC::Config->lock_config($vmid, $updatefn);
1048
1049 return undef;
1050 }});
1051
1052 __PACKAGE__->register_method({
1053 name => 'clone_vm',
1054 path => '{vmid}/clone',
1055 method => 'POST',
1056 protected => 1,
1057 proxyto => 'node',
1058 description => "Create a container clone/copy",
1059 permissions => {
1060 description => "You need 'VM.Clone' permissions on /vms/{vmid}, " .
1061 "and 'VM.Allocate' permissions " .
1062 "on /vms/{newid} (or on the VM pool /pool/{pool}). You also need " .
1063 "'Datastore.AllocateSpace' on any used storage.",
1064 check =>
1065 [ 'and',
1066 ['perm', '/vms/{vmid}', [ 'VM.Clone' ]],
1067 [ 'or',
1068 [ 'perm', '/vms/{newid}', ['VM.Allocate']],
1069 [ 'perm', '/pool/{pool}', ['VM.Allocate'], require_param => 'pool'],
1070 ],
1071 ]
1072 },
1073 parameters => {
1074 additionalProperties => 0,
1075 properties => {
1076 node => get_standard_option('pve-node'),
1077 vmid => get_standard_option('pve-vmid', { completion => \&PVE::LXC::complete_ctid }),
1078 newid => get_standard_option('pve-vmid', {
1079 completion => \&PVE::Cluster::complete_next_vmid,
1080 description => 'VMID for the clone.' }),
1081 hostname => {
1082 optional => 1,
1083 type => 'string', format => 'dns-name',
1084 description => "Set a hostname for the new CT.",
1085 },
1086 description => {
1087 optional => 1,
1088 type => 'string',
1089 description => "Description for the new CT.",
1090 },
1091 pool => {
1092 optional => 1,
1093 type => 'string', format => 'pve-poolid',
1094 description => "Add the new CT to the specified pool.",
1095 },
1096 snapname => get_standard_option('pve-lxc-snapshot-name', {
1097 optional => 1,
1098 }),
1099 storage => get_standard_option('pve-storage-id', {
1100 description => "Target storage for full clone.",
1101 requires => 'full',
1102 optional => 1,
1103 }),
1104 full => {
1105 optional => 1,
1106 type => 'boolean',
1107 description => "Create a full copy of all disk. This is always done when " .
1108 "you clone a normal CT. For CT templates, we try to create a linked clone by default.",
1109 default => 0,
1110 },
1111 experimental => {
1112 type => 'boolean',
1113 description => "The clone feature is experimental, set this " .
1114 "flag if you know what you are doing.",
1115 default => 0,
1116 },
1117 # target => get_standard_option('pve-node', {
1118 # description => "Target node. Only allowed if the original VM is on shared storage.",
1119 # optional => 1,
1120 # }),
1121 },
1122 },
1123 returns => {
1124 type => 'string',
1125 },
1126 code => sub {
1127 my ($param) = @_;
1128
1129 my $rpcenv = PVE::RPCEnvironment::get();
1130
1131 my $authuser = $rpcenv->get_user();
1132
1133 my $node = extract_param($param, 'node');
1134
1135 my $vmid = extract_param($param, 'vmid');
1136
1137 my $newid = extract_param($param, 'newid');
1138
1139 my $pool = extract_param($param, 'pool');
1140
1141 if (defined($pool)) {
1142 $rpcenv->check_pool_exist($pool);
1143 }
1144
1145 my $snapname = extract_param($param, 'snapname');
1146
1147 my $storage = extract_param($param, 'storage');
1148
1149 my $localnode = PVE::INotify::nodename();
1150
1151 my $storecfg = PVE::Storage::config();
1152
1153 if ($storage) {
1154 # check if storage is enabled on local node
1155 PVE::Storage::storage_check_enabled($storecfg, $storage);
1156 }
1157
1158 PVE::Cluster::check_cfs_quorum();
1159
1160 my $running = PVE::LXC::check_running($vmid) || 0;
1161
1162 my $clonefn = sub {
1163
1164 # do all tests after lock
1165 # we also try to do all tests before we fork the worker
1166 my $conf = PVE::LXC::Config->load_config($vmid);
1167
1168 PVE::LXC::Config->check_lock($conf);
1169
1170 my $verify_running = PVE::LXC::check_running($vmid) || 0;
1171
1172 die "unexpected state change\n" if $verify_running != $running;
1173
1174 die "snapshot '$snapname' does not exist\n"
1175 if $snapname && !defined( $conf->{snapshots}->{$snapname});
1176
1177 my $oldconf = $snapname ? $conf->{snapshots}->{$snapname} : $conf;
1178
1179 my $conffile = PVE::LXC::Config->config_file($newid);
1180 die "unable to create CT $newid: config file already exists\n"
1181 if -f $conffile;
1182
1183 my $newconf = { lock => 'clone' };
1184 my $mountpoints = {};
1185 my $fullclone = {};
1186 my $vollist = [];
1187
1188 foreach my $opt (keys %$oldconf) {
1189 my $value = $oldconf->{$opt};
1190
1191 # no need to copy unused images, because VMID(owner) changes anyways
1192 next if $opt =~ m/^unused\d+$/;
1193
1194 if (($opt eq 'rootfs') || ($opt =~ m/^mp\d+$/)) {
1195 my $mp = $opt eq 'rootfs' ?
1196 PVE::LXC::Config->parse_ct_rootfs($value) :
1197 PVE::LXC::Config->parse_ct_mountpoint($value);
1198
1199 if ($mp->{type} eq 'volume') {
1200 my $volid = $mp->{volume};
1201 if ($param->{full}) {
1202 die "fixme: full clone not implemented";
1203
1204 die "Full clone feature for '$volid' is not available\n"
1205 if !PVE::Storage::volume_has_feature($storecfg, 'copy', $volid, $snapname, $running);
1206 $fullclone->{$opt} = 1;
1207 } else {
1208 # not full means clone instead of copy
1209 die "Linked clone feature for '$volid' is not available\n"
1210 if !PVE::Storage::volume_has_feature($storecfg, 'clone', $volid, $snapname, $running);
1211 }
1212
1213 $mountpoints->{$opt} = $mp;
1214 push @$vollist, $volid;
1215
1216 } else {
1217 # TODO: allow bind mounts?
1218 die "unable to clone mountpint '$opt' (type $mp->{type})\n";
1219 }
1220
1221 } else {
1222 # copy everything else
1223 $newconf->{$opt} = $value;
1224 }
1225 }
1226
1227 delete $newconf->{template};
1228 if ($param->{hostname}) {
1229 $newconf->{hostname} = $param->{hostname};
1230 }
1231
1232 if ($param->{description}) {
1233 $newconf->{description} = $param->{description};
1234 }
1235
1236 # create empty/temp config - this fails if CT already exists on other node
1237 PVE::Tools::file_set_contents($conffile, "# ctclone temporary file\nlock: clone\n");
1238
1239 my $realcmd = sub {
1240 my $upid = shift;
1241
1242 my $newvollist = [];
1243
1244 eval {
1245 local $SIG{INT} = $SIG{TERM} = $SIG{QUIT} = $SIG{HUP} = sub { die "interrupted by signal\n"; };
1246
1247 PVE::Storage::activate_volumes($storecfg, $vollist, $snapname);
1248
1249 foreach my $opt (keys %$mountpoints) {
1250 my $mp = $mountpoints->{$opt};
1251 my $volid = $mp->{volume};
1252
1253 if ($fullclone->{$opt}) {
1254 die "fixme: full clone not implemented\n";
1255 } else {
1256 print "create linked clone of mountpoint $opt ($volid)\n";
1257 my $newvolid = PVE::Storage::vdisk_clone($storecfg, $volid, $newid, $snapname);
1258 push @$newvollist, $newvolid;
1259 $mp->{volume} = $newvolid;
1260
1261 $newconf->{$opt} = PVE::LXC::Config->print_ct_mountpoint($mp, $opt eq 'rootfs');
1262 PVE::LXC::Config->write_config($newid, $newconf);
1263 }
1264 }
1265
1266 delete $newconf->{lock};
1267 PVE::LXC::Config->write_config($newid, $newconf);
1268
1269 PVE::AccessControl::add_vm_to_pool($newid, $pool) if $pool;
1270 };
1271 if (my $err = $@) {
1272 unlink $conffile;
1273
1274 sleep 1; # some storage like rbd need to wait before release volume - really?
1275
1276 foreach my $volid (@$newvollist) {
1277 eval { PVE::Storage::vdisk_free($storecfg, $volid); };
1278 warn $@ if $@;
1279 }
1280 die "clone failed: $err";
1281 }
1282
1283 return;
1284 };
1285
1286 PVE::Firewall::clone_vmfw_conf($vmid, $newid);
1287
1288 return $rpcenv->fork_worker('vzclone', $vmid, $authuser, $realcmd);
1289
1290 };
1291
1292 return PVE::LXC::Config->lock_config($vmid, $clonefn);
1293 }});
1294
1295
1296 __PACKAGE__->register_method({
1297 name => 'resize_vm',
1298 path => '{vmid}/resize',
1299 method => 'PUT',
1300 protected => 1,
1301 proxyto => 'node',
1302 description => "Resize a container mountpoint.",
1303 permissions => {
1304 check => ['perm', '/vms/{vmid}', ['VM.Config.Disk'], any => 1],
1305 },
1306 parameters => {
1307 additionalProperties => 0,
1308 properties => {
1309 node => get_standard_option('pve-node'),
1310 vmid => get_standard_option('pve-vmid', { completion => \&PVE::LXC::complete_ctid }),
1311 disk => {
1312 type => 'string',
1313 description => "The disk you want to resize.",
1314 enum => [PVE::LXC::Config->mountpoint_names()],
1315 },
1316 size => {
1317 type => 'string',
1318 pattern => '\+?\d+(\.\d+)?[KMGT]?',
1319 description => "The new size. With the '+' sign the value is added to the actual size of the volume and without it, the value is taken as an absolute one. Shrinking disk size is not supported.",
1320 },
1321 digest => {
1322 type => 'string',
1323 description => 'Prevent changes if current configuration file has different SHA1 digest. This can be used to prevent concurrent modifications.',
1324 maxLength => 40,
1325 optional => 1,
1326 }
1327 },
1328 },
1329 returns => {
1330 type => 'string',
1331 description => "the task ID.",
1332 },
1333 code => sub {
1334 my ($param) = @_;
1335
1336 my $rpcenv = PVE::RPCEnvironment::get();
1337
1338 my $authuser = $rpcenv->get_user();
1339
1340 my $node = extract_param($param, 'node');
1341
1342 my $vmid = extract_param($param, 'vmid');
1343
1344 my $digest = extract_param($param, 'digest');
1345
1346 my $sizestr = extract_param($param, 'size');
1347 my $ext = ($sizestr =~ s/^\+//);
1348 my $newsize = PVE::JSONSchema::parse_size($sizestr);
1349 die "invalid size string" if !defined($newsize);
1350
1351 die "no options specified\n" if !scalar(keys %$param);
1352
1353 PVE::LXC::check_ct_modify_config_perm($rpcenv, $authuser, $vmid, undef, $param, []);
1354
1355 my $storage_cfg = cfs_read_file("storage.cfg");
1356
1357 my $code = sub {
1358
1359 my $conf = PVE::LXC::Config->load_config($vmid);
1360 PVE::LXC::Config->check_lock($conf);
1361
1362 PVE::Tools::assert_if_modified($digest, $conf->{digest});
1363
1364 my $running = PVE::LXC::check_running($vmid);
1365
1366 my $disk = $param->{disk};
1367 my $mp = $disk eq 'rootfs' ? PVE::LXC::Config->parse_ct_rootfs($conf->{$disk}) :
1368 PVE::LXC::Config->parse_ct_mountpoint($conf->{$disk});
1369
1370 my $volid = $mp->{volume};
1371
1372 my (undef, undef, $owner, undef, undef, undef, $format) =
1373 PVE::Storage::parse_volname($storage_cfg, $volid);
1374
1375 die "can't resize mountpoint owned by another container ($owner)"
1376 if $vmid != $owner;
1377
1378 die "can't resize volume: $disk if snapshot exists\n"
1379 if %{$conf->{snapshots}} && $format eq 'qcow2';
1380
1381 my ($storeid, $volname) = PVE::Storage::parse_volume_id($volid);
1382
1383 $rpcenv->check($authuser, "/storage/$storeid", ['Datastore.AllocateSpace']);
1384
1385 PVE::Storage::activate_volumes($storage_cfg, [$volid]);
1386
1387 my $size = PVE::Storage::volume_size_info($storage_cfg, $volid, 5);
1388 $newsize += $size if $ext;
1389 $newsize = int($newsize);
1390
1391 die "unable to shrink disk size\n" if $newsize < $size;
1392
1393 return if $size == $newsize;
1394
1395 PVE::Cluster::log_msg('info', $authuser, "update CT $vmid: resize --disk $disk --size $sizestr");
1396 my $realcmd = sub {
1397 # Note: PVE::Storage::volume_resize doesn't do anything if $running=1, so
1398 # we pass 0 here (parameter only makes sense for qemu)
1399 PVE::Storage::volume_resize($storage_cfg, $volid, $newsize, 0);
1400
1401 $mp->{size} = $newsize;
1402 $conf->{$disk} = PVE::LXC::Config->print_ct_mountpoint($mp, $disk eq 'rootfs');
1403
1404 PVE::LXC::Config->write_config($vmid, $conf);
1405
1406 if ($format eq 'raw') {
1407 my $path = PVE::Storage::path($storage_cfg, $volid, undef);
1408 if ($running) {
1409
1410 $mp->{mp} = '/';
1411 my $use_loopdev = (PVE::LXC::mountpoint_mount_path($mp, $storage_cfg))[1];
1412 $path = PVE::LXC::query_loopdev($path) if $use_loopdev;
1413 die "internal error: CT running but mountpoint not attached to a loop device"
1414 if !$path;
1415 PVE::Tools::run_command(['losetup', '--set-capacity', $path]) if $use_loopdev;
1416
1417 # In order for resize2fs to know that we need online-resizing a mountpoint needs
1418 # to be visible to it in its namespace.
1419 # To not interfere with the rest of the system we unshare the current mount namespace,
1420 # mount over /tmp and then run resize2fs.
1421
1422 # interestingly we don't need to e2fsck on mounted systems...
1423 my $quoted = PVE::Tools::shellquote($path);
1424 my $cmd = "mount --make-rprivate / && mount $quoted /tmp && resize2fs $quoted";
1425 eval {
1426 PVE::Tools::run_command(['unshare', '-m', '--', 'sh', '-c', $cmd]);
1427 };
1428 warn "Failed to update the container's filesystem: $@\n" if $@;
1429 } else {
1430 eval {
1431 PVE::Tools::run_command(['e2fsck', '-f', '-y', $path]);
1432 PVE::Tools::run_command(['resize2fs', $path]);
1433 };
1434 warn "Failed to update the container's filesystem: $@\n" if $@;
1435 }
1436 }
1437 };
1438
1439 return $rpcenv->fork_worker('resize', $vmid, $authuser, $realcmd);
1440 };
1441
1442 return PVE::LXC::Config->lock_config($vmid, $code);;
1443 }});
1444
1445 1;