diff --git a/cmd/containerd/builtins_linux.go b/cmd/containerd/builtins_linux.go index 6c56744df..7804664c2 100644 --- a/cmd/containerd/builtins_linux.go +++ b/cmd/containerd/builtins_linux.go @@ -22,6 +22,7 @@ import ( _ "github.com/containerd/containerd/runtime/v1/linux" _ "github.com/containerd/containerd/runtime/v2" _ "github.com/containerd/containerd/runtime/v2/runc/options" + _ "github.com/containerd/containerd/snapshots/devmapper" _ "github.com/containerd/containerd/snapshots/native" _ "github.com/containerd/containerd/snapshots/overlay" _ "github.com/containerd/zfs" diff --git a/snapshots/devmapper/snapshotter.go b/snapshots/devmapper/snapshotter.go index aa396c4e9..b9cc64ed3 100644 --- a/snapshots/devmapper/snapshotter.go +++ b/snapshots/devmapper/snapshotter.go @@ -27,14 +27,44 @@ import ( "github.com/containerd/containerd/log" "github.com/containerd/containerd/mount" + "github.com/containerd/containerd/plugin" "github.com/containerd/containerd/snapshots" "github.com/containerd/containerd/snapshots/devmapper/dmsetup" "github.com/containerd/containerd/snapshots/storage" "github.com/hashicorp/go-multierror" + ocispec "github.com/opencontainers/image-spec/specs-go/v1" "github.com/pkg/errors" "github.com/sirupsen/logrus" ) +func init() { + plugin.Register(&plugin.Registration{ + Type: plugin.SnapshotPlugin, + ID: "devmapper", + Config: &Config{ + PoolName: "containerd-pool", + BaseImageSize: "128Mb", + }, + InitFn: func(ic *plugin.InitContext) (interface{}, error) { + ic.Meta.Platforms = append(ic.Meta.Platforms, ocispec.Platform{ + OS: "linux", + Architecture: "amd64", + }) + + config, ok := ic.Config.(*Config) + if !ok { + return nil, errors.New("invalid devmapper configuration") + } + + if config.RootPath == "" { + config.RootPath = ic.Root + } + + return NewSnapshotter(ic.Context, config) + }, + }) +} + const ( metadataFileName = "metadata.db" fsTypeExt4 = "ext4"