The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/6562
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) ===
From 5f83b94ce53c43a98be9d4862e50a837b5d4d010 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com> Date: Thu, 5 Dec 2019 14:03:02 -0500 Subject: [PATCH 1/2] lxd/vm: Update comment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber <stgra...@ubuntu.com> --- lxd/vm_qemu.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lxd/vm_qemu.go b/lxd/vm_qemu.go index 973483ac2c..923c8d3709 100644 --- a/lxd/vm_qemu.go +++ b/lxd/vm_qemu.go @@ -54,7 +54,7 @@ var vmConsole = map[int]bool{} var vmConsoleLock sync.Mutex func vmQemuLoad(s *state.State, args db.InstanceArgs, profiles []api.Profile) (instance.Instance, error) { - // Create the container struct. + // Create the instance struct. vm := vmQemuInstantiate(s, args) // Expand config and devices. @@ -2867,7 +2867,7 @@ func (vm *vmQemu) ExpiryDate() time.Time { return vm.expiryDate } - // Return zero time if the container is not a snapshot. + // Return zero time if the instance is not a snapshot. return time.Time{} } @@ -2938,10 +2938,10 @@ func (vm *vmQemu) DeferTemplateApply(trigger string) error { } func (vm *vmQemu) DaemonState() *state.State { - // FIXME: This function should go away, since the abstract container + // FIXME: This function should go away, since the abstract instance // interface should not be coupled with internal state details. // However this is not currently possible, because many - // higher-level APIs use container variables as "implicit + // higher-level APIs use instance variables as "implicit // handles" to database/OS state and then need a way to get a // reference to it. return vm.state From 4ce9ab9f530b37d5250dbeaafe8410985e4b33cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com> Date: Thu, 5 Dec 2019 14:03:17 -0500 Subject: [PATCH 2/2] lxd/vm: Record power state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #6469 Signed-off-by: Stéphane Graber <stgra...@ubuntu.com> --- lxd/vm_qemu.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/lxd/vm_qemu.go b/lxd/vm_qemu.go index 923c8d3709..daf2aecf33 100644 --- a/lxd/vm_qemu.go +++ b/lxd/vm_qemu.go @@ -451,6 +451,12 @@ func (vm *vmQemu) OnStop(target string) error { os.Remove(vm.getMonitorPath()) vm.unmount() + // Record power state + err := vm.state.Cluster.ContainerSetState(vm.id, "STOPPED") + if err != nil { + return err + } + if target == "reboot" { return vm.Start(false) } @@ -638,6 +644,26 @@ func (vm *vmQemu) Start(stateful bool) error { return err } + // Database updates + err = vm.state.Cluster.Transaction(func(tx *db.ClusterTx) error { + // Record current state + err = tx.ContainerSetState(vm.id, "RUNNING") + if err != nil { + return errors.Wrap(err, "Error updating instance state") + } + + // Update time instance last started time + err = tx.ContainerLastUsedUpdate(vm.id, time.Now().UTC()) + if err != nil { + return errors.Wrap(err, "Error updating instance last used") + } + + return nil + }) + if err != nil { + return err + } + return nil }
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel