]> git.proxmox.com Git - qemu-server.git/blob - PVE/CLI/qm.pm
qm terminal: add --escape option
[qemu-server.git] / PVE / CLI / qm.pm
1 package PVE::CLI::qm;
2
3 use strict;
4 use warnings;
5
6 # Note: disable '+' prefix for Getopt::Long (for resize command)
7 use Getopt::Long qw(:config no_getopt_compat);
8
9 use Fcntl ':flock';
10 use File::Path;
11 use IO::Socket::UNIX;
12 use IO::Select;
13
14 use PVE::Tools qw(extract_param);
15 use PVE::Cluster;
16 use PVE::SafeSyslog;
17 use PVE::INotify;
18 use PVE::RPCEnvironment;
19 use PVE::QemuServer;
20 use PVE::QemuServer::ImportDisk;
21 use PVE::QemuServer::OVF;
22 use PVE::API2::Qemu;
23 use JSON;
24 use PVE::JSONSchema qw(get_standard_option);
25 use Term::ReadLine;
26
27 use PVE::CLIHandler;
28
29 use base qw(PVE::CLIHandler);
30
31 my $upid_exit = sub {
32 my $upid = shift;
33 my $status = PVE::Tools::upid_read_status($upid);
34 exit($status eq 'OK' ? 0 : -1);
35 };
36
37 my $nodename = PVE::INotify::nodename();
38
39 sub setup_environment {
40 PVE::RPCEnvironment->setup_default_cli_env();
41 }
42
43 sub run_vnc_proxy {
44 my ($path) = @_;
45
46 my $c;
47 while ( ++$c < 10 && !-e $path ) { sleep(1); }
48
49 my $s = IO::Socket::UNIX->new(Peer => $path, Timeout => 120);
50
51 die "unable to connect to socket '$path' - $!" if !$s;
52
53 my $select = new IO::Select;
54
55 $select->add(\*STDIN);
56 $select->add($s);
57
58 my $timeout = 60*15; # 15 minutes
59
60 my @handles;
61 while ($select->count &&
62 scalar(@handles = $select->can_read ($timeout))) {
63 foreach my $h (@handles) {
64 my $buf;
65 my $n = $h->sysread($buf, 4096);
66
67 if ($h == \*STDIN) {
68 if ($n) {
69 syswrite($s, $buf);
70 } else {
71 exit(0);
72 }
73 } elsif ($h == $s) {
74 if ($n) {
75 syswrite(\*STDOUT, $buf);
76 } else {
77 exit(0);
78 }
79 }
80 }
81 }
82 exit(0);
83 }
84
85 sub print_recursive_hash {
86 my ($prefix, $hash, $key) = @_;
87
88 if (ref($hash) eq 'HASH') {
89 if (defined($key)) {
90 print "$prefix$key:\n";
91 }
92 foreach my $itemkey (keys %$hash) {
93 print_recursive_hash("\t$prefix", $hash->{$itemkey}, $itemkey);
94 }
95 } elsif (ref($hash) eq 'ARRAY') {
96 if (defined($key)) {
97 print "$prefix$key:\n";
98 }
99 foreach my $item (@$hash) {
100 print_recursive_hash("\t$prefix", $item);
101 }
102 } elsif (!ref($hash) && defined($hash)) {
103 if (defined($key)) {
104 print "$prefix$key: $hash\n";
105 } else {
106 print "$prefix$hash\n";
107 }
108 }
109 }
110
111 __PACKAGE__->register_method ({
112 name => 'showcmd',
113 path => 'showcmd',
114 method => 'GET',
115 description => "Show command line which is used to start the VM (debug info).",
116 parameters => {
117 additionalProperties => 0,
118 properties => {
119 vmid => get_standard_option('pve-vmid', { completion => \&PVE::QemuServer::complete_vmid }),
120 },
121 },
122 returns => { type => 'null'},
123 code => sub {
124 my ($param) = @_;
125
126 my $storecfg = PVE::Storage::config();
127 print PVE::QemuServer::vm_commandline($storecfg, $param->{vmid}) . "\n";
128
129 return undef;
130 }});
131
132 __PACKAGE__->register_method ({
133 name => 'status',
134 path => 'status',
135 method => 'GET',
136 description => "Show VM status.",
137 parameters => {
138 additionalProperties => 0,
139 properties => {
140 vmid => get_standard_option('pve-vmid', { completion => \&PVE::QemuServer::complete_vmid }),
141 verbose => {
142 description => "Verbose output format",
143 type => 'boolean',
144 optional => 1,
145 }
146 },
147 },
148 returns => { type => 'null'},
149 code => sub {
150 my ($param) = @_;
151
152 # test if VM exists
153 my $conf = PVE::QemuConfig->load_config ($param->{vmid});
154
155 my $vmstatus = PVE::QemuServer::vmstatus($param->{vmid}, 1);
156 my $stat = $vmstatus->{$param->{vmid}};
157 if ($param->{verbose}) {
158 foreach my $k (sort (keys %$stat)) {
159 next if $k eq 'cpu' || $k eq 'relcpu'; # always 0
160 my $v = $stat->{$k};
161 print_recursive_hash("", $v, $k);
162 }
163 } else {
164 my $status = $stat->{qmpstatus} || 'unknown';
165 print "status: $status\n";
166 }
167
168 return undef;
169 }});
170
171 __PACKAGE__->register_method ({
172 name => 'vncproxy',
173 path => 'vncproxy',
174 method => 'PUT',
175 description => "Proxy VM VNC traffic to stdin/stdout",
176 parameters => {
177 additionalProperties => 0,
178 properties => {
179 vmid => get_standard_option('pve-vmid', { completion => \&PVE::QemuServer::complete_vmid_running }),
180 },
181 },
182 returns => { type => 'null'},
183 code => sub {
184 my ($param) = @_;
185
186 my $vmid = $param->{vmid};
187 my $vnc_socket = PVE::QemuServer::vnc_socket($vmid);
188
189 if (my $ticket = $ENV{LC_PVE_TICKET}) { # NOTE: ssh on debian only pass LC_* variables
190 PVE::QemuServer::vm_mon_cmd($vmid, "change", device => 'vnc', target => "unix:$vnc_socket,password");
191 PVE::QemuServer::vm_mon_cmd($vmid, "set_password", protocol => 'vnc', password => $ticket);
192 PVE::QemuServer::vm_mon_cmd($vmid, "expire_password", protocol => 'vnc', time => "+30");
193 } else {
194 PVE::QemuServer::vm_mon_cmd($vmid, "change", device => 'vnc', target => "unix:$vnc_socket,x509,password");
195 }
196
197 run_vnc_proxy($vnc_socket);
198
199 return undef;
200 }});
201
202 __PACKAGE__->register_method ({
203 name => 'unlock',
204 path => 'unlock',
205 method => 'PUT',
206 description => "Unlock the VM.",
207 parameters => {
208 additionalProperties => 0,
209 properties => {
210 vmid => get_standard_option('pve-vmid', { completion => \&PVE::QemuServer::complete_vmid }),
211 },
212 },
213 returns => { type => 'null'},
214 code => sub {
215 my ($param) = @_;
216
217 my $vmid = $param->{vmid};
218
219 PVE::QemuConfig->lock_config ($vmid, sub {
220 my $conf = PVE::QemuConfig->load_config($vmid);
221 delete $conf->{lock};
222 delete $conf->{pending}->{lock} if $conf->{pending}; # just to be sure
223 PVE::QemuConfig->write_config($vmid, $conf);
224 });
225
226 return undef;
227 }});
228
229 __PACKAGE__->register_method ({
230 name => 'nbdstop',
231 path => 'nbdstop',
232 method => 'PUT',
233 description => "Stop embedded nbd server.",
234 parameters => {
235 additionalProperties => 0,
236 properties => {
237 vmid => get_standard_option('pve-vmid', { completion => \&PVE::QemuServer::complete_vmid }),
238 },
239 },
240 returns => { type => 'null'},
241 code => sub {
242 my ($param) = @_;
243
244 my $vmid = $param->{vmid};
245
246 PVE::QemuServer::nbd_stop($vmid);
247
248 return undef;
249 }});
250
251 __PACKAGE__->register_method ({
252 name => 'mtunnel',
253 path => 'mtunnel',
254 method => 'POST',
255 description => "Used by qmigrate - do not use manually.",
256 parameters => {
257 additionalProperties => 0,
258 properties => {},
259 },
260 returns => { type => 'null'},
261 code => sub {
262 my ($param) = @_;
263
264 if (!PVE::Cluster::check_cfs_quorum(1)) {
265 print "no quorum\n";
266 return undef;
267 }
268
269 my $tunnel_write = sub {
270 my $text = shift;
271 chomp $text;
272 print "$text\n";
273 *STDOUT->flush();
274 };
275
276 $tunnel_write->("tunnel online");
277 $tunnel_write->("ver 1");
278
279 while (my $line = <>) {
280 chomp $line;
281 if ($line =~ /^quit$/) {
282 $tunnel_write->("OK");
283 last;
284 } elsif ($line =~ /^resume (\d+)$/) {
285 my $vmid = $1;
286 if (PVE::QemuServer::check_running($vmid, 1)) {
287 eval { PVE::QemuServer::vm_resume($vmid, 1, 1); };
288 if ($@) {
289 $tunnel_write->("ERR: resume failed - $@");
290 } else {
291 $tunnel_write->("OK");
292 }
293 } else {
294 $tunnel_write->("ERR: resume failed - VM $vmid not running");
295 }
296 }
297 }
298
299 return undef;
300 }});
301
302 __PACKAGE__->register_method ({
303 name => 'wait',
304 path => 'wait',
305 method => 'GET',
306 description => "Wait until the VM is stopped.",
307 parameters => {
308 additionalProperties => 0,
309 properties => {
310 vmid => get_standard_option('pve-vmid', { completion => \&PVE::QemuServer::complete_vmid_running }),
311 timeout => {
312 description => "Timeout in seconds. Default is to wait forever.",
313 type => 'integer',
314 minimum => 1,
315 optional => 1,
316 }
317 },
318 },
319 returns => { type => 'null'},
320 code => sub {
321 my ($param) = @_;
322
323 my $vmid = $param->{vmid};
324 my $timeout = $param->{timeout};
325
326 my $pid = PVE::QemuServer::check_running ($vmid);
327 return if !$pid;
328
329 print "waiting until VM $vmid stopps (PID $pid)\n";
330
331 my $count = 0;
332 while ((!$timeout || ($count < $timeout)) && PVE::QemuServer::check_running ($vmid)) {
333 $count++;
334 sleep 1;
335 }
336
337 die "wait failed - got timeout\n" if PVE::QemuServer::check_running ($vmid);
338
339 return undef;
340 }});
341
342 __PACKAGE__->register_method ({
343 name => 'monitor',
344 path => 'monitor',
345 method => 'POST',
346 description => "Enter Qemu Monitor interface.",
347 parameters => {
348 additionalProperties => 0,
349 properties => {
350 vmid => get_standard_option('pve-vmid', { completion => \&PVE::QemuServer::complete_vmid_running }),
351 },
352 },
353 returns => { type => 'null'},
354 code => sub {
355 my ($param) = @_;
356
357 my $vmid = $param->{vmid};
358
359 my $conf = PVE::QemuConfig->load_config ($vmid); # check if VM exists
360
361 print "Entering Qemu Monitor for VM $vmid - type 'help' for help\n";
362
363 my $term = new Term::ReadLine ('qm');
364
365 my $input;
366 while (defined ($input = $term->readline('qm> '))) {
367 chomp $input;
368
369 next if $input =~ m/^\s*$/;
370
371 last if $input =~ m/^\s*q(uit)?\s*$/;
372
373 eval {
374 print PVE::QemuServer::vm_human_monitor_command ($vmid, $input);
375 };
376 print "ERROR: $@" if $@;
377 }
378
379 return undef;
380
381 }});
382
383 __PACKAGE__->register_method ({
384 name => 'rescan',
385 path => 'rescan',
386 method => 'POST',
387 description => "Rescan all storages and update disk sizes and unused disk images.",
388 parameters => {
389 additionalProperties => 0,
390 properties => {
391 vmid => get_standard_option('pve-vmid', {
392 optional => 1,
393 completion => \&PVE::QemuServer::complete_vmid,
394 }),
395 },
396 },
397 returns => { type => 'null'},
398 code => sub {
399 my ($param) = @_;
400
401 PVE::QemuServer::rescan($param->{vmid});
402
403 return undef;
404 }});
405
406 __PACKAGE__->register_method ({
407 name => 'importdisk',
408 path => 'importdisk',
409 method => 'POST',
410 description => "Import an external disk image as an unused disk in a VM. The
411 image format has to be supported by qemu-img(1).",
412 parameters => {
413 additionalProperties => 0,
414 properties => {
415 vmid => get_standard_option('pve-vmid', {completion => \&PVE::QemuServer::complete_vmid}),
416 source => {
417 description => 'Path to the disk image to import',
418 type => 'string',
419 optional => 0,
420 },
421 storage => get_standard_option('pve-storage-id', {
422 description => 'Target storage ID',
423 completion => \&PVE::QemuServer::complete_storage,
424 optional => 0,
425 }),
426 format => {
427 type => 'string',
428 description => 'Target format',
429 enum => [ 'raw', 'qcow2', 'vmdk' ],
430 optional => 1,
431 },
432 },
433 },
434 returns => { type => 'null'},
435 code => sub {
436 my ($param) = @_;
437
438 my $vmid = extract_param($param, 'vmid');
439 my $source = extract_param($param, 'source');
440 my $storeid = extract_param($param, 'storage');
441 my $format = extract_param($param, 'format');
442
443 my $vm_conf = PVE::QemuConfig->load_config($vmid);
444 PVE::QemuConfig->check_lock($vm_conf);
445 die "$source: non-existent or non-regular file\n" if (! -f $source);
446
447 my $storecfg = PVE::Storage::config();
448 PVE::Storage::storage_check_enabled($storecfg, $storeid);
449
450 my $target_storage_config =
451 PVE::Storage::storage_config($storecfg, $storeid);
452 die "storage $storeid does not support vm images\n"
453 if !$target_storage_config->{content}->{images};
454
455 PVE::QemuServer::ImportDisk::do_import($source, $vmid, $storeid, { format => $format });
456
457 return undef;
458 }});
459
460 __PACKAGE__->register_method ({
461 name => 'terminal',
462 path => 'terminal',
463 method => 'POST',
464 description => "Open a terminal using a serial device (The VM need to have a serial device configured, for example 'serial0: socket')",
465 parameters => {
466 additionalProperties => 0,
467 properties => {
468 vmid => get_standard_option('pve-vmid', { completion => \&PVE::QemuServer::complete_vmid_running }),
469 iface => {
470 description => "Select the serial device. By default we simply use the first suitable device.",
471 type => 'string',
472 optional => 1,
473 enum => [qw(serial0 serial1 serial2 serial3)],
474 },
475 escape => {
476 description => "Escape character.",
477 type => 'string',
478 optional => 1,
479 default => '^O',
480 },
481 },
482 },
483 returns => { type => 'null'},
484 code => sub {
485 my ($param) = @_;
486
487 my $vmid = $param->{vmid};
488
489 my $escape = $param->{escape} // '^O';
490 if ($escape =~ /^\^([\x40-\x7a])$/) {
491 $escape = ord($1) & 0x1F;
492 } elsif ($escape =~ /^0x[0-9a-f]+$/i) {
493 $escape = hex($escape);
494 } elsif ($escape =~ /^[0-9]+$/) {
495 $escape = int($escape);
496 } else {
497 die "invalid escape character definition: $escape\n";
498 }
499 my $escapemsg = '';
500 if ($escape) {
501 $escapemsg = sprintf(' (press Ctrl+%c to exit)', $escape+0x40);
502 $escape = sprintf(',escape=0x%x', $escape);
503 } else {
504 $escape = '';
505 }
506
507 my $conf = PVE::QemuConfig->load_config ($vmid); # check if VM exists
508
509 my $iface = $param->{iface};
510
511 if ($iface) {
512 die "serial interface '$iface' is not configured\n" if !$conf->{$iface};
513 die "wrong serial type on interface '$iface'\n" if $conf->{$iface} ne 'socket';
514 } else {
515 foreach my $opt (qw(serial0 serial1 serial2 serial3)) {
516 if ($conf->{$opt} && ($conf->{$opt} eq 'socket')) {
517 $iface = $opt;
518 last;
519 }
520 }
521 die "unable to find a serial interface\n" if !$iface;
522 }
523
524 die "VM $vmid not running\n" if !PVE::QemuServer::check_running($vmid);
525
526 my $socket = "/var/run/qemu-server/${vmid}.$iface";
527
528 my $cmd = "socat UNIX-CONNECT:$socket STDIO,raw,echo=0$escape";
529
530 print "starting serial terminal on interface ${iface}${escapemsg}\n";
531
532 system($cmd);
533
534 return undef;
535 }});
536
537 __PACKAGE__->register_method ({
538 name => 'importovf',
539 path => 'importovf',
540 description => "Create a new VM using parameters read from an OVF manifest",
541 parameters => {
542 additionalProperties => 0,
543 properties => {
544 vmid => get_standard_option('pve-vmid', { completion => \&PVE::Cluster::complete_next_vmid }),
545 manifest => {
546 type => 'string',
547 description => 'path to the ovf file',
548 },
549 storage => get_standard_option('pve-storage-id', {
550 description => 'Target storage ID',
551 completion => \&PVE::QemuServer::complete_storage,
552 optional => 0,
553 }),
554 format => {
555 type => 'string',
556 description => 'Target format',
557 enum => [ 'raw', 'qcow2', 'vmdk' ],
558 optional => 1,
559 },
560 dryrun => {
561 type => 'boolean',
562 description => 'Print a parsed representation of the extracted OVF parameters, but do not create a VM',
563 optional => 1,
564 }
565 },
566 },
567 returns => { type => 'null' },
568 code => sub {
569 my ($param) = @_;
570
571 my $vmid = PVE::Tools::extract_param($param, 'vmid');
572 my $ovf_file = PVE::Tools::extract_param($param, 'manifest');
573 my $storeid = PVE::Tools::extract_param($param, 'storage');
574 my $format = PVE::Tools::extract_param($param, 'format');
575 my $dryrun = PVE::Tools::extract_param($param, 'dryrun');
576
577 die "$ovf_file: non-existent or non-regular file\n" if (! -f $ovf_file);
578 my $storecfg = PVE::Storage::config();
579 PVE::Storage::storage_check_enabled($storecfg, $storeid);
580
581 my $parsed = PVE::QemuServer::OVF::parse_ovf($ovf_file);
582
583 if ($dryrun) {
584 print to_json($parsed, { pretty => 1, canonical => 1});
585 return;
586 }
587
588 $param->{name} = $parsed->{qm}->{name} if defined($parsed->{qm}->{name});
589 $param->{memory} = $parsed->{qm}->{memory} if defined($parsed->{qm}->{memory});
590 $param->{cores} = $parsed->{qm}->{cores} if defined($parsed->{qm}->{cores});
591
592 my $importfn = sub {
593
594 PVE::Cluster::check_vmid_unused($vmid);
595
596 my $conf = $param;
597
598 eval {
599 # order matters, as do_import() will load_config() internally
600 $conf->{smbios1} = PVE::QemuServer::generate_smbios1_uuid();
601 PVE::QemuConfig->write_config($vmid, $conf);
602
603 foreach my $disk (@{ $parsed->{disks} }) {
604 my ($file, $drive) = ($disk->{backing_file}, $disk->{disk_address});
605 PVE::QemuServer::ImportDisk::do_import($file, $vmid, $storeid,
606 { drive_name => $drive, format => $format });
607 }
608
609 # reload after disks entries have been created
610 $conf = PVE::QemuConfig->load_config($vmid);
611 PVE::QemuConfig->check_lock($conf);
612 my $firstdisk = PVE::QemuServer::resolve_first_disk($conf);
613 $conf->{bootdisk} = $firstdisk if $firstdisk;
614 PVE::QemuConfig->write_config($vmid, $conf);
615 };
616
617 my $err = $@;
618 if ($err) {
619 my $skiplock = 1;
620 eval { PVE::QemuServer::vm_destroy($storecfg, $vmid, $skiplock); };
621 die "import failed - $err";
622 }
623 };
624
625 my $wait_for_lock = 1;
626 PVE::QemuConfig->lock_config_full($vmid, $wait_for_lock, $importfn);
627
628 return undef;
629
630 }
631 });
632
633 my $print_agent_result = sub {
634 my ($data) = @_;
635
636 my $result = $data->{result};
637 return if !defined($result);
638
639 my $class = ref($result);
640
641 if (!$class) {
642 chomp $result;
643 return if $result =~ m/^\s*$/;
644 print "$result\n";
645 return;
646 }
647
648 if (($class eq 'HASH') && !scalar(keys %$result)) { # empty hash
649 return;
650 }
651
652 print to_json($result, { pretty => 1, canonical => 1});
653 };
654
655 our $cmddef = {
656 list => [ "PVE::API2::Qemu", 'vmlist', [],
657 { node => $nodename }, sub {
658 my $vmlist = shift;
659
660 exit 0 if (!scalar(@$vmlist));
661
662 printf "%10s %-20s %-10s %-10s %12s %-10s\n",
663 qw(VMID NAME STATUS MEM(MB) BOOTDISK(GB) PID);
664
665 foreach my $rec (sort { $a->{vmid} <=> $b->{vmid} } @$vmlist) {
666 printf "%10s %-20s %-10s %-10s %12.2f %-10s\n", $rec->{vmid}, $rec->{name},
667 $rec->{qmpstatus} || $rec->{status},
668 ($rec->{maxmem} || 0)/(1024*1024),
669 ($rec->{maxdisk} || 0)/(1024*1024*1024),
670 $rec->{pid}||0;
671 }
672
673
674 } ],
675
676 create => [ "PVE::API2::Qemu", 'create_vm', ['vmid'], { node => $nodename }, $upid_exit ],
677
678 destroy => [ "PVE::API2::Qemu", 'destroy_vm', ['vmid'], { node => $nodename }, $upid_exit ],
679
680 clone => [ "PVE::API2::Qemu", 'clone_vm', ['vmid', 'newid'], { node => $nodename }, $upid_exit ],
681
682 migrate => [ "PVE::API2::Qemu", 'migrate_vm', ['vmid', 'target'], { node => $nodename }, $upid_exit ],
683
684 set => [ "PVE::API2::Qemu", 'update_vm', ['vmid'], { node => $nodename } ],
685
686 resize => [ "PVE::API2::Qemu", 'resize_vm', ['vmid', 'disk', 'size'], { node => $nodename } ],
687
688 move_disk => [ "PVE::API2::Qemu", 'move_vm_disk', ['vmid', 'disk', 'storage'], { node => $nodename }, $upid_exit ],
689
690 unlink => [ "PVE::API2::Qemu", 'unlink', ['vmid'], { node => $nodename } ],
691
692 config => [ "PVE::API2::Qemu", 'vm_config', ['vmid'],
693 { node => $nodename }, sub {
694 my $config = shift;
695 foreach my $k (sort (keys %$config)) {
696 next if $k eq 'digest';
697 my $v = $config->{$k};
698 if ($k eq 'description') {
699 $v = PVE::Tools::encode_text($v);
700 }
701 print "$k: $v\n";
702 }
703 }],
704
705 pending => [ "PVE::API2::Qemu", 'vm_pending', ['vmid'],
706 { node => $nodename }, sub {
707 my $data = shift;
708 foreach my $item (sort { $a->{key} cmp $b->{key}} @$data) {
709 my $k = $item->{key};
710 next if $k eq 'digest';
711 my $v = $item->{value};
712 my $p = $item->{pending};
713 if ($k eq 'description') {
714 $v = PVE::Tools::encode_text($v) if defined($v);
715 $p = PVE::Tools::encode_text($p) if defined($p);
716 }
717 if (defined($v)) {
718 if ($item->{delete}) {
719 print "del $k: $v\n";
720 } elsif (defined($p)) {
721 print "cur $k: $v\n";
722 print "new $k: $p\n";
723 } else {
724 print "cur $k: $v\n";
725 }
726 } elsif (defined($p)) {
727 print "new $k: $p\n";
728 }
729 }
730 }],
731
732 showcmd => [ __PACKAGE__, 'showcmd', ['vmid']],
733
734 status => [ __PACKAGE__, 'status', ['vmid']],
735
736 snapshot => [ "PVE::API2::Qemu", 'snapshot', ['vmid', 'snapname'], { node => $nodename } , $upid_exit ],
737
738 delsnapshot => [ "PVE::API2::Qemu", 'delsnapshot', ['vmid', 'snapname'], { node => $nodename } , $upid_exit ],
739
740 listsnapshot => [ "PVE::API2::Qemu", 'snapshot_list', ['vmid'], { node => $nodename },
741 sub {
742 my $res = shift;
743 foreach my $e (@$res) {
744 my $headline = $e->{description} || 'no-description';
745 $headline =~ s/\n.*//sg;
746 my $parent = $e->{parent} // 'no-parent';
747 printf("%-20s %-20s %s\n", $e->{name}, $parent, $headline);
748 }
749 }],
750
751 rollback => [ "PVE::API2::Qemu", 'rollback', ['vmid', 'snapname'], { node => $nodename } , $upid_exit ],
752
753 template => [ "PVE::API2::Qemu", 'template', ['vmid'], { node => $nodename }],
754
755 start => [ "PVE::API2::Qemu", 'vm_start', ['vmid'], { node => $nodename } , $upid_exit ],
756
757 stop => [ "PVE::API2::Qemu", 'vm_stop', ['vmid'], { node => $nodename }, $upid_exit ],
758
759 reset => [ "PVE::API2::Qemu", 'vm_reset', ['vmid'], { node => $nodename }, $upid_exit ],
760
761 shutdown => [ "PVE::API2::Qemu", 'vm_shutdown', ['vmid'], { node => $nodename }, $upid_exit ],
762
763 suspend => [ "PVE::API2::Qemu", 'vm_suspend', ['vmid'], { node => $nodename }, $upid_exit ],
764
765 resume => [ "PVE::API2::Qemu", 'vm_resume', ['vmid'], { node => $nodename }, $upid_exit ],
766
767 sendkey => [ "PVE::API2::Qemu", 'vm_sendkey', ['vmid', 'key'], { node => $nodename } ],
768
769 vncproxy => [ __PACKAGE__, 'vncproxy', ['vmid']],
770
771 wait => [ __PACKAGE__, 'wait', ['vmid']],
772
773 unlock => [ __PACKAGE__, 'unlock', ['vmid']],
774
775 rescan => [ __PACKAGE__, 'rescan', []],
776
777 monitor => [ __PACKAGE__, 'monitor', ['vmid']],
778
779 agent => [ "PVE::API2::Qemu", 'agent', ['vmid', 'command'],
780 { node => $nodename }, $print_agent_result ],
781
782 mtunnel => [ __PACKAGE__, 'mtunnel', []],
783
784 nbdstop => [ __PACKAGE__, 'nbdstop', ['vmid']],
785
786 terminal => [ __PACKAGE__, 'terminal', ['vmid']],
787
788 importdisk => [ __PACKAGE__, 'importdisk', ['vmid', 'source', 'storage']],
789
790 importovf => [ __PACKAGE__, 'importovf', ['vmid', 'manifest', 'storage']],
791
792 };
793
794 1;