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
5ef7547f
Unverified
Commit
5ef7547f
authored
Feb 02, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cgroups: switch back to returning ints
Whick makes for easier error checking and fallback code. Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
29619d41
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
22 deletions
+22
-22
cgfsng.c
src/lxc/cgroups/cgfsng.c
+4
-4
cgroup.h
src/lxc/cgroups/cgroup.h
+2
-2
freezer.c
src/lxc/freezer.c
+4
-4
lxc.h
src/lxc/lxc.h
+2
-2
lxccontainer.c
src/lxc/lxccontainer.c
+10
-10
No files found.
src/lxc/cgroups/cgfsng.c
View file @
5ef7547f
...
...
@@ -3592,7 +3592,7 @@ static int __cgroup_freeze(int unified_fd,
return
log_trace
(
0
,
"Container now %s"
,
(
state_num
==
1
)
?
"frozen"
:
"unfrozen"
);
}
bool
cgroup_freeze
(
const
char
*
name
,
const
char
*
lxcpath
,
int
timeout
)
int
cgroup_freeze
(
const
char
*
name
,
const
char
*
lxcpath
,
int
timeout
)
{
__do_close
int
unified_fd
=
-
EBADF
;
int
ret
;
...
...
@@ -3609,10 +3609,10 @@ bool cgroup_freeze(const char *name, const char *lxcpath, int timeout)
"Failed to create epoll instance to wait for container freeze"
,
"Failed to wait for container to be frozen"
);
lxc_cmd_notify_state_listeners
(
name
,
lxcpath
,
!
ret
?
FROZEN
:
RUNNING
);
return
ret
==
0
;
return
ret
;
}
bool
cgroup_unfreeze
(
const
char
*
name
,
const
char
*
lxcpath
,
int
timeout
)
int
cgroup_unfreeze
(
const
char
*
name
,
const
char
*
lxcpath
,
int
timeout
)
{
__do_close
int
unified_fd
=
-
EBADF
;
int
ret
;
...
...
@@ -3629,5 +3629,5 @@ bool cgroup_unfreeze(const char *name, const char *lxcpath, int timeout)
"Failed to create epoll instance to wait for container freeze"
,
"Failed to wait for container to be frozen"
);
lxc_cmd_notify_state_listeners
(
name
,
lxcpath
,
!
ret
?
RUNNING
:
FROZEN
);
return
ret
==
0
;
return
ret
;
}
src/lxc/cgroups/cgroup.h
View file @
5ef7547f
...
...
@@ -195,8 +195,8 @@ __hidden extern int cgroup_get(const char *name, const char *lxcpath,
const
char
*
filename
,
char
*
buf
,
size_t
len
);
__hidden
extern
int
cgroup_set
(
const
char
*
name
,
const
char
*
lxcpath
,
const
char
*
filename
,
const
char
*
value
);
__hidden
extern
bool
cgroup_freeze
(
const
char
*
name
,
const
char
*
lxcpath
,
int
timeout
);
__hidden
extern
bool
cgroup_unfreeze
(
const
char
*
name
,
const
char
*
lxcpath
,
int
timeout
);
__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
);
static
inline
bool
pure_unified_layout
(
const
struct
cgroup_ops
*
ops
)
{
...
...
src/lxc/freezer.c
View file @
5ef7547f
...
...
@@ -68,7 +68,7 @@ static int do_freeze_thaw(bool freeze, struct lxc_conf *conf, const char *name,
return
0
;
}
bool
lxc_freeze
(
struct
lxc_conf
*
conf
,
const
char
*
name
,
const
char
*
lxcpath
)
int
lxc_freeze
(
struct
lxc_conf
*
conf
,
const
char
*
name
,
const
char
*
lxcpath
)
{
int
ret
;
...
...
@@ -78,10 +78,10 @@ bool lxc_freeze(struct lxc_conf *conf, const char *name, const char *lxcpath)
else
ret
=
do_freeze_thaw
(
true
,
conf
,
name
,
lxcpath
);
lxc_cmd_notify_state_listeners
(
name
,
lxcpath
,
!
ret
?
FROZEN
:
RUNNING
);
return
ret
==
0
;
return
ret
;
}
bool
lxc_unfreeze
(
struct
lxc_conf
*
conf
,
const
char
*
name
,
const
char
*
lxcpath
)
int
lxc_unfreeze
(
struct
lxc_conf
*
conf
,
const
char
*
name
,
const
char
*
lxcpath
)
{
int
ret
;
...
...
@@ -91,5 +91,5 @@ bool lxc_unfreeze(struct lxc_conf *conf, const char *name, const char *lxcpath)
else
ret
=
do_freeze_thaw
(
false
,
conf
,
name
,
lxcpath
);
lxc_cmd_notify_state_listeners
(
name
,
lxcpath
,
!
ret
?
RUNNING
:
FROZEN
);
return
ret
==
0
;
return
ret
;
}
src/lxc/lxc.h
View file @
5ef7547f
...
...
@@ -62,14 +62,14 @@ __hidden extern int lxc_monitor_close(int fd);
* @name : the container name
* Returns 0 on success, < 0 otherwise
*/
__hidden
extern
bool
lxc_freeze
(
struct
lxc_conf
*
conf
,
const
char
*
name
,
const
char
*
lxcpath
);
__hidden
extern
int
lxc_freeze
(
struct
lxc_conf
*
conf
,
const
char
*
name
,
const
char
*
lxcpath
);
/*
* Unfreeze all previously frozen tasks.
* @name : the name of the container
* Return 0 on success, < 0 otherwise
*/
__hidden
extern
bool
lxc_unfreeze
(
struct
lxc_conf
*
conf
,
const
char
*
name
,
const
char
*
lxcpath
);
__hidden
extern
int
lxc_unfreeze
(
struct
lxc_conf
*
conf
,
const
char
*
name
,
const
char
*
lxcpath
);
/*
* Retrieve the container state
...
...
src/lxc/lxccontainer.c
View file @
5ef7547f
...
...
@@ -507,7 +507,7 @@ WRAP_API(bool, lxcapi_is_running)
static
bool
do_lxcapi_freeze
(
struct
lxc_container
*
c
)
{
bool
bret
=
true
;
int
ret
=
0
;
lxc_state_t
s
;
if
(
!
c
||
!
c
->
lxc_conf
)
...
...
@@ -515,19 +515,19 @@ static bool do_lxcapi_freeze(struct lxc_container *c)
s
=
lxc_getstate
(
c
->
name
,
c
->
config_path
);
if
(
s
!=
FROZEN
)
{
b
ret
=
cgroup_freeze
(
c
->
name
,
c
->
config_path
,
-
1
);
if
(
!
bret
&&
errno
==
ENOCGROUP2
)
b
ret
=
lxc_freeze
(
c
->
lxc_conf
,
c
->
name
,
c
->
config_path
);
ret
=
cgroup_freeze
(
c
->
name
,
c
->
config_path
,
-
1
);
if
(
ret
==
-
ENOCGROUP2
)
ret
=
lxc_freeze
(
c
->
lxc_conf
,
c
->
name
,
c
->
config_path
);
}
return
bret
;
return
ret
==
0
;
}
WRAP_API
(
bool
,
lxcapi_freeze
)
static
bool
do_lxcapi_unfreeze
(
struct
lxc_container
*
c
)
{
bool
bret
=
true
;
int
ret
=
0
;
lxc_state_t
s
;
if
(
!
c
||
!
c
->
lxc_conf
)
...
...
@@ -535,13 +535,13 @@ static bool do_lxcapi_unfreeze(struct lxc_container *c)
s
=
lxc_getstate
(
c
->
name
,
c
->
config_path
);
if
(
s
==
FROZEN
)
{
b
ret
=
cgroup_unfreeze
(
c
->
name
,
c
->
config_path
,
-
1
);
if
(
!
bret
&&
errno
==
ENOCGROUP2
)
b
ret
=
lxc_unfreeze
(
c
->
lxc_conf
,
c
->
name
,
c
->
config_path
);
ret
=
cgroup_unfreeze
(
c
->
name
,
c
->
config_path
,
-
1
);
if
(
ret
==
-
ENOCGROUP2
)
ret
=
lxc_unfreeze
(
c
->
lxc_conf
,
c
->
name
,
c
->
config_path
);
}
return
bret
;
return
ret
==
0
;
}
WRAP_API
(
bool
,
lxcapi_unfreeze
)
...
...
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