summaryrefslogtreecommitdiff
path: root/libpod/runtime.go
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2019-04-15 22:03:47 +0200
committerGiuseppe Scrivano <gscrivan@redhat.com>2019-04-26 22:23:45 +0200
commit525f0b30ac280565a1f98fd4208821a4984a7515 (patch)
tree795c0e3bac1f9baf11fd6ecfbebf73518f5009f1 /libpod/runtime.go
parentb6e2cbad0a4581a8fe4954ff4a9202461a526781 (diff)
downloadpodman-525f0b30ac280565a1f98fd4208821a4984a7515.tar.gz
podman-525f0b30ac280565a1f98fd4208821a4984a7515.tar.bz2
podman-525f0b30ac280565a1f98fd4208821a4984a7515.zip
system: add new subcommand "migrate"
it is useful to migrate existing containers to a new version of podman. Currently, it is needed to migrate rootless containers that were created with podman <= 1.2 to a newer version which requires all containers to be running in the same user namespace. Closes: https://github.com/containers/libpod/issues/2935 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'libpod/runtime.go')
-rw-r--r--libpod/runtime.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/libpod/runtime.go b/libpod/runtime.go
index 69cc10389..6d279a107 100644
--- a/libpod/runtime.go
+++ b/libpod/runtime.go
@@ -100,6 +100,8 @@ type Runtime struct {
// unused.
doRenumber bool
+ doMigrate bool
+
// valid indicates whether the runtime is ready to use.
// valid is set to true when a runtime is returned from GetRuntime(),
// and remains true until the runtime is shut down (rendering its
@@ -962,6 +964,24 @@ func makeRuntime(runtime *Runtime) (err error) {
// further
runtime.valid = true
+ if runtime.doMigrate {
+ if os.Geteuid() != 0 {
+ aliveLock.Unlock()
+ locked = false
+
+ became, ret, err := rootless.BecomeRootInUserNS()
+ if err != nil {
+ return err
+ }
+ if became {
+ os.Exit(ret)
+ }
+ }
+ if err := runtime.migrate(); err != nil {
+ return err
+ }
+ }
+
return nil
}