summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--runsc/cmd/checkpoint.go17
-rw-r--r--runsc/cmd/restore.go17
2 files changed, 30 insertions, 4 deletions
diff --git a/runsc/cmd/checkpoint.go b/runsc/cmd/checkpoint.go
index 927027c2b..e5fc7bdc4 100644
--- a/runsc/cmd/checkpoint.go
+++ b/runsc/cmd/checkpoint.go
@@ -16,6 +16,7 @@ package cmd
import (
"os"
+ "path/filepath"
"context"
"flag"
@@ -24,6 +25,9 @@ import (
"gvisor.googlesource.com/gvisor/runsc/container"
)
+// File containing the container's saved image/state within the given image-path's directory.
+const checkpointFileName = "checkpoint.img"
+
// Checkpoint implements subcommands.Command for the "checkpoint" command.
type Checkpoint struct {
imagePath string
@@ -48,6 +52,13 @@ func (*Checkpoint) Usage() string {
// SetFlags implements subcommands.Command.SetFlags.
func (c *Checkpoint) SetFlags(f *flag.FlagSet) {
f.StringVar(&c.imagePath, "image-path", "", "path to saved container image")
+
+ // Unimplemented flags necessary for compatibility with docker.
+ var wp string
+ f.StringVar(&wp, "work-path", "", "ignored")
+
+ var lr bool
+ f.BoolVar(&lr, "leave-running", false, "ignored")
}
// Execute implements subcommands.Command.Execute.
@@ -70,10 +81,12 @@ func (c *Checkpoint) Execute(_ context.Context, f *flag.FlagSet, args ...interfa
Fatalf("image-path flag must be provided")
}
+ fullImagePath := filepath.Join(c.imagePath, checkpointFileName)
+
// Create the image file and open for writing.
- file, err := os.OpenFile(c.imagePath, os.O_CREATE|os.O_EXCL|os.O_RDWR, 0644)
+ file, err := os.OpenFile(fullImagePath, os.O_CREATE|os.O_EXCL|os.O_RDWR, 0644)
if err != nil {
- Fatalf("os.OpenFile(%q) failed: %v", c.imagePath, err)
+ Fatalf("os.OpenFile(%q) failed: %v", fullImagePath, err)
}
defer file.Close()
diff --git a/runsc/cmd/restore.go b/runsc/cmd/restore.go
index 0589a36bf..cc55beeaf 100644
--- a/runsc/cmd/restore.go
+++ b/runsc/cmd/restore.go
@@ -15,6 +15,7 @@
package cmd
import (
+ "path/filepath"
"syscall"
"context"
@@ -53,7 +54,17 @@ func (*Restore) Usage() string {
// SetFlags implements subcommands.Command.SetFlags.
func (r *Restore) SetFlags(f *flag.FlagSet) {
r.Create.SetFlags(f)
- f.StringVar(&r.imagePath, "image-path", "", "path to saved container image")
+ f.StringVar(&r.imagePath, "image-path", "", "directory path to saved container image")
+
+ // Unimplemented flags necessary for compatibility with docker.
+ var d bool
+ f.BoolVar(&d, "detach", false, "ignored")
+
+ var nsr bool
+ f.BoolVar(&nsr, "no-subreaper", false, "ignored")
+
+ var wp string
+ f.StringVar(&wp, "work-path", "", "ignored")
}
// Execute implements subcommands.Command.Execute.
@@ -81,7 +92,9 @@ func (r *Restore) Execute(_ context.Context, f *flag.FlagSet, args ...interface{
Fatalf("image-path flag must be provided")
}
- cont, err := container.Create(id, spec, conf, bundleDir, r.consoleSocket, r.pidFile, r.imagePath)
+ restoreFile := filepath.Join(r.imagePath, checkpointFileName)
+
+ cont, err := container.Create(id, spec, conf, bundleDir, r.consoleSocket, r.pidFile, restoreFile)
if err != nil {
Fatalf("error restoring container: %v", err)
}