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
07c5b72a
Unverified
Commit
07c5b72a
authored
May 16, 2019
by
Stéphane Graber
Committed by
GitHub
May 16, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3009 from brauner/2019-05-16/rework_attach
attach: do not reload container
parents
6ae34d21
908fbc1a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
12 deletions
+20
-12
attach.c
src/lxc/attach.c
+17
-9
attach.h
src/lxc/attach.h
+1
-1
lxccontainer.c
src/lxc/lxccontainer.c
+2
-2
No files found.
src/lxc/attach.c
View file @
07c5b72a
...
@@ -1008,9 +1008,9 @@ static inline void lxc_attach_terminal_close_log(struct lxc_terminal *terminal)
...
@@ -1008,9 +1008,9 @@ static inline void lxc_attach_terminal_close_log(struct lxc_terminal *terminal)
close_prot_errno_disarm
(
terminal
->
log_fd
);
close_prot_errno_disarm
(
terminal
->
log_fd
);
}
}
int
lxc_attach
(
const
char
*
name
,
const
char
*
lxcpath
,
int
lxc_attach
(
struct
lxc_container
*
container
,
lxc_attach_exec_t
exec_function
,
lxc_attach_exec_t
exec_function
,
void
*
exec_payload
,
void
*
exec_payload
,
lxc_attach_options_t
*
options
,
lxc_attach_options_t
*
options
,
pid_t
*
attached_process
)
pid_t
*
attached_process
)
{
{
int
i
,
ret
,
status
;
int
i
,
ret
,
status
;
int
ipc_sockets
[
2
];
int
ipc_sockets
[
2
];
...
@@ -1020,6 +1020,7 @@ int lxc_attach(const char *name, const char *lxcpath,
...
@@ -1020,6 +1020,7 @@ int lxc_attach(const char *name, const char *lxcpath,
struct
lxc_proc_context_info
*
init_ctx
;
struct
lxc_proc_context_info
*
init_ctx
;
struct
lxc_terminal
terminal
;
struct
lxc_terminal
terminal
;
struct
lxc_conf
*
conf
;
struct
lxc_conf
*
conf
;
char
*
name
,
*
lxcpath
;
struct
attach_clone_payload
payload
=
{
0
};
struct
attach_clone_payload
payload
=
{
0
};
ret
=
access
(
"/proc/self/ns"
,
X_OK
);
ret
=
access
(
"/proc/self/ns"
,
X_OK
);
...
@@ -1028,21 +1029,34 @@ int lxc_attach(const char *name, const char *lxcpath,
...
@@ -1028,21 +1029,34 @@ int lxc_attach(const char *name, const char *lxcpath,
return
-
1
;
return
-
1
;
}
}
if
(
!
container
)
return
minus_one_set_errno
(
EINVAL
);
if
(
!
lxc_container_get
(
container
))
return
minus_one_set_errno
(
EINVAL
);
name
=
container
->
name
;
lxcpath
=
container
->
config_path
;
if
(
!
options
)
if
(
!
options
)
options
=
&
attach_static_default_options
;
options
=
&
attach_static_default_options
;
init_pid
=
lxc_cmd_get_init_pid
(
name
,
lxcpath
);
init_pid
=
lxc_cmd_get_init_pid
(
name
,
lxcpath
);
if
(
init_pid
<
0
)
{
if
(
init_pid
<
0
)
{
ERROR
(
"Failed to get init pid"
);
ERROR
(
"Failed to get init pid"
);
lxc_container_put
(
container
);
return
-
1
;
return
-
1
;
}
}
init_ctx
=
lxc_proc_get_context_info
(
init_pid
);
init_ctx
=
lxc_proc_get_context_info
(
init_pid
);
if
(
!
init_ctx
)
{
if
(
!
init_ctx
)
{
ERROR
(
"Failed to get context of init process: %ld"
,
(
long
)
init_pid
);
ERROR
(
"Failed to get context of init process: %ld"
,
(
long
)
init_pid
);
lxc_container_put
(
container
);
return
-
1
;
return
-
1
;
}
}
init_ctx
->
container
=
container
;
personality
=
get_personality
(
name
,
lxcpath
);
personality
=
get_personality
(
name
,
lxcpath
);
if
(
init_ctx
->
personality
<
0
)
{
if
(
init_ctx
->
personality
<
0
)
{
ERROR
(
"Failed to get personality of the container"
);
ERROR
(
"Failed to get personality of the container"
);
...
@@ -1051,12 +1065,6 @@ int lxc_attach(const char *name, const char *lxcpath,
...
@@ -1051,12 +1065,6 @@ int lxc_attach(const char *name, const char *lxcpath,
}
}
init_ctx
->
personality
=
personality
;
init_ctx
->
personality
=
personality
;
init_ctx
->
container
=
lxc_container_new
(
name
,
lxcpath
);
if
(
!
init_ctx
->
container
)
{
lxc_proc_put_context_info
(
init_ctx
);
return
-
1
;
}
if
(
!
init_ctx
->
container
->
lxc_conf
)
{
if
(
!
init_ctx
->
container
->
lxc_conf
)
{
init_ctx
->
container
->
lxc_conf
=
lxc_conf_init
();
init_ctx
->
container
->
lxc_conf
=
lxc_conf_init
();
if
(
!
init_ctx
->
container
->
lxc_conf
)
{
if
(
!
init_ctx
->
container
->
lxc_conf
)
{
...
...
src/lxc/attach.h
View file @
07c5b72a
...
@@ -41,7 +41,7 @@ struct lxc_proc_context_info {
...
@@ -41,7 +41,7 @@ struct lxc_proc_context_info {
int
ns_fd
[
LXC_NS_MAX
];
int
ns_fd
[
LXC_NS_MAX
];
};
};
extern
int
lxc_attach
(
const
char
*
name
,
const
char
*
lxcpath
,
extern
int
lxc_attach
(
struct
lxc_container
*
container
,
lxc_attach_exec_t
exec_function
,
void
*
exec_payload
,
lxc_attach_exec_t
exec_function
,
void
*
exec_payload
,
lxc_attach_options_t
*
options
,
pid_t
*
attached_process
);
lxc_attach_options_t
*
options
,
pid_t
*
attached_process
);
...
...
src/lxc/lxccontainer.c
View file @
07c5b72a
...
@@ -4064,7 +4064,7 @@ static int lxcapi_attach(struct lxc_container *c, lxc_attach_exec_t exec_functio
...
@@ -4064,7 +4064,7 @@ static int lxcapi_attach(struct lxc_container *c, lxc_attach_exec_t exec_functio
current_config
=
c
->
lxc_conf
;
current_config
=
c
->
lxc_conf
;
ret
=
lxc_attach
(
c
->
name
,
c
->
config_path
,
exec_function
,
exec_payload
,
options
,
attached_process
);
ret
=
lxc_attach
(
c
,
exec_function
,
exec_payload
,
options
,
attached_process
);
current_config
=
NULL
;
current_config
=
NULL
;
return
ret
;
return
ret
;
}
}
...
@@ -4081,7 +4081,7 @@ static int do_lxcapi_attach_run_wait(struct lxc_container *c, lxc_attach_options
...
@@ -4081,7 +4081,7 @@ static int do_lxcapi_attach_run_wait(struct lxc_container *c, lxc_attach_options
command
.
program
=
(
char
*
)
program
;
command
.
program
=
(
char
*
)
program
;
command
.
argv
=
(
char
**
)
argv
;
command
.
argv
=
(
char
**
)
argv
;
r
=
lxc_attach
(
c
->
name
,
c
->
config_path
,
lxc_attach_run_command
,
&
command
,
options
,
&
pid
);
r
=
lxc_attach
(
c
,
lxc_attach_run_command
,
&
command
,
options
,
&
pid
);
if
(
r
<
0
)
{
if
(
r
<
0
)
{
ERROR
(
"ups"
);
ERROR
(
"ups"
);
return
r
;
return
r
;
...
...
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