[pve-devel] [PATCH qemu-server] qmreboot: clear reboot request if reboot fails

Oguz Bektas o.bektas at proxmox.com
Mon Nov 11 17:29:23 CET 2019


the reboot request is only cleaned in the vm_start path, so if reboot
fails for some reason, the request still exists. this causes an
unintentional reboot when a shutdown/stop/hibernate is called.

to mitigate, we can just clear the reboot request in case of an error.

Signed-off-by: Oguz Bektas <o.bektas at proxmox.com>
---
 PVE/QemuServer.pm | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index a50b4e1..6361785 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -5794,15 +5794,22 @@ sub vm_reboot {
     my ($vmid, $timeout) = @_;
 
     PVE::QemuConfig->lock_config($vmid, sub {
+	eval {
 
-	# only reboot if running, as qmeventd starts it again on a stop event
-	return if !check_running($vmid);
+	    # only reboot if running, as qmeventd starts it again on a stop event
+	    return if !check_running($vmid);
 
-	create_reboot_request($vmid);
+	    create_reboot_request($vmid);
 
-	my $storecfg = PVE::Storage::config();
-	_do_vm_stop($storecfg, $vmid, undef, undef, $timeout, 1);
+	    my $storecfg = PVE::Storage::config();
+	    _do_vm_stop($storecfg, $vmid, undef, undef, $timeout, 1);
 
+	};
+	if (my $err = $@) {
+	    # clear reboot request if reboot fails for some reason
+	    clear_reboot_request($vmid);
+	    die $err;
+	}
    });
 }
 
-- 
2.20.1




More information about the pve-devel mailing list