]> xenbits.xensource.com Git - libvirt.git/commitdiff
lxc: make container's init process session leader
authorKaterina Koukiou <k.koukiou@googlemail.com>
Thu, 21 Jul 2016 15:37:24 +0000 (15:37 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Fri, 22 Jul 2016 08:40:10 +0000 (09:40 +0100)
This patch forces container's init process, to become a session leader,
that is its session ID is made the same as its process ID.
That might seem unnecessary in general, but if we want to checkpoint a
container with CRIU, which is needed for container migration,
we must ensure that the SID of each process inside the container points
to a process that lives in the same PID namespace as the container.
Therefore, we force that the session leader is the init.

Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com>
src/lxc/lxc_container.c

index a39e24fc341986ead3200797578b40a1c5590177..124b4416fa49d13b4226388f7a441cbf81b4f766 100644 (file)
@@ -2245,6 +2245,15 @@ static int lxcContainerChild(void *data)
                              argv->npassFDs, argv->passFDs) < 0)
         goto cleanup;
 
+    /* Make init process of the container the leader of the new session.
+     * That is needed when checkpointing container.
+     */
+    if (setsid() < 0) {
+        virReportSystemError(errno, "%s",
+                             _("Unable to become session leader"));
+        goto cleanup;
+    }
+
     ret = 0;
  cleanup:
     VIR_FREE(ttyPath);