Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
28937cc3
Unverified
Commit
28937cc3
authored
Jan 17, 2018
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
freezer: non-functional changes
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
ba9605d8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
15 deletions
+27
-15
freezer.c
src/lxc/freezer.c
+27
-15
No files found.
src/lxc/freezer.c
View file @
28937cc3
...
...
@@ -32,45 +32,57 @@
#include <sys/param.h>
#include "error.h"
#include "state.h"
#include "monitor.h"
#include "log.h"
#include "lxc.h"
#include "monitor.h"
#include "parse.h"
#include "state.h"
lxc_log_define
(
lxc_freezer
,
lxc
);
lxc_state_t
freezer_state
(
const
char
*
name
,
const
char
*
lxcpath
)
{
int
ret
;
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
;
if
(
v
[
strlen
(
v
)
-
1
]
==
'\n'
)
v
[
strlen
(
v
)
-
1
]
=
'\0'
;
v
[
99
]
=
'\0'
;
v
[
lxc_char_right_gc
(
v
,
strlen
(
v
))]
=
'\0'
;
return
lxc_str2state
(
v
);
}
static
int
do_freeze_thaw
(
int
freeze
,
const
char
*
name
,
const
char
*
lxcpath
)
{
int
ret
;
char
v
[
100
];
const
char
*
state
=
freeze
?
"FROZEN"
:
"THAWED"
;
if
(
lxc_cgroup_set
(
"freezer.state"
,
state
,
name
,
lxcpath
)
<
0
)
{
ERROR
(
"Failed to freeze %s:%s"
,
lxcpath
,
name
);
ret
=
lxc_cgroup_set
(
"freezer.state"
,
state
,
name
,
lxcpath
);
if
(
ret
<
0
)
{
ERROR
(
"Failed to freeze %s"
,
name
);
return
-
1
;
}
while
(
1
)
{
if
(
lxc_cgroup_get
(
"freezer.state"
,
v
,
100
,
name
,
lxcpath
)
<
0
)
{
ERROR
(
"Failed to get new freezer state for %s:%s"
,
lxcpath
,
name
);
for
(;;)
{
ret
=
lxc_cgroup_get
(
"freezer.state"
,
v
,
100
,
name
,
lxcpath
);
if
(
ret
<
0
)
{
ERROR
(
"Failed to get freezer state of %s"
,
name
);
return
-
1
;
}
if
(
v
[
strlen
(
v
)
-
1
]
==
'\n'
)
v
[
strlen
(
v
)
-
1
]
=
'\0'
;
if
(
strncmp
(
v
,
state
,
strlen
(
state
))
==
0
)
{
if
(
name
)
lxc_monitor_send_state
(
name
,
freeze
?
FROZEN
:
THAWED
,
lxcpath
);
v
[
99
]
=
'\0'
;
v
[
lxc_char_right_gc
(
v
,
strlen
(
v
))]
=
'\0'
;
ret
=
strncmp
(
v
,
state
,
strlen
(
state
));
if
(
ret
==
0
)
{
lxc_monitor_send_state
(
name
,
freeze
?
FROZEN
:
THAWED
,
lxcpath
);
return
0
;
}
sleep
(
1
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment