1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #26640 from Microsoft/jjh/removeosversion

Windows: Remove osversion from OCI
This commit is contained in:
Brian Goff 2016-09-19 15:42:34 -04:00 committed by GitHub
commit b7e189ed1f
6 changed files with 1 additions and 68 deletions

View file

@ -35,8 +35,6 @@ func (daemon *Daemon) createSpec(c *container.Container) (*libcontainerd.Spec, e
return nil, fmt.Errorf("Failed to graph.Get on ImageID %s - %s", c.ImageID, err) return nil, fmt.Errorf("Failed to graph.Get on ImageID %s - %s", c.ImageID, err)
} }
s.Platform.OSVersion = img.OSVersion
// In base spec // In base spec
s.Hostname = c.FullHostname() s.Hostname = c.FullHostname()

View file

@ -84,13 +84,6 @@ func (clnt *client) Create(containerID string, checkpoint string, checkpointDir
configuration.HvRuntime = &hcsshim.HvRuntime{ configuration.HvRuntime = &hcsshim.HvRuntime{
ImagePath: spec.Windows.HvRuntime.ImagePath, ImagePath: spec.Windows.HvRuntime.ImagePath,
} }
// Images with build version < 14350 don't support running with clone, but
// Windows cannot automatically detect this. Explicitly block cloning in this
// case.
if build := buildFromVersion(spec.Platform.OSVersion); build > 0 && build < 14350 {
configuration.HvRuntime.SkipTemplate = true
}
} }
if configuration.HvPartition { if configuration.HvPartition {
@ -236,9 +229,6 @@ func (clnt *client) AddProcess(ctx context.Context, containerID, processFriendly
iopipe := &IOPipe{Terminal: procToAdd.Terminal} iopipe := &IOPipe{Terminal: procToAdd.Terminal}
iopipe.Stdin = createStdInCloser(stdin, newProcess) iopipe.Stdin = createStdInCloser(stdin, newProcess)
// TEMP: Work around Windows BS/DEL behavior.
iopipe.Stdin = fixStdinBackspaceBehavior(iopipe.Stdin, container.ociSpec.Platform.OSVersion, procToAdd.Terminal)
// Convert io.ReadClosers to io.Readers // Convert io.ReadClosers to io.Readers
if stdout != nil { if stdout != nil {
iopipe.Stdout = openReaderFromPipe(stdout) iopipe.Stdout = openReaderFromPipe(stdout)

View file

@ -122,9 +122,6 @@ func (ctr *container) start() error {
iopipe.Stdin = createStdInCloser(stdin, hcsProcess) iopipe.Stdin = createStdInCloser(stdin, hcsProcess)
// TEMP: Work around Windows BS/DEL behavior.
iopipe.Stdin = fixStdinBackspaceBehavior(iopipe.Stdin, ctr.ociSpec.Platform.OSVersion, ctr.ociSpec.Process.Terminal)
// Convert io.ReadClosers to io.Readers // Convert io.ReadClosers to io.Readers
if stdout != nil { if stdout != nil {
iopipe.Stdout = openReaderFromPipe(stdout) iopipe.Stdout = openReaderFromPipe(stdout)

View file

@ -29,40 +29,6 @@ func openReaderFromPipe(p io.ReadCloser) io.Reader {
return r return r
} }
// fixStdinBackspaceBehavior works around a bug in Windows before build 14350
// where it interpreted DEL as VK_DELETE instead of as VK_BACK. This replaces
// DEL with BS to work around this.
func fixStdinBackspaceBehavior(w io.WriteCloser, osversion string, tty bool) io.WriteCloser {
if !tty {
return w
}
if build := buildFromVersion(osversion); build == 0 || build >= 14350 {
return w
}
return &delToBsWriter{w}
}
type delToBsWriter struct {
io.WriteCloser
}
func (w *delToBsWriter) Write(b []byte) (int, error) {
const (
backspace = 0x8
del = 0x7f
)
bc := make([]byte, len(b))
for i, c := range b {
if c == del {
bc[i] = backspace
} else {
bc[i] = c
}
}
return w.WriteCloser.Write(bc)
}
type stdInCloser struct { type stdInCloser struct {
io.WriteCloser io.WriteCloser
hcsshim.Process hcsshim.Process

View file

@ -1,9 +1,6 @@
package libcontainerd package libcontainerd
import ( import "strings"
"strconv"
"strings"
)
// setupEnvironmentVariables converts a string array of environment variables // setupEnvironmentVariables converts a string array of environment variables
// into a map as required by the HCS. Source array is in format [v1=k1] [v2=k2] etc. // into a map as required by the HCS. Source array is in format [v1=k1] [v2=k2] etc.
@ -27,16 +24,3 @@ func (s *ServicingOption) Apply(interface{}) error {
func (s *FlushOption) Apply(interface{}) error { func (s *FlushOption) Apply(interface{}) error {
return nil return nil
} }
// buildFromVersion takes an image version string and returns the Windows build
// number. It returns 0 if the build number is not present.
func buildFromVersion(osver string) int {
v := strings.Split(osver, ".")
if len(v) < 3 {
return 0
}
if build, err := strconv.Atoi(v[2]); err == nil {
return build
}
return 0
}

View file

@ -91,8 +91,6 @@ type Platform struct {
OS string `json:"os"` OS string `json:"os"`
// Arch is the architecture // Arch is the architecture
Arch string `json:"arch"` Arch string `json:"arch"`
// OSVersion is the version of the operating system.
OSVersion string `json:"os.version,omitempty"`
} }
// Mount specifies a mount for a container. // Mount specifies a mount for a container.