Stateful start/stop

I notice that incus start has a flag

      --stateless             Ignore the instance state

and incus stop has a flag

      --stateful              Store the instance state

However, I can’t find any documentation for what those flags actually mean. The incus manual just duplicates the above flag definitions.

As far as I can tell from the source code, it looks like a stop --stateful will store some additional state (what kind of state? is it like CRIU?) and start will by default restore that state unless told not to:

                        if shutdownAction == "stateful-stop" {
                                // Attempt to restore state.
                                err = inst.Start(true)
                        } else {
                                // Normal startup.
                                err = inst.Start(false)
                        }

Therefore, this suggest to me that it’s like a suspend/resume operation, i.e. stop --stateful doesn’t shutdown the container but freezes its state. Is that correct?

Does it work for containers and VMs?

Thanks,

Brian.

That’s CRIU or QEMU runtime state, yeah.
The CRIU side of things almost never works so can be mostly ignored :slight_smile:

On the VM side of things, if your VM has migration.stateful=true set and you have a sufficiently large size.state set on the root device, you can then do incus stop --stateful foo which will not really stop the VM so much as do an on-disk hibernate of it.

Then incus start will restore it the way it was, unless you pass incus start --stateless in which case that state will be ignored and the VM will go through a normal full boot.

1 Like