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
649529d6
Unverified
Commit
649529d6
authored
Sep 02, 2019
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cgroups: unify cgfsng_{un}freeze()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
63753e8d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
37 deletions
+56
-37
cgfsng.c
src/lxc/cgroups/cgfsng.c
+56
-37
No files found.
src/lxc/cgroups/cgfsng.c
View file @
649529d6
...
...
@@ -1995,40 +1995,38 @@ again:
return
(
pfd
.
revents
&
POLLIN
);
}
__cgfsng_ops
static
bool
cgfsng
_freeze
(
struct
cgroup_ops
*
ops
)
static
bool
cg_legacy
_freeze
(
struct
cgroup_ops
*
ops
)
{
int
ret
;
__do_close_prot_errno
int
fd
=
-
EBADF
;
__do_free
char
*
events_file
=
NULL
,
*
fullpath
=
NULL
,
*
line
=
NULL
;
__do_fclose
FILE
*
f
=
NULL
;
__do_free
char
*
path
=
NULL
;
struct
hierarchy
*
h
;
if
(
!
ops
->
hierarchies
)
return
true
;
h
=
get_hierarchy
(
ops
,
"freezer"
);
if
(
!
h
)
return
false
;
if
(
ops
->
cgroup_layout
!=
CGROUP_LAYOUT_UNIFIED
)
{
h
=
get_hierarchy
(
ops
,
"freezer"
);
if
(
!
h
)
return
false
;
path
=
must_make_path
(
h
->
container_full_path
,
"freezer.state"
,
NULL
);
return
lxc_write_to_file
(
path
,
"FROZEN"
,
STRLITERALLEN
(
"FROZEN"
),
false
,
0666
)
==
0
;
}
fullpath
=
must_make_path
(
h
->
container_full_path
,
"freezer.state"
,
NULL
);
return
lxc_write_to_file
(
fullpath
,
"FROZEN"
,
STRLITERALLEN
(
"FROZEN"
),
false
,
0666
)
==
0
;
}
static
bool
cg_unified_freeze
(
struct
cgroup_ops
*
ops
)
{
int
ret
;
__do_close_prot_errno
int
fd
=
-
EBADF
;
__do_free
char
*
events_file
=
NULL
,
*
path
=
NULL
,
*
line
=
NULL
;
__do_fclose
FILE
*
f
=
NULL
;
struct
hierarchy
*
h
;
h
=
ops
->
unified
;
if
(
!
h
)
return
false
;
full
path
=
must_make_path
(
h
->
container_full_path
,
"cgroup.freeze"
,
NULL
);
ret
=
lxc_write_to_file
(
full
path
,
"1"
,
1
,
false
,
0666
);
path
=
must_make_path
(
h
->
container_full_path
,
"cgroup.freeze"
,
NULL
);
ret
=
lxc_write_to_file
(
path
,
"1"
,
1
,
false
,
0666
);
if
(
ret
<
0
)
return
false
;
events_file
=
must_make_path
(
h
->
container_full_path
,
"cgroup.events"
,
NULL
);
events_file
=
must_make_path
(
h
->
container_full_path
,
"cgroup.events"
,
NULL
);
fd
=
open
(
events_file
,
O_RDONLY
|
O_CLOEXEC
);
if
(
fd
<
0
)
return
false
;
...
...
@@ -2052,32 +2050,53 @@ __cgfsng_ops static bool cgfsng_freeze(struct cgroup_ops *ops)
return
false
;
}
__cgfsng_ops
static
bool
cgfsng_
un
freeze
(
struct
cgroup_ops
*
ops
)
__cgfsng_ops
static
bool
cgfsng_freeze
(
struct
cgroup_ops
*
ops
)
{
__do_free
char
*
fullpath
=
NULL
;
struct
hierarchy
*
h
;
if
(
!
ops
->
hierarchies
)
return
true
;
if
(
ops
->
cgroup_layout
!=
CGROUP_LAYOUT_UNIFIED
)
{
h
=
get_hierarchy
(
ops
,
"freezer"
);
if
(
!
h
)
return
false
;
if
(
ops
->
cgroup_layout
!=
CGROUP_LAYOUT_UNIFIED
)
return
cg_legacy_freeze
(
ops
);
fullpath
=
must_make_path
(
h
->
container_full_path
,
"freezer.state"
,
NULL
);
return
lxc_write_to_file
(
fullpath
,
"THAWED"
,
STRLITERALLEN
(
"THAWED"
),
false
,
0666
)
==
0
;
}
return
cg_unified_freeze
(
ops
);
}
static
bool
cg_legacy_unfreeze
(
struct
cgroup_ops
*
ops
)
{
__do_free
char
*
path
=
NULL
;
struct
hierarchy
*
h
;
h
=
get_hierarchy
(
ops
,
"freezer"
);
if
(
!
h
)
return
false
;
path
=
must_make_path
(
h
->
container_full_path
,
"freezer.state"
,
NULL
);
return
lxc_write_to_file
(
path
,
"THAWED"
,
STRLITERALLEN
(
"THAWED"
),
false
,
0666
)
==
0
;
}
static
bool
cg_unified_unfreeze
(
struct
cgroup_ops
*
ops
)
{
__do_free
char
*
path
=
NULL
;
struct
hierarchy
*
h
;
h
=
ops
->
unified
;
if
(
!
h
)
return
false
;
fullpath
=
must_make_path
(
h
->
container_full_path
,
"cgroup.freeze"
,
NULL
);
return
lxc_write_to_file
(
fullpath
,
"0"
,
1
,
false
,
0666
)
==
0
;
path
=
must_make_path
(
h
->
container_full_path
,
"cgroup.freeze"
,
NULL
);
return
lxc_write_to_file
(
path
,
"0"
,
1
,
false
,
0666
)
==
0
;
}
__cgfsng_ops
static
bool
cgfsng_unfreeze
(
struct
cgroup_ops
*
ops
)
{
if
(
!
ops
->
hierarchies
)
return
true
;
if
(
ops
->
cgroup_layout
!=
CGROUP_LAYOUT_UNIFIED
)
return
cg_legacy_unfreeze
(
ops
);
return
cg_unified_unfreeze
(
ops
);
}
__cgfsng_ops
static
const
char
*
cgfsng_get_cgroup
(
struct
cgroup_ops
*
ops
,
...
...
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