]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
improve LXC_CMD_GET_CGROUP compatibility 3414/head
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Fri, 15 May 2020 14:33:34 +0000 (16:33 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Fri, 15 May 2020 14:33:34 +0000 (16:33 +0200)
When a newer lxc library communicates with an older one
(such as running an lxc 4.0 lxc-freeze on a longer running
container which was started while lxc was still at version
3), the LXC_CMD_GET_LIMITING_CGROUP command is not
available, causing the remote to just close the socket.
Catch this and try the previous command instead.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/lxc/commands.c

index 6309f68e028c858b8b792ab704ab24bf3e4dccad..25c409e3bc0204d930e30501dcebcb2f15d93ccd 100644 (file)
@@ -509,8 +509,21 @@ static char *lxc_cmd_get_cgroup_path_do(const char *name, const char *lxcpath,
        if (ret < 0)
                return NULL;
 
-       if (ret == 0)
+       if (ret == 0) {
+               if (command == LXC_CMD_GET_LIMITING_CGROUP) {
+                       /*
+                        * This may indicate that the container was started
+                        * under an ealier version before
+                        * `cgroup_advanced_isolation` as implemented, there
+                        * it sees an unknown command and just closes the
+                        * socket, sending us an EOF.
+                        */
+                       return lxc_cmd_get_cgroup_path_do(name, lxcpath,
+                                                         subsystem,
+                                                         LXC_CMD_GET_CGROUP);
+               }
                return NULL;
+       }
 
        if (cmd.rsp.ret < 0 || cmd.rsp.datalen < 0)
                return NULL;