]> git.ipfire.org Git - thirdparty/libvirt.git/commit
lxc: Cleanup after failed startup
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 11 Nov 2020 12:51:21 +0000 (13:51 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 7 Dec 2020 09:12:32 +0000 (10:12 +0100)
commitb0d3053a2be55a417661de3a3adacd8ef70e8327
tree6ccdf96f5a9e700cff9a19ab555304deb952c90b
parent50c7a272441f32aff2c8f1a98afa3e5b451d0e99
lxc: Cleanup after failed startup

If starting an container fails, the virLXCProcessStop() is
called. But since vm->def->id is not set until libvirt_lxc is
spawned (the domain's ID is PID of that process),
virLXCProcessStop() returns early as virDomainObjIsActive()
returns false. But doing so leaves behind resources reserved for
the containers during the startup process. Most notably, hostdevs
are not re-attached to the host, the domain's transient XML is
not removed, etc.

To resolve this, virLXCProcessCleanup() is called in this case.
However, it is modified to accept @flags which allows caller to
run only specific cleanups (depending how far in container
creation the failure occurred). There is plenty of cleanups which
don't need this guard because either they detect a NULL pointer
or try to release an unique resource.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
src/lxc/lxc_process.c