my $nodename = PVE::INotify::nodename();
-PVE::JSONSchema::register_standard_option('skiplock', {
- description => "Ignore locks - only root is allowed to use this option.",
- type => 'boolean',
- optional => 1,
-});
-
sub run_vnc_proxy {
my ($vmid) = @_;
name => 'mtunnel',
path => 'mtunnel',
method => 'POST',
- description => "Used by vzmigrate - do not use manually.",
+ description => "Used by qmigrate - do not use manually.",
parameters => {
additionalProperties => 0,
properties => {},
code => sub {
my ($param) = @_;
+ if (!PVE::Cluster::check_cfs_quorum(1)) {
+ print "no quorum\n";
+ return undef;
+ }
+
print "tunnel online\n";
*STDOUT->flush();
my $vzlist = PVE::QemuServer::vzlist();
my $storecfg = PVE::Storage::config();
+ PVE::Cluster::check_cfs_quorum();
+
my $count = 0;
foreach my $vmid (keys %$vzlist) {
next if $vzlist->{$vmid}->{pid}; # already running
sleep(2) if $count != 0; # reduce load
$count++;
+ PVE::Cluster::check_cfs_quorum(); # abort when we loose quorum
+
eval {
my $conf = PVE::QemuServer::load_config($vmid);
if ($conf->{onboot}) {
my $timeout = $param->{timeout};
- PVE::QemuServer::vm_stopall($timeout);
+ my $storecfg = PVE::Storage::config();
+
+ PVE::QemuServer::vm_stopall($storecfg, $timeout);
return undef;
}});
destroy => [ "PVE::API2::Qemu", 'destroy_vm', ['vmid'], { node => $nodename } ],
+ migrate => [ "PVE::API2::Qemu", 'migrate_vm', ['target', 'vmid'], { node => $nodename },
+ sub {
+ my $upid = shift;
+ my $status = PVE::Tools::upid_read_status($upid);
+ exit($status eq 'OK' ? 0 : -1);
+ }],
+
set => [ "PVE::API2::Qemu", 'update_vm', ['vmid'], { node => $nodename } ],
unlink => [ "PVE::API2::Qemu", 'unlink', ['vmid', 'idlist'], { node => $nodename } ],
status => [ __PACKAGE__, 'status', ['vmid']],
+ start => [ "PVE::API2::Qemu", 'vm_start', ['vmid'], { node => $nodename } ],
+
+ stop => [ "PVE::API2::Qemu", 'vm_stop', ['vmid'], { node => $nodename } ],
+
+ reset => [ "PVE::API2::Qemu", 'vm_reset', ['vmid'], { node => $nodename } ],
+
+ shutdown => [ "PVE::API2::Qemu", 'vm_shutdown', ['vmid'], { node => $nodename } ],
+
+ suspend => [ "PVE::API2::Qemu", 'vm_suspend', ['vmid'], { node => $nodename } ],
+
+ resume => [ "PVE::API2::Qemu", 'vm_resume', ['vmid'], { node => $nodename } ],
+
+ sendkey => [ "PVE::API2::Qemu", 'vm_sendkey', ['vmid', 'key'], { node => $nodename } ],
+
vncproxy => [ __PACKAGE__, 'vncproxy', ['vmid']],
wait => [ __PACKAGE__, 'wait', ['vmid']],
mtunnel => [ __PACKAGE__, 'mtunnel', []],
};
-sub register_vm_command {
- my ($cmd, $descr) = @_;
-
- # we create a wrapper, because we want one 'description' per command
- __PACKAGE__->register_method ({
- name => $cmd,
- path => $cmd,
- method => 'PUT',
- description => $descr,
- parameters => {
- additionalProperties => 0,
- properties => {
- vmid => get_standard_option('pve-vmid'),
- skiplock => get_standard_option('skiplock'),
- },
- },
- returns => { type => 'null'},
- code => sub {
- my ($param) = @_;
-
- $param->{command} = $cmd;
- $param->{node} = $nodename;
-
- return PVE::API2::Qemu->vm_command($param);
- }});
-
- $cmddef->{$cmd} = [ __PACKAGE__, $cmd, ['vmid']];
-}
-
-register_vm_command('start', "Start virtual machine.");
-register_vm_command('stop', "Stop virtual machine.");
-register_vm_command('reset', "Reset virtual machine.");
-register_vm_command('shutdown', "Shutdown virtual machine (send ACPI showdown request)");
-register_vm_command('suspend', "Suspend virtual machine.");
-register_vm_command('resume', "Resume virtual machine.");
-register_vm_command('cad', "Send CTRL-ALT-DELETE keys.");
-
my $cmd = shift;
PVE::CLIHandler::handle_cmd($cmddef, "qm", $cmd, \@ARGV, undef, $0);