[pve-devel] [PATCH qemu-server v3 2/4] add create and remove reboot trigger subs

Dominik Csapak d.csapak at proxmox.com
Fri Sep 6 14:24:06 CEST 2019


Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
changes from  v2:
* renamed to clear/create_reboot_request
 PVE/QemuServer.pm | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index a424720..535297d 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -7401,6 +7401,26 @@ sub nbd_stop {
     vm_mon_cmd($vmid, 'nbd-server-stop');
 }
 
+sub create_reboot_request {
+    my ($vmid) = @_;
+    open(my $fh, '>', "/run/qemu-server/$vmid.reboot")
+	or die "failed to create reboot trigger file: $!\n";
+    close($fh);
+}
+
+sub clear_reboot_request {
+    my ($vmid) = @_;
+    my $path = "/run/qemu-server/$vmid.reboot";
+    my $res = 0;
+
+    if (-e $path) {
+	$res = unlink($path);
+	die "could not remove reboot request for $vmid: $!" if !$res;
+    }
+
+    return $res;
+}
+
 # bash completion helper
 
 sub complete_backup_archives {
-- 
2.20.1





More information about the pve-devel mailing list