Skip to content

Commit 2218275

Browse files
committed
devmapper: register plugin
Signed-off-by: Maksym Pavlenko <[email protected]>
1 parent cec72ef commit 2218275

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

cmd/containerd/builtins_linux.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
_ "github.com/containerd/containerd/runtime/v1/linux"
2323
_ "github.com/containerd/containerd/runtime/v2"
2424
_ "github.com/containerd/containerd/runtime/v2/runc/options"
25+
_ "github.com/containerd/containerd/snapshots/devmapper"
2526
_ "github.com/containerd/containerd/snapshots/native"
2627
_ "github.com/containerd/containerd/snapshots/overlay"
2728
_ "github.com/containerd/zfs"

snapshots/devmapper/snapshotter.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,44 @@ import (
2727

2828
"github.com/containerd/containerd/log"
2929
"github.com/containerd/containerd/mount"
30+
"github.com/containerd/containerd/plugin"
3031
"github.com/containerd/containerd/snapshots"
3132
"github.com/containerd/containerd/snapshots/devmapper/dmsetup"
3233
"github.com/containerd/containerd/snapshots/storage"
3334
"github.com/hashicorp/go-multierror"
35+
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
3436
"github.com/pkg/errors"
3537
"github.com/sirupsen/logrus"
3638
)
3739

40+
func init() {
41+
plugin.Register(&plugin.Registration{
42+
Type: plugin.SnapshotPlugin,
43+
ID: "devmapper",
44+
Config: &Config{
45+
PoolName: "containerd-pool",
46+
BaseImageSize: "128Mb",
47+
},
48+
InitFn: func(ic *plugin.InitContext) (interface{}, error) {
49+
ic.Meta.Platforms = append(ic.Meta.Platforms, ocispec.Platform{
50+
OS: "linux",
51+
Architecture: "amd64",
52+
})
53+
54+
config, ok := ic.Config.(*Config)
55+
if !ok {
56+
return nil, errors.New("invalid devmapper configuration")
57+
}
58+
59+
if config.RootPath == "" {
60+
config.RootPath = ic.Root
61+
}
62+
63+
return NewSnapshotter(ic.Context, config)
64+
},
65+
})
66+
}
67+
3868
const (
3969
metadataFileName = "metadata.db"
4070
fsTypeExt4 = "ext4"

0 commit comments

Comments
 (0)