[lxc-devel] [lxd/master] add more checks for the criu binary
tych0 on Github
lxc-bot at linuxcontainers.org
Mon May 9 14:15:06 UTC 2016
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 423 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160509/9981b074/attachment.bin>
-------------- next part --------------
From d73d0bb26c76fe31fb33332da5593cbd76704cf2 Mon Sep 17 00:00:00 2001
From: Tycho Andersen <tycho.andersen at canonical.com>
Date: Mon, 9 May 2016 08:09:45 -0600
Subject: [PATCH] add more checks for the criu binary
In particular, stateful stop/snapshot didn't have a check.
Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
---
lxd/container.go | 4 ++++
lxd/container_lxc.go | 17 +++++++++++++++++
2 files changed, 21 insertions(+)
diff --git a/lxd/container.go b/lxd/container.go
index 51524ab..9c196ca 100644
--- a/lxd/container.go
+++ b/lxd/container.go
@@ -507,6 +507,10 @@ func containerCreateAsSnapshot(d *Daemon, args containerArgs, sourceContainer co
return nil, fmt.Errorf("Container not running, cannot do stateful snapshot")
}
+ if err := findCriu("snapshot"); err != nil {
+ return nil, err
+ }
+
stateDir := sourceContainer.StatePath()
err := os.MkdirAll(stateDir, 0700)
if err != nil {
diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index 8672394..6aa3510 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -1134,6 +1134,10 @@ func (c *containerLXC) Start(stateful bool) error {
return fmt.Errorf("Container has no existing state to restore.")
}
+ if err := findCriu("snapshot"); err != nil {
+ return err
+ }
+
if !c.IsPrivileged() {
if err := c.IdmapSet().ShiftRootfs(c.StatePath()); err != nil {
return err
@@ -1344,6 +1348,10 @@ func (c *containerLXC) setupStopping() *sync.WaitGroup {
func (c *containerLXC) Stop(stateful bool) error {
// Handle stateful stop
if stateful {
+ if err := findCriu("snapshot"); err != nil {
+ return err
+ }
+
// Cleanup any existing state
stateDir := c.StatePath()
os.RemoveAll(stateDir)
@@ -1676,6 +1684,15 @@ func (c *containerLXC) Restore(sourceContainer container) error {
return err
}
+ /* let's also check for CRIU if necessary, before doing a bunch of
+ * filesystem manipulations
+ */
+ if shared.PathExists(c.StatePath()) {
+ if err := findCriu("snapshot"); err != nil {
+ return err
+ }
+ }
+
// Stop the container
wasRunning := false
if c.IsRunning() {
More information about the lxc-devel
mailing list