qmreboot: clear reboot request if reboot fails

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@proxmox.com>
This commit is contained in:
Oguz Bektas 2019-11-11 17:29:23 +01:00 committed by Thomas Lamprecht
parent ba728fb535
commit 66026117b0

View File

@ -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;
}
});
}