From de848a14caf1636cc24e621a35d7073cebe5444d Mon Sep 17 00:00:00 2001
From: Vincent Batts <vbatts@redhat.com>
Date: Mon, 24 Feb 2014 13:42:09 -0500
Subject: [PATCH 1/3] seperate out the terminal functions from lxc to the
 pkg/term

  Since these functions are indepenent of lxc, and could be used by
  other drivers.

Docker-DCO-1.1-Signed-off-by: Vincent Batts <vbatts@redhat.com> (github: vbatts)
---
 execdriver/lxc/driver.go                     | 3 ++-
 execdriver/lxc/term.go => pkg/term/driver.go | 5 ++---
 2 files changed, 4 insertions(+), 4 deletions(-)
 rename execdriver/lxc/term.go => pkg/term/driver.go (94%)

diff --git a/execdriver/lxc/driver.go b/execdriver/lxc/driver.go
index 5be7ad2219..145965a383 100644
--- a/execdriver/lxc/driver.go
+++ b/execdriver/lxc/driver.go
@@ -4,6 +4,7 @@ import (
 	"fmt"
 	"github.com/dotcloud/docker/execdriver"
 	"github.com/dotcloud/docker/pkg/cgroups"
+	"github.com/dotcloud/docker/pkg/term"
 	"github.com/dotcloud/docker/utils"
 	"io/ioutil"
 	"log"
@@ -77,7 +78,7 @@ func (d *driver) Name() string {
 }
 
 func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallback execdriver.StartCallback) (int, error) {
-	if err := SetTerminal(c, pipes); err != nil {
+	if err := term.SetTerminal(c, pipes); err != nil {
 		return -1, err
 	}
 	configPath, err := d.generateLXCConfig(c)
diff --git a/execdriver/lxc/term.go b/pkg/term/driver.go
similarity index 94%
rename from execdriver/lxc/term.go
rename to pkg/term/driver.go
index d772f60972..6e1fae41ba 100644
--- a/execdriver/lxc/term.go
+++ b/pkg/term/driver.go
@@ -1,8 +1,7 @@
-package lxc
+package term
 
 import (
 	"github.com/dotcloud/docker/execdriver"
-	"github.com/dotcloud/docker/pkg/term"
 	"github.com/kr/pty"
 	"io"
 	"os"
@@ -51,7 +50,7 @@ func (t *TtyConsole) Master() *os.File {
 }
 
 func (t *TtyConsole) Resize(h, w int) error {
-	return term.SetWinsize(t.master.Fd(), &term.Winsize{Height: uint16(h), Width: uint16(w)})
+	return SetWinsize(t.master.Fd(), &Winsize{Height: uint16(h), Width: uint16(w)})
 }
 
 func (t *TtyConsole) attach(command *execdriver.Command, pipes *execdriver.Pipes) error {

From fabc478e7e33fd3b3c00c3bd74bad0d87a2c23e3 Mon Sep 17 00:00:00 2001
From: Vincent Batts <vbatts@redhat.com>
Date: Mon, 24 Feb 2014 15:28:45 -0500
Subject: [PATCH 2/3] Move the terminal setup to execdriver, instead of
 ./pkg/term

  It is independent of any particular driver, but likely used by
  multiple execdrivers. Also, pkg/... is not to have any links to
  docker, which this terminal setup does.

Docker-DCO-1.1-Signed-off-by: Vincent Batts <vbatts@redhat.com> (github: vbatts)
---
 .../driver.go => execdriver/termconsole.go     | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
 rename pkg/term/driver.go => execdriver/termconsole.go (74%)

diff --git a/pkg/term/driver.go b/execdriver/termconsole.go
similarity index 74%
rename from pkg/term/driver.go
rename to execdriver/termconsole.go
index 6e1fae41ba..2da48d1864 100644
--- a/pkg/term/driver.go
+++ b/execdriver/termconsole.go
@@ -1,15 +1,15 @@
-package term
+package execdriver
 
 import (
-	"github.com/dotcloud/docker/execdriver"
+	"github.com/dotcloud/docker/pkg/term"
 	"github.com/kr/pty"
 	"io"
 	"os"
 )
 
-func SetTerminal(command *execdriver.Command, pipes *execdriver.Pipes) error {
+func SetTerminal(command *Command, pipes *Pipes) error {
 	var (
-		term execdriver.Terminal
+		term Terminal
 		err  error
 	)
 	if command.Tty {
@@ -29,7 +29,7 @@ type TtyConsole struct {
 	slave  *os.File
 }
 
-func NewTtyConsole(command *execdriver.Command, pipes *execdriver.Pipes) (*TtyConsole, error) {
+func NewTtyConsole(command *Command, pipes *Pipes) (*TtyConsole, error) {
 	ptyMaster, ptySlave, err := pty.Open()
 	if err != nil {
 		return nil, err
@@ -50,10 +50,10 @@ func (t *TtyConsole) Master() *os.File {
 }
 
 func (t *TtyConsole) Resize(h, w int) error {
-	return SetWinsize(t.master.Fd(), &Winsize{Height: uint16(h), Width: uint16(w)})
+	return term.SetWinsize(t.master.Fd(), &term.Winsize{Height: uint16(h), Width: uint16(w)})
 }
 
-func (t *TtyConsole) attach(command *execdriver.Command, pipes *execdriver.Pipes) error {
+func (t *TtyConsole) attach(command *Command, pipes *Pipes) error {
 	command.Stdout = t.slave
 	command.Stderr = t.slave
 	command.Console = t.slave.Name()
@@ -87,7 +87,7 @@ func (t *TtyConsole) Close() error {
 type StdConsole struct {
 }
 
-func NewStdConsole(command *execdriver.Command, pipes *execdriver.Pipes) (*StdConsole, error) {
+func NewStdConsole(command *Command, pipes *Pipes) (*StdConsole, error) {
 	std := &StdConsole{}
 
 	if err := std.attach(command, pipes); err != nil {
@@ -96,7 +96,7 @@ func NewStdConsole(command *execdriver.Command, pipes *execdriver.Pipes) (*StdCo
 	return std, nil
 }
 
-func (s *StdConsole) attach(command *execdriver.Command, pipes *execdriver.Pipes) error {
+func (s *StdConsole) attach(command *Command, pipes *Pipes) error {
 	command.Stdout = pipes.Stdout
 	command.Stderr = pipes.Stderr
 

From c35853191ccd9ca8fe91b666d598eac3e4e12c67 Mon Sep 17 00:00:00 2001
From: Vincent Batts <vbatts@redhat.com>
Date: Tue, 25 Feb 2014 10:07:06 -0500
Subject: [PATCH 3/3] correcting the package name for the terminal setup

Docker-DCO-1.1-Signed-off-by: Vincent Batts <vbatts@redhat.com> (github: vbatts)
---
 execdriver/lxc/driver.go | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/execdriver/lxc/driver.go b/execdriver/lxc/driver.go
index 145965a383..c18b2e6ab4 100644
--- a/execdriver/lxc/driver.go
+++ b/execdriver/lxc/driver.go
@@ -4,7 +4,6 @@ import (
 	"fmt"
 	"github.com/dotcloud/docker/execdriver"
 	"github.com/dotcloud/docker/pkg/cgroups"
-	"github.com/dotcloud/docker/pkg/term"
 	"github.com/dotcloud/docker/utils"
 	"io/ioutil"
 	"log"
@@ -78,7 +77,7 @@ func (d *driver) Name() string {
 }
 
 func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallback execdriver.StartCallback) (int, error) {
-	if err := term.SetTerminal(c, pipes); err != nil {
+	if err := execdriver.SetTerminal(c, pipes); err != nil {
 		return -1, err
 	}
 	configPath, err := d.generateLXCConfig(c)