13 use PVE
::Exception
qw(raise_param_exc);
14 use PVE
::GuestHelpers
;
16 use PVE
::JSONSchema
qw(get_standard_option);
18 use PVE
::RPCEnvironment
;
20 use PVE
::Tools
qw(extract_param);
22 use PVE
::API2
::LXC
::Config
;
23 use PVE
::API2
::LXC
::Snapshot
;
24 use PVE
::API2
::LXC
::Status
;
27 use base
qw(PVE::CLIHandler);
29 my $nodename = PVE
::INotify
::nodename
();
33 my $status = PVE
::Tools
::upid_read_status
($upid);
34 exit(PVE
::Tools
::upid_status_is_error
($status) ?
-1 : 0);
37 sub setup_environment
{
38 PVE
::RPCEnvironment-
>setup_default_cli_env();
41 __PACKAGE__-
>register_method ({
45 description
=> "Show CT status.",
47 additionalProperties
=> 0,
49 vmid
=> get_standard_option
('pve-vmid', { completion
=> \
&PVE
::LXC
::complete_ctid
}),
51 description
=> "Verbose output format",
57 returns
=> { type
=> 'null'},
62 my $conf = PVE
::LXC
::Config-
>load_config ($param->{vmid
});
64 my $vmstatus = PVE
::LXC
::vmstatus
($param->{vmid
});
65 my $stat = $vmstatus->{$param->{vmid
}};
66 if ($param->{verbose
}) {
67 foreach my $k (sort (keys %$stat)) {
73 my $status = $stat->{status
} || 'unknown';
74 print "status: $status\n";
85 PVE
::CLIHandler
::get_standard_mapping
('pve-password'),
90 return $mapping->{$name};
93 __PACKAGE__-
>register_method ({
97 description
=> "Unlock the VM.",
99 additionalProperties
=> 0,
101 vmid
=> get_standard_option
('pve-vmid', { completion
=> \
&PVE
::LXC
::complete_ctid
}),
104 returns
=> { type
=> 'null'},
108 my $vmid = $param->{vmid
};
110 PVE
::LXC
::Config-
>remove_lock($vmid);
115 __PACKAGE__-
>register_method ({
119 description
=> "Launch a console for the specified container.",
121 additionalProperties
=> 0,
123 vmid
=> get_standard_option
('pve-vmid', { completion
=> \
&PVE
::LXC
::complete_ctid_running
}),
125 description
=> "Escape sequence prefix. For example to use <Ctrl+b q> as the escape sequence pass '^b'.",
128 pattern
=> '\^?[a-z]',
133 returns
=> { type
=> 'null' },
138 # test if container exists on this node
139 my $conf = PVE
::LXC
::Config-
>load_config($param->{vmid
});
141 my $cmd = PVE
::LXC
::get_console_command
($param->{vmid
}, $conf, $param->{escape
});
145 __PACKAGE__-
>register_method ({
149 description
=> "Launch a shell for the specified container.",
151 additionalProperties
=> 0,
153 vmid
=> get_standard_option
('pve-vmid', { completion
=> \
&PVE
::LXC
::complete_ctid_running
}),
156 returns
=> { type
=> 'null' },
161 my $vmid = $param->{vmid
};
163 PVE
::LXC
::Config-
>load_config($vmid); # test if container exists on this node
164 die "container '$vmid' not running!\n" if !PVE
::LXC
::check_running
($vmid);
166 exec('lxc-attach', '-n', $vmid);
169 __PACKAGE__-
>register_method ({
173 description
=> "Launch a command inside the specified container.",
175 additionalProperties
=> 0,
177 vmid
=> get_standard_option
('pve-vmid', { completion
=> \
&PVE
::LXC
::complete_ctid_running
}),
178 'extra-args' => get_standard_option
('extra-args'),
181 returns
=> { type
=> 'null' },
185 my $vmid = $param->{vmid
};
186 PVE
::LXC
::Config-
>load_config($vmid); # test if container exists on this node
187 die "container '$vmid' not running!\n" if !PVE
::LXC
::check_running
($vmid);
189 die "missing command" if !@{$param->{'extra-args'}};
191 exec('lxc-attach', '-n', $vmid, '--', @{$param->{'extra-args'}});
194 __PACKAGE__-
>register_method ({
198 description
=> "Run a filesystem check (fsck) on a container volume.",
200 additionalProperties
=> 0,
202 vmid
=> get_standard_option
('pve-vmid', { completion
=> \
&PVE
::LXC
::complete_ctid_stopped
}),
206 description
=> "Force checking, even if the filesystem seems clean",
212 description
=> "A volume on which to run the filesystem check",
213 enum
=> [PVE
::LXC
::Config-
>valid_volume_keys()],
217 returns
=> { type
=> 'null' },
221 my $vmid = $param->{'vmid'};
222 my $device = defined($param->{'device'}) ?
$param->{'device'} : 'rootfs';
224 my $command = ['fsck', '-a', '-l'];
225 push(@$command, '-f') if $param->{force
};
227 # critical path: all of this will be done while the container is locked
230 my $conf = PVE
::LXC
::Config-
>load_config($vmid);
231 my $storage_cfg = PVE
::Storage
::config
();
233 defined($conf->{$device}) || die "cannot run command on non-existing mount point $device\n";
235 my $mount_point = PVE
::LXC
::Config-
>parse_volume($device, $conf->{$device});
237 die "cannot run fsck when container is running\n"
238 if PVE
::LXC
::check_running
($vmid);
240 my $volid = $mount_point->{volume
};
243 my $storage_id = PVE
::Storage
::parse_volume_id
($volid, 1);
246 my (undef, undef, undef, undef, undef, undef, $format) =
247 PVE
::Storage
::parse_volname
($storage_cfg, $volid);
249 die "unable to run fsck for '$volid' (format == $format)\n"
252 $path = PVE
::Storage
::map_volume
($storage_cfg, $volid);
255 if (($volid =~ m
|^/.+|) && (-b
$volid)) {
256 # pass block devices directly
259 die "path '$volid' does not point to a block device\n";
263 push(@$command, $path);
264 PVE
::Tools
::run_command
($command);
266 PVE
::Storage
::unmap_volume
($storage_cfg, $volid) if $storage_id;
269 PVE
::LXC
::Config-
>lock_config($vmid, $do_fsck);
273 __PACKAGE__-
>register_method({
277 description
=> "Mount the container's filesystem on the host. " .
278 "This will hold a lock on the container and is meant for emergency maintenance only " .
279 "as it will prevent further operations on the container other than start and stop.",
281 additionalProperties
=> 0,
283 vmid
=> get_standard_option
('pve-vmid', { completion
=> \
&PVE
::LXC
::complete_ctid
}),
286 returns
=> { type
=> 'null' },
290 my $rpcenv = PVE
::RPCEnvironment
::get
();
292 my $vmid = extract_param
($param, 'vmid');
293 my $storecfg = PVE
::Storage
::config
();
294 PVE
::LXC
::Config-
>lock_config($vmid, sub {
295 my $conf = PVE
::LXC
::Config-
>set_lock($vmid, 'mounted');
296 PVE
::LXC
::mount_all
($vmid, $storecfg, $conf);
299 print "mounted CT $vmid in '/var/lib/lxc/$vmid/rootfs'\n";
303 __PACKAGE__-
>register_method({
307 description
=> "Unmount the container's filesystem.",
309 additionalProperties
=> 0,
311 vmid
=> get_standard_option
('pve-vmid', { completion
=> \
&PVE
::LXC
::complete_ctid
}),
314 returns
=> { type
=> 'null' },
318 my $rpcenv = PVE
::RPCEnvironment
::get
();
320 my $vmid = extract_param
($param, 'vmid');
321 my $storecfg = PVE
::Storage
::config
();
322 PVE
::LXC
::Config-
>lock_config($vmid, sub {
323 my $conf = PVE
::LXC
::Config-
>load_config($vmid);
324 PVE
::LXC
::umount_all
($vmid, $storecfg, $conf, 0);
325 PVE
::LXC
::Config-
>remove_lock($vmid, 'mounted');
330 __PACKAGE__-
>register_method({
334 description
=> "Get the container's current disk usage.",
336 additionalProperties
=> 0,
338 vmid
=> get_standard_option
('pve-vmid', { completion
=> \
&PVE
::LXC
::complete_ctid
}),
341 returns
=> { type
=> 'null' },
345 my $rpcenv = PVE
::RPCEnvironment
::get
();
347 # JSONSchema's format_size is exact, this uses floating point numbers
350 return $size if $size < 1024.;
352 return sprintf('%.1fK', ${size
}) if $size < 1024.;
354 return sprintf('%.1fM', ${size
}) if $size < 1024.;
356 return sprintf('%.1fG', ${size
}) if $size < 1024.;
358 return sprintf('%.1fT', ${size
}) if $size < 1024.;
361 my $vmid = extract_param
($param, 'vmid');
362 PVE
::LXC
::Config-
>lock_config($vmid, sub {
363 my $pid = eval { PVE
::LXC
::find_lxc_pid
($vmid) };
364 my ($conf, $rootdir, $storecfg, $mounted);
366 $conf = PVE
::LXC
::Config-
>set_lock($vmid, 'mounted');
367 $rootdir = "/var/lib/lxc/$vmid/rootfs";
368 $storecfg = PVE
::Storage
::config
();
369 PVE
::LXC
::mount_all
($vmid, $storecfg, $conf);
372 $conf = PVE
::LXC
::Config-
>load_config($vmid);
373 $rootdir = "/proc/$pid/root";
376 my @list = [qw(MP Volume Size Used Avail Use% Path)];
377 my @len = map { length($_) } @{$list[0]};
380 PVE
::LXC
::Config-
>foreach_volume($conf, sub {
381 my ($name, $mp) = @_;
382 my $path = $mp->{mp
};
384 my $df = PVE
::Tools
::df
("$rootdir/$path", 3);
385 my $total = $format->($df->{total
});
386 my $used = $format->($df->{used
});
387 my $avail = $format->($df->{avail
});
389 my $pc = sprintf('%.1f', $df->{used
}/$df->{total
});
391 my $entry = [ $name, $mp->{volume
}, $total, $used, $avail, $pc, $path ];
394 foreach my $i (0..5) {
395 $len[$i] = length($entry->[$i])
396 if $len[$i] < length($entry->[$i]);
400 my $format = "%-$len[0]s %-$len[1]s %$len[2]s %$len[3]s %$len[4]s %$len[5]s %s\n";
401 printf($format, @$_) foreach @list;
406 PVE
::LXC
::umount_all
($vmid, $storecfg, $conf, 0);
407 PVE
::LXC
::Config-
>remove_lock($vmid, 'mounted');
413 # File creation with specified ownership and permissions.
414 # User and group can be names or decimal numbers.
415 # Permissions are explicit (not affected by umask) and can be numeric with the
416 # usual 0/0x prefixes for octal/hex.
418 my ($path, $perms, $user, $group) = @_;
420 if (defined($user)) {
421 if ($user =~ /^\d+$/) {
424 $uid = getpwnam($user);
425 die "failed to get uid for: $user\n" if !defined($uid);
428 if (defined($group)) {
429 if ($group =~ /^\d+$/) {
432 $gid = getgrnam($group);
433 die "failed to get gid for: $group\n" if !defined($gid);
437 if (defined($perms)) {
439 my ($mode, $unparsed) = POSIX
::strtoul
($perms, 0);
440 die "invalid mode: '$perms'\n" if $perms eq '' || $unparsed > 0 || $!;
445 if (sysopen($fd, $path, O_WRONLY
| O_CREAT
| O_EXCL
, 0)) {
446 $perms = 0666 & ~umask if !defined($perms);
448 # If the path previously existed then we do not care about left-over
449 # file descriptors even if the permissions/ownership is changed.
450 sysopen($fd, $path, O_WRONLY
| O_CREAT
| O_TRUNC
)
451 or die "failed to create file: $path: $!\n";
456 if (defined($perms)) {
461 if (defined($uid) || defined($gid)) {
463 my ($fuid, $fgid) = (stat($fd))[4,5] if !defined($uid) || !defined($gid);
464 $uid = $fuid if !defined($uid);
465 $gid = $fgid if !defined($gid);
466 chown($uid, $gid, $fd)
467 or die "failed to change file owner: $!\n";
472 __PACKAGE__-
>register_method ({
476 description
=> "Rescan all storages and update disk sizes and unused disk images.",
478 additionalProperties
=> 0,
480 vmid
=> get_standard_option
('pve-vmid', {
482 completion
=> \
&PVE
::LXC
::complete_ctid
,
488 description
=> 'Do not actually write changes out to conifg.',
492 returns
=> { type
=> 'null'},
496 my $dryrun = $param->{dryrun
};
498 print "NOTE: running in dry-run mode, won't write changes out!\n" if $dryrun;
500 PVE
::LXC
::rescan
($param->{vmid
}, 0, $dryrun);
505 __PACKAGE__-
>register_method({
509 description
=> "Copy a file from the container to the local system.",
511 additionalProperties
=> 0,
513 vmid
=> get_standard_option
('pve-vmid', { completion
=> \
&PVE
::LXC
::complete_ctid
}),
516 description
=> "Path to a file inside the container to pull.",
520 description
=> "Destination",
524 description
=> 'Owner user name or id.',
529 description
=> 'Owner group name or id.',
534 description
=> "File permissions to use (octal by default, prefix with '0x' for hexadecimal).",
541 description
=> "the task ID.",
546 my $rpcenv = PVE
::RPCEnvironment
::get
();
548 my $vmid = extract_param
($param, 'vmid');
549 my $path = extract_param
($param, 'path');
550 my $dest = extract_param
($param, 'destination');
552 my $perms = extract_param
($param, 'perms');
553 # assume octal as default
554 $perms = "0$perms" if defined($perms) && $perms !~m/^0/;
555 my $user = extract_param
($param, 'user');
556 my $group = extract_param
($param, 'group');
559 my $running = PVE
::LXC
::check_running
($vmid);
560 die "can only pull files from a running VM" if !$running;
563 my $pid = PVE
::LXC
::find_lxc_pid
($vmid);
564 # Avoid symlink issues by opening the files from inside the
565 # corresponding namespaces.
566 my $destfd = create_file
($dest, $perms, $user, $group);
568 sysopen my $mntnsfd, "/proc/$pid/ns/mnt", O_RDONLY
569 or die "failed to open the container's mount namespace\n";
570 PVE
::Tools
::setns
(fileno($mntnsfd), PVE
::Tools
::CLONE_NEWNS
)
571 or die "failed to enter the container's mount namespace\n";
573 chdir('/') or die "failed to change to container root directory\n";
575 open my $srcfd, '<', $path
576 or die "failed to open $path: $!\n";
578 copy
($srcfd, $destfd);
581 # This avoids having to setns() back to our namespace.
582 return $rpcenv->fork_worker('pull_file', $vmid, undef, $realcmd);
585 return PVE
::LXC
::Config-
>lock_config($vmid, $code);
588 __PACKAGE__-
>register_method({
592 description
=> "Copy a local file to the container.",
594 additionalProperties
=> 0,
596 vmid
=> get_standard_option
('pve-vmid', { completion
=> \
&PVE
::LXC
::complete_ctid
}),
599 description
=> "Path to a local file.",
603 description
=> "Destination inside the container to write to.",
607 description
=> 'Owner user name or id. When using a name it must exist inside the container.',
612 description
=> 'Owner group name or id. When using a name it must exist inside the container.',
617 description
=> "File permissions to use (octal by default, prefix with '0x' for hexadecimal).",
624 description
=> "the task ID.",
629 my $rpcenv = PVE
::RPCEnvironment
::get
();
631 my $vmid = extract_param
($param, 'vmid');
632 my $file = extract_param
($param, 'file');
633 my $dest = extract_param
($param, 'destination');
635 my $perms = extract_param
($param, 'perms');
636 # assume octal as default
637 $perms = "0$perms" if defined($perms) && $perms !~m/^0/;
638 my $user = extract_param
($param, 'user');
639 my $group = extract_param
($param, 'group');
642 my $running = PVE
::LXC
::check_running
($vmid);
643 die "can only push files to a running CT\n" if !$running;
645 my $conf = PVE
::LXC
::Config-
>load_config($vmid);
646 my $unprivileged = $conf->{unprivileged
};
649 my $pid = PVE
::LXC
::find_lxc_pid
($vmid);
650 # We open the file then enter the container's mount - and for
651 # unprivileged containers - user namespace and then create the
652 # file. This avoids symlink attacks as a symlink cannot point
653 # outside the namespace and our own access is equivalent to the
654 # container-local's root user. Also the user-passed -user and
655 # -group parameters will use the container-local's user and
657 sysopen my $srcfd, $file, O_RDONLY
658 or die "failed to open $file for reading\n";
660 sysopen my $mntnsfd, "/proc/$pid/ns/mnt", O_RDONLY
661 or die "failed to open the container's mount namespace\n";
664 sysopen $usernsfd, "/proc/$pid/ns/user", O_RDONLY
665 or die "failed to open the container's user namespace\n";
668 PVE
::Tools
::setns
(fileno($mntnsfd), PVE
::Tools
::CLONE_NEWNS
)
669 or die "failed to enter the container's mount namespace\n";
671 chdir('/') or die "failed to change to container root directory\n";
674 PVE
::Tools
::setns
(fileno($usernsfd), PVE
::Tools
::CLONE_NEWUSER
)
675 or die "failed to enter the container's user namespace\n";
677 POSIX
::setgid
(0) or die "setgid failed: $!\n";
678 POSIX
::setuid
(0) or die "setuid failed: $!\n";
681 my $destfd = create_file
($dest, $perms, $user, $group);
682 copy
($srcfd, $destfd);
685 # This avoids having to setns() back to our namespace.
686 return $rpcenv->fork_worker('push_file', $vmid, undef, $realcmd);
689 return PVE
::LXC
::Config-
>lock_config($vmid, $code);
692 __PACKAGE__-
>register_method ({
696 description
=> "Print the list of assigned CPU sets.",
698 additionalProperties
=> 0,
701 returns
=> { type
=> 'null'},
705 my $ctlist = PVE
::LXC
::config_list
();
711 foreach my $vmid (sort keys %$ctlist) {
712 my $cgroup = PVE
::LXC
::CGroup-
>new($vmid);
715 if (defined($path = $cgroup->get_path('cpuset', 1))) {
716 $cpuset = eval { PVE
::CpuSet-
>new_from_path($path, 1); };
717 } elsif (defined($path = $cgroup->get_path(undef, 1))) {
718 $cpuset = eval { PVE
::CpuSet-
>new_from_path($path, 1); };
720 # Container not running.
728 my @cpuset_members = $cpuset->members();
732 my $last = $cpuset_members[-1];
734 for (my $id = 0; $id <= $last; $id++) {
735 my $empty = ' ' x
length("$id");
736 $line .= ' ' . ($cpuset->has($id) ?
$id : $empty);
738 $len = length($line) if length($line) > $len;
739 $id_len = length($vmid) if length($vmid) > $id_len;
741 $res->{$vmid} = $line;
744 my @vmlist = sort keys %$res;
746 if (scalar(@vmlist)) {
747 my $header = '-' x
($len + $id_len) . "\n";
750 foreach my $vmid (@vmlist) {
751 print sprintf("%${id_len}i%s\n", $vmid, $res->{$vmid});
756 print "no running containers\n";
762 __PACKAGE__-
>register_method ({
766 description
=> "Run fstrim on a chosen CT and its mountpoints, except bind or read-only mountpoints.",
768 additionalProperties
=> 0,
770 vmid
=> get_standard_option
('pve-vmid', { completion
=> \
&PVE
::LXC
::complete_ctid
}),
771 'ignore-mountpoints' => {
772 description
=> 'Skip all mountpoints, only do fstrim on the container root.',
778 returns
=> { type
=> 'null' },
782 my $vmid = $param->{'vmid'};
784 my $rootdir = "/var/lib/lxc/$vmid/rootfs";
786 my $storecfg = PVE
::Storage
::config
();
787 my $conf = PVE
::LXC
::Config-
>set_lock($vmid, 'fstrim');
790 PVE
::LXC
::mount_all
($vmid, $storecfg, $conf);
791 PVE
::LXC
::Config-
>foreach_volume($conf, sub {
792 my ($name, $mp) = @_;
794 return if $mp->{type
} eq 'bind' || $mp->{ro
};
795 return if $param->{'ignore-mountpoints'} && $name =~ /^mp\d+/;
796 my $cmd = ["fstrim", "-v", "$rootdir$path"];
797 PVE
::Tools
::run_command
($cmd, noerr
=> 1);
802 PVE
::LXC
::umount_all
($vmid, $storecfg, $conf, 0);
803 PVE
::LXC
::Config-
>remove_lock($vmid, 'fstrim');
809 __PACKAGE__-
>register_method({
810 name
=> 'remote_migrate_vm',
811 path
=> 'remote_migrate_vm',
813 description
=> "Migrate container to a remote cluster. Creates a new migration task. EXPERIMENTAL feature!",
815 check
=> ['perm', '/vms/{vmid}', [ 'VM.Migrate' ]],
818 additionalProperties
=> 0,
820 node
=> get_standard_option
('pve-node'),
821 vmid
=> get_standard_option
('pve-vmid', { completion
=> \
&PVE
::QemuServer
::complete_vmid
}),
822 'target-vmid' => get_standard_option
('pve-vmid', { optional
=> 1 }),
823 'target-endpoint' => get_standard_option
('proxmox-remote', {
824 description
=> "Remote target endpoint",
828 description
=> "Use online/live migration.",
833 description
=> "Use restart migration",
838 description
=> "Timeout in seconds for shutdown for restart migration",
844 description
=> "Delete the original CT and related data after successful migration. By default the original CT is kept on the source cluster in a stopped state.",
848 'target-storage' => get_standard_option
('pve-targetstorage', {
849 completion
=> \
&PVE
::QemuServer
::complete_migration_storage
,
854 description
=> "Mapping from source to target bridges. Providing only a single bridge ID maps all source bridges to that bridge. Providing the special value '1' will map each source bridge to itself.",
855 format
=> 'bridge-pair-list',
858 description
=> "Override I/O bandwidth limit (in KiB/s).",
862 default => 'migrate limit from datacenter or storage config',
868 description
=> "the task ID.",
873 my $rpcenv = PVE
::RPCEnvironment
::get
();
874 my $authuser = $rpcenv->get_user();
876 my $source_vmid = $param->{vmid
};
877 my $target_endpoint = $param->{'target-endpoint'};
878 my $target_vmid = $param->{'target-vmid'} // $source_vmid;
880 my $remote = PVE
::JSONSchema
::parse_property_string
('proxmox-remote', $target_endpoint);
882 # TODO: move this as helper somewhere appropriate?
885 host
=> $remote->{host
},
886 port
=> $remote->{port
} // 8006,
887 apitoken
=> $remote->{apitoken
},
890 $conn_args->{cached_fingerprints
} = { uc($remote->{fingerprint
}) => 1 }
891 if defined($remote->{fingerprint
});
893 my $api_client = PVE
::APIClient
::LWP-
>new(%$conn_args);
894 my $resources = $api_client->get("/cluster/resources", { type
=> 'vm' });
895 if (grep { defined($_->{vmid
}) && $_->{vmid
} eq $target_vmid } @$resources) {
896 raise_param_exc
({ target_vmid
=> "Guest with ID '$target_vmid' already exists on remote cluster" });
899 my $storages = $api_client->get("/nodes/localhost/storage", { enabled
=> 1 });
901 my $storecfg = PVE
::Storage
::config
();
902 my $target_storage = $param->{'target-storage'};
903 my $storagemap = eval { PVE
::JSONSchema
::parse_idmap
($target_storage, 'pve-storage-id') };
904 raise_param_exc
({ 'target-storage' => "failed to parse storage map: $@" })
907 my $check_remote_storage = sub {
909 my $found = [ grep { $_->{storage
} eq $storage } @$storages ];
910 die "remote: storage '$storage' does not exist!\n"
915 my $content_types = [ PVE
::Tools
::split_list
($found->{content
}) ];
916 die "remote: storage '$storage' cannot store CT rootdir\n"
917 if !grep { $_ eq 'rootdir' } @$content_types;
920 foreach my $target_sid (values %{$storagemap->{entries
}}) {
921 $check_remote_storage->($target_sid);
924 $check_remote_storage->($storagemap->{default})
925 if $storagemap->{default};
927 return PVE
::API2
::LXC-
>remote_migrate_vm($param);
931 list
=> [ 'PVE::API2::LXC', 'vmlist', [], { node
=> $nodename }, sub {
933 return if !scalar(@$res);
934 my $format = "%-10s %-10s %-12s %-20s\n";
935 printf($format, 'VMID', 'Status', 'Lock', 'Name');
936 foreach my $d (sort {$a->{vmid
} <=> $b->{vmid
} } @$res) {
937 my $lock = $d->{lock} || '';
938 printf($format, $d->{vmid
}, $d->{status
}, $lock, $d->{name
});
941 config
=> [ "PVE::API2::LXC::Config", 'vm_config', ['vmid'], { node
=> $nodename }, sub {
943 for my $k (sort (keys %$config)) {
944 next if $k eq 'digest' || $k eq 'lxc';
945 my $v = $config->{$k};
946 if ($k eq 'description') {
947 $v = PVE
::Tools
::encode_text
($v);
951 if (defined(my $lxc_list = $config->{'lxc'})) {
952 for my $lxc_opt (@$lxc_list) {
953 print "$lxc_opt->[0]: $lxc_opt->[1]\n"
958 pending
=> [ "PVE::API2::LXC", "vm_pending", ['vmid'], { node
=> $nodename }, \
&PVE
::GuestHelpers
::format_pending
],
959 set
=> [ 'PVE::API2::LXC::Config', 'update_vm', ['vmid'], { node
=> $nodename }],
961 resize
=> [ "PVE::API2::LXC", 'resize_vm', ['vmid', 'disk', 'size'], { node
=> $nodename } ],
963 create
=> [ 'PVE::API2::LXC', 'create_vm', ['vmid', 'ostemplate'], { node
=> $nodename }, $upid_exit ],
964 restore
=> [ 'PVE::API2::LXC', 'create_vm', ['vmid', 'ostemplate'], { node
=> $nodename, restore
=> 1 }, $upid_exit ],
965 destroy
=> [ 'PVE::API2::LXC', 'destroy_vm', ['vmid'], { node
=> $nodename }, $upid_exit ],
967 start
=> [ 'PVE::API2::LXC::Status', 'vm_start', ['vmid'], { node
=> $nodename }, $upid_exit],
968 suspend
=> [ 'PVE::API2::LXC::Status', 'vm_suspend', ['vmid'], { node
=> $nodename }, $upid_exit],
969 resume
=> [ 'PVE::API2::LXC::Status', 'vm_resume', ['vmid'], { node
=> $nodename }, $upid_exit],
970 shutdown => [ 'PVE::API2::LXC::Status', 'vm_shutdown', ['vmid'], { node
=> $nodename }, $upid_exit],
971 stop
=> [ 'PVE::API2::LXC::Status', 'vm_stop', ['vmid'], { node
=> $nodename }, $upid_exit],
972 reboot
=> [ 'PVE::API2::LXC::Status', 'vm_reboot', ['vmid'], { node
=> $nodename }, $upid_exit],
974 clone
=> [ "PVE::API2::LXC", 'clone_vm', ['vmid', 'newid'], { node
=> $nodename }, $upid_exit ],
975 migrate
=> [ "PVE::API2::LXC", 'migrate_vm', ['vmid', 'target'], { node
=> $nodename }, $upid_exit],
976 'move-volume' => [ "PVE::API2::LXC", 'move_volume', ['vmid', 'volume', 'storage', 'target-vmid', 'target-volume'], { node
=> $nodename }, $upid_exit ],
977 move_volume
=> { alias
=> 'move-volume' },
978 'remote-migrate' => [ __PACKAGE__
, 'remote_migrate_vm', ['vmid', 'target-vmid', 'target-endpoint'], { node
=> $nodename }, $upid_exit ],
980 snapshot
=> [ "PVE::API2::LXC::Snapshot", 'snapshot', ['vmid', 'snapname'], { node
=> $nodename } , $upid_exit ],
981 delsnapshot
=> [ "PVE::API2::LXC::Snapshot", 'delsnapshot', ['vmid', 'snapname'], { node
=> $nodename } , $upid_exit ],
982 listsnapshot
=> [ "PVE::API2::LXC::Snapshot", 'list', ['vmid'], { node
=> $nodename }, \
&PVE
::GuestHelpers
::print_snapshot_tree
],
983 rollback
=> [ "PVE::API2::LXC::Snapshot", 'rollback', ['vmid', 'snapname'], { node
=> $nodename } , $upid_exit ],
984 template
=> [ "PVE::API2::LXC", 'template', ['vmid'], { node
=> $nodename }],
986 status
=> [ __PACKAGE__
, 'status', ['vmid']],
987 console
=> [ __PACKAGE__
, 'console', ['vmid']],
988 enter
=> [ __PACKAGE__
, 'enter', ['vmid']],
989 unlock
=> [ __PACKAGE__
, 'unlock', ['vmid']],
990 exec => [ __PACKAGE__
, 'exec', ['vmid', 'extra-args']],
991 fsck
=> [ __PACKAGE__
, 'fsck', ['vmid']],
993 mount
=> [ __PACKAGE__
, 'mount', ['vmid']],
994 unmount
=> [ __PACKAGE__
, 'unmount', ['vmid']],
995 push => [ __PACKAGE__
, 'push', ['vmid', 'file', 'destination']],
996 pull
=> [ __PACKAGE__
, 'pull', ['vmid', 'path', 'destination']],
998 df
=> [ __PACKAGE__
, 'df', ['vmid']],
999 rescan
=> [ __PACKAGE__
, 'rescan', []],
1000 cpusets
=> [ __PACKAGE__
, 'cpusets', []],
1001 fstrim
=> [ __PACKAGE__
, 'fstrim', ['vmid']],