Skip to content

Commit

Permalink
commands: handle older clients elegantly
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
  • Loading branch information
Christian Brauner committed Feb 23, 2021
1 parent ebc548a commit d3be623
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/lxc/commands.c
Expand Up @@ -609,6 +609,9 @@ int lxc_cmd_get_cgroup_ctx(const char *name, const char *lxcpath,
.datalen = size_ret_ctx,
.data = ret_ctx,
},
.rsp = {
.ret = -ENOSYS,
},
};
int ret, stopped;

Expand All @@ -617,7 +620,7 @@ int lxc_cmd_get_cgroup_ctx(const char *name, const char *lxcpath,

ret = lxc_cmd(name, &cmd, &stopped, lxcpath, NULL);
if (ret < 0)
return log_debug_errno(-1, errno, "Failed to process cgroup fd command");
return log_debug_errno(-1, errno, "Failed to process cgroup context command");

if (cmd.rsp.ret < 0)
return log_debug_errno(-EBADF, errno, "Failed to receive cgroup fds");
Expand Down Expand Up @@ -1542,6 +1545,9 @@ int lxc_cmd_get_cgroup2_fd(const char *name, const char *lxcpath)
.req = {
.cmd = LXC_CMD_GET_CGROUP2_FD,
},
.rsp = {
ret = -ENOSYS,
},
};

ret = lxc_cmd(name, &cmd, &stopped, lxcpath, NULL);
Expand All @@ -1561,14 +1567,17 @@ int lxc_cmd_get_limiting_cgroup2_fd(const char *name, const char *lxcpath)
.req = {
.cmd = LXC_CMD_GET_LIMITING_CGROUP2_FD,
},
.rsp = {
.ret = -ENOSYS,
},
};

ret = lxc_cmd(name, &cmd, &stopped, lxcpath, NULL);
if (ret < 0)
return -1;

if (cmd.rsp.ret < 0)
return log_debug_errno(cmd.rsp.ret, -cmd.rsp.ret, "Failed to receive cgroup2 fd");
return syswarn_set(cmd.rsp.ret, "Failed to receive cgroup2 limit fd");

return PTR_TO_INT(cmd.rsp.data);
}
Expand Down

0 comments on commit d3be623

Please sign in to comment.