Unverified Commit ae2d267e by Stéphane Graber Committed by GitHub

Merge pull request #3663 from brauner/2021-02-10/fixes

criu: fixes
parents 11a3696f d9fc9be8
...@@ -2018,7 +2018,7 @@ __cgfsng_ops static bool cgfsng_mount(struct cgroup_ops *ops, ...@@ -2018,7 +2018,7 @@ __cgfsng_ops static bool cgfsng_mount(struct cgroup_ops *ops,
} }
/* Only root needs to escape to the cgroup of its init. */ /* Only root needs to escape to the cgroup of its init. */
__cgfsng_ops static bool cgfsng_escape(const struct cgroup_ops *ops, __cgfsng_ops static bool cgfsng_criu_escape(const struct cgroup_ops *ops,
struct lxc_conf *conf) struct lxc_conf *conf)
{ {
if (!ops) if (!ops)
...@@ -2049,7 +2049,7 @@ __cgfsng_ops static bool cgfsng_escape(const struct cgroup_ops *ops, ...@@ -2049,7 +2049,7 @@ __cgfsng_ops static bool cgfsng_escape(const struct cgroup_ops *ops,
return true; return true;
} }
__cgfsng_ops static int cgfsng_num_hierarchies(struct cgroup_ops *ops) __cgfsng_ops static int cgfsng_criu_num_hierarchies(struct cgroup_ops *ops)
{ {
int i = 0; int i = 0;
...@@ -2065,8 +2065,8 @@ __cgfsng_ops static int cgfsng_num_hierarchies(struct cgroup_ops *ops) ...@@ -2065,8 +2065,8 @@ __cgfsng_ops static int cgfsng_num_hierarchies(struct cgroup_ops *ops)
return i; return i;
} }
__cgfsng_ops static bool cgfsng_get_hierarchies(struct cgroup_ops *ops, int n, __cgfsng_ops static bool cgfsng_criu_get_hierarchies(struct cgroup_ops *ops,
char ***out) int n, char ***out)
{ {
int i; int i;
...@@ -3516,9 +3516,6 @@ struct cgroup_ops *cgfsng_ops_init(struct lxc_conf *conf) ...@@ -3516,9 +3516,6 @@ struct cgroup_ops *cgfsng_ops_init(struct lxc_conf *conf)
cgfsng_ops->payload_create = cgfsng_payload_create; cgfsng_ops->payload_create = cgfsng_payload_create;
cgfsng_ops->payload_enter = cgfsng_payload_enter; cgfsng_ops->payload_enter = cgfsng_payload_enter;
cgfsng_ops->payload_finalize = cgfsng_payload_finalize; cgfsng_ops->payload_finalize = cgfsng_payload_finalize;
cgfsng_ops->escape = cgfsng_escape;
cgfsng_ops->num_hierarchies = cgfsng_num_hierarchies;
cgfsng_ops->get_hierarchies = cgfsng_get_hierarchies;
cgfsng_ops->get_cgroup = cgfsng_get_cgroup; cgfsng_ops->get_cgroup = cgfsng_get_cgroup;
cgfsng_ops->get = cgfsng_get; cgfsng_ops->get = cgfsng_get;
cgfsng_ops->set = cgfsng_set; cgfsng_ops->set = cgfsng_set;
...@@ -3534,6 +3531,10 @@ struct cgroup_ops *cgfsng_ops_init(struct lxc_conf *conf) ...@@ -3534,6 +3531,10 @@ struct cgroup_ops *cgfsng_ops_init(struct lxc_conf *conf)
cgfsng_ops->devices_activate = cgfsng_devices_activate; cgfsng_ops->devices_activate = cgfsng_devices_activate;
cgfsng_ops->get_limiting_cgroup = cgfsng_get_limiting_cgroup; cgfsng_ops->get_limiting_cgroup = cgfsng_get_limiting_cgroup;
cgfsng_ops->criu_escape = cgfsng_criu_escape;
cgfsng_ops->criu_num_hierarchies = cgfsng_criu_num_hierarchies;
cgfsng_ops->criu_get_hierarchies = cgfsng_criu_get_hierarchies;
return move_ptr(cgfsng_ops); return move_ptr(cgfsng_ops);
} }
......
...@@ -157,9 +157,9 @@ struct cgroup_ops { ...@@ -157,9 +157,9 @@ struct cgroup_ops {
bool (*payload_create)(struct cgroup_ops *ops, struct lxc_handler *handler); bool (*payload_create)(struct cgroup_ops *ops, struct lxc_handler *handler);
bool (*payload_enter)(struct cgroup_ops *ops, struct lxc_handler *handler); bool (*payload_enter)(struct cgroup_ops *ops, struct lxc_handler *handler);
const char *(*get_cgroup)(struct cgroup_ops *ops, const char *controller); const char *(*get_cgroup)(struct cgroup_ops *ops, const char *controller);
bool (*escape)(const struct cgroup_ops *ops, struct lxc_conf *conf); bool (*criu_escape)(const struct cgroup_ops *ops, struct lxc_conf *conf);
int (*num_hierarchies)(struct cgroup_ops *ops); int (*criu_num_hierarchies)(struct cgroup_ops *ops);
bool (*get_hierarchies)(struct cgroup_ops *ops, int n, char ***out); bool (*criu_get_hierarchies)(struct cgroup_ops *ops, int n, char ***out);
int (*set)(struct cgroup_ops *ops, const char *filename, int (*set)(struct cgroup_ops *ops, const char *filename,
const char *value, const char *name, const char *lxcpath); const char *value, const char *name, const char *lxcpath);
int (*get)(struct cgroup_ops *ops, const char *filename, char *value, int (*get)(struct cgroup_ops *ops, const char *filename, char *value,
......
...@@ -911,22 +911,23 @@ static int lxc_setup_ttys(struct lxc_conf *conf) ...@@ -911,22 +911,23 @@ static int lxc_setup_ttys(struct lxc_conf *conf)
return 0; return 0;
} }
define_cleanup_function(struct lxc_tty_info *, lxc_delete_tty);
static int lxc_allocate_ttys(struct lxc_conf *conf) static int lxc_allocate_ttys(struct lxc_conf *conf)
{ {
struct lxc_terminal_info *tty_new = NULL; call_cleaner(lxc_delete_tty) struct lxc_tty_info *ttys = &conf->ttys;
int ret; int ret;
struct lxc_tty_info *ttys = &conf->ttys;
/* no tty in the configuration */ /* no tty in the configuration */
if (ttys->max == 0) if (ttys->max == 0)
return 0; return 0;
tty_new = malloc(sizeof(struct lxc_terminal_info) * ttys->max); ttys->tty = zalloc(sizeof(struct lxc_terminal_info) * ttys->max);
if (!tty_new) if (!ttys->tty)
return -ENOMEM; return -ENOMEM;
for (size_t i = 0; i < conf->ttys.max; i++) { for (size_t i = 0; i < conf->ttys.max; i++) {
struct lxc_terminal_info *tty = &tty_new[i]; struct lxc_terminal_info *tty = &ttys->tty[i];
tty->ptx = -EBADF; tty->ptx = -EBADF;
tty->pty = -EBADF; tty->pty = -EBADF;
...@@ -959,7 +960,7 @@ static int lxc_allocate_ttys(struct lxc_conf *conf) ...@@ -959,7 +960,7 @@ static int lxc_allocate_ttys(struct lxc_conf *conf)
} }
INFO("Finished creating %zu tty devices", ttys->max); INFO("Finished creating %zu tty devices", ttys->max);
conf->ttys.tty = move_ptr(tty_new); move_ptr(ttys);
return 0; return 0;
} }
......
...@@ -644,12 +644,6 @@ enum { ...@@ -644,12 +644,6 @@ enum {
-(__errno__); \ -(__errno__); \
}) })
#define free_move_ptr(a, b) \
({ \
free(a); \
(a) = move_ptr((b)); \
})
/* Container's specific file/directory names */ /* Container's specific file/directory names */
#define LXC_CONFIG_FNAME "config" #define LXC_CONFIG_FNAME "config"
#define LXC_PARTIAL_FNAME "partial" #define LXC_PARTIAL_FNAME "partial"
......
...@@ -83,4 +83,10 @@ static inline void *memdup(const void *data, size_t len) ...@@ -83,4 +83,10 @@ static inline void *memdup(const void *data, size_t len)
#define zalloc(__size__) (calloc(1, __size__)) #define zalloc(__size__) (calloc(1, __size__))
#define free_move_ptr(a, b) \
({ \
free(a); \
(a) = move_ptr((b)); \
})
#endif /* __LXC_MEMORY_UTILS_H */ #endif /* __LXC_MEMORY_UTILS_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment