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 = new IO
::Select
;
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)) {
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 PVE
::QemuServer
::nbd_stop
($vmid);
282 __PACKAGE__-
>register_method ({
286 description
=> "Used by qmigrate - do not use manually.",
288 additionalProperties
=> 0,
291 returns
=> { type
=> 'null'},
295 if (!PVE
::Cluster
::check_cfs_quorum
(1)) {
300 my $tunnel_write = sub {
307 $tunnel_write->("tunnel online");
308 $tunnel_write->("ver 1");
310 while (my $line = <STDIN
>) {
312 if ($line =~ /^quit$/) {
313 $tunnel_write->("OK");
315 } elsif ($line =~ /^resume (\d+)$/) {
317 if (PVE
::QemuServer
::check_running
($vmid, 1)) {
318 eval { PVE
::QemuServer
::vm_resume
($vmid, 1, 1); };
320 $tunnel_write->("ERR: resume failed - $@");
322 $tunnel_write->("OK");
325 $tunnel_write->("ERR: resume failed - VM $vmid not running");
333 __PACKAGE__-
>register_method ({
337 description
=> "Wait until the VM is stopped.",
339 additionalProperties
=> 0,
341 vmid
=> get_standard_option
('pve-vmid', { completion
=> \
&PVE
::QemuServer
::complete_vmid_running
}),
343 description
=> "Timeout in seconds. Default is to wait forever.",
350 returns
=> { type
=> 'null'},
354 my $vmid = $param->{vmid
};
355 my $timeout = $param->{timeout
};
357 my $pid = PVE
::QemuServer
::check_running
($vmid);
360 print "waiting until VM $vmid stopps (PID $pid)\n";
363 while ((!$timeout || ($count < $timeout)) && PVE
::QemuServer
::check_running
($vmid)) {
368 die "wait failed - got timeout\n" if PVE
::QemuServer
::check_running
($vmid);
373 __PACKAGE__-
>register_method ({
377 description
=> "Enter Qemu Monitor interface.",
379 additionalProperties
=> 0,
381 vmid
=> get_standard_option
('pve-vmid', { completion
=> \
&PVE
::QemuServer
::complete_vmid_running
}),
384 returns
=> { type
=> 'null'},
388 my $vmid = $param->{vmid
};
390 my $conf = PVE
::QemuConfig-
>load_config ($vmid); # check if VM exists
392 print "Entering Qemu Monitor for VM $vmid - type 'help' for help\n";
394 my $term = new Term
::ReadLine
('qm');
397 while (defined ($input = $term->readline('qm> '))) {
400 next if $input =~ m/^\s*$/;
402 last if $input =~ m/^\s*q(uit)?\s*$/;
405 print PVE
::QemuServer
::Monitor
::hmp_cmd
($vmid, $input);
407 print "ERROR: $@" if $@;
414 __PACKAGE__-
>register_method ({
418 description
=> "Rescan all storages and update disk sizes and unused disk images.",
420 additionalProperties
=> 0,
422 vmid
=> get_standard_option
('pve-vmid', {
424 completion
=> \
&PVE
::QemuServer
::complete_vmid
,
430 description
=> 'Do not actually write changes out to VM config(s).',
434 returns
=> { type
=> 'null'},
438 my $dryrun = $param->{dryrun
};
440 print "NOTE: running in dry-run mode, won't write changes out!\n" if $dryrun;
442 PVE
::QemuServer
::rescan
($param->{vmid
}, 0, $dryrun);
447 __PACKAGE__-
>register_method ({
448 name
=> 'importdisk',
449 path
=> 'importdisk',
451 description
=> "Import an external disk image as an unused disk in a VM. The
452 image format has to be supported by qemu-img(1).",
454 additionalProperties
=> 0,
456 vmid
=> get_standard_option
('pve-vmid', {completion
=> \
&PVE
::QemuServer
::complete_vmid
}),
458 description
=> 'Path to the disk image to import',
462 storage
=> get_standard_option
('pve-storage-id', {
463 description
=> 'Target storage ID',
464 completion
=> \
&PVE
::QemuServer
::complete_storage
,
469 description
=> 'Target format',
470 enum
=> [ 'raw', 'qcow2', 'vmdk' ],
475 returns
=> { type
=> 'null'},
479 my $vmid = extract_param
($param, 'vmid');
480 my $source = extract_param
($param, 'source');
481 my $storeid = extract_param
($param, 'storage');
482 my $format = extract_param
($param, 'format');
484 my $vm_conf = PVE
::QemuConfig-
>load_config($vmid);
485 PVE
::QemuConfig-
>check_lock($vm_conf);
486 die "$source: non-existent or non-regular file\n" if (! -f
$source);
488 my $storecfg = PVE
::Storage
::config
();
489 PVE
::Storage
::storage_check_enabled
($storecfg, $storeid);
491 my $target_storage_config = PVE
::Storage
::storage_config
($storecfg, $storeid);
492 die "storage $storeid does not support vm images\n"
493 if !$target_storage_config->{content
}->{images
};
495 print "importing disk '$source' to VM $vmid ...\n";
496 my ($drive_id, $volid) = PVE
::QemuServer
::ImportDisk
::do_import
($source, $vmid, $storeid, { format
=> $format });
497 print "Successfully imported disk as '$drive_id:$volid'\n";
502 __PACKAGE__-
>register_method ({
506 description
=> "Open a terminal using a serial device (The VM need to have a serial device configured, for example 'serial0: socket')",
508 additionalProperties
=> 0,
510 vmid
=> get_standard_option
('pve-vmid', { completion
=> \
&PVE
::QemuServer
::complete_vmid_running
}),
512 description
=> "Select the serial device. By default we simply use the first suitable device.",
515 enum
=> [qw(serial0 serial1 serial2 serial3)],
518 description
=> "Escape character.",
525 returns
=> { type
=> 'null'},
529 my $vmid = $param->{vmid
};
531 my $escape = $param->{escape
} // '^O';
532 if ($escape =~ /^\^([\x40-\x7a])$/) {
533 $escape = ord($1) & 0x1F;
534 } elsif ($escape =~ /^0x[0-9a-f]+$/i) {
535 $escape = hex($escape);
536 } elsif ($escape =~ /^[0-9]+$/) {
537 $escape = int($escape);
539 die "invalid escape character definition: $escape\n";
543 $escapemsg = sprintf(' (press Ctrl+%c to exit)', $escape+0x40);
544 $escape = sprintf(',escape=0x%x', $escape);
549 my $conf = PVE
::QemuConfig-
>load_config ($vmid); # check if VM exists
551 my $iface = $param->{iface
};
554 die "serial interface '$iface' is not configured\n" if !$conf->{$iface};
555 die "wrong serial type on interface '$iface'\n" if $conf->{$iface} ne 'socket';
557 foreach my $opt (qw(serial0 serial1 serial2 serial3)) {
558 if ($conf->{$opt} && ($conf->{$opt} eq 'socket')) {
563 die "unable to find a serial interface\n" if !$iface;
566 die "VM $vmid not running\n" if !PVE
::QemuServer
::check_running
($vmid);
568 my $socket = "/var/run/qemu-server/${vmid}.$iface";
570 my $cmd = "socat UNIX-CONNECT:$socket STDIO,raw,echo=0$escape";
572 print "starting serial terminal on interface ${iface}${escapemsg}\n";
579 __PACKAGE__-
>register_method ({
582 description
=> "Create a new VM using parameters read from an OVF manifest",
584 additionalProperties
=> 0,
586 vmid
=> get_standard_option
('pve-vmid', { completion
=> \
&PVE
::Cluster
::complete_next_vmid
}),
589 description
=> 'path to the ovf file',
591 storage
=> get_standard_option
('pve-storage-id', {
592 description
=> 'Target storage ID',
593 completion
=> \
&PVE
::QemuServer
::complete_storage
,
598 description
=> 'Target format',
599 enum
=> [ 'raw', 'qcow2', 'vmdk' ],
604 description
=> 'Print a parsed representation of the extracted OVF parameters, but do not create a VM',
609 returns
=> { type
=> 'null' },
613 my $vmid = PVE
::Tools
::extract_param
($param, 'vmid');
614 my $ovf_file = PVE
::Tools
::extract_param
($param, 'manifest');
615 my $storeid = PVE
::Tools
::extract_param
($param, 'storage');
616 my $format = PVE
::Tools
::extract_param
($param, 'format');
617 my $dryrun = PVE
::Tools
::extract_param
($param, 'dryrun');
619 die "$ovf_file: non-existent or non-regular file\n" if (! -f
$ovf_file);
620 my $storecfg = PVE
::Storage
::config
();
621 PVE
::Storage
::storage_check_enabled
($storecfg, $storeid);
623 my $parsed = PVE
::QemuServer
::OVF
::parse_ovf
($ovf_file);
626 print to_json
($parsed, { pretty
=> 1, canonical
=> 1});
630 eval { PVE
::QemuConfig-
>create_and_lock_config($vmid) };
631 die "Reserving empty config for OVF import to VM $vmid failed: $@" if $@;
633 my $conf = PVE
::QemuConfig-
>load_config($vmid);
634 die "Internal error: Expected 'create' lock in config of VM $vmid!"
635 if !PVE
::QemuConfig-
>has_lock($conf, "create");
637 $conf->{name
} = $parsed->{qm
}->{name
} if defined($parsed->{qm
}->{name
});
638 $conf->{memory
} = $parsed->{qm
}->{memory
} if defined($parsed->{qm
}->{memory
});
639 $conf->{cores
} = $parsed->{qm
}->{cores
} if defined($parsed->{qm
}->{cores
});
642 # order matters, as do_import() will load_config() internally
643 $conf->{vmgenid
} = PVE
::QemuServer
::generate_uuid
();
644 $conf->{smbios1
} = PVE
::QemuServer
::generate_smbios1_uuid
();
645 PVE
::QemuConfig-
>write_config($vmid, $conf);
647 foreach my $disk (@{ $parsed->{disks
} }) {
648 my ($file, $drive) = ($disk->{backing_file
}, $disk->{disk_address
});
649 PVE
::QemuServer
::ImportDisk
::do_import
($file, $vmid, $storeid, {
650 drive_name
=> $drive,
656 # reload after disks entries have been created
657 $conf = PVE
::QemuConfig-
>load_config($vmid);
658 my $firstdisk = PVE
::QemuServer
::Drive
::resolve_first_disk
($conf);
659 $conf->{bootdisk
} = $firstdisk if $firstdisk;
660 PVE
::QemuConfig-
>write_config($vmid, $conf);
666 # eval for additional safety in error path
667 eval { PVE
::QemuServer
::destroy_vm
($storecfg, $vmid, $skiplock) };
668 warn "Could not destroy VM $vmid: $@" if "$@";
669 die "import failed - $err";
672 PVE
::QemuConfig-
>remove_lock($vmid, "create");
679 __PACKAGE__-
>register_method({
684 description
=> "Executes the given command via the guest agent",
686 additionalProperties
=> 0,
688 node
=> get_standard_option
('pve-node'),
689 vmid
=> get_standard_option
('pve-vmid', {
690 completion
=> \
&PVE
::QemuServer
::complete_vmid_running
}),
695 description
=> "If set to off, returns the pid immediately instead of waiting for the commmand to finish or the timeout.",
699 description
=> "The maximum time to wait synchronously for the command to finish. If reached, the pid gets returned. Set to 0 to deactivate",
706 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.",
710 'extra-args' => get_standard_option
('extra-args'),
719 my $vmid = $param->{vmid
};
720 my $sync = $param->{synchronous
} // 1;
721 my $pass_stdin = $param->{'pass-stdin'};
722 if (defined($param->{timeout
}) && !$sync) {
723 raise_param_exc
({ synchronous
=> "needs to be set for 'timeout'"});
726 my $input_data = undef;
729 while (my $line = <STDIN
>) {
730 $input_data .= $line;
731 if (length($input_data) > 1024*1024) {
732 # not sure how QEMU handles large amounts of data being
733 # passed into the QMP socket, so limit to be safe
734 die "'input-data' (STDIN) is limited to 1 MiB, aborting\n";
739 my $args = $param->{'extra-args'};
740 $args = undef if !$args || !@$args;
742 my $res = PVE
::QemuServer
::Agent
::qemu_exec
($vmid, $input_data, $args);
745 my $pid = $res->{pid
};
746 my $timeout = $param->{timeout
} // 30;
747 my $starttime = time();
749 while ($timeout == 0 || (time() - $starttime) < $timeout) {
750 my $out = PVE
::QemuServer
::Agent
::qemu_exec_status
($vmid, $pid);
751 if ($out->{exited
}) {
758 if (!$res->{exited
}) {
759 warn "timeout reached, returning pid\n";
763 return { result
=> $res };
766 __PACKAGE__-
>register_method({
771 description
=> "Cleans up resources like tap devices, vgpus, etc. Called after a vm shuts down, crashes, etc.",
773 additionalProperties
=> 0,
775 node
=> get_standard_option
('pve-node'),
776 vmid
=> get_standard_option
('pve-vmid', {
777 completion
=> \
&PVE
::QemuServer
::complete_vmid_running
}),
778 'clean-shutdown' => {
780 description
=> "Indicates if qemu shutdown cleanly.",
782 'guest-requested' => {
784 description
=> "Indicates if the shutdown was requested by the guest or via qmp.",
788 returns
=> { type
=> 'null', },
792 my $vmid = $param->{vmid
};
793 my $clean = $param->{'clean-shutdown'};
794 my $guest = $param->{'guest-requested'};
797 # return if we do not have the config anymore
798 return if !-f PVE
::QemuConfig-
>config_file($vmid);
800 my $storecfg = PVE
::Storage
::config
();
801 warn "Starting cleanup for $vmid\n";
803 PVE
::QemuConfig-
>lock_config($vmid, sub {
804 my $conf = PVE
::QemuConfig-
>load_config ($vmid);
805 my $pid = PVE
::QemuServer
::check_running
($vmid);
806 die "vm still running\n" if $pid;
809 # we have to cleanup the tap devices after a crash
811 foreach my $opt (keys %$conf) {
812 next if $opt !~ m/^net(\d)+$/;
814 PVE
::Network
::tap_unplug
("tap${vmid}i${interface}");
818 if (!$clean || $guest) {
819 # vm was shutdown from inside the guest or crashed, doing api cleanup
820 PVE
::QemuServer
::vm_stop_cleanup
($storecfg, $vmid, $conf, 0, 0);
822 PVE
::GuestHelpers
::exec_hookscript
($conf, $vmid, 'post-stop');
824 $restart = eval { PVE
::QemuServer
::clear_reboot_request
($vmid) };
828 warn "Finished cleanup for $vmid\n";
831 warn "Restarting VM $vmid\n";
832 PVE
::API2
::Qemu-
>vm_start({
841 my $print_agent_result = sub {
844 my $result = $data->{result
} // $data;
845 return if !defined($result);
847 my $class = ref($result);
851 return if $result =~ m/^\s*$/;
856 if (($class eq 'HASH') && !scalar(keys %$result)) { # empty hash
860 print to_json
($result, { pretty
=> 1, canonical
=> 1});
866 my $ssh_key_map = ['sshkeys', sub {
867 return URI
::Escape
::uri_escape
(PVE
::Tools
::file_get_contents
($_[0]));
869 my $cipassword_map = PVE
::CLIHandler
::get_standard_mapping
('pve-password', { name
=> 'cipassword' });
870 my $password_map = PVE
::CLIHandler
::get_standard_mapping
('pve-password');
872 'update_vm' => [$ssh_key_map, $cipassword_map],
873 'create_vm' => [$ssh_key_map, $cipassword_map],
874 'set-user-password' => [$password_map],
877 return $mapping->{$name};
881 list
=> [ "PVE::API2::Qemu", 'vmlist', [],
882 { node
=> $nodename }, sub {
885 exit 0 if (!scalar(@$vmlist));
887 printf "%10s %-20s %-10s %-10s %12s %-10s\n",
888 qw(VMID NAME STATUS MEM(MB) BOOTDISK
(GB
) PID
);
890 foreach my $rec (sort { $a->{vmid
} <=> $b->{vmid
} } @$vmlist) {
891 printf "%10s %-20s %-10s %-10s %12.2f %-10s\n", $rec->{vmid
}, $rec->{name
},
892 $rec->{qmpstatus
} || $rec->{status
},
893 ($rec->{maxmem
} || 0)/(1024*1024),
894 ($rec->{maxdisk
} || 0)/(1024*1024*1024),
901 create
=> [ "PVE::API2::Qemu", 'create_vm', ['vmid'], { node
=> $nodename }, $upid_exit ],
903 destroy
=> [ "PVE::API2::Qemu", 'destroy_vm', ['vmid'], { node
=> $nodename }, $upid_exit ],
905 clone
=> [ "PVE::API2::Qemu", 'clone_vm', ['vmid', 'newid'], { node
=> $nodename }, $upid_exit ],
907 migrate
=> [ "PVE::API2::Qemu", 'migrate_vm', ['vmid', 'target'], { node
=> $nodename }, $upid_exit ],
909 set
=> [ "PVE::API2::Qemu", 'update_vm', ['vmid'], { node
=> $nodename } ],
911 resize
=> [ "PVE::API2::Qemu", 'resize_vm', ['vmid', 'disk', 'size'], { node
=> $nodename } ],
913 move_disk
=> [ "PVE::API2::Qemu", 'move_vm_disk', ['vmid', 'disk', 'storage'], { node
=> $nodename }, $upid_exit ],
915 unlink => [ "PVE::API2::Qemu", 'unlink', ['vmid'], { node
=> $nodename } ],
917 config
=> [ "PVE::API2::Qemu", 'vm_config', ['vmid'],
918 { node
=> $nodename }, sub {
920 foreach my $k (sort (keys %$config)) {
921 next if $k eq 'digest';
922 my $v = $config->{$k};
923 if ($k eq 'description') {
924 $v = PVE
::Tools
::encode_text
($v);
930 pending
=> [ "PVE::API2::Qemu", 'vm_pending', ['vmid'], { node
=> $nodename }, \
&PVE
::GuestHelpers
::format_pending
],
931 showcmd
=> [ __PACKAGE__
, 'showcmd', ['vmid']],
933 status
=> [ __PACKAGE__
, 'status', ['vmid']],
935 snapshot
=> [ "PVE::API2::Qemu", 'snapshot', ['vmid', 'snapname'], { node
=> $nodename } , $upid_exit ],
937 delsnapshot
=> [ "PVE::API2::Qemu", 'delsnapshot', ['vmid', 'snapname'], { node
=> $nodename } , $upid_exit ],
939 listsnapshot
=> [ "PVE::API2::Qemu", 'snapshot_list', ['vmid'], { node
=> $nodename }, \
&PVE
::GuestHelpers
::print_snapshot_tree
],
941 rollback
=> [ "PVE::API2::Qemu", 'rollback', ['vmid', 'snapname'], { node
=> $nodename } , $upid_exit ],
943 template
=> [ "PVE::API2::Qemu", 'template', ['vmid'], { node
=> $nodename }],
945 start
=> [ "PVE::API2::Qemu", 'vm_start', ['vmid'], { node
=> $nodename } , $upid_exit ],
947 stop
=> [ "PVE::API2::Qemu", 'vm_stop', ['vmid'], { node
=> $nodename }, $upid_exit ],
949 reset => [ "PVE::API2::Qemu", 'vm_reset', ['vmid'], { node
=> $nodename }, $upid_exit ],
951 shutdown => [ "PVE::API2::Qemu", 'vm_shutdown', ['vmid'], { node
=> $nodename }, $upid_exit ],
953 reboot
=> [ "PVE::API2::Qemu", 'vm_reboot', ['vmid'], { node
=> $nodename }, $upid_exit ],
955 suspend
=> [ "PVE::API2::Qemu", 'vm_suspend', ['vmid'], { node
=> $nodename }, $upid_exit ],
957 resume
=> [ "PVE::API2::Qemu", 'vm_resume', ['vmid'], { node
=> $nodename }, $upid_exit ],
959 sendkey
=> [ "PVE::API2::Qemu", 'vm_sendkey', ['vmid', 'key'], { node
=> $nodename } ],
961 vncproxy
=> [ __PACKAGE__
, 'vncproxy', ['vmid']],
963 wait => [ __PACKAGE__
, 'wait', ['vmid']],
965 unlock
=> [ __PACKAGE__
, 'unlock', ['vmid']],
967 rescan
=> [ __PACKAGE__
, 'rescan', []],
969 monitor
=> [ __PACKAGE__
, 'monitor', ['vmid']],
971 agent
=> { alias
=> 'guest cmd' },
974 cmd
=> [ "PVE::API2::Qemu::Agent", 'agent', ['vmid', 'command'], { node
=> $nodename }, $print_agent_result ],
975 passwd
=> [ "PVE::API2::Qemu::Agent", 'set-user-password', [ 'vmid', 'username' ], { node
=> $nodename }],
976 exec => [ __PACKAGE__
, 'exec', [ 'vmid', 'extra-args' ], { node
=> $nodename }, $print_agent_result],
977 'exec-status' => [ "PVE::API2::Qemu::Agent", 'exec-status', [ 'vmid', 'pid' ], { node
=> $nodename }, $print_agent_result],
980 mtunnel
=> [ __PACKAGE__
, 'mtunnel', []],
982 nbdstop
=> [ __PACKAGE__
, 'nbdstop', ['vmid']],
984 terminal
=> [ __PACKAGE__
, 'terminal', ['vmid']],
986 importdisk
=> [ __PACKAGE__
, 'importdisk', ['vmid', 'source', 'storage']],
988 importovf
=> [ __PACKAGE__
, 'importovf', ['vmid', 'manifest', 'storage']],
990 cleanup
=> [ __PACKAGE__
, 'cleanup', ['vmid', 'clean-shutdown', 'guest-requested'], { node
=> $nodename }],
993 dump => [ "PVE::API2::Qemu", 'cloudinit_generated_config_dump', ['vmid', 'type'], { node
=> $nodename }, sub {