[libvirt] [PATCH] [RFC] lxc: Remove !priv->cgroup case

Currently we enforce that every container has a cgroup. So we can delete these two !priv->cgroup branches. Signed-off-by: Richard Weinberger <richard@nod.at> --- Hi! Maybe I miss something but I think we can delete these two !priv->cgroup branches. If virLXCCgroupCreate() returns NULL the LXC controller exists. Thanks, //richard --- src/lxc/lxc_process.c | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index ed729f6..f75d353 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -203,10 +203,8 @@ static void virLXCProcessCleanup(virLXCDriverPtr driver, virDomainConfVMNWFilterTeardown(vm); - if (priv->cgroup) { - virCgroupRemove(priv->cgroup); - virCgroupFree(&priv->cgroup); - } + virCgroupRemove(priv->cgroup); + virCgroupFree(&priv->cgroup); /* Get machined to terminate the machine as it may not have cleaned it * properly. See https://bugs.freedesktop.org/show_bug.cgi?id=68370 for @@ -697,23 +695,13 @@ int virLXCProcessStop(virLXCDriverPtr driver, VIR_FREE(vm->def->seclabels[0]->imagelabel); } - if (priv->cgroup) { - rc = virCgroupKillPainfully(priv->cgroup); - if (rc < 0) - return -1; - if (rc > 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Some processes refused to die")); - return -1; - } - } else { - /* If cgroup doesn't exist, just try cleaning up the - * libvirt_lxc process */ - if (virProcessKillPainfully(vm->pid, true) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Processes %d refused to die"), (int)vm->pid); - return -1; - } + rc = virCgroupKillPainfully(priv->cgroup); + if (rc < 0) + return -1; + if (rc > 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Some processes refused to die")); + return -1; } virLXCProcessCleanup(driver, vm, reason); -- 1.8.4.5

On Fri, Feb 14, 2014 at 03:21:01PM +0100, Richard Weinberger wrote:
Currently we enforce that every container has a cgroup. So we can delete these two !priv->cgroup branches.
Signed-off-by: Richard Weinberger <richard@nod.at> --- Hi!
Maybe I miss something but I think we can delete these two !priv->cgroup branches. If virLXCCgroupCreate() returns NULL the LXC controller exists.
Unfortunately there's an issue that 'virLXCProcessStop' method can be called from 'virLXCProcessStart' when container startup fails and in this case we don't guarantee cgroup != NULL. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

Am 14.02.2014 15:30, schrieb Daniel P. Berrange:
On Fri, Feb 14, 2014 at 03:21:01PM +0100, Richard Weinberger wrote:
Currently we enforce that every container has a cgroup. So we can delete these two !priv->cgroup branches.
Signed-off-by: Richard Weinberger <richard@nod.at> --- Hi!
Maybe I miss something but I think we can delete these two !priv->cgroup branches. If virLXCCgroupCreate() returns NULL the LXC controller exists.
Unfortunately there's an issue that 'virLXCProcessStop' method can be called from 'virLXCProcessStart' when container startup fails and in this case we don't guarantee cgroup != NULL.
Hmm, I see the issue. Maybe I find a nice solution to clean this up. Thanks, //richard
participants (2)
-
Daniel P. Berrange
-
Richard Weinberger