mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-17 22:05:27 +00:00
freezer: non-functional changes
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
parent
f577e0613c
commit
fd5838e506
@ -32,45 +32,57 @@
|
|||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "state.h"
|
|
||||||
#include "monitor.h"
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "lxc.h"
|
#include "lxc.h"
|
||||||
|
#include "monitor.h"
|
||||||
|
#include "parse.h"
|
||||||
|
#include "state.h"
|
||||||
|
|
||||||
lxc_log_define(lxc_freezer, lxc);
|
lxc_log_define(lxc_freezer, lxc);
|
||||||
|
|
||||||
lxc_state_t freezer_state(const char *name, const char *lxcpath)
|
lxc_state_t freezer_state(const char *name, const char *lxcpath)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
char v[100];
|
char v[100];
|
||||||
if (lxc_cgroup_get("freezer.state", v, 100, name, lxcpath) < 0)
|
|
||||||
|
ret = lxc_cgroup_get("freezer.state", v, 100, name, lxcpath);
|
||||||
|
if (ret < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (v[strlen(v)-1] == '\n')
|
v[99] = '\0';
|
||||||
v[strlen(v)-1] = '\0';
|
v[lxc_char_right_gc(v, strlen(v))] = '\0';
|
||||||
|
|
||||||
return lxc_str2state(v);
|
return lxc_str2state(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int do_freeze_thaw(int freeze, const char *name, const char *lxcpath)
|
static int do_freeze_thaw(int freeze, const char *name, const char *lxcpath)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
char v[100];
|
char v[100];
|
||||||
const char *state = freeze ? "FROZEN" : "THAWED";
|
const char *state = freeze ? "FROZEN" : "THAWED";
|
||||||
|
|
||||||
if (lxc_cgroup_set("freezer.state", state, name, lxcpath) < 0) {
|
ret = lxc_cgroup_set("freezer.state", state, name, lxcpath);
|
||||||
ERROR("Failed to freeze %s:%s", lxcpath, name);
|
if (ret < 0) {
|
||||||
|
ERROR("Failed to freeze %s", name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
while (1) {
|
|
||||||
if (lxc_cgroup_get("freezer.state", v, 100, name, lxcpath) < 0) {
|
for (;;) {
|
||||||
ERROR("Failed to get new freezer state for %s:%s", lxcpath, name);
|
ret = lxc_cgroup_get("freezer.state", v, 100, name, lxcpath);
|
||||||
|
if (ret < 0) {
|
||||||
|
ERROR("Failed to get freezer state of %s", name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (v[strlen(v)-1] == '\n')
|
|
||||||
v[strlen(v)-1] = '\0';
|
v[99] = '\0';
|
||||||
if (strncmp(v, state, strlen(state)) == 0) {
|
v[lxc_char_right_gc(v, strlen(v))] = '\0';
|
||||||
if (name)
|
|
||||||
lxc_monitor_send_state(name, freeze ? FROZEN : THAWED, lxcpath);
|
ret = strncmp(v, state, strlen(state));
|
||||||
|
if (ret == 0) {
|
||||||
|
lxc_monitor_send_state(name, freeze ? FROZEN : THAWED, lxcpath);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user