-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Checkpoint/Restore Support: add functionality to daemon
Support was added to the daemon to use the Checkpoint and Restore methods of the native exec driver for checkpointing and restoring containers. Signed-off-by: Saied Kazemi <[email protected]> Conflicts: api/server/server.go daemon/container.go daemon/daemon.go daemon/networkdriver/bridge/driver.go daemon/state.go vendor/src/github.com/docker/libnetwork/ipallocator/allocator.go Conflicts: api/server/server.go
- Loading branch information
Showing
7 changed files
with
321 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package daemon | ||
|
||
import ( | ||
"github.com/docker/docker/engine" | ||
) | ||
|
||
// Checkpoint a running container. | ||
func (daemon *Daemon) ContainerCheckpoint(job *engine.Job) engine.Status { | ||
if len(job.Args) != 1 { | ||
return job.Errorf("Usage: %s CONTAINER\n", job.Name) | ||
} | ||
|
||
name := job.Args[0] | ||
container, err := daemon.Get(name) | ||
if err != nil { | ||
return job.Error(err) | ||
} | ||
if !container.IsRunning() { | ||
return job.Errorf("Container %s not running", name) | ||
} | ||
|
||
if err := container.Checkpoint(); err != nil { | ||
return job.Errorf("Cannot checkpoint container %s: %s", name, err) | ||
} | ||
|
||
container.LogEvent("checkpoint") | ||
return engine.StatusOK | ||
} | ||
|
||
// Restore a checkpointed container. | ||
func (daemon *Daemon) ContainerRestore(job *engine.Job) engine.Status { | ||
if len(job.Args) != 1 { | ||
return job.Errorf("Usage: %s CONTAINER\n", job.Name) | ||
} | ||
|
||
name := job.Args[0] | ||
container, err := daemon.Get(name) | ||
if err != nil { | ||
return job.Error(err) | ||
} | ||
if container.IsRunning() { | ||
return job.Errorf("Container %s already running", name) | ||
} | ||
if !container.State.IsCheckpointed() { | ||
return job.Errorf("Container %s is not checkpointed", name) | ||
} | ||
|
||
if err := container.Restore(); err != nil { | ||
container.LogEvent("die") | ||
return job.Errorf("Cannot restore container %s: %s", name, err) | ||
} | ||
|
||
container.LogEvent("restore") | ||
return engine.StatusOK | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.