[lxc-devel] [lxd/master] add new "restarted" event to reboot section of onStop in both lxc and qemu

dlemel8 on Github lxc-bot at linuxcontainers.org
Tue Oct 20 19:43:41 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 301 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20201020/075b5bf4/attachment.bin>
-------------- next part --------------
From 95d2afa5f5ba37e635a8236f5f8775c438fd6da8 Mon Sep 17 00:00:00 2001
From: Daniel Segal <dlemel8 at gmail.com>
Date: Tue, 20 Oct 2020 22:42:06 +0300
Subject: [PATCH] add new "restarted" event to reboot section of onStop in both
 lxc and qemu

Signed-off-by: Daniel Segal <dlemel8 at gmail.com>
---
 lxd/instance/drivers/driver_lxc.go  | 2 ++
 lxd/instance/drivers/driver_qemu.go | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/lxd/instance/drivers/driver_lxc.go b/lxd/instance/drivers/driver_lxc.go
index ac307d6d1e..ccb8945587 100644
--- a/lxd/instance/drivers/driver_lxc.go
+++ b/lxd/instance/drivers/driver_lxc.go
@@ -2914,6 +2914,8 @@ func (c *lxc) onStop(args map[string]string) error {
 		if target == "reboot" {
 			// Start the container again
 			err = c.Start(false)
+			c.state.Events.SendLifecycle(c.project, "container-restarted",
+				fmt.Sprintf("/1.0/containers/%s", c.name), nil)
 			return
 		}
 
diff --git a/lxd/instance/drivers/driver_qemu.go b/lxd/instance/drivers/driver_qemu.go
index 5aebe9509c..d1436b9263 100644
--- a/lxd/instance/drivers/driver_qemu.go
+++ b/lxd/instance/drivers/driver_qemu.go
@@ -545,6 +545,8 @@ func (vm *qemu) onStop(target string) error {
 
 	if target == "reboot" {
 		err = vm.Start(false)
+		vm.state.Events.SendLifecycle(vm.project, "virtual-machine-restarted",
+			fmt.Sprintf("/1.0/virtual-machines/%s", vm.name), nil)
 	} else if vm.ephemeral {
 		// Destroy ephemeral virtual machines
 		err = vm.Delete()


More information about the lxc-devel mailing list