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

Dominik Csapak d.csapak at proxmox.com
Wed Sep 11 14:07:42 CEST 2019


Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
changes from v3:
* use ENOENT to check for existance
 PVE/QemuServer.pm | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 7128723..367d080 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -7400,6 +7400,25 @@ 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;
+
+    $res = unlink($path);
+    die "could not remove reboot request for $vmid: $!"
+	if !$res && $! != POSIX::ENOENT;
+
+    return $res;
+}
+
 # bash completion helper
 
 sub complete_backup_archives {
-- 
2.20.1





More information about the pve-devel mailing list