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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Currently we enforce that every container has a cgroup.
So we can delete these two !priv->cgroup branches.

Signed-off-by: Richard Weinberger <richard@xxxxxx>
---
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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]