|
@@ -8,6 +8,12 @@ import (
|
|
|
"path/filepath"
|
|
|
|
|
|
"github.com/docker/docker/api/types"
|
|
|
+ "github.com/docker/docker/utils"
|
|
|
+)
|
|
|
+
|
|
|
+var (
|
|
|
+ validCheckpointNameChars = utils.RestrictedNameChars
|
|
|
+ validCheckpointNamePattern = utils.RestrictedNamePattern
|
|
|
)
|
|
|
|
|
|
// CheckpointCreate checkpoints the process running in a container with CRIU
|
|
@@ -28,6 +34,10 @@ func (daemon *Daemon) CheckpointCreate(name string, config types.CheckpointCreat
|
|
|
checkpointDir = container.CheckpointDir()
|
|
|
}
|
|
|
|
|
|
+ if !validCheckpointNamePattern.MatchString(config.CheckpointID) {
|
|
|
+ return fmt.Errorf("Invalid checkpoint ID (%s), only %s are allowed", config.CheckpointID, validCheckpointNameChars)
|
|
|
+ }
|
|
|
+
|
|
|
err = daemon.containerd.CreateCheckpoint(container.ID, config.CheckpointID, checkpointDir, config.Exit)
|
|
|
if err != nil {
|
|
|
return fmt.Errorf("Cannot checkpoint container %s: %s", name, err)
|