blob: b08eedcde03fee369c0c0aa1f875dcbea01761f0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
package main
import (
"github.com/containers/libpod/cmd/podman/cliconfig"
"github.com/containers/libpod/cmd/podman/libpodruntime"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
var (
migrateCommand cliconfig.SystemMigrateValues
migrateDescription = `
podman system migrate
Migrate existing containers to a new version of Podman.
`
_migrateCommand = &cobra.Command{
Use: "migrate",
Args: noSubArgs,
Short: "Migrate containers",
Long: migrateDescription,
RunE: func(cmd *cobra.Command, args []string) error {
migrateCommand.InputArgs = args
migrateCommand.GlobalFlags = MainGlobalOpts
return migrateCmd(&migrateCommand)
},
}
)
func init() {
migrateCommand.Command = _migrateCommand
migrateCommand.SetHelpTemplate(HelpTemplate())
migrateCommand.SetUsageTemplate(UsageTemplate())
}
func migrateCmd(c *cliconfig.SystemMigrateValues) error {
// We need to pass one extra option to NewRuntime.
// This will inform the OCI runtime to start a migrate.
// That's controlled by the last argument to GetRuntime.
r, err := libpodruntime.GetRuntimeMigrate(&c.PodmanCommand)
if err != nil {
return errors.Wrapf(err, "error migrating containers")
}
if err := r.Shutdown(false); err != nil {
return err
}
return nil
}
|