]> git.proxmox.com Git - mirror_lxc.git/commitdiff
cgroups: export __cgroup_unfreeze() for use in commands
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 2 Feb 2021 22:19:23 +0000 (23:19 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 2 Feb 2021 22:21:19 +0000 (23:21 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/cgroups/cgfsng.c
src/lxc/cgroups/cgroup.h

index 00470ae0a50fe97a731f76b7ef13487b4d96bb12..766ed3677b856916c70112bdcf333330daaccd65 100644 (file)
@@ -3550,12 +3550,12 @@ int cgroup_set(const char *name, const char *lxcpath,
        return ret;
 }
 
-static int __cgroup_freeze(int unified_fd,
-                          const char *state_string,
-                          int state_num,
-                          int timeout,
-                          const char *epoll_error,
-                          const char *wait_error)
+static int do_cgroup_freeze(int unified_fd,
+                           const char *state_string,
+                           int state_num,
+                           int timeout,
+                           const char *epoll_error,
+                           const char *wait_error)
 {
        __do_close int events_fd = -EBADF;
        call_cleaner(lxc_mainloop_close) struct lxc_epoll_descr *descr_ptr = NULL;
@@ -3592,6 +3592,13 @@ static int __cgroup_freeze(int unified_fd,
        return log_trace(0, "Container now %s", (state_num == 1) ? "frozen" : "unfrozen");
 }
 
+static inline int __cgroup_freeze(int unified_fd, int timeout)
+{
+       return do_cgroup_freeze(unified_fd, "1", 1, timeout,
+                               "Failed to create epoll instance to wait for container freeze",
+                               "Failed to wait for container to be frozen");
+}
+
 int cgroup_freeze(const char *name, const char *lxcpath, int timeout)
 {
        __do_close int unified_fd = -EBADF;
@@ -3605,13 +3612,18 @@ int cgroup_freeze(const char *name, const char *lxcpath, int timeout)
                return ret_errno(ENOCGROUP2);
 
        lxc_cmd_notify_state_listeners(name, lxcpath, FREEZING);
-       ret = __cgroup_freeze(unified_fd, "1", 1, timeout,
-                             "Failed to create epoll instance to wait for container freeze",
-                             "Failed to wait for container to be frozen");
+       ret = __cgroup_freeze(unified_fd, timeout);
        lxc_cmd_notify_state_listeners(name, lxcpath, !ret ? FROZEN : RUNNING);
        return ret;
 }
 
+int __cgroup_unfreeze(int unified_fd, int timeout)
+{
+       return do_cgroup_freeze(unified_fd, "0", 0, timeout,
+                               "Failed to create epoll instance to wait for container freeze",
+                               "Failed to wait for container to be frozen");
+}
+
 int cgroup_unfreeze(const char *name, const char *lxcpath, int timeout)
 {
        __do_close int unified_fd = -EBADF;
@@ -3625,9 +3637,7 @@ int cgroup_unfreeze(const char *name, const char *lxcpath, int timeout)
                return ret_errno(ENOCGROUP2);
 
        lxc_cmd_notify_state_listeners(name, lxcpath, THAWED);
-       ret = __cgroup_freeze(unified_fd, "0", 0, timeout,
-                             "Failed to create epoll instance to wait for container freeze",
-                             "Failed to wait for container to be frozen");
+       ret = __cgroup_unfreeze(unified_fd, timeout);
        lxc_cmd_notify_state_listeners(name, lxcpath, !ret ? RUNNING : FROZEN);
        return ret;
 }
index 68c12d33e191e7876ec0587fa014bc97aee2fe78..82137564c0ff8ac07a68b929962c1492c2145724 100644 (file)
@@ -197,6 +197,7 @@ __hidden extern int cgroup_set(const char *name, const char *lxcpath,
                                const char *filename, const char *value);
 __hidden extern int cgroup_freeze(const char *name, const char *lxcpath, int timeout);
 __hidden extern int cgroup_unfreeze(const char *name, const char *lxcpath, int timeout);
+__hidden extern int __cgroup_unfreeze(int unified_fd, int timeout);
 
 static inline bool pure_unified_layout(const struct cgroup_ops *ops)
 {