new-api: add Console to ProcessConfig
Add ability to execute a process with a specified terminal. Signed-off-by: Andrey Vagin <avagin@openvz.org>
This commit is contained in:
parent
0f9f14c1ac
commit
76d395eff2
|
@ -100,7 +100,7 @@ func (c *linuxContainer) StartProcess(config *ProcessConfig) (int, error) {
|
|||
|
||||
if state != configs.Destroyed {
|
||||
glog.Info("start new container process")
|
||||
return namespaces.ExecIn(config.Args, config.Env, cmd, c.config, c.state)
|
||||
return namespaces.ExecIn(config.Args, config.Env, config.Console, cmd, c.config, c.state)
|
||||
}
|
||||
|
||||
if err := c.startInitProcess(cmd, config); err != nil {
|
||||
|
@ -134,7 +134,7 @@ func (c *linuxContainer) updateStateFile() error {
|
|||
}
|
||||
|
||||
func (c *linuxContainer) startInitProcess(cmd *exec.Cmd, config *ProcessConfig) error {
|
||||
err := namespaces.Exec(config.Args, config.Env, cmd, c.config, c.cgroupManager, c.state)
|
||||
err := namespaces.Exec(config.Args, config.Env, config.Console, cmd, c.config, c.cgroupManager, c.state)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ import (
|
|||
// Move this to libcontainer package.
|
||||
// Exec performs setup outside of a namespace so that a container can be
|
||||
// executed. Exec is a high level function for working with container namespaces.
|
||||
func Exec(args []string, env []string, command *exec.Cmd, container *configs.Config, cgroupManager cgroups.Manager, state *configs.State) error {
|
||||
func Exec(args []string, env []string, console string, command *exec.Cmd, container *configs.Config, cgroupManager cgroups.Manager, state *configs.State) error {
|
||||
var err error
|
||||
|
||||
// create a pipe so that we can syncronize with the namespaced process and
|
||||
|
@ -54,8 +54,9 @@ func Exec(args []string, env []string, command *exec.Cmd, container *configs.Con
|
|||
}
|
||||
|
||||
process := processArgs{
|
||||
Env: append(env[0:], container.Env...),
|
||||
Args: args,
|
||||
Env: append(env[0:], container.Env...),
|
||||
Args: args,
|
||||
ConsolePath: console,
|
||||
}
|
||||
if err := encoder.Encode(process); err != nil {
|
||||
return terminate(err)
|
||||
|
|
|
@ -18,7 +18,7 @@ import (
|
|||
|
||||
// ExecIn reexec's cmd with _LIBCONTAINER_INITPID=PID so that it is able to run the
|
||||
// setns code in a single threaded environment joining the existing containers' namespaces.
|
||||
func ExecIn(args []string, env []string, cmd *exec.Cmd, container *configs.Config, state *configs.State) (int, error) {
|
||||
func ExecIn(args []string, env []string, console string, cmd *exec.Cmd, container *configs.Config, state *configs.State) (int, error) {
|
||||
var err error
|
||||
|
||||
parent, child, err := newInitPipe()
|
||||
|
@ -50,8 +50,9 @@ func ExecIn(args []string, env []string, cmd *exec.Cmd, container *configs.Confi
|
|||
}
|
||||
|
||||
process := processArgs{
|
||||
Env: append(env[0:], container.Env...),
|
||||
Args: args,
|
||||
Env: append(env[0:], container.Env...),
|
||||
Args: args,
|
||||
ConsolePath: console,
|
||||
}
|
||||
if err := encoder.Encode(process); err != nil {
|
||||
return terminate(err)
|
||||
|
|
|
@ -21,4 +21,7 @@ type ProcessConfig struct {
|
|||
Stdin io.Reader
|
||||
Stdout io.Writer
|
||||
Stderr io.Writer
|
||||
|
||||
// Console is the path to the pty slave for use by the master
|
||||
Console string
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue