[pve-devel] [PATCH v2 container 1/5] add vm_reboot sub to later use in api

Oguz Bektas o.bektas at proxmox.com
Tue Nov 19 15:53:43 CET 2019


Signed-off-by: Oguz Bektas <o.bektas at proxmox.com>
---
 src/PVE/LXC.pm | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index 61f9bae..c400f21 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -2009,6 +2009,19 @@ sub vm_stop {
     die "container did not stop\n";
 }
 
+sub vm_reboot {
+    my ($vmid, $timeout, $skiplock) = @_;
+
+    PVE::LXC::Config->lock_config($vmid, sub {
+	return if !check_running($vmid);
+
+	vm_stop($vmid, 0, $timeout, 1); # kill if timeout exceeds
+
+	my $conf = PVE::LXC::Config->load_config($vmid);
+	vm_start($vmid, $conf);
+    });
+}
+
 sub run_unshared {
     my ($code) = @_;
 
-- 
2.20.1




More information about the pve-devel mailing list