6 # Note: disable '+' prefix for Getopt::Long (for resize command)
7 use Getopt
::Long
qw(:config no_getopt_compat);
14 use POSIX
qw(strftime);
19 use PVE
::Exception
qw(raise_param_exc);
20 use PVE
::GuestHelpers
;
22 use PVE
::JSONSchema
qw(get_standard_option);
24 use PVE
::RPCEnvironment
;
26 use PVE
::Tools
qw(extract_param);
28 use PVE
::API2
::Qemu
::Agent
;
31 use PVE
::QemuServer
::Drive
;
32 use PVE
::QemuServer
::Helpers
;
33 use PVE
::QemuServer
::Agent
qw(agent_available);
34 use PVE
::QemuServer
::ImportDisk
;
35 use PVE
::QemuServer
::Monitor
qw(mon_cmd);
36 use PVE
::QemuServer
::OVF
;
40 use base
qw(PVE::CLIHandler);
44 my $status = PVE
::Tools
::upid_read_status
($upid);
45 exit($status eq 'OK' ?
0 : -1);
48 my $nodename = PVE
::INotify
::nodename
();
50 sub setup_environment
{
51 PVE
::RPCEnvironment-
>setup_default_cli_env();
58 while ( ++$c < 10 && !-e
$path ) { sleep(1); }
60 my $s = IO
::Socket
::UNIX-
>new(Peer
=> $path, Timeout
=> 120);
62 die "unable to connect to socket '$path' - $!" if !$s;
64 my $select = IO
::Select-
>new();
66 $select->add(\
*STDIN
);
69 my $timeout = 60*15; # 15 minutes
72 while ($select->count &&
73 scalar(@handles = $select->can_read ($timeout))) {
74 foreach my $h (@handles) {
76 my $n = $h->sysread($buf, 4096);
86 syswrite(\
*STDOUT
, $buf);
96 sub print_recursive_hash
{
97 my ($prefix, $hash, $key) = @_;
99 if (ref($hash) eq 'HASH') {
101 print "$prefix$key:\n";
103 foreach my $itemkey (keys %$hash) {
104 print_recursive_hash
("\t$prefix", $hash->{$itemkey}, $itemkey);
106 } elsif (ref($hash) eq 'ARRAY') {
108 print "$prefix$key:\n";
110 foreach my $item (@$hash) {
111 print_recursive_hash
("\t$prefix", $item);
113 } elsif ((!ref($hash) && defined($hash)) || ref($hash) eq 'JSON::PP::Boolean') {
115 print "$prefix$key: $hash\n";
117 print "$prefix$hash\n";
122 __PACKAGE__-
>register_method ({
126 description
=> "Show command line which is used to start the VM (debug info).",
128 additionalProperties
=> 0,
130 vmid
=> get_standard_option
('pve-vmid', { completion
=> \
&PVE
::QemuServer
::complete_vmid
}),
132 description
=> "Puts each option on a new line to enhance human readability",
137 snapshot
=> get_standard_option
('pve-snapshot-name', {
138 description
=> "Fetch config values from given snapshot.",
141 my ($cmd, $pname, $cur, $args) = @_;
142 PVE
::QemuConfig-
>snapshot_list($args->[0]);
147 returns
=> { type
=> 'null'},
151 my $storecfg = PVE
::Storage
::config
();
152 my $cmdline = PVE
::QemuServer
::vm_commandline
($storecfg, $param->{vmid
}, $param->{snapshot
});
154 $cmdline =~ s/ -/ \\\n -/g if $param->{pretty
};
161 __PACKAGE__-
>register_method ({
165 description
=> "Show VM status.",
167 additionalProperties
=> 0,
169 vmid
=> get_standard_option
('pve-vmid', { completion
=> \
&PVE
::QemuServer
::complete_vmid
}),
171 description
=> "Verbose output format",
177 returns
=> { type
=> 'null'},
182 my $conf = PVE
::QemuConfig-
>load_config ($param->{vmid
});
184 my $vmstatus = PVE
::QemuServer
::vmstatus
($param->{vmid
}, 1);
185 my $stat = $vmstatus->{$param->{vmid
}};
186 if ($param->{verbose
}) {
187 foreach my $k (sort (keys %$stat)) {
188 next if $k eq 'cpu' || $k eq 'relcpu'; # always 0
190 print_recursive_hash
("", $v, $k);
193 my $status = $stat->{qmpstatus
} || 'unknown';
194 print "status: $status\n";
200 __PACKAGE__-
>register_method ({
204 description
=> "Proxy VM VNC traffic to stdin/stdout",
206 additionalProperties
=> 0,
208 vmid
=> get_standard_option
('pve-vmid', { completion
=> \
&PVE
::QemuServer
::complete_vmid_running
}),
211 returns
=> { type
=> 'null'},
215 my $vmid = $param->{vmid
};
216 PVE
::QemuConfig
::assert_config_exists_on_node
($vmid);
217 my $vnc_socket = PVE
::QemuServer
::Helpers
::vnc_socket
($vmid);
219 if (my $ticket = $ENV{LC_PVE_TICKET
}) { # NOTE: ssh on debian only pass LC_* variables
220 mon_cmd
($vmid, "change", device
=> 'vnc', target
=> "unix:$vnc_socket,password");
221 mon_cmd
($vmid, "set_password", protocol
=> 'vnc', password
=> $ticket);
222 mon_cmd
($vmid, "expire_password", protocol
=> 'vnc', time => "+30");
224 # FIXME: remove or allow to add tls-creds object, as x509 vnc param is removed with qemu 4??
225 mon_cmd
($vmid, "change", device
=> 'vnc', target
=> "unix:$vnc_socket,password");
228 run_vnc_proxy
($vnc_socket);
233 __PACKAGE__-
>register_method ({
237 description
=> "Unlock the VM.",
239 additionalProperties
=> 0,
241 vmid
=> get_standard_option
('pve-vmid', { completion
=> \
&PVE
::QemuServer
::complete_vmid
}),
244 returns
=> { type
=> 'null'},
248 my $vmid = $param->{vmid
};
250 PVE
::QemuConfig-
>lock_config ($vmid, sub {
251 my $conf = PVE
::QemuConfig-
>load_config($vmid);
252 delete $conf->{lock};
253 delete $conf->{pending
}->{lock} if $conf->{pending
}; # just to be sure
254 PVE
::QemuConfig-
>write_config($vmid, $conf);
260 __PACKAGE__-
>register_method ({
264 description
=> "Stop embedded nbd server.",
266 additionalProperties
=> 0,
268 vmid
=> get_standard_option
('pve-vmid', { completion
=> \
&PVE
::QemuServer
::complete_vmid
}),
271 returns
=> { type
=> 'null'},
275 my $vmid = $param->{vmid
};
277 eval { PVE
::QemuServer
::nbd_stop
($vmid) };
283 __PACKAGE__-
>register_method ({
287 description
=> "Used by qmigrate - do not use manually.",
289 additionalProperties
=> 0,
292 returns
=> { type
=> 'null'},
296 if (!PVE
::Cluster
::check_cfs_quorum
(1)) {
301 my $tunnel_write = sub {
308 $tunnel_write->("tunnel online");
309 $tunnel_write->("ver 1");
311 while (my $line = <STDIN
>) {
313 if ($line =~ /^quit$/) {
314 $tunnel_write->("OK");
316 } elsif ($line =~ /^resume (\d+)$/) {
318 if (PVE
::QemuServer
::check_running
($vmid, 1)) {
319 eval { PVE
::QemuServer
::vm_resume
($vmid, 1, 1); };
321 $tunnel_write->("ERR: resume failed - $@");
323 $tunnel_write->("OK");
326 $tunnel_write->("ERR: resume failed - VM $vmid not running");
334 __PACKAGE__-
>register_method ({
338 description
=> "Wait until the VM is stopped.",
340 additionalProperties
=> 0,
342 vmid
=> get_standard_option
('pve-vmid', { completion
=> \
&PVE
::QemuServer
::complete_vmid_running
}),
344 description
=> "Timeout in seconds. Default is to wait forever.",
351 returns
=> { type
=> 'null'},
355 my $vmid = $param->{vmid
};
356 my $timeout = $param->{timeout
};
358 my $pid = PVE
::QemuServer
::check_running
($vmid);
361 print "waiting until VM $vmid stopps (PID $pid)\n";
364 while ((!$timeout || ($count < $timeout)) && PVE
::QemuServer
::check_running
($vmid)) {
369 die "wait failed - got timeout\n" if PVE
::QemuServer
::check_running
($vmid);
374 __PACKAGE__-
>register_method ({
378 description
=> "Enter Qemu Monitor interface.",
380 additionalProperties
=> 0,
382 vmid
=> get_standard_option
('pve-vmid', { completion
=> \
&PVE
::QemuServer
::complete_vmid_running
}),
385 returns
=> { type
=> 'null'},
389 my $vmid = $param->{vmid
};
391 my $conf = PVE
::QemuConfig-
>load_config ($vmid); # check if VM exists
393 print "Entering Qemu Monitor for VM $vmid - type 'help' for help\n";
395 my $term = Term
::ReadLine-
>new('qm');
397 while (defined(my $input = $term->readline('qm> '))) {
399 next if $input =~ m/^\s*$/;
400 last if $input =~ m/^\s*q(uit)?\s*$/;
402 eval { print PVE
::QemuServer
::Monitor
::hmp_cmd
($vmid, $input) };
403 print "ERROR: $@" if $@;
410 __PACKAGE__-
>register_method ({
414 description
=> "Rescan all storages and update disk sizes and unused disk images.",
416 additionalProperties
=> 0,
418 vmid
=> get_standard_option
('pve-vmid', {
420 completion
=> \
&PVE
::QemuServer
::complete_vmid
,
426 description
=> 'Do not actually write changes out to VM config(s).',
430 returns
=> { type
=> 'null'},
434 my $dryrun = $param->{dryrun
};
436 print "NOTE: running in dry-run mode, won't write changes out!\n" if $dryrun;
438 PVE
::QemuServer
::rescan
($param->{vmid
}, 0, $dryrun);
443 __PACKAGE__-
>register_method ({
444 name
=> 'importdisk',
445 path
=> 'importdisk',
447 description
=> "Import an external disk image as an unused disk in a VM. The
448 image format has to be supported by qemu-img(1).",
450 additionalProperties
=> 0,
452 vmid
=> get_standard_option
('pve-vmid', {completion
=> \
&PVE
::QemuServer
::complete_vmid
}),
454 description
=> 'Path to the disk image to import',
458 storage
=> get_standard_option
('pve-storage-id', {
459 description
=> 'Target storage ID',
460 completion
=> \
&PVE
::QemuServer
::complete_storage
,
465 description
=> 'Target format',
466 enum
=> [ 'raw', 'qcow2', 'vmdk' ],
471 returns
=> { type
=> 'null'},
475 my $vmid = extract_param
($param, 'vmid');
476 my $source = extract_param
($param, 'source');
477 my $storeid = extract_param
($param, 'storage');
478 my $format = extract_param
($param, 'format');
480 my $vm_conf = PVE
::QemuConfig-
>load_config($vmid);
481 PVE
::QemuConfig-
>check_lock($vm_conf);
482 die "$source: non-existent or non-regular file\n" if (! -f
$source);
484 my $storecfg = PVE
::Storage
::config
();
485 PVE
::Storage
::storage_check_enabled
($storecfg, $storeid);
487 my $target_storage_config = PVE
::Storage
::storage_config
($storecfg, $storeid);
488 die "storage $storeid does not support vm images\n"
489 if !$target_storage_config->{content
}->{images
};
491 print "importing disk '$source' to VM $vmid ...\n";
492 my ($drive_id, $volid) = PVE
::QemuServer
::ImportDisk
::do_import
($source, $vmid, $storeid, { format
=> $format });
493 print "Successfully imported disk as '$drive_id:$volid'\n";
498 __PACKAGE__-
>register_method ({
502 description
=> "Open a terminal using a serial device (The VM need to have a serial device configured, for example 'serial0: socket')",
504 additionalProperties
=> 0,
506 vmid
=> get_standard_option
('pve-vmid', { completion
=> \
&PVE
::QemuServer
::complete_vmid_running
}),
508 description
=> "Select the serial device. By default we simply use the first suitable device.",
511 enum
=> [qw(serial0 serial1 serial2 serial3)],
514 description
=> "Escape character.",
521 returns
=> { type
=> 'null'},
525 my $vmid = $param->{vmid
};
527 my $escape = $param->{escape
} // '^O';
528 if ($escape =~ /^\^([\x40-\x7a])$/) {
529 $escape = ord($1) & 0x1F;
530 } elsif ($escape =~ /^0x[0-9a-f]+$/i) {
531 $escape = hex($escape);
532 } elsif ($escape =~ /^[0-9]+$/) {
533 $escape = int($escape);
535 die "invalid escape character definition: $escape\n";
539 $escapemsg = sprintf(' (press Ctrl+%c to exit)', $escape+0x40);
540 $escape = sprintf(',escape=0x%x', $escape);
545 my $conf = PVE
::QemuConfig-
>load_config ($vmid); # check if VM exists
547 my $iface = $param->{iface
};
550 die "serial interface '$iface' is not configured\n" if !$conf->{$iface};
551 die "wrong serial type on interface '$iface'\n" if $conf->{$iface} ne 'socket';
553 foreach my $opt (qw(serial0 serial1 serial2 serial3)) {
554 if ($conf->{$opt} && ($conf->{$opt} eq 'socket')) {
559 die "unable to find a serial interface\n" if !$iface;
562 die "VM $vmid not running\n" if !PVE
::QemuServer
::check_running
($vmid);
564 my $socket = "/var/run/qemu-server/${vmid}.$iface";
566 my $cmd = "socat UNIX-CONNECT:$socket STDIO,raw,echo=0$escape";
568 print "starting serial terminal on interface ${iface}${escapemsg}\n";
575 __PACKAGE__-
>register_method ({
578 description
=> "Create a new VM using parameters read from an OVF manifest",
580 additionalProperties
=> 0,
582 vmid
=> get_standard_option
('pve-vmid', { completion
=> \
&PVE
::Cluster
::complete_next_vmid
}),
585 description
=> 'path to the ovf file',
587 storage
=> get_standard_option
('pve-storage-id', {
588 description
=> 'Target storage ID',
589 completion
=> \
&PVE
::QemuServer
::complete_storage
,
594 description
=> 'Target format',
595 enum
=> [ 'raw', 'qcow2', 'vmdk' ],
600 description
=> 'Print a parsed representation of the extracted OVF parameters, but do not create a VM',
605 returns
=> { type
=> 'null' },
609 my $vmid = PVE
::Tools
::extract_param
($param, 'vmid');
610 my $ovf_file = PVE
::Tools
::extract_param
($param, 'manifest');
611 my $storeid = PVE
::Tools
::extract_param
($param, 'storage');
612 my $format = PVE
::Tools
::extract_param
($param, 'format');
613 my $dryrun = PVE
::Tools
::extract_param
($param, 'dryrun');
615 die "$ovf_file: non-existent or non-regular file\n" if (! -f
$ovf_file);
616 my $storecfg = PVE
::Storage
::config
();
617 PVE
::Storage
::storage_check_enabled
($storecfg, $storeid);
619 my $parsed = PVE
::QemuServer
::OVF
::parse_ovf
($ovf_file);
622 print to_json
($parsed, { pretty
=> 1, canonical
=> 1});
626 eval { PVE
::QemuConfig-
>create_and_lock_config($vmid) };
627 die "Reserving empty config for OVF import to VM $vmid failed: $@" if $@;
629 my $conf = PVE
::QemuConfig-
>load_config($vmid);
630 die "Internal error: Expected 'create' lock in config of VM $vmid!"
631 if !PVE
::QemuConfig-
>has_lock($conf, "create");
633 $conf->{name
} = $parsed->{qm
}->{name
} if defined($parsed->{qm
}->{name
});
634 $conf->{memory
} = $parsed->{qm
}->{memory
} if defined($parsed->{qm
}->{memory
});
635 $conf->{cores
} = $parsed->{qm
}->{cores
} if defined($parsed->{qm
}->{cores
});
637 my $imported_disks = [];
639 # order matters, as do_import() will load_config() internally
640 $conf->{vmgenid
} = PVE
::QemuServer
::generate_uuid
();
641 $conf->{smbios1
} = PVE
::QemuServer
::generate_smbios1_uuid
();
642 PVE
::QemuConfig-
>write_config($vmid, $conf);
644 foreach my $disk (@{ $parsed->{disks
} }) {
645 my ($file, $drive) = ($disk->{backing_file
}, $disk->{disk_address
});
646 my ($name, $volid) = PVE
::QemuServer
::ImportDisk
::do_import
($file, $vmid, $storeid, {
647 drive_name
=> $drive,
651 # for cleanup on (later) error
652 push @$imported_disks, $volid;
655 # reload after disks entries have been created
656 $conf = PVE
::QemuConfig-
>load_config($vmid);
657 my $devs = PVE
::QemuServer
::get_default_bootdevices
($conf);
658 $conf->{boot
} = PVE
::QemuServer
::print_bootorder
($devs);
659 PVE
::QemuConfig-
>write_config($vmid, $conf);
664 warn "error during import, cleaning up created resources...\n";
665 for my $volid (@$imported_disks) {
666 eval { PVE
::Storage
::vdisk_free
($storecfg, $volid) };
667 warn "cleanup of $volid failed: $@\n" if $@;
669 eval { PVE
::QemuServer
::destroy_vm
($storecfg, $vmid, $skiplock) };
670 warn "Could not destroy VM $vmid: $@" if "$@";
671 die "import failed - $err";
674 PVE
::QemuConfig-
>remove_lock($vmid, "create");
681 __PACKAGE__-
>register_method({
686 description
=> "Executes the given command via the guest agent",
688 additionalProperties
=> 0,
690 node
=> get_standard_option
('pve-node'),
691 vmid
=> get_standard_option
('pve-vmid', {
692 completion
=> \
&PVE
::QemuServer
::complete_vmid_running
}),
697 description
=> "If set to off, returns the pid immediately instead of waiting for the commmand to finish or the timeout.",
701 description
=> "The maximum time to wait synchronously for the command to finish. If reached, the pid gets returned. Set to 0 to deactivate",
708 description
=> "When set, read STDIN until EOF and forward to guest agent via 'input-data' (usually treated as STDIN to process launched by guest agent). Allows maximal 1 MiB.",
712 'extra-args' => get_standard_option
('extra-args'),
721 my $vmid = $param->{vmid
};
722 my $sync = $param->{synchronous
} // 1;
723 my $pass_stdin = $param->{'pass-stdin'};
724 if (defined($param->{timeout
}) && !$sync) {
725 raise_param_exc
({ synchronous
=> "needs to be set for 'timeout'"});
728 my $input_data = undef;
731 while (my $line = <STDIN
>) {
732 $input_data .= $line;
733 if (length($input_data) > 1024*1024) {
734 # not sure how QEMU handles large amounts of data being
735 # passed into the QMP socket, so limit to be safe
736 die "'input-data' (STDIN) is limited to 1 MiB, aborting\n";
741 my $args = $param->{'extra-args'};
742 $args = undef if !$args || !@$args;
744 my $res = PVE
::QemuServer
::Agent
::qemu_exec
($vmid, $input_data, $args);
747 my $pid = $res->{pid
};
748 my $timeout = $param->{timeout
} // 30;
749 my $starttime = time();
751 while ($timeout == 0 || (time() - $starttime) < $timeout) {
752 my $out = PVE
::QemuServer
::Agent
::qemu_exec_status
($vmid, $pid);
753 if ($out->{exited
}) {
760 if (!$res->{exited
}) {
761 warn "timeout reached, returning pid\n";
765 return { result
=> $res };
768 __PACKAGE__-
>register_method({
773 description
=> "Cleans up resources like tap devices, vgpus, etc. Called after a vm shuts down, crashes, etc.",
775 additionalProperties
=> 0,
777 node
=> get_standard_option
('pve-node'),
778 vmid
=> get_standard_option
('pve-vmid', {
779 completion
=> \
&PVE
::QemuServer
::complete_vmid_running
}),
780 'clean-shutdown' => {
782 description
=> "Indicates if qemu shutdown cleanly.",
784 'guest-requested' => {
786 description
=> "Indicates if the shutdown was requested by the guest or via qmp.",
790 returns
=> { type
=> 'null', },
794 my $vmid = $param->{vmid
};
795 my $clean = $param->{'clean-shutdown'};
796 my $guest = $param->{'guest-requested'};
799 # return if we do not have the config anymore
800 return if !-f PVE
::QemuConfig-
>config_file($vmid);
802 my $storecfg = PVE
::Storage
::config
();
803 warn "Starting cleanup for $vmid\n";
805 PVE
::QemuConfig-
>lock_config($vmid, sub {
806 my $conf = PVE
::QemuConfig-
>load_config ($vmid);
807 my $pid = PVE
::QemuServer
::check_running
($vmid);
808 die "vm still running\n" if $pid;
811 # we have to cleanup the tap devices after a crash
813 foreach my $opt (keys %$conf) {
814 next if $opt !~ m/^net(\d)+$/;
816 PVE
::Network
::tap_unplug
("tap${vmid}i${interface}");
820 if (!$clean || $guest) {
821 # vm was shutdown from inside the guest or crashed, doing api cleanup
822 PVE
::QemuServer
::vm_stop_cleanup
($storecfg, $vmid, $conf, 0, 0);
824 PVE
::GuestHelpers
::exec_hookscript
($conf, $vmid, 'post-stop');
826 $restart = eval { PVE
::QemuServer
::clear_reboot_request
($vmid) };
830 warn "Finished cleanup for $vmid\n";
833 warn "Restarting VM $vmid\n";
834 PVE
::API2
::Qemu-
>vm_start({
843 my $print_agent_result = sub {
846 my $result = $data->{result
} // $data;
847 return if !defined($result);
849 my $class = ref($result);
853 return if $result =~ m/^\s*$/;
858 if (($class eq 'HASH') && !scalar(keys %$result)) { # empty hash
862 print to_json
($result, { pretty
=> 1, canonical
=> 1});
868 my $ssh_key_map = ['sshkeys', sub {
869 return URI
::Escape
::uri_escape
(PVE
::Tools
::file_get_contents
($_[0]));
871 my $cipassword_map = PVE
::CLIHandler
::get_standard_mapping
('pve-password', { name
=> 'cipassword' });
872 my $password_map = PVE
::CLIHandler
::get_standard_mapping
('pve-password');
874 'update_vm' => [$ssh_key_map, $cipassword_map],
875 'create_vm' => [$ssh_key_map, $cipassword_map],
876 'set-user-password' => [$password_map],
879 return $mapping->{$name};
883 list
=> [ "PVE::API2::Qemu", 'vmlist', [],
884 { node
=> $nodename }, sub {
887 exit 0 if (!scalar(@$vmlist));
889 printf "%10s %-20s %-10s %-10s %12s %-10s\n",
890 qw(VMID NAME STATUS MEM(MB) BOOTDISK
(GB
) PID
);
892 foreach my $rec (sort { $a->{vmid
} <=> $b->{vmid
} } @$vmlist) {
893 printf "%10s %-20s %-10s %-10s %12.2f %-10s\n", $rec->{vmid
}, $rec->{name
},
894 $rec->{qmpstatus
} || $rec->{status
},
895 ($rec->{maxmem
} || 0)/(1024*1024),
896 ($rec->{maxdisk
} || 0)/(1024*1024*1024),
903 create
=> [ "PVE::API2::Qemu", 'create_vm', ['vmid'], { node
=> $nodename }, $upid_exit ],
905 destroy
=> [ "PVE::API2::Qemu", 'destroy_vm', ['vmid'], { node
=> $nodename }, $upid_exit ],
907 clone
=> [ "PVE::API2::Qemu", 'clone_vm', ['vmid', 'newid'], { node
=> $nodename }, $upid_exit ],
909 migrate
=> [ "PVE::API2::Qemu", 'migrate_vm', ['vmid', 'target'], { node
=> $nodename }, $upid_exit ],
911 set
=> [ "PVE::API2::Qemu", 'update_vm', ['vmid'], { node
=> $nodename } ],
913 resize
=> [ "PVE::API2::Qemu", 'resize_vm', ['vmid', 'disk', 'size'], { node
=> $nodename } ],
915 move_disk
=> [ "PVE::API2::Qemu", 'move_vm_disk', ['vmid', 'disk', 'storage'], { node
=> $nodename }, $upid_exit ],
917 unlink => [ "PVE::API2::Qemu", 'unlink', ['vmid'], { node
=> $nodename } ],
919 config
=> [ "PVE::API2::Qemu", 'vm_config', ['vmid'],
920 { node
=> $nodename }, sub {
922 foreach my $k (sort (keys %$config)) {
923 next if $k eq 'digest';
924 my $v = $config->{$k};
925 if ($k eq 'description') {
926 $v = PVE
::Tools
::encode_text
($v);
932 pending
=> [ "PVE::API2::Qemu", 'vm_pending', ['vmid'], { node
=> $nodename }, \
&PVE
::GuestHelpers
::format_pending
],
933 showcmd
=> [ __PACKAGE__
, 'showcmd', ['vmid']],
935 status
=> [ __PACKAGE__
, 'status', ['vmid']],
937 snapshot
=> [ "PVE::API2::Qemu", 'snapshot', ['vmid', 'snapname'], { node
=> $nodename } , $upid_exit ],
939 delsnapshot
=> [ "PVE::API2::Qemu", 'delsnapshot', ['vmid', 'snapname'], { node
=> $nodename } , $upid_exit ],
941 listsnapshot
=> [ "PVE::API2::Qemu", 'snapshot_list', ['vmid'], { node
=> $nodename }, \
&PVE
::GuestHelpers
::print_snapshot_tree
],
943 rollback
=> [ "PVE::API2::Qemu", 'rollback', ['vmid', 'snapname'], { node
=> $nodename } , $upid_exit ],
945 template
=> [ "PVE::API2::Qemu", 'template', ['vmid'], { node
=> $nodename }],
947 start
=> [ "PVE::API2::Qemu", 'vm_start', ['vmid'], { node
=> $nodename } , $upid_exit ],
949 stop
=> [ "PVE::API2::Qemu", 'vm_stop', ['vmid'], { node
=> $nodename }, $upid_exit ],
951 reset => [ "PVE::API2::Qemu", 'vm_reset', ['vmid'], { node
=> $nodename }, $upid_exit ],
953 shutdown => [ "PVE::API2::Qemu", 'vm_shutdown', ['vmid'], { node
=> $nodename }, $upid_exit ],
955 reboot
=> [ "PVE::API2::Qemu", 'vm_reboot', ['vmid'], { node
=> $nodename }, $upid_exit ],
957 suspend
=> [ "PVE::API2::Qemu", 'vm_suspend', ['vmid'], { node
=> $nodename }, $upid_exit ],
959 resume
=> [ "PVE::API2::Qemu", 'vm_resume', ['vmid'], { node
=> $nodename }, $upid_exit ],
961 sendkey
=> [ "PVE::API2::Qemu", 'vm_sendkey', ['vmid', 'key'], { node
=> $nodename } ],
963 vncproxy
=> [ __PACKAGE__
, 'vncproxy', ['vmid']],
965 wait => [ __PACKAGE__
, 'wait', ['vmid']],
967 unlock
=> [ __PACKAGE__
, 'unlock', ['vmid']],
969 rescan
=> [ __PACKAGE__
, 'rescan', []],
971 monitor
=> [ __PACKAGE__
, 'monitor', ['vmid']],
973 agent
=> { alias
=> 'guest cmd' },
976 cmd
=> [ "PVE::API2::Qemu::Agent", 'agent', ['vmid', 'command'], { node
=> $nodename }, $print_agent_result ],
977 passwd
=> [ "PVE::API2::Qemu::Agent", 'set-user-password', [ 'vmid', 'username' ], { node
=> $nodename }],
978 exec => [ __PACKAGE__
, 'exec', [ 'vmid', 'extra-args' ], { node
=> $nodename }, $print_agent_result],
979 'exec-status' => [ "PVE::API2::Qemu::Agent", 'exec-status', [ 'vmid', 'pid' ], { node
=> $nodename }, $print_agent_result],
982 mtunnel
=> [ __PACKAGE__
, 'mtunnel', []],
984 nbdstop
=> [ __PACKAGE__
, 'nbdstop', ['vmid']],
986 terminal
=> [ __PACKAGE__
, 'terminal', ['vmid']],
988 importdisk
=> [ __PACKAGE__
, 'importdisk', ['vmid', 'source', 'storage']],
990 importovf
=> [ __PACKAGE__
, 'importovf', ['vmid', 'manifest', 'storage']],
992 cleanup
=> [ __PACKAGE__
, 'cleanup', ['vmid', 'clean-shutdown', 'guest-requested'], { node
=> $nodename }],
995 dump => [ "PVE::API2::Qemu", 'cloudinit_generated_config_dump', ['vmid', 'type'], { node
=> $nodename }, sub {