lxc / go-lxc

Go bindings for liblxc
https://linuxcontainers.org/lxc
Other
430 stars 76 forks source link

Failed to create loopback storage #147

Closed 3lding closed 3 years ago

3lding commented 3 years ago

Hello

I tried to spawn an lxc container with a loopback storage device as backend type. But it failed to create the storage device. Following lines were logged:

lxc 20210226152722.259 ERROR    lxccontainer - lxccontainer.c:do_storage_create:1272 - Failed to create "loopback" storage
lxc 20210226152722.259 ERROR    lxccontainer - lxccontainer.c:do_lxcapi_create:1869 - Failed to create loopback storage for test0
lxc 20210226153541.279 ERROR    lxccontainer - lxccontainer.c:do_storage_create:1272 - Failed to create "loopback" storage
lxc 20210226153541.279 ERROR    lxccontainer - lxccontainer.c:do_lxcapi_create:1869 - Failed to create loopback storage for test0
lxc 20210226154424.601 ERROR    lxccontainer - lxccontainer.c:do_storage_create:1272 - Failed to create "loopback" storage
lxc 20210226154424.601 ERROR    lxccontainer - lxccontainer.c:do_lxcapi_create:1869 - Failed to create loopback storage for test0
lxc 20210226154726.197 ERROR    lxccontainer - lxccontainer.c:do_storage_create:1272 - Failed to create "loopback" storage
lxc 20210226154726.197 ERROR    lxccontainer - lxccontainer.c:do_lxcapi_create:1869 - Failed to create loopback storage for test0
lxc 20210226155147.131 ERROR    lxccontainer - lxccontainer.c:do_storage_create:1272 - Failed to create "loopback" storage
lxc 20210226155147.131 ERROR    lxccontainer - lxccontainer.c:do_lxcapi_create:1869 - Failed to create loopback storage for test0

For creating an instance I copied the examples/create.go and modified the function init() inside it:

func init() {
        flag.StringVar(&lxcpath, "lxcpath",  lxc.DefaultConfigPath(), "Use specified container path")
        flag.StringVar(&template, "template", "debian", "Template to use")
        flag.StringVar(&distro, "distro", "debian", "Template to use")
        flag.StringVar(&release, "release", "buster", "Template to use")
        flag.StringVar(&arch, "arch", "amd64", "Template to use")
        flag.StringVar(&name, "name", "test0", "Name of the container")
        flag.BoolVar(&verbose, "verbose", true, "Verbose output")
        flag.BoolVar(&flush, "flush", false, "Flush the cache")
        flag.BoolVar(&validation, "validation", false, "GPG validation")
        flag.StringVar(&bdevtype, "bdev", "loopback", "backing store type")
        flag.StringVar(&fssize, "fssize", "8192MB", "backing store size")
        flag.Parse()
}

I tried this on Ubuntu 20.04 as well as on Debian 10.8 with Go 1.16/1.15.7 and both resulted with the same error. Are there any required parameters missing to create the loopback storage device? 🤔

If I try to create the container with lxc-create -t debian -B loop --fssize 8192 -n test0 -- -a amd64 -r buster the container instance will be created without any issues.