[pve-devel] [PATCH v2 qemu-server] Use crm-command stop to allow shutdown with timeout and hard stop for HA

Fabian Ebner f.ebner at proxmox.com
Thu Nov 14 12:23:56 CET 2019


Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---

Changes from v1:
    * don't change the API

 PVE/API2/Qemu.pm | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index c31dd1d..8e162aa 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -2111,7 +2111,7 @@ __PACKAGE__->register_method({
 
 		print "Requesting HA stop for VM $vmid\n";
 
-		my $cmd = ['ha-manager', 'set',  "vm:$vmid", '--state', 'stopped'];
+		my $cmd = ['ha-manager', 'crm-command', 'stop',  "vm:$vmid", '0'];
 		PVE::Tools::run_command($cmd);
 		return;
 	    };
@@ -2267,12 +2267,13 @@ __PACKAGE__->register_method({
 
 	if (PVE::HA::Config::vm_is_ha_managed($vmid) && $rpcenv->{type} ne 'ha') {
 
+	    my $timeout = $param->{timeout} // 60;
 	    my $hacmd = sub {
 		my $upid = shift;
 
 		print "Requesting HA stop for VM $vmid\n";
 
-		my $cmd = ['ha-manager', 'set', "vm:$vmid", '--state', 'stopped'];
+		my $cmd = ['ha-manager', 'crm-command', 'stop', "vm:$vmid", "$timeout"];
 		PVE::Tools::run_command($cmd);
 		return;
 	    };
-- 
2.20.1





More information about the pve-devel mailing list