summaryrefslogtreecommitdiffhomepage
path: root/runsc/cmd
diff options
context:
space:
mode:
authorBrielle Broder <bbroder@google.com>2018-06-12 13:24:22 -0700
committerShentubot <shentubot@google.com>2018-06-12 13:25:23 -0700
commit711a9869e54743b05fc3478be5adce31d45cefe5 (patch)
tree7e0b61d5b8a075f96dc868a7c548252b231101ed /runsc/cmd
parent7a10df454b1c12b207f479cdda7338fff2875d5f (diff)
Runsc checkpoint works.
This is the first iteration of checkpoint that actually saves to a file. Tests for checkpoint are included. Ran into an issue when private unix sockets are enabled. An error message was added for this case and the mutex state was set. PiperOrigin-RevId: 200269470 Change-Id: I28d29a9f92c44bf73dc4a4b12ae0509ee4070e93
Diffstat (limited to 'runsc/cmd')
-rw-r--r--runsc/cmd/checkpoint.go17
1 files changed, 16 insertions, 1 deletions
diff --git a/runsc/cmd/checkpoint.go b/runsc/cmd/checkpoint.go
index 9b045da1c..927027c2b 100644
--- a/runsc/cmd/checkpoint.go
+++ b/runsc/cmd/checkpoint.go
@@ -15,6 +15,8 @@
package cmd
import (
+ "os"
+
"context"
"flag"
"github.com/google/subcommands"
@@ -24,6 +26,7 @@ import (
// Checkpoint implements subcommands.Command for the "checkpoint" command.
type Checkpoint struct {
+ imagePath string
}
// Name implements subcommands.Command.Name.
@@ -44,6 +47,7 @@ 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")
}
// Execute implements subcommands.Command.Execute.
@@ -62,7 +66,18 @@ func (c *Checkpoint) Execute(_ context.Context, f *flag.FlagSet, args ...interfa
Fatalf("error loading container: %v", err)
}
- if err := cont.Checkpoint(); err != nil {
+ if c.imagePath == "" {
+ Fatalf("image-path flag must be provided")
+ }
+
+ // Create the image file and open for writing.
+ file, err := os.OpenFile(c.imagePath, os.O_CREATE|os.O_EXCL|os.O_RDWR, 0644)
+ if err != nil {
+ Fatalf("os.OpenFile(%q) failed: %v", c.imagePath, err)
+ }
+ defer file.Close()
+
+ if err := cont.Checkpoint(file); err != nil {
Fatalf("checkpoint failed: %v", err)
}