]> git.proxmox.com Git - qemu-server.git/blobdiff - qm
activate LVM LVs more carefully
[qemu-server.git] / qm
diff --git a/qm b/qm
index 7f572887e5f7aefbf8fb987edea397f5b0c221da..5444e73783c644bb15d7ab282243f9460f1ef0a4 100755 (executable)
--- a/qm
+++ b/qm
@@ -37,12 +37,6 @@ $rpcenv->set_user('root@pam');
 
 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) = @_;
 
@@ -195,7 +189,7 @@ __PACKAGE__->register_method ({
     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 => {},
@@ -204,6 +198,11 @@ __PACKAGE__->register_method ({
     code => sub {
        my ($param) = @_;
 
+       if (!PVE::Cluster::check_cfs_quorum(1)) {
+           print "no quorum\n";
+           return undef;
+       }
        print "tunnel online\n";
        *STDOUT->flush();
 
@@ -231,6 +230,8 @@ __PACKAGE__->register_method ({
        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
@@ -238,6 +239,8 @@ __PACKAGE__->register_method ({
            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}) {
@@ -273,7 +276,9 @@ __PACKAGE__->register_method ({
 
        my $timeout = $param->{timeout};
 
-       PVE::QemuServer::vm_stopall($timeout);
+       my $storecfg = PVE::Storage::config();
+
+       PVE::QemuServer::vm_stopall($storecfg, $timeout);
 
        return undef;
     }});
@@ -384,6 +389,13 @@ my $cmddef = {
 
     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 } ],
@@ -405,6 +417,20 @@ my $cmddef = {
 
     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']],
@@ -420,43 +446,6 @@ my $cmddef = {
     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);