1 package PVE
::API2
::Qemu
;
8 use PVE
::Tools
qw(extract_param);
9 use PVE
::Exception
qw(raise raise_param_exc);
11 use PVE
::JSONSchema
qw(get_standard_option);
15 use PVE
::RPCEnvironment
;
16 use PVE
::AccessControl
;
19 use Data
::Dumper
; # fixme: remove
21 use base
qw(PVE::RESTHandler);
23 my $opt_force_description = "Force physical removal. Without this, we simple remove the disk from the config file and create an additional configuration entry called 'unused[n]', which contains the volume ID. Unlink of unused[n] always cause physical removal.";
25 my $resolve_cdrom_alias = sub {
28 if (my $value = $param->{cdrom
}) {
29 $value .= ",media=cdrom" if $value !~ m/media=/;
30 $param->{ide2
} = $value;
31 delete $param->{cdrom
};
35 __PACKAGE__-
>register_method({
39 description
=> "Virtual machine index (per node).",
41 protected
=> 1, # qemu pid files are only readable by root
43 additionalProperties
=> 0,
45 node
=> get_standard_option
('pve-node'),
54 links
=> [ { rel
=> 'child', href
=> "{vmid}" } ],
59 my $vmstatus = PVE
::QemuServer
::vmstatus
();
61 return PVE
::RESTHandler
::hash_to_array
($vmstatus, 'vmid');
65 __PACKAGE__-
>register_method({
69 description
=> "Create new virtual machine.",
73 additionalProperties
=> 0,
74 properties
=> PVE
::QemuServer
::json_config_properties
(
76 node
=> get_standard_option
('pve-node'),
77 vmid
=> get_standard_option
('pve-vmid'),
86 my $rpcenv = PVE
::RPCEnvironment
::get
();
88 my $user = $rpcenv->get_user();
90 my $node = extract_param
($param, 'node');
94 my $vmid = extract_param
($param, 'vmid');
96 my $filename = PVE
::QemuServer
::config_file
($vmid);
97 # first test (befor locking)
98 die "unable to create vm $vmid: config file already exists\n"
101 my $storecfg = PVE
::Storage
::config
();
103 &$resolve_cdrom_alias($param);
105 foreach my $opt (keys %$param) {
106 if (PVE
::QemuServer
::valid_drivename
($opt)) {
107 my $drive = PVE
::QemuServer
::parse_drive
($opt, $param->{$opt});
108 raise_param_exc
({ $opt => "unable to parse drive options" }) if !$drive;
110 PVE
::QemuServer
::cleanup_drive_path
($opt, $storecfg, $drive);
111 $param->{$opt} = PVE
::QemuServer
::print_drive
($vmid, $drive);
115 PVE
::QemuServer
::add_random_macs
($param);
119 # second test (after locking test is accurate)
120 die "unable to create vm $vmid: config file already exists\n"
128 $vollist = PVE
::QemuServer
::create_disks
($storecfg, $vmid, $param);
130 # try to be smart about bootdisk
131 my @disks = PVE
::QemuServer
::disknames
();
133 foreach my $ds (reverse @disks) {
134 next if !$param->{$ds};
135 my $disk = PVE
::QemuServer
::parse_drive
($ds, $param->{$ds});
136 next if PVE
::QemuServer
::drive_is_cdrom
($disk);
140 if (!$param->{bootdisk
} && $firstdisk) {
141 $param->{bootdisk
} = $firstdisk;
144 PVE
::QemuServer
::create_conf_nolock
($vmid, $param);
149 foreach my $volid (@$vollist) {
150 eval { PVE
::Storage
::vdisk_free
($storecfg, $volid); };
153 die "create failed - $err";
157 return $rpcenv->fork_worker('qmcreate', $vmid, $user, $realcmd);
160 return PVE
::QemuServer
::lock_config
($vmid, $createfn);
163 __PACKAGE__-
>register_method({
168 description
=> "Directory index",
170 additionalProperties
=> 0,
172 node
=> get_standard_option
('pve-node'),
173 vmid
=> get_standard_option
('pve-vmid'),
181 subdir
=> { type
=> 'string' },
184 links
=> [ { rel
=> 'child', href
=> "{subdir}" } ],
190 { subdir
=> 'config' },
191 { subdir
=> 'status' },
192 { subdir
=> 'unlink' },
193 { subdir
=> 'vncproxy' },
194 { subdir
=> 'migrate' },
196 { subdir
=> 'rrddata' },
202 __PACKAGE__-
>register_method({
204 path
=> '{vmid}/rrd',
206 protected
=> 1, # fixme: can we avoid that?
208 path
=> '/vms/{vmid}',
209 privs
=> [ 'VM.Audit' ],
211 description
=> "Read VM RRD statistics (returns PNG)",
213 additionalProperties
=> 0,
215 node
=> get_standard_option
('pve-node'),
216 vmid
=> get_standard_option
('pve-vmid'),
218 description
=> "Specify the time frame you are interested in.",
220 enum
=> [ 'hour', 'day', 'week', 'month', 'year' ],
223 description
=> "The list of datasources you want to display.",
224 type
=> 'string', format
=> 'pve-configid-list',
227 description
=> "The RRD consolidation function",
229 enum
=> [ 'AVERAGE', 'MAX' ],
237 filename
=> { type
=> 'string' },
243 return PVE
::Cluster
::create_rrd_graph
(
244 "pve2-vm/$param->{vmid}", $param->{timeframe
},
245 $param->{ds
}, $param->{cf
});
249 __PACKAGE__-
>register_method({
251 path
=> '{vmid}/rrddata',
253 protected
=> 1, # fixme: can we avoid that?
255 path
=> '/vms/{vmid}',
256 privs
=> [ 'VM.Audit' ],
258 description
=> "Read VM RRD statistics",
260 additionalProperties
=> 0,
262 node
=> get_standard_option
('pve-node'),
263 vmid
=> get_standard_option
('pve-vmid'),
265 description
=> "Specify the time frame you are interested in.",
267 enum
=> [ 'hour', 'day', 'week', 'month', 'year' ],
270 description
=> "The RRD consolidation function",
272 enum
=> [ 'AVERAGE', 'MAX' ],
287 return PVE
::Cluster
::create_rrd_data
(
288 "pve2-vm/$param->{vmid}", $param->{timeframe
}, $param->{cf
});
292 __PACKAGE__-
>register_method({
294 path
=> '{vmid}/config',
297 description
=> "Get virtual machine configuration.",
299 additionalProperties
=> 0,
301 node
=> get_standard_option
('pve-node'),
302 vmid
=> get_standard_option
('pve-vmid'),
310 description
=> 'SHA1 digest of configuration file. This can be used to prevent concurrent modifications.',
317 my $conf = PVE
::QemuServer
::load_config
($param->{vmid
});
322 __PACKAGE__-
>register_method({
324 path
=> '{vmid}/config',
328 description
=> "Set virtual machine options.",
330 additionalProperties
=> 0,
331 properties
=> PVE
::QemuServer
::json_config_properties
(
333 node
=> get_standard_option
('pve-node'),
334 vmid
=> get_standard_option
('pve-vmid'),
335 skiplock
=> get_standard_option
('skiplock'),
337 type
=> 'string', format
=> 'pve-configid-list',
338 description
=> "A list of settings you want to delete.",
343 description
=> $opt_force_description,
345 requires
=> 'delete',
349 description
=> 'Prevent changes if current configuration file has different SHA1 digest. This can be used to prevent concurrent modifications.',
355 returns
=> { type
=> 'null'},
359 my $rpcenv = PVE
::RPCEnvironment
::get
();
361 my $user = $rpcenv->get_user();
363 my $node = extract_param
($param, 'node');
365 my $vmid = extract_param
($param, 'vmid');
367 my $digest = extract_param
($param, 'digest');
369 my @paramarr = (); # used for log message
370 foreach my $key (keys %$param) {
371 push @paramarr, "-$key", $param->{$key};
374 my $skiplock = extract_param
($param, 'skiplock');
375 raise_param_exc
({ skiplock
=> "Only root may use this option." })
376 if $skiplock && $user ne 'root@pam';
378 my $delete = extract_param
($param, 'delete');
379 my $force = extract_param
($param, 'force');
381 die "no options specified\n" if !$delete && !scalar(keys %$param);
383 my $storecfg = PVE
::Storage
::config
();
385 &$resolve_cdrom_alias($param);
390 foreach my $opt (keys %$param) {
391 if (PVE
::QemuServer
::valid_drivename
($opt)) {
392 my $drive = PVE
::QemuServer
::parse_drive
($opt, $param->{$opt});
393 raise_param_exc
({ $opt => "unable to parse drive options" }) if !$drive;
394 if ($drive->{file
} eq 'eject') {
396 delete $param->{$opt};
400 PVE
::QemuServer
::cleanup_drive_path
($opt, $storecfg, $drive);
401 $param->{$opt} = PVE
::QemuServer
::print_drive
($vmid, $drive);
403 if (PVE
::QemuServer
::drive_is_cdrom
($drive)) {
404 $cdchange->{$opt} = PVE
::QemuServer
::get_iso_path
($storecfg, $vmid, $drive->{file
});
409 foreach my $opt (PVE
::Tools
::split_list
($delete)) {
410 $opt = 'ide2' if $opt eq 'cdrom';
411 die "you can't use '-$opt' and '-delete $opt' at the same time\n"
412 if defined($param->{$opt});
415 PVE
::QemuServer
::add_random_macs
($param);
421 my $conf = PVE
::QemuServer
::load_config
($vmid);
423 die "checksum missmatch (file change by other user?)\n"
424 if $digest && $digest ne $conf->{digest
};
426 PVE
::QemuServer
::check_lock
($conf) if !$skiplock;
428 PVE
::Cluster
::log_msg
('info', $user, "update VM $vmid: " . join (' ', @paramarr));
430 foreach my $opt (keys %$eject) {
432 my $drive = PVE
::QemuServer
::parse_drive
($opt, $conf->{$opt});
433 $cdchange->{$opt} = undef if PVE
::QemuServer
::drive_is_cdrom
($drive);
435 raise_param_exc
({ $opt => "eject failed - drive does not exist." });
439 foreach my $opt (keys %$param) {
440 next if !PVE
::QemuServer
::valid_drivename
($opt);
441 next if !$conf->{$opt};
442 my $old_drive = PVE
::QemuServer
::parse_drive
($opt, $conf->{$opt});
443 next if PVE
::QemuServer
::drive_is_cdrom
($old_drive);
444 my $new_drive = PVE
::QemuServer
::parse_drive
($opt, $param->{$opt});
445 if ($new_drive->{file
} ne $old_drive->{file
}) {
447 eval { ($path, $owner) = PVE
::Storage
::path
($storecfg, $old_drive->{file
}); };
448 if ($owner && ($owner == $vmid)) {
449 PVE
::QemuServer
::add_unused_volume
($conf, $param, $old_drive->{file
});
456 foreach my $opt (PVE
::Tools
::split_list
($delete)) {
457 $opt = 'ide2' if $opt eq 'cdrom';
458 if (!PVE
::QemuServer
::option_exists
($opt)) {
459 raise_param_exc
({ delete => "unknown option '$opt'" });
461 next if !defined($conf->{$opt});
462 if (PVE
::QemuServer
::valid_drivename
($opt)) {
463 my $drive = PVE
::QemuServer
::parse_drive
($opt, $conf->{$opt});
464 if (PVE
::QemuServer
::drive_is_cdrom
($drive)) {
465 $cdchange->{$opt} = undef;
467 my $volid = $drive->{file
};
469 if ($volid !~ m
|^/|) {
471 eval { ($path, $owner) = PVE
::Storage
::path
($storecfg, $volid); };
472 if ($owner && ($owner == $vmid)) {
474 push @$vollist, $volid;
476 PVE
::QemuServer
::add_unused_volume
($conf, $param, $volid);
481 } elsif ($opt =~ m/^unused/) {
482 push @$vollist, $conf->{$opt};
488 PVE
::QemuServer
::create_disks
($storecfg, $vmid, $param);
490 PVE
::QemuServer
::change_config_nolock
($vmid, $param, $unset, 1);
492 return if !PVE
::QemuServer
::check_running
($vmid);
494 foreach my $opt (keys %$cdchange) {
495 my $qdn = PVE
::QemuServer
::qemu_drive_name
($opt, 'cdrom');
496 my $path = $cdchange->{$opt};
497 PVE
::QemuServer
::vm_monitor_command
($vmid, "eject $qdn", 0);
498 PVE
::QemuServer
::vm_monitor_command
($vmid, "change $qdn \"$path\"", 0) if $path;
502 PVE::QemuServer::lock_config($vmid, $updatefn);
504 foreach my $volid (@$vollist) {
505 eval { PVE::Storage::vdisk_free($storecfg, $volid); };
514 __PACKAGE__->register_method({
515 name => 'destroy_vm',
520 description => "Destroy the vm
(also
delete all used
/owned volumes
).",
522 additionalProperties => 0,
524 node => get_standard_option('pve-node'),
525 vmid => get_standard_option('pve-vmid'),
526 skiplock => get_standard_option('skiplock'),
535 my $rpcenv = PVE::RPCEnvironment::get();
537 my $user = $rpcenv->get_user();
539 my $vmid = $param->{vmid};
541 my $skiplock = $param->{skiplock};
542 raise_param_exc({ skiplock => "Only root may
use this option
." })
543 if $skiplock && $user ne 'root@pam';
546 my $conf = PVE::QemuServer::load_config($vmid);
548 my $storecfg = PVE::Storage::config();
551 PVE::QemuServer::vm_destroy($storecfg, $vmid, $skiplock);
554 return $rpcenv->fork_worker('qmdestroy', $vmid, $user, $realcmd);
557 __PACKAGE__->register_method({
559 path => '{vmid}/unlink',
563 description => "Unlink
/delete disk images
.",
565 additionalProperties => 0,
567 node => get_standard_option('pve-node'),
568 vmid => get_standard_option('pve-vmid'),
570 type => 'string', format => 'pve-configid-list',
571 description => "A list of disk IDs you want to
delete.",
575 description => $opt_force_description,
580 returns => { type => 'null'},
584 $param->{delete} = extract_param($param, 'idlist');
586 __PACKAGE__->update_vm($param);
593 __PACKAGE__->register_method({
595 path => '{vmid}/vncproxy',
599 path => '/vms/{vmid}',
600 privs => [ 'VM.Console' ],
602 description => "Creates a TCP VNC proxy connections
.",
604 additionalProperties => 0,
606 node => get_standard_option('pve-node'),
607 vmid => get_standard_option('pve-vmid'),
611 additionalProperties => 0,
613 user => { type => 'string' },
614 ticket => { type => 'string' },
615 cert => { type => 'string' },
616 port => { type => 'integer' },
617 upid => { type => 'string' },
623 my $rpcenv = PVE::RPCEnvironment::get();
625 my $user = $rpcenv->get_user();
626 my $ticket = PVE::AccessControl::assemble_ticket($user);
628 my $vmid = $param->{vmid};
629 my $node = $param->{node};
631 $sslcert = PVE::Tools::file_get_contents("/etc/pve
/pve-root-ca
.pem
", 8192)
634 my $port = PVE::Tools::next_vnc_port();
638 if ($node ne PVE::INotify::nodename()) {
639 $remip = PVE::Cluster::remote_node_ip($node);
642 # NOTE: kvm VNC traffic is already TLS encrypted,
643 # so we select the fastest chipher here (or 'none'?)
644 my $remcmd = $remip ? ['/usr/bin/ssh', '-T', '-o', 'BatchMode=yes',
645 '-c', 'blowfish-cbc', $remip] : [];
652 syslog('info', "starting vnc proxy
$upid\n");
654 my $qmcmd = [@$remcmd, "/usr/sbin
/qm
", 'vncproxy', $vmid];
656 my $qmstr = join(' ', @$qmcmd);
658 # also redirect stderr (else we get RFB protocol errors)
659 my $cmd = ['/bin/nc', '-l', '-p', $port, '-w', $timeout, '-c', "$qmstr 2>/dev/null
"];
661 PVE::Tools::run_command($cmd);
666 my $upid = $rpcenv->fork_worker('vncproxy', $vmid, $user, $realcmd);
677 __PACKAGE__->register_method({
679 path => '{vmid}/status',
682 description => "Directory
index",
684 additionalProperties => 0,
686 node => get_standard_option('pve-node'),
687 vmid => get_standard_option('pve-vmid'),
695 subdir => { type => 'string' },
698 links => [ { rel => 'child', href => "{subdir
}" } ],
704 my $conf = PVE::QemuServer::load_config($param->{vmid});
707 { subdir => 'current' },
708 { subdir => 'start' },
709 { subdir => 'stop' },
715 __PACKAGE__->register_method({
717 path => '{vmid}/status/current',
720 protected => 1, # qemu pid files are only readable by root
721 description => "Get virtual machine status
.",
723 additionalProperties => 0,
725 node => get_standard_option('pve-node'),
726 vmid => get_standard_option('pve-vmid'),
729 returns => { type => 'object' },
734 my $conf = PVE::QemuServer::load_config($param->{vmid});
736 my $vmstatus = PVE::QemuServer::vmstatus($param->{vmid});
738 return $vmstatus->{$param->{vmid}};
741 __PACKAGE__->register_method({
743 path => '{vmid}/status/start',
747 description => "Start virtual machine
.",
749 additionalProperties => 0,
751 node => get_standard_option('pve-node'),
752 vmid => get_standard_option('pve-vmid'),
753 skiplock => get_standard_option('skiplock'),
754 stateuri => get_standard_option('pve-qm-stateuri'),
763 my $rpcenv = PVE::RPCEnvironment::get();
765 my $user = $rpcenv->get_user();
767 my $node = extract_param($param, 'node');
769 my $vmid = extract_param($param, 'vmid');
771 my $stateuri = extract_param($param, 'stateuri');
772 raise_param_exc({ stateuri => "Only root may
use this option
." })
773 if $stateuri && $user ne 'root@pam';
775 my $skiplock = extract_param($param, 'skiplock');
776 raise_param_exc({ skiplock => "Only root may
use this option
." })
777 if $skiplock && $user ne 'root@pam';
779 my $storecfg = PVE::Storage::config();
784 syslog('info', "start VM
$vmid: $upid\n");
786 PVE::QemuServer::vm_start($storecfg, $vmid, $stateuri, $skiplock);
791 return $rpcenv->fork_worker('qmstart', $vmid, $user, $realcmd);
794 __PACKAGE__->register_method({
796 path => '{vmid}/status/stop',
800 description => "Stop virtual machine
.",
802 additionalProperties => 0,
804 node => get_standard_option('pve-node'),
805 vmid => get_standard_option('pve-vmid'),
806 skiplock => get_standard_option('skiplock'),
815 my $rpcenv = PVE::RPCEnvironment::get();
817 my $user = $rpcenv->get_user();
819 my $node = extract_param($param, 'node');
821 my $vmid = extract_param($param, 'vmid');
823 my $skiplock = extract_param($param, 'skiplock');
824 raise_param_exc({ skiplock => "Only root may
use this option
." })
825 if $skiplock && $user ne 'root@pam';
830 syslog('info', "stop VM
$vmid: $upid\n");
832 PVE::QemuServer::vm_stop($vmid, $skiplock);
837 return $rpcenv->fork_worker('qmstop', $vmid, $user, $realcmd);
840 __PACKAGE__->register_method({
842 path => '{vmid}/status/reset',
846 description => "Reset virtual machine
.",
848 additionalProperties => 0,
850 node => get_standard_option('pve-node'),
851 vmid => get_standard_option('pve-vmid'),
852 skiplock => get_standard_option('skiplock'),
861 my $rpcenv = PVE::RPCEnvironment::get();
863 my $user = $rpcenv->get_user();
865 my $node = extract_param($param, 'node');
867 my $vmid = extract_param($param, 'vmid');
869 my $skiplock = extract_param($param, 'skiplock');
870 raise_param_exc({ skiplock => "Only root may
use this option
." })
871 if $skiplock && $user ne 'root@pam';
876 syslog('info', "reset VM
$vmid: $upid\n");
878 PVE::QemuServer::vm_reset($vmid, $skiplock);
883 return $rpcenv->fork_worker('qmreset', $vmid, $user, $realcmd);
886 __PACKAGE__->register_method({
887 name => 'vm_shutdown',
888 path => '{vmid}/status/shutdown',
892 description => "Shutdown virtual machine
.",
894 additionalProperties => 0,
896 node => get_standard_option('pve-node'),
897 vmid => get_standard_option('pve-vmid'),
898 skiplock => get_standard_option('skiplock'),
907 my $rpcenv = PVE::RPCEnvironment::get();
909 my $user = $rpcenv->get_user();
911 my $node = extract_param($param, 'node');
913 my $vmid = extract_param($param, 'vmid');
915 my $skiplock = extract_param($param, 'skiplock');
916 raise_param_exc({ skiplock => "Only root may
use this option
." })
917 if $skiplock && $user ne 'root@pam';
922 syslog('info', "shutdown VM
$vmid: $upid\n");
924 PVE::QemuServer::vm_shutdown($vmid, $skiplock);
929 return $rpcenv->fork_worker('qmshutdown', $vmid, $user, $realcmd);
932 __PACKAGE__->register_method({
933 name => 'vm_suspend',
934 path => '{vmid}/status/suspend',
938 description => "Suspend virtual machine
.",
940 additionalProperties => 0,
942 node => get_standard_option('pve-node'),
943 vmid => get_standard_option('pve-vmid'),
944 skiplock => get_standard_option('skiplock'),
953 my $rpcenv = PVE::RPCEnvironment::get();
955 my $user = $rpcenv->get_user();
957 my $node = extract_param($param, 'node');
959 my $vmid = extract_param($param, 'vmid');
961 my $skiplock = extract_param($param, 'skiplock');
962 raise_param_exc({ skiplock => "Only root may
use this option
." })
963 if $skiplock && $user ne 'root@pam';
968 syslog('info', "suspend VM
$vmid: $upid\n");
970 PVE::QemuServer::vm_suspend($vmid, $skiplock);
975 return $rpcenv->fork_worker('qmsuspend', $vmid, $user, $realcmd);
978 __PACKAGE__->register_method({
980 path => '{vmid}/status/resume',
984 description => "Resume virtual machine
.",
986 additionalProperties => 0,
988 node => get_standard_option('pve-node'),
989 vmid => get_standard_option('pve-vmid'),
990 skiplock => get_standard_option('skiplock'),
999 my $rpcenv = PVE::RPCEnvironment::get();
1001 my $user = $rpcenv->get_user();
1003 my $node = extract_param($param, 'node');
1005 my $vmid = extract_param($param, 'vmid');
1007 my $skiplock = extract_param($param, 'skiplock');
1008 raise_param_exc({ skiplock => "Only root may
use this option
." })
1009 if $skiplock && $user ne 'root@pam';
1014 syslog('info', "resume VM
$vmid: $upid\n");
1016 PVE::QemuServer::vm_resume($vmid, $skiplock);
1021 return $rpcenv->fork_worker('qmresume', $vmid, $user, $realcmd);
1024 __PACKAGE__->register_method({
1025 name => 'vm_sendkey',
1026 path => '{vmid}/sendkey',
1030 description => "Send key event to virtual machine
.",
1032 additionalProperties => 0,
1034 node => get_standard_option('pve-node'),
1035 vmid => get_standard_option('pve-vmid'),
1036 skiplock => get_standard_option('skiplock'),
1038 description => "The key
(qemu monitor encoding
).",
1043 returns => { type => 'null'},
1047 my $rpcenv = PVE::RPCEnvironment::get();
1049 my $user = $rpcenv->get_user();
1051 my $node = extract_param($param, 'node');
1053 my $vmid = extract_param($param, 'vmid');
1055 my $skiplock = extract_param($param, 'skiplock');
1056 raise_param_exc({ skiplock => "Only root may
use this option
." })
1057 if $skiplock && $user ne 'root@pam';
1059 PVE::QemuServer::vm_sendkey($vmid, $skiplock, $param->{key});
1064 __PACKAGE__->register_method({
1065 name => 'migrate_vm',
1066 path => '{vmid}/migrate',
1070 description => "Migrate virtual machine
. Creates a new migration task
.",
1072 additionalProperties => 0,
1074 node => get_standard_option('pve-node'),
1075 vmid => get_standard_option('pve-vmid'),
1076 target => get_standard_option('pve-node', { description => "Target node
." }),
1079 description => "Use online
/live migration
.",
1084 description => "Allow to migrate VMs which
use local devices
. Only root may
use this option
.",
1091 description => "the task ID
.",
1096 my $rpcenv = PVE::RPCEnvironment::get();
1098 my $user = $rpcenv->get_user();
1100 my $target = extract_param($param, 'target');
1102 my $localnode = PVE::INotify::nodename();
1103 raise_param_exc({ target => "target
is local node
."}) if $target eq $localnode;
1105 PVE::Cluster::check_cfs_quorum();
1107 PVE::Cluster::check_node_exists($target);
1109 my $targetip = PVE::Cluster::remote_node_ip($target);
1111 my $vmid = extract_param($param, 'vmid');
1113 raise_param_exc({ force => "Only root may
use this option
." }) if $user ne 'root@pam';
1116 PVE::QemuServer::load_config($vmid);
1118 # try to detect errors early
1119 if (PVE::QemuServer::check_running($vmid)) {
1120 die "cant migrate running VM without
--online
\n"
1121 if !$param->{online};
1127 PVE::QemuMigrate::migrate($target, $targetip, $vmid, $param->{online}, $param->{force});
1130 my $upid = $rpcenv->fork_worker('qmigrate', $vmid, $user, $realcmd);