Browse Source

Update hcsshim for HostRoute policy in Windows VXLAN

ksubrmnn 6 years ago
parent
commit
403cffd8d4
100 changed files with 1076 additions and 1785 deletions
  1. 1 1
      glide.lock
  2. 0 1
      glide.yaml
  3. 9 8
      vendor/github.com/Microsoft/hcsshim/appveyor.yml
  4. 0 22
      vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/NOTICE
  5. 0 125
      vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs.go
  6. 0 10
      vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_create-scratch.go
  7. 0 91
      vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_create.go
  8. 0 33
      vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_delete.go
  9. 0 82
      vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_exec.go
  10. 0 11
      vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_kill.go
  11. 0 28
      vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_list.go
  12. 0 10
      vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_pause.go
  13. 0 20
      vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_ps.go
  14. 0 33
      vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_resize-tty.go
  15. 0 10
      vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_resume.go
  16. 0 10
      vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_start.go
  17. 0 20
      vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_state.go
  18. 0 103
      vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_test.go
  19. 81 66
      vendor/github.com/Microsoft/hcsshim/cmd/runhcs/container.go
  20. 3 8
      vendor/github.com/Microsoft/hcsshim/cmd/runhcs/create-scratch.go
  21. 29 2
      vendor/github.com/Microsoft/hcsshim/cmd/runhcs/kill.go
  22. 35 15
      vendor/github.com/Microsoft/hcsshim/cmd/runhcs/kill_test.go
  23. 9 1
      vendor/github.com/Microsoft/hcsshim/cmd/runhcs/main.go
  24. 0 120
      vendor/github.com/Microsoft/hcsshim/cmd/runhcs/tar2vhd.go
  25. 0 3
      vendor/github.com/Microsoft/hcsshim/functional/manifest.go
  26. 27 0
      vendor/github.com/Microsoft/hcsshim/hcn/hcn.go
  27. 3 3
      vendor/github.com/Microsoft/hcsshim/hcn/hcnendpoint.go
  28. 19 19
      vendor/github.com/Microsoft/hcsshim/hcn/hcnendpoint_test.go
  29. 6 0
      vendor/github.com/Microsoft/hcsshim/hcn/hcnglobals.go
  30. 39 25
      vendor/github.com/Microsoft/hcsshim/hcn/hcnloadbalancer.go
  31. 39 22
      vendor/github.com/Microsoft/hcsshim/hcn/hcnloadbalancer_test.go
  32. 3 3
      vendor/github.com/Microsoft/hcsshim/hcn/hcnnamespace.go
  33. 20 20
      vendor/github.com/Microsoft/hcsshim/hcn/hcnnamespace_test.go
  34. 14 5
      vendor/github.com/Microsoft/hcsshim/hcn/hcnnetwork.go
  35. 66 27
      vendor/github.com/Microsoft/hcsshim/hcn/hcnnetwork_test.go
  36. 1 0
      vendor/github.com/Microsoft/hcsshim/hcn/hcnpolicy.go
  37. 9 2
      vendor/github.com/Microsoft/hcsshim/hcn/hcnsupport.go
  38. 38 1
      vendor/github.com/Microsoft/hcsshim/hcn/hcnsupport_test.go
  39. 15 1
      vendor/github.com/Microsoft/hcsshim/hcn/hcnutils_test.go
  40. 3 3
      vendor/github.com/Microsoft/hcsshim/hcn/hcnv1schema_test.go
  41. 0 37
      vendor/github.com/Microsoft/hcsshim/internal/cmd/createuvm/createuvm.go
  42. 0 210
      vendor/github.com/Microsoft/hcsshim/internal/cmd/rootfs2vhd/rootfs2vhd.go
  43. 16 1
      vendor/github.com/Microsoft/hcsshim/internal/guestrequest/types.go
  44. 9 12
      vendor/github.com/Microsoft/hcsshim/internal/hcs/process.go
  45. 61 53
      vendor/github.com/Microsoft/hcsshim/internal/hcs/system.go
  46. 20 12
      vendor/github.com/Microsoft/hcsshim/internal/hcs/watcher.go
  47. 11 1
      vendor/github.com/Microsoft/hcsshim/internal/hcsoci/hcsdoc_lcow.go
  48. 2 0
      vendor/github.com/Microsoft/hcsshim/internal/hns/hnsendpoint.go
  49. 0 51
      vendor/github.com/Microsoft/hcsshim/internal/osversion/osversion.go
  50. 0 11
      vendor/github.com/Microsoft/hcsshim/internal/osversion/windowsbuilds.go
  51. 7 0
      vendor/github.com/Microsoft/hcsshim/internal/schema2/plan9_share.go
  52. 3 0
      vendor/github.com/Microsoft/hcsshim/internal/schema2/virtual_machine.go
  53. 1 1
      vendor/github.com/Microsoft/hcsshim/internal/schemaversion/schemaversion_test.go
  54. 6 16
      vendor/github.com/Microsoft/hcsshim/internal/uvm/create.go
  55. 129 140
      vendor/github.com/Microsoft/hcsshim/internal/uvm/create_lcow.go
  56. 5 5
      vendor/github.com/Microsoft/hcsshim/internal/uvm/create_test.go
  57. 36 17
      vendor/github.com/Microsoft/hcsshim/internal/uvm/create_wcow.go
  58. 32 12
      vendor/github.com/Microsoft/hcsshim/internal/uvm/network.go
  59. 20 3
      vendor/github.com/Microsoft/hcsshim/internal/uvm/plan9.go
  60. 31 9
      vendor/github.com/Microsoft/hcsshim/internal/uvm/start.go
  61. 5 3
      vendor/github.com/Microsoft/hcsshim/internal/uvm/types.go
  62. 19 0
      vendor/github.com/Microsoft/hcsshim/internal/uvm/wait.go
  63. 16 3
      vendor/github.com/Microsoft/hcsshim/pkg/go-runhcs/runhcs.go
  64. 0 65
      vendor/github.com/Microsoft/hcsshim/pkg/go-runhcs/runhcs_create-scratch_test.go
  65. 0 7
      vendor/github.com/Microsoft/hcsshim/pkg/go-runhcs/runhcs_integration_test.go
  66. 0 23
      vendor/github.com/Microsoft/hcsshim/pkg/go-runhcs/runhcs_list_test.go
  67. 0 0
      vendor/github.com/Microsoft/hcsshim/test/functional/assets/defaultlinuxspec.json
  68. 0 0
      vendor/github.com/Microsoft/hcsshim/test/functional/assets/defaultwindowsspec.json
  69. 0 0
      vendor/github.com/Microsoft/hcsshim/test/functional/assets/samples/config.justin.lcow.working.json
  70. 0 0
      vendor/github.com/Microsoft/hcsshim/test/functional/assets/samples/from-docker-linux/privileged.json
  71. 0 0
      vendor/github.com/Microsoft/hcsshim/test/functional/assets/samples/from-docker-linux/sh.json
  72. 25 31
      vendor/github.com/Microsoft/hcsshim/test/functional/lcow_test.go
  73. 0 0
      vendor/github.com/Microsoft/hcsshim/test/functional/manifest/manifest.go
  74. 0 0
      vendor/github.com/Microsoft/hcsshim/test/functional/manifest/rsrc_amd64.syso
  75. 3 0
      vendor/github.com/Microsoft/hcsshim/test/functional/manifest_test.go
  76. 0 0
      vendor/github.com/Microsoft/hcsshim/test/functional/test.go
  77. 3 12
      vendor/github.com/Microsoft/hcsshim/test/functional/utilities/createuvm.go
  78. 0 0
      vendor/github.com/Microsoft/hcsshim/test/functional/utilities/defaultlinuxspec.go
  79. 0 0
      vendor/github.com/Microsoft/hcsshim/test/functional/utilities/defaultwindowsspec.go
  80. 0 0
      vendor/github.com/Microsoft/hcsshim/test/functional/utilities/layerfolders.go
  81. 0 0
      vendor/github.com/Microsoft/hcsshim/test/functional/utilities/requiresbuild.go
  82. 0 0
      vendor/github.com/Microsoft/hcsshim/test/functional/utilities/scratch.go
  83. 0 0
      vendor/github.com/Microsoft/hcsshim/test/functional/utilities/tempdir.go
  84. 27 32
      vendor/github.com/Microsoft/hcsshim/test/functional/uvm_mem_backingtype_test.go
  85. 1 1
      vendor/github.com/Microsoft/hcsshim/test/functional/uvm_plannine_test.go
  86. 1 1
      vendor/github.com/Microsoft/hcsshim/test/functional/uvm_properties_test.go
  87. 1 1
      vendor/github.com/Microsoft/hcsshim/test/functional/uvm_scratch_test.go
  88. 1 1
      vendor/github.com/Microsoft/hcsshim/test/functional/uvm_scsi_test.go
  89. 1 1
      vendor/github.com/Microsoft/hcsshim/test/functional/uvm_vpmem_test.go
  90. 1 1
      vendor/github.com/Microsoft/hcsshim/test/functional/uvm_vsmb_test.go
  91. 4 8
      vendor/github.com/Microsoft/hcsshim/test/functional/wcow_test.go
  92. 1 1
      vendor/github.com/Microsoft/hcsshim/test/functional/wcow_xenon_v2_test.go
  93. 5 3
      vendor/github.com/Microsoft/hcsshim/test/runhcs/create-scratch_test.go
  94. 5 4
      vendor/github.com/Microsoft/hcsshim/test/runhcs/e2e_matrix_test.go
  95. 3 1
      vendor/github.com/Microsoft/hcsshim/test/runhcs/list_test.go
  96. 7 0
      vendor/github.com/Microsoft/hcsshim/test/runhcs/runhcs_test.go
  97. 24 31
      vendor/github.com/Microsoft/hcsshim/tools/uvmboot/main.go
  98. 21 0
      vendor/github.com/Microsoft/hcsshim/vendor.conf
  99. 22 0
      vendor/github.com/Microsoft/hcsshim/vendor/github.com/Microsoft/go-winio/LICENSE
  100. 22 0
      vendor/github.com/Microsoft/hcsshim/vendor/github.com/Microsoft/go-winio/README.md

+ 1 - 1
glide.lock

@@ -139,7 +139,7 @@ imports:
 - name: github.com/Microsoft/go-winio
   version: 97e4973ce50b2ff5f09635a57e2b88a037aae829
 - name: github.com/Microsoft/hcsshim
-  version: 2bf3a7ac42318aacfffd0805be705ff2e4d1138f
+  version: bc49f75c72216a28ffc7443177f477aae7e61d1f
   subpackages:
   - internal/guid
   - internal/hcs

+ 0 - 1
glide.yaml

@@ -63,7 +63,6 @@ import:
 - package: github.com/bronze1man/goStrongswanVici
   version: 4d72634a2f113aa48347dbc7dcb14adb806b6534
 - package: github.com/Microsoft/hcsshim
-  version: v0.8.3
 - package: github.com/Microsoft/go-winio
   version: v0.4.11
 - pacakge: github.com/sirupsen/logrus

+ 9 - 8
vendor/github.com/Microsoft/hcsshim/appveyor.yml

@@ -6,23 +6,24 @@ clone_folder: c:\gopath\src\github.com\Microsoft\hcsshim
 
 environment:
   GOPATH: c:\gopath
-  PATH: C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin;%GOPATH%\bin;%PATH%
+  PATH: C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin;%GOPATH%\bin;C:\gometalinter-2.0.12-windows-amd64;%PATH%
+
+stack: go 1.11
 
 build_script:
-  - go get -u github.com/alecthomas/gometalinter
-  - gometalinter.exe --install
+  - appveyor DownloadFile https://github.com/alecthomas/gometalinter/releases/download/v2.0.12/gometalinter-2.0.12-windows-amd64.zip
+  - 7z x gometalinter-2.0.12-windows-amd64.zip -y -oC:\ > NUL
   - gometalinter.exe --config .gometalinter.json ./...
-  - go get -v -d -t -tags "functional integration admin" ./...
   - go build ./cmd/wclayer
   - go build ./cmd/runhcs
-  - go test -c ./pkg/go-runhcs/ -tags integration
   - go build ./cmd/tar2ext4
   - go test -v ./... -tags admin
-  - go test -c ./functional/ -tags functional
+  - go test -c ./test/functional/ -tags functional
+  - go test -c ./test/runhcs/ -tags integration
 
 artifacts:
   - path: 'wclayer.exe'
   - path: 'runhcs.exe'
-  - path: 'go-runhcs.test.exe'
   - path: 'tar2ext4.exe'
-  - path: 'functional.test.exe'
+  - path: 'functional.test.exe'
+  - path: 'runhcs.test.exe'

+ 0 - 22
vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/NOTICE

@@ -1,22 +0,0 @@
-go-runhcs is a fork of go-runc
-
-The following is runc's legal notice.
-
----
-
-runc
-
-Copyright 2012-2015 Docker, Inc.
-
-This product includes software developed at Docker, Inc. (http://www.docker.com).
-
-The following is courtesy of our legal counsel:
-
-Use and transfer of Docker may be subject to certain restrictions by the
-United States and other governments.
-It is your responsibility to ensure that your use and/or transfer does not
-violate applicable laws.
-
-For more information, please see http://www.bis.doc.gov
-
-See also http://www.apache.org/dev/crypto.html and/or seek legal counsel.

+ 0 - 125
vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs.go

@@ -1,125 +0,0 @@
-package runhcs
-
-import (
-	"bytes"
-	"context"
-	"fmt"
-	"os"
-	"os/exec"
-	"sync"
-
-	"github.com/containerd/go-runc"
-)
-
-// Format is the type of log formatting options available.
-type Format string
-
-const (
-	none Format = ""
-	// Text is the default text log ouput.
-	Text Format = "text"
-	// JSON is the JSON formatted log output.
-	JSON Format = "json"
-
-	command = "runhcs"
-)
-
-var bytesBufferPool = sync.Pool{
-	New: func() interface{} {
-		return bytes.NewBuffer(nil)
-	},
-}
-
-func getBuf() *bytes.Buffer {
-	return bytesBufferPool.Get().(*bytes.Buffer)
-}
-
-func putBuf(b *bytes.Buffer) {
-	b.Reset()
-	bytesBufferPool.Put(b)
-}
-
-// Runhcs is the client to the runhcs cli
-type Runhcs struct {
-	// Debug enables debug output for logging.
-	Debug bool
-	// Log sets the log file path where internal debug information is written.
-	Log string
-	// LogFormat sets the format used by logs.
-	LogFormat Format
-	// Owner sets the compute system owner property.
-	Owner string
-	// Root is the registry key root for storage of runhcs container state.
-	Root string
-}
-
-func (r *Runhcs) args() []string {
-	var out []string
-	if r.Debug {
-		out = append(out, "--debug")
-	}
-	if r.Log != "" {
-		// TODO: JTERRY75 - Should we do abs here?
-		out = append(out, "--log", r.Log)
-	}
-	if r.LogFormat != none {
-		out = append(out, "--log-format", string(r.LogFormat))
-	}
-	if r.Owner != "" {
-		out = append(out, "--owner", r.Owner)
-	}
-	if r.Root != "" {
-		out = append(out, "--root", r.Root)
-	}
-	return out
-}
-
-func (r *Runhcs) command(context context.Context, args ...string) *exec.Cmd {
-	cmd := exec.CommandContext(context, command, append(r.args(), args...)...)
-	cmd.Env = os.Environ()
-	return cmd
-}
-
-// runOrError will run the provided command.  If an error is
-// encountered and neither Stdout or Stderr was set the error and the
-// stderr of the command will be returned in the format of <error>:
-// <stderr>
-func (r *Runhcs) runOrError(cmd *exec.Cmd) error {
-	if cmd.Stdout != nil || cmd.Stderr != nil {
-		ec, err := runc.Monitor.Start(cmd)
-		if err != nil {
-			return err
-		}
-		status, err := runc.Monitor.Wait(cmd, ec)
-		if err == nil && status != 0 {
-			err = fmt.Errorf("%s did not terminate sucessfully", cmd.Args[0])
-		}
-		return err
-	}
-	data, err := cmdOutput(cmd, true)
-	if err != nil {
-		return fmt.Errorf("%s: %s", err, data)
-	}
-	return nil
-}
-
-func cmdOutput(cmd *exec.Cmd, combined bool) ([]byte, error) {
-	b := getBuf()
-	defer putBuf(b)
-
-	cmd.Stdout = b
-	if combined {
-		cmd.Stderr = b
-	}
-	ec, err := runc.Monitor.Start(cmd)
-	if err != nil {
-		return nil, err
-	}
-
-	status, err := runc.Monitor.Wait(cmd, ec)
-	if err == nil && status != 0 {
-		err = fmt.Errorf("%s did not terminate sucessfully", cmd.Args[0])
-	}
-
-	return b.Bytes(), err
-}

+ 0 - 10
vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_create-scratch.go

@@ -1,10 +0,0 @@
-package runhcs
-
-import (
-	"context"
-)
-
-// CreateScratch creates a scratch vhdx at 'destpath' that is ext4 formatted.
-func (r *Runhcs) CreateScratch(context context.Context, destpath string) error {
-	return r.runOrError(r.command(context, "create-scratch", "--destpath", destpath))
-}

+ 0 - 91
vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_create.go

@@ -1,91 +0,0 @@
-package runhcs
-
-import (
-	"context"
-	"fmt"
-	"path/filepath"
-
-	runc "github.com/containerd/go-runc"
-)
-
-// CreateOpts is set of options that can be used with the Create command.
-type CreateOpts struct {
-	runc.IO
-	// PidFile is the path to the file to write the process id to.
-	PidFile string
-	// ShimLog is the path to the log file for the launched shim process.
-	ShimLog string
-	// VMLog is the path to the log file for the launched VM shim process.
-	VMLog string
-	// VMConsole is the path to the pipe for the VM's console (e.g. \\.\pipe\debugpipe)
-	VMConsole string
-}
-
-func (opt *CreateOpts) args() ([]string, error) {
-	var out []string
-	if opt.PidFile != "" {
-		abs, err := filepath.Abs(opt.PidFile)
-		if err != nil {
-			return nil, err
-		}
-		out = append(out, "--pid-file", abs)
-	}
-	if opt.ShimLog != "" {
-		abs, err := filepath.Abs(opt.ShimLog)
-		if err != nil {
-			return nil, err
-		}
-		out = append(out, "--shim-log", abs)
-	}
-	if opt.VMLog != "" {
-		abs, err := filepath.Abs(opt.VMLog)
-		if err != nil {
-			return nil, err
-		}
-		out = append(out, "--vm-log", abs)
-	}
-	if opt.VMConsole != "" {
-		out = append(out, "--vm-console", opt.VMConsole)
-	}
-	return out, nil
-}
-
-// Create creates a new container and returns its pid if it was created
-// successfully.
-func (r *Runhcs) Create(context context.Context, id, bundle string, opts *CreateOpts) error {
-	args := []string{"create", "--bundle", bundle}
-	if opts != nil {
-		oargs, err := opts.args()
-		if err != nil {
-			return err
-		}
-		args = append(args, oargs...)
-	}
-	cmd := r.command(context, append(args, id)...)
-	if opts != nil && opts.IO != nil {
-		opts.Set(cmd)
-	}
-	if cmd.Stdout == nil && cmd.Stderr == nil {
-		data, err := cmdOutput(cmd, true)
-		if err != nil {
-			return fmt.Errorf("%s: %s", err, data)
-		}
-		return nil
-	}
-	ec, err := runc.Monitor.Start(cmd)
-	if err != nil {
-		return err
-	}
-	if opts != nil && opts.IO != nil {
-		if c, ok := opts.IO.(runc.StartCloser); ok {
-			if err := c.CloseAfterStart(); err != nil {
-				return err
-			}
-		}
-	}
-	status, err := runc.Monitor.Wait(cmd, ec)
-	if err == nil && status != 0 {
-		err = fmt.Errorf("%s did not terminate sucessfully", cmd.Args[0])
-	}
-	return nil
-}

+ 0 - 33
vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_delete.go

@@ -1,33 +0,0 @@
-package runhcs
-
-import (
-	"context"
-)
-
-// DeleteOpts is set of options that can be used with the Delete command.
-type DeleteOpts struct {
-	// Force forcibly deletes the container if it is still running (uses SIGKILL).
-	Force bool
-}
-
-func (opt *DeleteOpts) args() ([]string, error) {
-	var out []string
-	if opt.Force {
-		out = append(out, "--force")
-	}
-	return out, nil
-}
-
-// Delete any resources held by the container often used with detached
-// containers.
-func (r *Runhcs) Delete(context context.Context, id string, opts *DeleteOpts) error {
-	args := []string{"delete"}
-	if opts != nil {
-		oargs, err := opts.args()
-		if err != nil {
-			return err
-		}
-		args = append(args, oargs...)
-	}
-	return r.runOrError(r.command(context, append(args, id)...))
-}

+ 0 - 82
vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_exec.go

@@ -1,82 +0,0 @@
-package runhcs
-
-import (
-	"context"
-	"fmt"
-	"path/filepath"
-
-	"github.com/containerd/go-runc"
-)
-
-// ExecOpts is set of options that can be used with the Exec command.
-type ExecOpts struct {
-	runc.IO
-	// Detach from the container's process.
-	Detach bool
-	// PidFile is the path to the file to write the process id to.
-	PidFile string
-	// ShimLog is the path to the log file for the launched shim process.
-	ShimLog string
-}
-
-func (opt *ExecOpts) args() ([]string, error) {
-	var out []string
-	if opt.Detach {
-		out = append(out, "--detach")
-	}
-	if opt.PidFile != "" {
-		abs, err := filepath.Abs(opt.PidFile)
-		if err != nil {
-			return nil, err
-		}
-		out = append(out, "--pid-file", abs)
-	}
-	if opt.ShimLog != "" {
-		abs, err := filepath.Abs(opt.ShimLog)
-		if err != nil {
-			return nil, err
-		}
-		out = append(out, "--shim-log", abs)
-	}
-	return out, nil
-}
-
-// Exec executes an additional process inside the container based on the
-// oci.Process spec found at processFile.
-func (r *Runhcs) Exec(context context.Context, id, processFile string, opts *ExecOpts) error {
-	args := []string{"exec", "--process", processFile}
-	if opts != nil {
-		oargs, err := opts.args()
-		if err != nil {
-			return err
-		}
-		args = append(args, oargs...)
-	}
-	cmd := r.command(context, append(args, id)...)
-	if opts != nil && opts.IO != nil {
-		opts.Set(cmd)
-	}
-	if cmd.Stdout == nil && cmd.Stderr == nil {
-		data, err := cmdOutput(cmd, true)
-		if err != nil {
-			return fmt.Errorf("%s: %s", err, data)
-		}
-		return nil
-	}
-	ec, err := runc.Monitor.Start(cmd)
-	if err != nil {
-		return err
-	}
-	if opts != nil && opts.IO != nil {
-		if c, ok := opts.IO.(runc.StartCloser); ok {
-			if err := c.CloseAfterStart(); err != nil {
-				return err
-			}
-		}
-	}
-	status, err := runc.Monitor.Wait(cmd, ec)
-	if err == nil && status != 0 {
-		err = fmt.Errorf("%s did not terminate sucessfully", cmd.Args[0])
-	}
-	return err
-}

+ 0 - 11
vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_kill.go

@@ -1,11 +0,0 @@
-package runhcs
-
-import (
-	"context"
-)
-
-// Kill sends the specified signal (default: SIGTERM) to the container's init
-// process.
-func (r *Runhcs) Kill(context context.Context, id, signal string) error {
-	return r.runOrError(r.command(context, "kill", id, signal))
-}

+ 0 - 28
vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_list.go

@@ -1,28 +0,0 @@
-package runhcs
-
-import (
-	"context"
-	"encoding/json"
-
-	irunhcs "github.com/Microsoft/hcsshim/internal/runhcs"
-)
-
-// ContainerState is the representation of the containers state at the moment of
-// query.
-type ContainerState = irunhcs.ContainerState
-
-// List containers started by runhcs.
-//
-// Note: This is specific to the Runhcs.Root namespace provided in the global
-// settings.
-func (r *Runhcs) List(context context.Context) ([]*ContainerState, error) {
-	data, err := cmdOutput(r.command(context, "list", "--format=json"), false)
-	if err != nil {
-		return nil, err
-	}
-	var out []*ContainerState
-	if err := json.Unmarshal(data, &out); err != nil {
-		return nil, err
-	}
-	return out, nil
-}

+ 0 - 10
vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_pause.go

@@ -1,10 +0,0 @@
-package runhcs
-
-import (
-	"context"
-)
-
-// Pause suspends all processes inside the container.
-func (r *Runhcs) Pause(context context.Context, id string) error {
-	return r.runOrError(r.command(context, "pause", id))
-}

+ 0 - 20
vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_ps.go

@@ -1,20 +0,0 @@
-package runhcs
-
-import (
-	"context"
-	"encoding/json"
-	"fmt"
-)
-
-// Ps displays the processes running inside a container.
-func (r *Runhcs) Ps(context context.Context, id string) ([]int, error) {
-	data, err := cmdOutput(r.command(context, "ps", "--format=json", id), true)
-	if err != nil {
-		return nil, fmt.Errorf("%s: %s", err, data)
-	}
-	var out []int
-	if err := json.Unmarshal(data, &out); err != nil {
-		return nil, err
-	}
-	return out, nil
-}

+ 0 - 33
vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_resize-tty.go

@@ -1,33 +0,0 @@
-package runhcs
-
-import (
-	"context"
-	"strconv"
-)
-
-// ResizeTTYOpts is set of options that can be used with the ResizeTTY command.
-type ResizeTTYOpts struct {
-	// Pid is the process pid (defaults to init pid).
-	Pid *int
-}
-
-func (opt *ResizeTTYOpts) args() ([]string, error) {
-	var out []string
-	if opt.Pid != nil {
-		out = append(out, "--pid", strconv.Itoa(*opt.Pid))
-	}
-	return out, nil
-}
-
-// ResizeTTY updates the terminal size for a container process.
-func (r *Runhcs) ResizeTTY(context context.Context, id string, width, height uint16, opts *ResizeTTYOpts) error {
-	args := []string{"resize-tty"}
-	if opts != nil {
-		oargs, err := opts.args()
-		if err != nil {
-			return err
-		}
-		args = append(args, oargs...)
-	}
-	return r.runOrError(r.command(context, append(args, id, strconv.FormatUint(uint64(width), 10), strconv.FormatUint(uint64(height), 10))...))
-}

+ 0 - 10
vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_resume.go

@@ -1,10 +0,0 @@
-package runhcs
-
-import (
-	"context"
-)
-
-// Resume resumes all processes that have been previously paused.
-func (r *Runhcs) Resume(context context.Context, id string) error {
-	return r.runOrError(r.command(context, "resume", id))
-}

+ 0 - 10
vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_start.go

@@ -1,10 +0,0 @@
-package runhcs
-
-import (
-	"context"
-)
-
-// Start will start an already created container.
-func (r *Runhcs) Start(context context.Context, id string) error {
-	return r.runOrError(r.command(context, "start", id))
-}

+ 0 - 20
vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_state.go

@@ -1,20 +0,0 @@
-package runhcs
-
-import (
-	"context"
-	"encoding/json"
-	"fmt"
-)
-
-// State outputs the state of a container.
-func (r *Runhcs) State(context context.Context, id string) (*ContainerState, error) {
-	data, err := cmdOutput(r.command(context, "state", id), true)
-	if err != nil {
-		return nil, fmt.Errorf("%s: %s", err, data)
-	}
-	var out ContainerState
-	if err := json.Unmarshal(data, &out); err != nil {
-		return nil, err
-	}
-	return &out, nil
-}

+ 0 - 103
vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_test.go

@@ -1,103 +0,0 @@
-// +build runhcs_test
-
-package runhcs
-
-import (
-	"bytes"
-	"context"
-	"io"
-	"os"
-	"path/filepath"
-	"sync"
-	"testing"
-
-	runc "github.com/containerd/go-runc"
-)
-
-func TestRunhcs_E2E(t *testing.T) {
-	rhcs := Runhcs{
-		Debug: true,
-	}
-
-	// TODO: JTERRY75 use this from assets dynamically
-	//dir, err := ioutil.TempDir("", "runhcs-bundle")
-	//if err != nil {
-	//	t.Fatalf("failed to create tempdir with error: %v", err)
-	//}
-	//defer os.Remove(dir)
-	br := os.Getenv("RUNHCS_TEST_BUNDLE_ROOT")
-	if br == "" {
-		t.Fatal("You must set %RUNHCS_TEST_BUNDLE_ROOT% to the folder containing the test bundles")
-		return
-	}
-	// TODO: JTERRY75 create this spec dynamically once we can do the layer
-	// extraction in some way so we dont need hard coded bundle/config.json's
-	dir := filepath.Join(br, "runhcs-tee-test")
-
-	ctx := context.TODO()
-	id := "runhcs-e2e-id"
-
-	pio, err := runc.NewPipeIO()
-	if err != nil {
-		t.Fatalf("failed to create new pipe io with error: %v", err)
-	}
-	defer pio.Close()
-
-	// Write our expected output
-	expected := "Hello go-runhcs-container!"
-	inbuff := bytes.NewBufferString(expected)
-	outbuff := &bytes.Buffer{}
-	errbuff := &bytes.Buffer{}
-	wg := sync.WaitGroup{}
-	wg.Add(2)
-	go func() {
-		_, err := io.Copy(pio.Stdin(), inbuff)
-		if err != nil {
-			t.Errorf("failed to copy string to stdin pipe.")
-		}
-		pio.Stdin().Close()
-	}()
-	go func() {
-		_, err := io.Copy(outbuff, pio.Stdout())
-		if err != nil {
-			t.Errorf("failed to copy string from stdout pipe")
-		}
-		wg.Done()
-	}()
-	go func() {
-		_, err := io.Copy(errbuff, pio.Stderr())
-		if err != nil {
-			t.Errorf("failed to copy string from stderr pipe")
-		}
-		wg.Done()
-	}()
-
-	copts := &CreateOpts{
-		IO:      pio,
-		PidFile: filepath.Join(dir, "pid-file.txt"),
-		ShimLog: filepath.Join(dir, "shim-log.txt"),
-		VMLog:   filepath.Join(dir, "vm-log.txt"),
-	}
-	if err := rhcs.Create(ctx, id, dir, copts); err != nil {
-		t.Fatalf("failed to create container with error: %v", err)
-	}
-	defer func() {
-		if err := rhcs.Delete(ctx, id, &DeleteOpts{Force: true}); err != nil {
-			t.Fatalf("failed to delete container with error: %v", err)
-		}
-	}()
-
-	if err := rhcs.Start(ctx, id); err != nil {
-		t.Fatalf("failed to start container with error: %v", err)
-	}
-	wg.Wait()
-
-	outstring := outbuff.String()
-	if outstring != expected {
-		t.Fatalf("stdout string '%s' != expected '%s'", outstring, expected)
-	}
-	errstring := errbuff.String()
-	if errstring != expected {
-		t.Fatalf("stderr string '%s' != expected '%s'", errstring, expected)
-	}
-}

+ 81 - 66
vendor/github.com/Microsoft/hcsshim/cmd/runhcs/container.go

@@ -225,16 +225,14 @@ func parseSandboxAnnotations(a map[string]string) (string, bool) {
 }
 
 // parseAnnotationsBool searches `a` for `key` and if found verifies that the
-// value is `true` or `false` in any case. If `key` is not found returns `nil`.
-func parseAnnotationsBool(a map[string]string, key string) *bool {
+// value is `true` or `false` in any case. If `key` is not found returns `def`.
+func parseAnnotationsBool(a map[string]string, key string, def bool) bool {
 	if v, ok := a[key]; ok {
-		yes := true
-		no := false
 		switch strings.ToLower(v) {
 		case "true":
-			return &yes
+			return true
 		case "false":
-			return &no
+			return false
 		default:
 			logrus.WithFields(logrus.Fields{
 				logfields.OCIAnnotation: key,
@@ -243,37 +241,67 @@ func parseAnnotationsBool(a map[string]string, key string) *bool {
 			}).Warning("annotation could not be parsed")
 		}
 	}
-	return nil
+	return def
+}
+
+// parseAnnotationsCPU searches `s.Annotations` for the CPU annotation. If
+// not found searches `s` for the Windows CPU section. If neither are found
+// returns `def`.
+func parseAnnotationsCPU(s *specs.Spec, annotation string, def int32) int32 {
+	if m := parseAnnotationsUint64(s.Annotations, annotation, 0); m != 0 {
+		return int32(m)
+	}
+	if s.Windows != nil &&
+		s.Windows.Resources != nil &&
+		s.Windows.Resources.CPU != nil &&
+		s.Windows.Resources.CPU.Count != nil &&
+		*s.Windows.Resources.CPU.Count > 0 {
+		return int32(*s.Windows.Resources.CPU.Count)
+	}
+	return def
+}
+
+// parseAnnotationsMemory searches `s.Annotations` for the memory annotation. If
+// not found searches `s` for the Windows memory section. If neither are found
+// returns `def`.
+func parseAnnotationsMemory(s *specs.Spec, annotation string, def int32) int32 {
+	if m := parseAnnotationsUint64(s.Annotations, annotation, 0); m != 0 {
+		return int32(m)
+	}
+	if s.Windows != nil &&
+		s.Windows.Resources != nil &&
+		s.Windows.Resources.Memory != nil &&
+		s.Windows.Resources.Memory.Limit != nil &&
+		*s.Windows.Resources.Memory.Limit > 0 {
+		return int32(*s.Windows.Resources.Memory.Limit)
+	}
+	return def
 }
 
 // parseAnnotationsPreferredRootFSType searches `a` for `key` and verifies that the
-// value is in the set of allowed values. If `key` is not found returns `nil`.
-// Otherwise returns the index at which it was found in allowed values.
-func parseAnnotationsPreferredRootFSType(a map[string]string, key string) *uvm.PreferredRootFSType {
+// value is in the set of allowed values. If `key` is not found returns `def`.
+func parseAnnotationsPreferredRootFSType(a map[string]string, key string, def uvm.PreferredRootFSType) uvm.PreferredRootFSType {
 	if v, ok := a[key]; ok {
-		// Following array must match enumeration uvm.PreferredRootFSType indexes
-		possibles := []string{"initrd", "vhd"}
-		for index, possible := range possibles {
-			if possible == v {
-				prfstype := uvm.PreferredRootFSType(index)
-				return &prfstype
-			}
+		switch v {
+		case "initrd":
+			return uvm.PreferredRootFSTypeInitRd
+		case "vhd":
+			return uvm.PreferredRootFSTypeVHD
+		default:
+			logrus.Warningf("annotation: '%s', with value: '%s' must be 'initrd' or 'vhd'", key, v)
 		}
-		logrus.Warningf("annotation: '%s', with value: '%s' must be one of %+v", key, v, possibles)
-		return nil
-
 	}
-	return nil
+	return def
 }
 
 // parseAnnotationsUint32 searches `a` for `key` and if found verifies that the
-// value is a 32 bit unsigned integer. If `key` is not found returns `nil`.
-func parseAnnotationsUint32(a map[string]string, key string) *uint32 {
+// value is a 32 bit unsigned integer. If `key` is not found returns `def`.
+func parseAnnotationsUint32(a map[string]string, key string, def uint32) uint32 {
 	if v, ok := a[key]; ok {
 		countu, err := strconv.ParseUint(v, 10, 32)
 		if err == nil {
 			v := uint32(countu)
-			return &v
+			return v
 		}
 		logrus.WithFields(logrus.Fields{
 			logfields.OCIAnnotation: key,
@@ -282,16 +310,16 @@ func parseAnnotationsUint32(a map[string]string, key string) *uint32 {
 			logrus.ErrorKey:         err,
 		}).Warning("annotation could not be parsed")
 	}
-	return nil
+	return def
 }
 
 // parseAnnotationsUint64 searches `a` for `key` and if found verifies that the
-// value is a 64 bit unsigned integer. If `key` is not found returns `nil`.
-func parseAnnotationsUint64(a map[string]string, key string) *uint64 {
+// value is a 64 bit unsigned integer. If `key` is not found returns `def`.
+func parseAnnotationsUint64(a map[string]string, key string, def uint64) uint64 {
 	if v, ok := a[key]; ok {
 		countu, err := strconv.ParseUint(v, 10, 64)
 		if err == nil {
-			return &countu
+			return countu
 		}
 		logrus.WithFields(logrus.Fields{
 			logfields.OCIAnnotation: key,
@@ -300,7 +328,7 @@ func parseAnnotationsUint64(a map[string]string, key string) *uint64 {
 			logrus.ErrorKey:         err,
 		}).Warning("annotation could not be parsed")
 	}
-	return nil
+	return def
 }
 
 // startVMShim starts a vm-shim command with the specified `opts`. `opts` can be `uvm.OptionsWCOW` or `uvm.OptionsLCOW`
@@ -468,7 +496,7 @@ func createContainer(cfg *containerConfig) (_ *container, err error) {
 		var opts interface{}
 
 		const (
-			annotationAllowOverCommit      = "io.microsoft.virtualmachine.computetopology.memory.allowovercommit"
+			annotationAllowOvercommit      = "io.microsoft.virtualmachine.computetopology.memory.allowovercommit"
 			annotationEnableDeferredCommit = "io.microsoft.virtualmachine.computetopology.memory.enabledeferredcommit"
 			annotationMemorySizeInMB       = "io.microsoft.virtualmachine.computetopology.memory.sizeinmb"
 			annotationProcessorCount       = "io.microsoft.virtualmachine.computetopology.processor.count"
@@ -477,41 +505,30 @@ func createContainer(cfg *containerConfig) (_ *container, err error) {
 			annotationPreferredRootFSType  = "io.microsoft.virtualmachine.lcow.preferredrootfstype"
 		)
 
-		bothOpts := &uvm.Options{
-			ID:                   vmID(c.ID),
-			Owner:                cfg.Owner,
-			AllowOvercommit:      parseAnnotationsBool(cfg.Spec.Annotations, annotationAllowOverCommit),
-			EnableDeferredCommit: parseAnnotationsBool(cfg.Spec.Annotations, annotationEnableDeferredCommit),
-		}
-
-		// If the Resources section of the config specified mem/cpu set it now.
-		if cfg.Spec.Windows != nil && cfg.Spec.Windows.Resources != nil {
-			if cfg.Spec.Windows.Resources.Memory != nil && cfg.Spec.Windows.Resources.Memory.Limit != nil {
-				bothOpts.MemorySizeInMB = int32(*cfg.Spec.Windows.Resources.Memory.Limit / 1024 / 1024)
-			}
-			if cfg.Spec.Windows.Resources.CPU != nil && cfg.Spec.Windows.Resources.CPU.Count != nil {
-				bothOpts.ProcessorCount = int32(*cfg.Spec.Windows.Resources.CPU.Count)
-			}
-		}
-		// Allow overrides of any mem/cpu annotations
-		memSize := parseAnnotationsUint64(cfg.Spec.Annotations, annotationMemorySizeInMB)
-		if memSize != nil {
-			bothOpts.MemorySizeInMB = int32(*memSize)
-		}
-		cpuCount := parseAnnotationsUint64(cfg.Spec.Annotations, annotationProcessorCount)
-		if cpuCount != nil {
-			bothOpts.ProcessorCount = int32(*cpuCount)
-		}
-
 		if cfg.Spec.Linux != nil {
-			opts = &uvm.OptionsLCOW{
-				Options:             bothOpts,
-				ConsolePipe:         cfg.VMConsolePipe,
-				VPMemDeviceCount:    parseAnnotationsUint32(cfg.Spec.Annotations, annotationVPMemCount),
-				VPMemSizeBytes:      parseAnnotationsUint64(cfg.Spec.Annotations, annotationVPMemSize),
-				PreferredRootFSType: parseAnnotationsPreferredRootFSType(cfg.Spec.Annotations, annotationPreferredRootFSType),
+			lopts := uvm.NewDefaultOptionsLCOW(vmID(c.ID), cfg.Owner)
+			lopts.MemorySizeInMB = parseAnnotationsMemory(cfg.Spec, annotationMemorySizeInMB, lopts.MemorySizeInMB)
+			lopts.AllowOvercommit = parseAnnotationsBool(cfg.Spec.Annotations, annotationAllowOvercommit, lopts.AllowOvercommit)
+			lopts.EnableDeferredCommit = parseAnnotationsBool(cfg.Spec.Annotations, annotationEnableDeferredCommit, lopts.EnableDeferredCommit)
+			lopts.ProcessorCount = parseAnnotationsCPU(cfg.Spec, annotationProcessorCount, lopts.ProcessorCount)
+			lopts.ConsolePipe = cfg.VMConsolePipe
+			lopts.VPMemDeviceCount = parseAnnotationsUint32(cfg.Spec.Annotations, annotationVPMemCount, lopts.VPMemDeviceCount)
+			lopts.VPMemSizeBytes = parseAnnotationsUint64(cfg.Spec.Annotations, annotationVPMemSize, lopts.VPMemSizeBytes)
+			lopts.PreferredRootFSType = parseAnnotationsPreferredRootFSType(cfg.Spec.Annotations, annotationPreferredRootFSType, lopts.PreferredRootFSType)
+			switch lopts.PreferredRootFSType {
+			case uvm.PreferredRootFSTypeInitRd:
+				lopts.RootFSFile = uvm.InitrdFile
+			case uvm.PreferredRootFSTypeVHD:
+				lopts.RootFSFile = uvm.VhdFile
 			}
+			opts = lopts
 		} else {
+			wopts := uvm.NewDefaultOptionsWCOW(vmID(c.ID), cfg.Owner)
+			wopts.MemorySizeInMB = parseAnnotationsMemory(cfg.Spec, annotationMemorySizeInMB, wopts.MemorySizeInMB)
+			wopts.AllowOvercommit = parseAnnotationsBool(cfg.Spec.Annotations, annotationAllowOvercommit, wopts.AllowOvercommit)
+			wopts.EnableDeferredCommit = parseAnnotationsBool(cfg.Spec.Annotations, annotationEnableDeferredCommit, wopts.EnableDeferredCommit)
+			wopts.ProcessorCount = parseAnnotationsCPU(cfg.Spec, annotationProcessorCount, wopts.ProcessorCount)
+
 			// In order for the UVM sandbox.vhdx not to collide with the actual
 			// nested Argon sandbox.vhdx we append the \vm folder to the last entry
 			// in the list.
@@ -526,10 +543,8 @@ func createContainer(cfg *containerConfig) (_ *container, err error) {
 			}
 			layers[layersLen-1] = vmPath
 
-			opts = &uvm.OptionsWCOW{
-				Options:      bothOpts,
-				LayerFolders: layers,
-			}
+			wopts.LayerFolders = layers
+			opts = wopts
 		}
 
 		shim, err := c.startVMShim(cfg.VMLogFile, opts)

+ 3 - 8
vendor/github.com/Microsoft/hcsshim/cmd/runhcs/create-scratch.go

@@ -36,7 +36,7 @@ var createScratchCommand = cli.Command{
 				Options: gcsclient.Options{
 					KirdPath:   filepath.Join(os.Getenv("ProgramFiles"), "Linux Containers"),
 					KernelFile: "kernel",
-					InitrdFile: "initrd.img",
+					InitrdFile: uvm.InitrdFile,
 				},
 				Name:              "createscratch-uvm",
 				UvmTimeoutSeconds: 5 * 60, // 5 Min
@@ -51,13 +51,8 @@ var createScratchCommand = cli.Command{
 				return errors.Wrapf(err, "failed to create ext4vhdx for '%s'", cfg.Name)
 			}
 		} else {
-			opts := uvm.OptionsLCOW{
-				Options: &uvm.Options{
-					ID:    "createscratch-uvm",
-					Owner: context.GlobalString("owner"),
-				},
-			}
-			convertUVM, err := uvm.CreateLCOW(&opts)
+			opts := uvm.NewDefaultOptionsLCOW("createscratch-uvm", context.GlobalString("owner"))
+			convertUVM, err := uvm.CreateLCOW(opts)
 			if err != nil {
 				return errors.Wrapf(err, "failed to create '%s'", opts.ID)
 			}

+ 29 - 2
vendor/github.com/Microsoft/hcsshim/cmd/runhcs/kill.go

@@ -116,6 +116,9 @@ func validateSigstr(sigstr string, signalsSupported bool, isLcow bool) (int, err
 	sigstr = strings.ToUpper(sigstr)
 
 	if !signalsSupported {
+		// If signals arent supported we just validate that its a known signal.
+		// We already return 0 since we only supported a platform Kill() at that
+		// time.
 		if isLcow {
 			switch sigstr {
 			case "15":
@@ -123,19 +126,43 @@ func validateSigstr(sigstr string, signalsSupported bool, isLcow bool) (int, err
 			case "TERM":
 				fallthrough
 			case "SIGTERM":
-				return 0xf, nil
+				return 0, nil
 			default:
 				return 0, errInvalidSignal
 			}
 		}
 		switch sigstr {
+		// Docker sends a UNIX term in the supported Windows Signal map.
+		case "15":
+			fallthrough
+		case "TERM":
+			fallthrough
 		case "0":
 			fallthrough
 		case "CTRLC":
-			return 0x0, nil
+			return 0, nil
+		case "9":
+			fallthrough
+		case "KILL":
+			return 0, nil
 		default:
 			return 0, errInvalidSignal
 		}
+	} else {
+		if !isLcow {
+			// Docker sends the UNIX signal name or value. Convert them to the
+			// correct Windows signals.
+			switch sigstr {
+			case "15":
+				fallthrough
+			case "TERM":
+				return 0x0, nil // Convert to CTRLC
+			case "9":
+				fallthrough
+			case "KILL":
+				return 0x6, nil // Convert to CTRLSHUTDOWN
+			}
+		}
 	}
 
 	var sigmap map[string]int

+ 35 - 15
vendor/github.com/Microsoft/hcsshim/cmd/runhcs/kill_test.go

@@ -24,35 +24,39 @@ func runValidateSigstrTest(sigstr string, signalsSupported, isLcow bool,
 	}
 }
 
-func TestValidateSigstrEmpty(t *testing.T) {
+func Test_ValidateSigstr_Empty(t *testing.T) {
 	runValidateSigstrTest("", false, false, 0, false, t)
 	runValidateSigstrTest("", false, true, 0xf, false, t)
 	runValidateSigstrTest("", true, false, 0, false, t)
 	runValidateSigstrTest("", true, true, 0xf, false, t)
 }
 
-func TestValidateSigstrDefaultLCOW(t *testing.T) {
-	runValidateSigstrTest("15", false, true, 0xf, false, t)
-	runValidateSigstrTest("TERM", false, true, 0xf, false, t)
-	runValidateSigstrTest("SIGTERM", false, true, 0xf, false, t)
+func Test_ValidateSigstr_LCOW_NoSignalSupport_Default(t *testing.T) {
+	runValidateSigstrTest("15", false, true, 0, false, t)
+	runValidateSigstrTest("TERM", false, true, 0, false, t)
+	runValidateSigstrTest("SIGTERM", false, true, 0, false, t)
 }
 
-func TestValidateSigstrDefaultLCOWInvalid(t *testing.T) {
+func Test_ValidateSigstr_LCOW_NoSignalSupport_Default_Invalid(t *testing.T) {
 	runValidateSigstrTest("2", false, true, 0, true, t)
 	runValidateSigstrTest("test", false, true, 0, true, t)
 }
 
-func TestValidateSigstrDefaultWCOW(t *testing.T) {
-	runValidateSigstrTest("0", false, false, 0x0, false, t)
-	runValidateSigstrTest("CTRLC", false, false, 0x0, false, t)
+func Test_ValidateSigstr_WCOW_NoSignalSupport_Default(t *testing.T) {
+	runValidateSigstrTest("15", false, false, 0, false, t)
+	runValidateSigstrTest("TERM", false, false, 0, false, t)
+	runValidateSigstrTest("0", false, false, 0, false, t)
+	runValidateSigstrTest("CTRLC", false, false, 0, false, t)
+	runValidateSigstrTest("9", false, false, 0, false, t)
+	runValidateSigstrTest("KILL", false, false, 0, false, t)
 }
 
-func TestValidateSigstrDefaultWCOWInvalid(t *testing.T) {
-	runValidateSigstrTest("15", false, false, 0, true, t)
+func Test_ValidateSigstr_WCOW_NoSignalSupport_Default_Invalid(t *testing.T) {
+	runValidateSigstrTest("2", false, false, 0, true, t)
 	runValidateSigstrTest("test", false, false, 0, true, t)
 }
 
-func TestValidateSignalStringLCOW(t *testing.T) {
+func Test_ValidateSigstr_LCOW_SignalSupport_SignalNames(t *testing.T) {
 	for k, v := range signalMapLcow {
 		runValidateSigstrTest(k, true, true, v, false, t)
 		// run it again with a case not in the map
@@ -64,7 +68,7 @@ func TestValidateSignalStringLCOW(t *testing.T) {
 	}
 }
 
-func TestValidateSignalStringWCOW(t *testing.T) {
+func Test_ValidateSigstr_WCOW_SignalSupport_SignalNames(t *testing.T) {
 	for k, v := range signalMapWindows {
 		runValidateSigstrTest(k, true, false, v, false, t)
 		// run it again with a case not in the map
@@ -76,16 +80,32 @@ func TestValidateSignalStringWCOW(t *testing.T) {
 	}
 }
 
-func TestValidateSignalValueLCOW(t *testing.T) {
+func Test_ValidateSigstr_LCOW_SignalSupport_SignalValues(t *testing.T) {
 	for _, v := range signalMapLcow {
 		str := strconv.Itoa(v)
 		runValidateSigstrTest(str, true, true, v, false, t)
 	}
 }
 
-func TestValidateSignalValueWCOW(t *testing.T) {
+func Test_ValidateSigstr_WCOW_SignalSupport_SignalValues(t *testing.T) {
 	for _, v := range signalMapWindows {
 		str := strconv.Itoa(v)
 		runValidateSigstrTest(str, true, false, v, false, t)
 	}
 }
+
+func Test_ValidateSigstr_WCOW_SignalSupport_Docker_SignalNames(t *testing.T) {
+	// Docker KILL -> CTRLSHUTDOWN when signals are supported
+	runValidateSigstrTest("KILL", true, false, 0x6, false, t)
+
+	// Docker TERM -> CTRLSHUTDOWN when signals are supported
+	runValidateSigstrTest("TERM", true, false, 0x0, false, t)
+}
+
+func Test_ValidateSigstr_WCOW_SignalSupport_Docker_SignalValues(t *testing.T) {
+	// Docker KILL -> CTRLSHUTDOWN when signals are supported
+	runValidateSigstrTest("9", true, false, 0x6, false, t)
+
+	// Docker TERM -> CTRLSHUTDOWN when signals are supported
+	runValidateSigstrTest("15", true, false, 0x0, false, t)
+}

+ 9 - 1
vendor/github.com/Microsoft/hcsshim/cmd/runhcs/main.go

@@ -7,6 +7,7 @@ import (
 	"strings"
 
 	"github.com/Microsoft/go-winio"
+	"github.com/Microsoft/go-winio/pkg/etwlogrus"
 	"github.com/Microsoft/hcsshim/internal/regstate"
 	"github.com/Microsoft/hcsshim/internal/runhcs"
 	"github.com/opencontainers/runtime-spec/specs-go"
@@ -50,6 +51,14 @@ Where "<container-id>" is your name for the instance of the container that you a
 )
 
 func main() {
+	// Provider ID: 0b52781f-b24d-5685-ddf6-69830ed40ec3
+	// Hook isn't closed explicitly, as it will exist until process exit.
+	if hook, err := etwlogrus.NewHook("Microsoft.Virtualization.RunHCS"); err == nil {
+		logrus.AddHook(hook)
+	} else {
+		logrus.Error(err)
+	}
+
 	app := cli.NewApp()
 	app.Name = "runhcs"
 	app.Usage = usage
@@ -148,7 +157,6 @@ func main() {
 	fatalWriter.Writer = cli.ErrWriter
 	cli.ErrWriter = &fatalWriter
 	if err := app.Run(os.Args); err != nil {
-		logrus.Error(err)
 		fmt.Fprintln(cli.ErrWriter, err)
 		os.Exit(1)
 	}

+ 0 - 120
vendor/github.com/Microsoft/hcsshim/cmd/runhcs/tar2vhd.go

@@ -1,120 +0,0 @@
-package main
-
-import (
-	"io"
-	"os"
-	"path/filepath"
-
-	"github.com/Microsoft/hcsshim/internal/appargs"
-	"github.com/Microsoft/hcsshim/internal/lcow"
-	"github.com/Microsoft/hcsshim/internal/osversion"
-	"github.com/Microsoft/hcsshim/internal/uvm"
-	"github.com/Microsoft/hcsshim/internal/wclayer"
-	gcsclient "github.com/Microsoft/opengcs/client"
-	"github.com/pkg/errors"
-	"github.com/sirupsen/logrus"
-	"github.com/urfave/cli"
-)
-
-var tarToVhdCommand = cli.Command{
-	Name:        "tar2vhd",
-	Usage:       "converts a tar over stdin to a vhd at 'destpath'",
-	Description: "The tar2vhd command converts the tar at ('sourcepath'|stdin) to a vhd at 'destpath'",
-	Flags: []cli.Flag{
-		cli.StringFlag{
-			Name:  "sourcepath",
-			Usage: "Optional: describes the path to the tar on disk",
-		},
-		cli.StringFlag{
-			Name:  "scratchpath",
-			Usage: "Required: describes the path to the scratch.vhdx file to use for the transformation",
-		},
-		cli.StringFlag{
-			Name:  "destpath",
-			Usage: "Required: describes the destination vhd path to write the contents of the tar to on disk",
-		},
-	},
-	Before: appargs.Validate(),
-	Action: func(context *cli.Context) error {
-		var rdr io.Reader
-		if src := context.String("sourcepath"); src != "" {
-			// Source is via file path not stdin
-			f, err := os.OpenFile(src, os.O_RDONLY, 0)
-			if err != nil {
-				return errors.Wrapf(err, "failed to open 'sourcepath': '%s'", src)
-			}
-			defer f.Close()
-			rdr = f
-		} else {
-			rdr = os.Stdin
-		}
-
-		scratch := context.String("scratchpath")
-		if scratch == "" {
-			return errors.New("'scratchpath' is required")
-		}
-
-		dest := context.String("destpath")
-		if dest == "" {
-			return errors.New("'destpath' is required")
-		}
-
-		// If we only have v1 lcow support do it the old way.
-		if osversion.Get().Build < osversion.RS5 {
-			cfg := gcsclient.Config{
-				Options: gcsclient.Options{
-					KirdPath:   filepath.Join(os.Getenv("ProgramFiles"), "Linux Containers"),
-					KernelFile: "kernel",
-					InitrdFile: "initrd.img",
-				},
-				Name:              "tar2vhd-uvm",
-				UvmTimeoutSeconds: 5 * 60, // 5 Min
-			}
-
-			if err := cfg.StartUtilityVM(); err != nil {
-				return errors.Wrapf(err, "failed to start '%s'", cfg.Name)
-			}
-			defer cfg.Uvm.Terminate()
-
-			if err := cfg.HotAddVhd(scratch, "/tmp/scratch", false, true); err != nil {
-				return errors.Wrapf(err, "failed to mount scratch path: '%s' to '%s'", scratch, cfg.Name)
-			}
-
-			n, err := cfg.TarToVhd(dest, rdr)
-			if err != nil {
-				return errors.Wrapf(err, "failed to convert tar2vhd for '%s'", cfg.Name)
-			}
-
-			logrus.Debugf("wrote %v bytes to %s", n, dest)
-		} else {
-			opts := uvm.UVMOptions{
-				ID:              "tar2vhd-uvm",
-				OperatingSystem: "linux",
-			}
-			convertUVM, err := uvm.Create(&opts)
-			if err != nil {
-				return errors.Wrapf(err, "failed to create '%s'", opts.ID)
-			}
-			if err := convertUVM.Start(); err != nil {
-				return errors.Wrapf(err, "failed to start '%s'", opts.ID)
-			}
-			defer convertUVM.Terminate()
-
-			if err := wclayer.GrantVmAccess(opts.ID, scratch); err != nil {
-				return errors.Wrapf(err, "failed to grant access to scratch path: '%s' to '%s'", scratch, opts.ID)
-			}
-			if _, _, err := convertUVM.AddSCSI(scratch, "/tmp/scratch"); err != nil {
-				return errors.Wrapf(err, "failed to mount scratch path: '%s' to '%s'", scratch, opts.ID)
-			}
-
-			n, err := lcow.TarToVhd(convertUVM, dest, rdr)
-			if err != nil {
-				return errors.Wrapf(err, "failed to convert tar2vhd for '%s'", opts.ID)
-			}
-
-			logrus.Debugf("wrote %v bytes to %s", n, dest)
-		}
-
-		return nil
-	},
-}

+ 0 - 3
vendor/github.com/Microsoft/hcsshim/functional/manifest.go

@@ -1,3 +0,0 @@
-package functional
-
-import _ "github.com/Microsoft/hcsshim/functional/manifest"

+ 27 - 0
vendor/github.com/Microsoft/hcsshim/hcn/hcn.go

@@ -134,6 +134,33 @@ func V2SchemaVersion() SchemaVersion {
 	}
 }
 
+// RemoteSubnetSupported returns an error if the HCN version does not support Remote Subnet policies.
+func RemoteSubnetSupported() error {
+	supported := GetSupportedFeatures()
+	if supported.RemoteSubnet {
+		return nil
+	}
+	return platformDoesNotSupportError("Remote Subnet")
+}
+
+// HostRouteSupported returns an error if the HCN version does not support Host Route policies.
+func HostRouteSupported() error {
+	supported := GetSupportedFeatures()
+	if supported.HostRoute {
+		return nil
+	}
+	return platformDoesNotSupportError("Host Route")
+}
+
+// DSRSupported returns an error if the HCN version does not support Direct Server Return.
+func DSRSupported() error {
+	supported := GetSupportedFeatures()
+	if supported.DSR {
+		return nil
+	}
+	return platformDoesNotSupportError("Direct Server Return (DSR)")
+}
+
 // RequestType are the different operations performed to settings.
 // Used to update the settings of Endpoint/Namespace objects.
 type RequestType string

+ 3 - 3
vendor/github.com/Microsoft/hcsshim/hcn/hcnendpoint.go

@@ -313,13 +313,13 @@ func (endpoint *HostComputeEndpoint) Create() (*HostComputeEndpoint, error) {
 }
 
 // Delete Endpoint.
-func (endpoint *HostComputeEndpoint) Delete() (*HostComputeEndpoint, error) {
+func (endpoint *HostComputeEndpoint) Delete() error {
 	logrus.Debugf("hcn::HostComputeEndpoint::Delete id=%s", endpoint.Id)
 
 	if err := deleteEndpoint(endpoint.Id); err != nil {
-		return nil, err
+		return err
 	}
-	return nil, nil
+	return nil
 }
 
 // ModifyEndpointSettings updates the Port/Policy of an Endpoint.

+ 19 - 19
vendor/github.com/Microsoft/hcsshim/hcn/hcnendpoint_test.go

@@ -23,11 +23,11 @@ func TestCreateDeleteEndpoint(t *testing.T) {
 	}
 	fmt.Printf("Endpoint JSON:\n%s \n", jsonString)
 
-	_, err = Endpoint.Delete()
+	err = Endpoint.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
-	_, err = network.Delete()
+	err = network.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -51,11 +51,11 @@ func TestGetEndpointById(t *testing.T) {
 		t.Fatal("No Endpoint found")
 	}
 
-	_, err = foundEndpoint.Delete()
+	err = foundEndpoint.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
-	_, err = network.Delete()
+	err = network.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -79,11 +79,11 @@ func TestGetEndpointByName(t *testing.T) {
 		t.Fatal("No Endpoint found")
 	}
 
-	_, err = foundEndpoint.Delete()
+	err = foundEndpoint.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
-	_, err = network.Delete()
+	err = network.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -107,11 +107,11 @@ func TestListEndpoints(t *testing.T) {
 		t.Fatal("No Endpoint found")
 	}
 
-	_, err = Endpoint.Delete()
+	err = Endpoint.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
-	_, err = network.Delete()
+	err = network.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -135,11 +135,11 @@ func TestListEndpointsOfNetwork(t *testing.T) {
 		t.Fatal("No Endpoint found")
 	}
 
-	_, err = Endpoint.Delete()
+	err = Endpoint.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
-	_, err = network.Delete()
+	err = network.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -168,15 +168,15 @@ func TestEndpointNamespaceAttachDetach(t *testing.T) {
 		t.Fatal(err)
 	}
 
-	_, err = namespace.Delete()
+	err = namespace.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
-	_, err = endpoint.Delete()
+	err = endpoint.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
-	_, err = network.Delete()
+	err = network.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -199,11 +199,11 @@ func TestCreateEndpointWithNamespace(t *testing.T) {
 		t.Fatal("No Namespace detected.")
 	}
 
-	_, err = Endpoint.Delete()
+	err = Endpoint.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
-	_, err = network.Delete()
+	err = network.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -240,11 +240,11 @@ func TestApplyPolicyOnEndpoint(t *testing.T) {
 		t.Fatal("No Endpoint Policies found")
 	}
 
-	_, err = Endpoint.Delete()
+	err = Endpoint.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
-	_, err = network.Delete()
+	err = network.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -287,11 +287,11 @@ func TestModifyEndpointSettings(t *testing.T) {
 		t.Fatal("No Endpoint Policies found")
 	}
 
-	_, err = endpoint.Delete()
+	err = endpoint.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
-	_, err = network.Delete()
+	err = network.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}

+ 6 - 0
vendor/github.com/Microsoft/hcsshim/hcn/hcnglobals.go

@@ -25,6 +25,12 @@ var (
 	HNSVersion1803 = Version{Major: 7, Minor: 2}
 	// V2ApiSupport allows the use of V2 Api calls and V2 Schema.
 	V2ApiSupport = Version{Major: 9, Minor: 1}
+	// Remote Subnet allows for Remote Subnet policies on Overlay networks
+	RemoteSubnetVersion = Version{Major: 9, Minor: 2}
+	// A Host Route policy allows for local container to local host communication Overlay networks
+	HostRouteVersion = Version{Major: 9, Minor: 2}
+	// HNS 10.2 allows for Direct Server Return for loadbalancing
+	DSRVersion = Version{Major: 10, Minor: 2}
 )
 
 // GetGlobals returns the global properties of the HCN Service.

+ 39 - 25
vendor/github.com/Microsoft/hcsshim/hcn/hcnloadbalancer.go

@@ -10,10 +10,10 @@ import (
 
 // LoadBalancerPortMapping is associated with HostComputeLoadBalancer
 type LoadBalancerPortMapping struct {
-	Protocol     uint32 `json:",omitempty"` // EX: TCP = 6, UDP = 17
-	InternalPort uint16 `json:",omitempty"`
-	ExternalPort uint16 `json:",omitempty"`
-	Flags        uint32 `json:",omitempty"` // 0: None, 1: EnableILB, 2: LocalRoutedVip
+	Protocol     uint32                       `json:",omitempty"` // EX: TCP = 6, UDP = 17
+	InternalPort uint16                       `json:",omitempty"`
+	ExternalPort uint16                       `json:",omitempty"`
+	Flags        LoadBalancerPortMappingFlags `json:",omitempty"`
 }
 
 // HostComputeLoadBalancer represents software load balancer.
@@ -24,9 +24,35 @@ type HostComputeLoadBalancer struct {
 	FrontendVIPs         []string                  `json:",omitempty"`
 	PortMappings         []LoadBalancerPortMapping `json:",omitempty"`
 	SchemaVersion        SchemaVersion             `json:",omitempty"`
-	Flags                uint32                    `json:",omitempty"` // 0: None, 1: EnableDirectServerReturn
+	Flags                LoadBalancerFlags         `json:",omitempty"` // 0: None, 1: EnableDirectServerReturn
 }
 
+//LoadBalancerFlags modify settings for a loadbalancer.
+type LoadBalancerFlags uint32
+
+var (
+	// LoadBalancerFlagsNone is the default.
+	LoadBalancerFlagsNone LoadBalancerFlags = 0
+	// LoadBalancerFlagsDSR enables Direct Server Return (DSR)
+	LoadBalancerFlagsDSR LoadBalancerFlags = 1
+)
+
+// LoadBalancerPortMappingFlags are special settings on a loadbalancer.
+type LoadBalancerPortMappingFlags uint32
+
+var (
+	// LoadBalancerPortMappingFlagsNone is the default.
+	LoadBalancerPortMappingFlagsNone LoadBalancerPortMappingFlags
+	// LoadBalancerPortMappingFlagsILB enables internal loadbalancing.
+	LoadBalancerPortMappingFlagsILB LoadBalancerPortMappingFlags = 1
+	// LoadBalancerPortMappingFlagsLocalRoutedVIP enables VIP access from the host.
+	LoadBalancerPortMappingFlagsLocalRoutedVIP LoadBalancerPortMappingFlags = 2
+	// LoadBalancerPortMappingFlagsUseMux enables DSR for NodePort access of VIP.
+	LoadBalancerPortMappingFlagsUseMux LoadBalancerPortMappingFlags = 4
+	// LoadBalancerPortMappingFlagsPreserveDIP delivers packets with destination IP as the VIP.
+	LoadBalancerPortMappingFlagsPreserveDIP LoadBalancerPortMappingFlags = 8
+)
+
 func getLoadBalancer(loadBalancerGuid guid.GUID, query string) (*HostComputeLoadBalancer, error) {
 	// Open loadBalancer.
 	var (
@@ -234,20 +260,20 @@ func (loadBalancer *HostComputeLoadBalancer) Create() (*HostComputeLoadBalancer,
 }
 
 // Delete LoadBalancer.
-func (loadBalancer *HostComputeLoadBalancer) Delete() (*HostComputeLoadBalancer, error) {
+func (loadBalancer *HostComputeLoadBalancer) Delete() error {
 	logrus.Debugf("hcn::HostComputeLoadBalancer::Delete id=%s", loadBalancer.Id)
 
 	if err := deleteLoadBalancer(loadBalancer.Id); err != nil {
-		return nil, err
+		return err
 	}
-	return nil, nil
+	return nil
 }
 
 // AddEndpoint add an endpoint to a LoadBalancer
 func (loadBalancer *HostComputeLoadBalancer) AddEndpoint(endpoint *HostComputeEndpoint) (*HostComputeLoadBalancer, error) {
 	logrus.Debugf("hcn::HostComputeLoadBalancer::AddEndpoint loadBalancer=%s endpoint=%s", loadBalancer.Id, endpoint.Id)
 
-	_, err := loadBalancer.Delete()
+	err := loadBalancer.Delete()
 	if err != nil {
 		return nil, err
 	}
@@ -262,7 +288,7 @@ func (loadBalancer *HostComputeLoadBalancer) AddEndpoint(endpoint *HostComputeEn
 func (loadBalancer *HostComputeLoadBalancer) RemoveEndpoint(endpoint *HostComputeEndpoint) (*HostComputeLoadBalancer, error) {
 	logrus.Debugf("hcn::HostComputeLoadBalancer::RemoveEndpoint loadBalancer=%s endpoint=%s", loadBalancer.Id, endpoint.Id)
 
-	_, err := loadBalancer.Delete()
+	err := loadBalancer.Delete()
 	if err != nil {
 		return nil, err
 	}
@@ -280,20 +306,8 @@ func (loadBalancer *HostComputeLoadBalancer) RemoveEndpoint(endpoint *HostComput
 }
 
 // AddLoadBalancer for the specified endpoints
-func AddLoadBalancer(endpoints []HostComputeEndpoint, isILB bool, isDSR bool, sourceVIP string, frontendVIPs []string, protocol uint16, internalPort uint16, externalPort uint16) (*HostComputeLoadBalancer, error) {
-	logrus.Debugf("hcn::HostComputeLoadBalancer::AddLoadBalancer endpointId=%v, isILB=%v, sourceVIP=%s, frontendVIPs=%v, protocol=%v, internalPort=%v, externalPort=%v", endpoints, isILB, sourceVIP, frontendVIPs, protocol, internalPort, externalPort)
-
-	var portMappingFlags uint32
-	portMappingFlags = 0
-	if isILB {
-		portMappingFlags = 1
-	}
-
-	var lbFlags uint32
-	lbFlags = 0
-	if isDSR {
-		lbFlags = 1 // EnableDirectServerReturn
-	}
+func AddLoadBalancer(endpoints []HostComputeEndpoint, flags LoadBalancerFlags, portMappingFlags LoadBalancerPortMappingFlags, sourceVIP string, frontendVIPs []string, protocol uint16, internalPort uint16, externalPort uint16) (*HostComputeLoadBalancer, error) {
+	logrus.Debugf("hcn::HostComputeLoadBalancer::AddLoadBalancer endpointId=%v, LoadBalancerFlags=%v, LoadBalancerPortMappingFlags=%v, sourceVIP=%s, frontendVIPs=%v, protocol=%v, internalPort=%v, externalPort=%v", endpoints, flags, portMappingFlags, sourceVIP, frontendVIPs, protocol, internalPort, externalPort)
 
 	loadBalancer := &HostComputeLoadBalancer{
 		SourceVIP: sourceVIP,
@@ -310,7 +324,7 @@ func AddLoadBalancer(endpoints []HostComputeEndpoint, isILB bool, isDSR bool, so
 			Major: 2,
 			Minor: 0,
 		},
-		Flags: lbFlags,
+		Flags: flags,
 	}
 
 	for _, endpoint := range endpoints {

+ 39 - 22
vendor/github.com/Microsoft/hcsshim/hcn/hcnloadbalancer_test.go

@@ -27,15 +27,15 @@ func TestCreateDeleteLoadBalancer(t *testing.T) {
 	}
 	fmt.Printf("LoadBalancer JSON:\n%s \n", jsonString)
 
-	_, err = loadBalancer.Delete()
+	err = loadBalancer.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
-	_, err = endpoint.Delete()
+	err = endpoint.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
-	_, err = network.Delete()
+	err = network.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -61,15 +61,15 @@ func TestGetLoadBalancerById(t *testing.T) {
 	if foundLB == nil {
 		t.Fatalf("No loadBalancer found")
 	}
-	_, err = loadBalancer.Delete()
+	err = loadBalancer.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
-	_, err = endpoint.Delete()
+	err = endpoint.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
-	_, err = network.Delete()
+	err = network.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -116,19 +116,19 @@ func TestLoadBalancerAddRemoveEndpoint(t *testing.T) {
 		t.Fatalf("Endpoint not removed from loadBalancer")
 	}
 
-	_, err = loadBalancer.Delete()
+	err = loadBalancer.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
-	_, err = secondEndpoint.Delete()
+	err = secondEndpoint.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
-	_, err = endpoint.Delete()
+	err = endpoint.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
-	_, err = network.Delete()
+	err = network.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -144,7 +144,7 @@ func TestAddLoadBalancer(t *testing.T) {
 		t.Fatal(err)
 	}
 
-	loadBalancer, err := AddLoadBalancer([]HostComputeEndpoint{*endpoint}, false, false, "10.0.0.1", []string{"1.1.1.2", "1.1.1.3"}, 6, 8080, 80)
+	loadBalancer, err := AddLoadBalancer([]HostComputeEndpoint{*endpoint}, LoadBalancerFlagsNone, LoadBalancerPortMappingFlagsNone, "10.0.0.1", []string{"1.1.1.2", "1.1.1.3"}, 6, 8080, 80)
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -156,15 +156,15 @@ func TestAddLoadBalancer(t *testing.T) {
 		t.Fatal(fmt.Errorf("No loadBalancer found"))
 	}
 
-	_, err = loadBalancer.Delete()
+	err = loadBalancer.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
-	_, err = endpoint.Delete()
+	err = endpoint.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
-	_, err = network.Delete()
+	err = network.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -180,7 +180,8 @@ func TestAddDSRLoadBalancer(t *testing.T) {
 		t.Fatal(err)
 	}
 
-	loadBalancer, err := AddLoadBalancer([]HostComputeEndpoint{*endpoint}, false, true, "10.0.0.1", []string{"1.1.1.2", "1.1.1.3"}, 6, 8080, 80)
+	portMappings := LoadBalancerPortMappingFlagsPreserveDIP | LoadBalancerPortMappingFlagsUseMux
+	loadBalancer, err := AddLoadBalancer([]HostComputeEndpoint{*endpoint}, LoadBalancerFlagsDSR, portMappings, "10.0.0.1", []string{"1.1.1.2", "1.1.1.3"}, 6, 8080, 80)
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -191,16 +192,27 @@ func TestAddDSRLoadBalancer(t *testing.T) {
 	if foundLB == nil {
 		t.Fatal(fmt.Errorf("No loadBalancer found"))
 	}
+	if foundLB.Flags != 1 {
+		t.Fatal(fmt.Errorf("IsDSR is not set"))
+	}
+
+	foundFlags := foundLB.PortMappings[0].Flags
+	if foundFlags&LoadBalancerPortMappingFlagsUseMux == 0 {
+		t.Fatal(fmt.Errorf("UseMux is not set"))
+	}
+	if foundFlags&LoadBalancerPortMappingFlagsPreserveDIP == 0 {
+		t.Fatal(fmt.Errorf("PreserveDIP is not set"))
+	}
 
-	_, err = loadBalancer.Delete()
+	err = loadBalancer.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
-	_, err = endpoint.Delete()
+	err = endpoint.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
-	_, err = network.Delete()
+	err = network.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -216,7 +228,7 @@ func TestAddILBLoadBalancer(t *testing.T) {
 		t.Fatal(err)
 	}
 
-	loadBalancer, err := AddLoadBalancer([]HostComputeEndpoint{*endpoint}, true, false, "10.0.0.1", []string{"1.1.1.2", "1.1.1.3"}, 6, 8080, 80)
+	loadBalancer, err := AddLoadBalancer([]HostComputeEndpoint{*endpoint}, LoadBalancerFlagsNone, LoadBalancerPortMappingFlagsILB, "10.0.0.1", []string{"1.1.1.2", "1.1.1.3"}, 6, 8080, 80)
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -228,15 +240,20 @@ func TestAddILBLoadBalancer(t *testing.T) {
 		t.Fatal(fmt.Errorf("No loadBalancer found"))
 	}
 
-	_, err = loadBalancer.Delete()
+	foundFlags := foundLB.PortMappings[0].Flags
+	if foundFlags&LoadBalancerPortMappingFlagsILB == 0 {
+		t.Fatal(fmt.Errorf("Loadbalancer is not ILB"))
+	}
+
+	err = loadBalancer.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
-	_, err = endpoint.Delete()
+	err = endpoint.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
-	_, err = network.Delete()
+	err = network.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}

+ 3 - 3
vendor/github.com/Microsoft/hcsshim/hcn/hcnnamespace.go

@@ -308,13 +308,13 @@ func (namespace *HostComputeNamespace) Create() (*HostComputeNamespace, error) {
 }
 
 // Delete Namespace.
-func (namespace *HostComputeNamespace) Delete() (*HostComputeNamespace, error) {
+func (namespace *HostComputeNamespace) Delete() error {
 	logrus.Debugf("hcn::HostComputeNamespace::Delete id=%s", namespace.Id)
 
 	if err := deleteNamespace(namespace.Id); err != nil {
-		return nil, err
+		return err
 	}
-	return nil, nil
+	return nil
 }
 
 // Sync Namespace endpoints with the appropriate sandbox container holding the

+ 20 - 20
vendor/github.com/Microsoft/hcsshim/hcn/hcnnamespace_test.go

@@ -30,7 +30,7 @@ func TestCreateDeleteNamespace(t *testing.T) {
 	}
 	fmt.Printf("Namespace JSON:\n%s \n", jsonString)
 
-	_, err = namespace.Delete()
+	err = namespace.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -50,7 +50,7 @@ func TestCreateDeleteNamespaceGuest(t *testing.T) {
 		t.Fatal(err)
 	}
 
-	_, err = hnsNamespace.Delete()
+	err = hnsNamespace.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -70,7 +70,7 @@ func TestGetNamespaceById(t *testing.T) {
 		t.Fatal("No namespace found")
 	}
 
-	_, err = namespace.Delete()
+	err = namespace.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -90,7 +90,7 @@ func TestListNamespaces(t *testing.T) {
 		t.Fatal("No Namespaces found")
 	}
 
-	_, err = namespace.Delete()
+	err = namespace.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -126,15 +126,15 @@ func TestGetNamespaceEndpointIds(t *testing.T) {
 		t.Fatal(err)
 	}
 
-	_, err = namespace.Delete()
+	err = namespace.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
-	_, err = endpoint.Delete()
+	err = endpoint.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
-	_, err = network.Delete()
+	err = network.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -154,7 +154,7 @@ func TestGetNamespaceContainers(t *testing.T) {
 		t.Fatal("Found containers when none should exist")
 	}
 
-	_, err = namespace.Delete()
+	err = namespace.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -190,15 +190,15 @@ func TestAddRemoveNamespaceEndpoint(t *testing.T) {
 		t.Fatal(err)
 	}
 
-	_, err = namespace.Delete()
+	err = namespace.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
-	_, err = endpoint.Delete()
+	err = endpoint.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
-	_, err = network.Delete()
+	err = network.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -245,15 +245,15 @@ func TestModifyNamespaceSettings(t *testing.T) {
 		t.Fatal(err)
 	}
 
-	_, err = namespace.Delete()
+	err = namespace.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
-	_, err = endpoint.Delete()
+	err = endpoint.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
-	_, err = network.Delete()
+	err = network.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -282,7 +282,7 @@ func TestSyncNamespaceHostDefault(t *testing.T) {
 		t.Fatal(err)
 	}
 
-	_, err = hnsNamespace.Delete()
+	err = hnsNamespace.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -309,7 +309,7 @@ func TestSyncNamespaceHost(t *testing.T) {
 		t.Fatal(err)
 	}
 
-	_, err = hnsNamespace.Delete()
+	err = hnsNamespace.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -336,7 +336,7 @@ func TestSyncNamespaceGuestNoReg(t *testing.T) {
 		t.Fatal(err)
 	}
 
-	_, err = hnsNamespace.Delete()
+	err = hnsNamespace.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -363,7 +363,7 @@ func TestSyncNamespaceGuestDefaultNoReg(t *testing.T) {
 		t.Fatal(err)
 	}
 
-	_, err = hnsNamespace.Delete()
+	err = hnsNamespace.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -404,7 +404,7 @@ func TestSyncNamespaceGuest(t *testing.T) {
 	if err != nil {
 		t.Fatal(err)
 	}
-	_, err = hnsNamespace.Delete()
+	err = hnsNamespace.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -444,7 +444,7 @@ func TestSyncNamespaceGuestDefault(t *testing.T) {
 	if err != nil {
 		t.Fatal(err)
 	}
-	_, err = hnsNamespace.Delete()
+	err = hnsNamespace.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}

+ 14 - 5
vendor/github.com/Microsoft/hcsshim/hcn/hcnnetwork.go

@@ -42,7 +42,7 @@ type MacPool struct {
 
 // Dns (Domain Name System is associated with a network.
 type Dns struct {
-	Suffix     string   `json:",omitempty"`
+	Domain     string   `json:",omitempty"`
 	Search     []string `json:",omitempty"`
 	ServerList []string `json:",omitempty"`
 	Options    []string `json:",omitempty"`
@@ -62,6 +62,15 @@ const (
 	Overlay     NetworkType = "Overlay"
 )
 
+// NetworkFlags are various network flags.
+type NetworkFlags uint32
+
+// NetworkFlags const
+const (
+	None                NetworkFlags = 0
+	EnableNonPersistent NetworkFlags = 8
+)
+
 // HostComputeNetwork represents a network
 type HostComputeNetwork struct {
 	Id            string          `json:"ID,omitempty"`
@@ -71,7 +80,7 @@ type HostComputeNetwork struct {
 	MacPool       MacPool         `json:",omitempty"`
 	Dns           Dns             `json:",omitempty"`
 	Ipams         []Ipam          `json:",omitempty"`
-	Flags         uint32          `json:",omitempty"` // 0: None
+	Flags         NetworkFlags    `json:",omitempty"` // 0: None
 	SchemaVersion SchemaVersion   `json:",omitempty"`
 }
 
@@ -326,13 +335,13 @@ func (network *HostComputeNetwork) Create() (*HostComputeNetwork, error) {
 }
 
 // Delete Network.
-func (network *HostComputeNetwork) Delete() (*HostComputeNetwork, error) {
+func (network *HostComputeNetwork) Delete() error {
 	logrus.Debugf("hcn::HostComputeNetwork::Delete id=%s", network.Id)
 
 	if err := deleteNetwork(network.Id); err != nil {
-		return nil, err
+		return err
 	}
-	return nil, nil
+	return nil
 }
 
 // ModifyNetworkSettings updates the Policy for a network.

+ 66 - 27
vendor/github.com/Microsoft/hcsshim/hcn/hcnnetwork_test.go

@@ -18,7 +18,7 @@ func TestCreateDeleteNetwork(t *testing.T) {
 		t.Fatal(err)
 	}
 	fmt.Printf("Network JSON:\n%s \n", jsonString)
-	_, err = network.Delete()
+	err = network.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -36,7 +36,7 @@ func TestGetNetworkByName(t *testing.T) {
 	if network == nil {
 		t.Fatal("No Network found")
 	}
-	_, err = network.Delete()
+	err = network.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -54,7 +54,7 @@ func TestGetNetworkById(t *testing.T) {
 	if network == nil {
 		t.Fatal("No Network found")
 	}
-	_, err = network.Delete()
+	err = network.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -67,20 +67,34 @@ func TestListNetwork(t *testing.T) {
 	}
 }
 
-func TestAddRemoveRemoteSubnetRoutePolicy(t *testing.T) {
-
+func testNetworkPolicy(t *testing.T, policiesToTest *PolicyNetworkRequest) {
 	network, err := CreateTestOverlayNetwork()
 	if err != nil {
 		t.Fatal(err)
 	}
 
-	remoteSubnetRoutePolicy, err := HcnCreateTestRemoteSubnetRoute()
+	network.AddPolicy(*policiesToTest)
+
+	//Reload the network object from HNS.
+	network, err = GetNetworkByID(network.Id)
 	if err != nil {
 		t.Fatal(err)
 	}
 
-	//Add Policy
-	network.AddPolicy(*remoteSubnetRoutePolicy)
+	for _, policyToTest := range policiesToTest.Policies {
+		foundPolicy := false
+		for _, policy := range network.Policies {
+			if policy.Type == policyToTest.Type {
+				foundPolicy = true
+				break
+			}
+		}
+		if !foundPolicy {
+			t.Fatalf("Could not find %s policy on network.", policyToTest.Type)
+		}
+	}
+
+	network.RemovePolicy(*policiesToTest)
 
 	//Reload the network object from HNS.
 	network, err = GetNetworkByID(network.Id)
@@ -88,19 +102,51 @@ func TestAddRemoveRemoteSubnetRoutePolicy(t *testing.T) {
 		t.Fatal(err)
 	}
 
-	foundPolicy := false
-	for _, policy := range network.Policies {
-		if policy.Type == RemoteSubnetRoute {
-			foundPolicy = true
-			break
+	for _, policyToTest := range policiesToTest.Policies {
+		foundPolicy := false
+		for _, policy := range network.Policies {
+			if policy.Type == policyToTest.Type {
+				foundPolicy = true
+				break
+			}
 		}
+		if foundPolicy {
+			t.Fatalf("Found %s policy on network when it should have been deleted.", policyToTest.Type)
+		}
+	}
+
+	err = network.Delete()
+	if err != nil {
+		t.Fatal(err)
+	}
+}
+
+func TestAddRemoveRemoteSubnetRoutePolicy(t *testing.T) {
+
+	remoteSubnetRoutePolicy, err := HcnCreateTestRemoteSubnetRoute()
+	if err != nil {
+		t.Fatal(err)
 	}
-	if !foundPolicy {
-		t.Fatalf("Could not find remote subnet route policy on network.")
+
+	testNetworkPolicy(t, remoteSubnetRoutePolicy)
+}
+
+func TestAddRemoveHostRoutePolicy(t *testing.T) {
+
+	hostRoutePolicy, err := HcnCreateTestHostRoute()
+	if err != nil {
+		t.Fatal(err)
 	}
 
-	//Remove Policy.
-	network.RemovePolicy(*remoteSubnetRoutePolicy)
+	testNetworkPolicy(t, hostRoutePolicy)
+}
+
+func TestNetworkFlags(t *testing.T) {
+
+	network, err := CreateTestOverlayNetwork()
+	if err != nil {
+		t.Fatal(err)
+	}
 
 	//Reload the network object from HNS.
 	network, err = GetNetworkByID(network.Id)
@@ -108,18 +154,11 @@ func TestAddRemoveRemoteSubnetRoutePolicy(t *testing.T) {
 		t.Fatal(err)
 	}
 
-	foundPolicy = false
-	for _, policy := range network.Policies {
-		if policy.Type == RemoteSubnetRoute {
-			foundPolicy = true
-			break
-		}
-	}
-	if foundPolicy {
-		t.Fatalf("Found remote subnet route policy on network when it should have been deleted.")
+	if network.Flags != EnableNonPersistent {
+		t.Errorf("EnableNonPersistent flag (%d) is not set on network", EnableNonPersistent)
 	}
 
-	_, err = network.Delete()
+	err = network.Delete()
 	if err != nil {
 		t.Fatal(err)
 	}

+ 1 - 0
vendor/github.com/Microsoft/hcsshim/hcn/hcnpolicy.go

@@ -40,6 +40,7 @@ const (
 	InterfaceConstraint NetworkPolicyType = "InterfaceConstraint"
 	ProviderAddress     NetworkPolicyType = "ProviderAddress"
 	RemoteSubnetRoute   NetworkPolicyType = "RemoteSubnetRoute"
+	HostRoute           NetworkPolicyType = "HostRoute"
 )
 
 // NetworkPolicy is a collection of Policy settings for a Network.

+ 9 - 2
vendor/github.com/Microsoft/hcsshim/hcn/hcnsupport.go

@@ -6,8 +6,11 @@ import (
 
 // SupportedFeatures are the features provided by the Service.
 type SupportedFeatures struct {
-	Acl AclFeatures `json:"ACL"`
-	Api ApiSupport  `json:"API"`
+	Acl          AclFeatures `json:"ACL"`
+	Api          ApiSupport  `json:"API"`
+	RemoteSubnet bool        `json:"RemoteSubnet"`
+	HostRoute    bool        `json:"HostRoute"`
+	DSR          bool        `json:"DSR"`
 }
 
 // AclFeatures are the supported ACL possibilities.
@@ -47,6 +50,10 @@ func GetSupportedFeatures() SupportedFeatures {
 		V1: true, // HNSCall is still available.
 	}
 
+	features.RemoteSubnet = isFeatureSupported(globals.Version, RemoteSubnetVersion)
+	features.HostRoute = isFeatureSupported(globals.Version, HostRouteVersion)
+	features.DSR = isFeatureSupported(globals.Version, DSRVersion)
+
 	return features
 }
 

+ 38 - 1
vendor/github.com/Microsoft/hcsshim/hcn/hcnsupport_test.go

@@ -18,8 +18,45 @@ func TestSupportedFeatures(t *testing.T) {
 }
 
 func TestV2ApiSupport(t *testing.T) {
+	supportedFeatures := GetSupportedFeatures()
 	err := V2ApiSupported()
-	if err != nil {
+	if supportedFeatures.Api.V2 && err != nil {
+		t.Fatal(err)
+	}
+	if !supportedFeatures.Api.V2 && err == nil {
+		t.Fatal(err)
+	}
+}
+
+func TestRemoteSubnetSupport(t *testing.T) {
+	supportedFeatures := GetSupportedFeatures()
+	err := RemoteSubnetSupported()
+	if supportedFeatures.RemoteSubnet && err != nil {
+		t.Fatal(err)
+	}
+	if !supportedFeatures.RemoteSubnet && err == nil {
+		t.Fatal(err)
+	}
+}
+
+func TestHostRouteSupport(t *testing.T) {
+	supportedFeatures := GetSupportedFeatures()
+	err := HostRouteSupported()
+	if supportedFeatures.HostRoute && err != nil {
+		t.Fatal(err)
+	}
+	if !supportedFeatures.HostRoute && err == nil {
+		t.Fatal(err)
+	}
+}
+
+func TestDSRSupport(t *testing.T) {
+	supportedFeatures := GetSupportedFeatures()
+	err := DSRSupported()
+	if supportedFeatures.DSR && err != nil {
+		t.Fatal(err)
+	}
+	if !supportedFeatures.DSR && err == nil {
 		t.Fatal(err)
 	}
 }

+ 15 - 1
vendor/github.com/Microsoft/hcsshim/hcn/hcnutils_test.go

@@ -13,7 +13,7 @@ func cleanup(networkName string) {
 		return
 	}
 	if testNetwork != nil {
-		_, err := testNetwork.Delete()
+		err := testNetwork.Delete()
 		if err != nil {
 			return
 		}
@@ -87,6 +87,7 @@ func CreateTestOverlayNetwork() (*HostComputeNetwork, error) {
 				},
 			},
 		},
+		Flags: EnableNonPersistent,
 		SchemaVersion: SchemaVersion{
 			Major: 2,
 			Minor: 0,
@@ -251,3 +252,16 @@ func HcnCreateTestRemoteSubnetRoute() (*PolicyNetworkRequest, error) {
 
 	return &networkRequest, nil
 }
+
+func HcnCreateTestHostRoute() (*PolicyNetworkRequest, error) {
+	hostRoutePolicy := NetworkPolicy{
+		Type:     HostRoute,
+		Settings: []byte("{}"),
+	}
+
+	networkRequest := PolicyNetworkRequest{
+		Policies: []NetworkPolicy{hostRoutePolicy},
+	}
+
+	return &networkRequest, nil
+}

+ 3 - 3
vendor/github.com/Microsoft/hcsshim/hcn/hcnv1schema_test.go

@@ -41,7 +41,7 @@ func TestV1Network(t *testing.T) {
 		t.Fail()
 	}
 
-	_, err = network.Delete()
+	err = network.Delete()
 	if err != nil {
 		t.Fatal(err)
 		t.Fail()
@@ -97,13 +97,13 @@ func TestV1Endpoint(t *testing.T) {
 		t.Fail()
 	}
 
-	_, err = endpoint.Delete()
+	err = endpoint.Delete()
 	if err != nil {
 		t.Fatal(err)
 		t.Fail()
 	}
 
-	_, err = network.Delete()
+	err = network.Delete()
 	if err != nil {
 		t.Fatal(err)
 		t.Fail()

+ 0 - 37
vendor/github.com/Microsoft/hcsshim/internal/cmd/createuvm/createuvm.go

@@ -1,37 +0,0 @@
-package main
-
-// createuvm does what it says on the tin. Simple test utility for looking
-// at startup timing.
-
-import (
-	"bufio"
-	"fmt"
-	"os"
-
-	"github.com/Microsoft/hcsshim/internal/uvm"
-)
-
-func main() {
-
-	fmt.Println("Creating...")
-	lcowUVM, err := uvm.Create(&uvm.UVMOptions{OperatingSystem: "linux", ID: "uvm"})
-	if err != nil {
-		fmt.Fprintf(os.Stderr, "Failed to create utility VM: %s", err)
-		os.Exit(-1)
-	}
-
-	fmt.Print("Created. Press 'Enter' to start...")
-	bufio.NewReader(os.Stdin).ReadBytes('\n')
-
-	fmt.Println("Starting...")
-	if err := lcowUVM.Start(); err != nil {
-		fmt.Fprintf(os.Stderr, "Failed to start utility VM: %s", err)
-		os.Exit(-1)
-	}
-
-	fmt.Print("Started. Use `hcsdiag console -uvm uvm`. Press 'Enter' to terminate...")
-	bufio.NewReader(os.Stdin).ReadBytes('\n')
-
-	lcowUVM.Terminate()
-	os.Exit(0)
-}

+ 0 - 210
vendor/github.com/Microsoft/hcsshim/internal/cmd/rootfs2vhd/rootfs2vhd.go

@@ -1,210 +0,0 @@
-package main
-
-// rootfs2vhd is a simple utility to convert rootfs.tar.gz generated by
-// the Microsoft/opengcs repos build.ps1 script to rootfs.vhd which LCOW
-// can use for the root filesystem added on VPMem (as opposed to an initrd).
-//
-// It's not pretty, but enough to get the job done. It does require
-// the Hyper-V RSAT to be installed for shelling out to New-VHD.
-
-import (
-	"bufio"
-	"bytes"
-	"fmt"
-	"os"
-	"os/exec"
-	"path/filepath"
-	"strings"
-	"time"
-
-	"github.com/Microsoft/hcsshim/internal/lcow"
-	"github.com/Microsoft/hcsshim/internal/uvm"
-	"github.com/Microsoft/hcsshim/internal/wclayer"
-	specs "github.com/opencontainers/runtime-spec/specs-go"
-	"github.com/sirupsen/logrus"
-	"github.com/urfave/cli"
-)
-
-var (
-	debug = false
-	pause = false
-)
-
-func main() {
-
-	app := cli.NewApp()
-	cwd, _ := filepath.Abs("./")
-
-	app.Flags = []cli.Flag{
-		cli.StringFlag{
-			Name:  "i",
-			Usage: "Full path to .tar.gz of the root file system to be converted",
-			Value: cwd + `\rootfs.tar.gz`,
-		},
-		cli.StringFlag{
-			Name:  "o",
-			Usage: "Full path to output filename",
-			Value: cwd + `\rootfs.vhd`,
-		},
-		cli.IntFlag{
-			Name:  "s",
-			Usage: "Size in MB of the new VHD",
-			Value: 19,
-		},
-		cli.BoolFlag{
-			Name:  "D",
-			Usage: "Debug mode",
-		},
-		cli.BoolFlag{
-			Name:  "P",
-			Usage: "Pause when complete but before tearing down the utility VM",
-		},
-	}
-	app.Action = func(c *cli.Context) {
-		rootfs2vhd(c)
-	}
-	fmt.Printf("\nrootfs2vhd: Converts an LCOW root filesystem tar.gz to a VHD\n\n")
-	if err := app.Run(os.Args); err != nil {
-		os.Exit(-1)
-	}
-}
-
-func rootfs2vhd(c *cli.Context) {
-	sourceRootFS := c.String("i")
-	destFile := c.String("o")
-	debug = c.Bool("D")
-	pause = c.Bool("P")
-
-	if debug {
-		logrus.SetLevel(logrus.DebugLevel)
-		logrus.SetFormatter(&logrus.TextFormatter{FullTimestamp: true})
-	}
-
-	if _, err := os.Stat(sourceRootFS); err != nil {
-		fmt.Fprintf(os.Stderr, "%s not found\n", sourceRootFS)
-		os.Exit(-1)
-	}
-
-	if _, err := os.Stat(destFile); err == nil {
-		fmt.Fprintf(os.Stderr, "%s exists. Not overwriting\n", destFile)
-		os.Exit(-1)
-	}
-
-	// TODO The right thing to do here is modify go-winio to be able to create this type of disk.
-	fmt.Printf("- Creating %s...\n", destFile)
-	if _, err := exec.Command(`powershell`, `-command`, fmt.Sprintf(`New-VHD %s -SizeBytes %dMB -fixed`, destFile, c.Int("s"))).Output(); err != nil {
-		fmt.Fprintf(os.Stderr, string(err.(*exec.ExitError).Stderr))
-		os.Exit(-1)
-	}
-
-	fmt.Println("- Creating an LCOW utility VM...")
-	lcowUVM, err := uvm.Create(&uvm.UVMOptions{OperatingSystem: "linux", ID: "rootfs2vhd"})
-	if err != nil {
-		fmt.Fprintf(os.Stderr, "Failed to create utility VM: %s", err)
-		os.Exit(-1)
-	}
-
-	fmt.Println("- Starting it....")
-	if err := lcowUVM.Start(); err != nil {
-		fmt.Fprintf(os.Stderr, "Failed to start utility VM: %s", err)
-		os.Exit(-1)
-	}
-
-	fmt.Printf("- Adding %s as read-only...\n", filepath.Dir(sourceRootFS))
-	if err := lcowUVM.AddPlan9(filepath.Dir(sourceRootFS), `/fssource`, true); err != nil {
-		fmt.Fprintf(os.Stderr, "failed to add %s: %s", filepath.Dir(sourceRootFS), err)
-		lcowUVM.Terminate()
-		lcowUVM.Wait()
-		os.Exit(-1)
-	}
-
-	fmt.Printf("- Granting access to %s...\n", destFile)
-	if err := wclayer.GrantVmAccess(lcowUVM.ID(), destFile); err != nil {
-		fmt.Fprintf(os.Stderr, "Failed to grant access: %s", err)
-		lcowUVM.Terminate()
-		lcowUVM.Wait()
-		os.Exit(-1)
-	}
-
-	fmt.Println("- Hot-adding SCSI disk...")
-	controller, lun, err := lcowUVM.AddSCSI(destFile, "") // No destination as not formatted
-	if err != nil {
-		fmt.Fprintf(os.Stderr, "Failed to add SCSI: %s", err)
-		lcowUVM.Terminate()
-		lcowUVM.Wait()
-		os.Exit(-1)
-	}
-	fmt.Printf("- Added at SCSI %d:%d\n", controller, lun)
-
-	uvmCommand(lcowUVM, []string{"test", "-d", fmt.Sprintf("/sys/bus/scsi/devices/%d:0:0:%d", controller, lun)})
-	device := fmt.Sprintf(`/dev/%s`, strings.TrimSpace(uvmCommand(lcowUVM, []string{"ls", fmt.Sprintf("/sys/bus/scsi/devices/%d:0:0:%d/block", controller, lun)})))
-	fmt.Printf("- Located at %s\n", device)
-
-	fmt.Printf("- Formatting ext4...\n")
-	uvmCommand(lcowUVM, []string{"mkfs.ext4", "-q", "-E", "lazy_itable_init=1", "-O", `^has_journal,sparse_super2,uninit_bg,^resize_inode`, device})
-
-	fmt.Printf("- Extracting %s...\n", filepath.Base(sourceRootFS))
-	uvmCommand(lcowUVM, []string{"mkdir", "/target"})
-	uvmCommand(lcowUVM, []string{"mount", device, "/target"})
-	uvmCommand(lcowUVM, []string{"rm", "-rf", "/target/lost+found"})
-	uvmCommand(lcowUVM, []string{"sh", "-c", fmt.Sprintf(`"cd /target; gzip -dc /fssource/%s | tar x"`, filepath.Base(sourceRootFS))})
-	fmt.Println("- Extract complete!")
-	fmt.Printf("\n%s\n", uvmCommand(lcowUVM, []string{"df", "/target"}))
-	possiblePause()
-	uvmCommand(lcowUVM, []string{"umount", device})
-
-	fmt.Println("- Removing SCSI disk...")
-	if err := lcowUVM.RemoveSCSI(destFile); err != nil {
-		fmt.Fprintf(os.Stderr, "Failed to remove SCSI: %s", err)
-		lcowUVM.Terminate()
-		lcowUVM.Wait()
-		os.Exit(-1)
-	}
-
-	lcowUVM.Terminate()
-
-	fmt.Printf("\nSuccess\n")
-	os.Exit(0)
-}
-
-func uvmCommand(lcowUVM *uvm.UtilityVM, args []string) string {
-	timeout := 30 * time.Second
-	var outB, errB bytes.Buffer
-	p, _, err := lcow.CreateProcess(&lcow.ProcessOptions{
-		HCSSystem:         lcowUVM.ComputeSystem(),
-		CreateInUtilityVm: true,
-		CopyTimeout:       timeout,
-		Process:           &specs.Process{Args: args},
-		Stdout:            &outB,
-		Stderr:            &errB,
-	})
-	if err != nil {
-		fmt.Fprintf(os.Stderr, "%+v failed:\n%s\n%s)", args, err, errB.String())
-		possiblePause()
-		lcowUVM.Terminate()
-		os.Exit(-1)
-	}
-	defer p.Close()
-	p.WaitTimeout(timeout)
-	ec, err := p.ExitCode()
-	if err != nil {
-		fmt.Fprintf(os.Stderr, "%+v failed to get exit code:\n%s\n%s)", args, err, errB.String())
-		possiblePause()
-		lcowUVM.Terminate()
-		os.Exit(-1)
-	}
-	if ec != 0 {
-		fmt.Fprintf(os.Stderr, "%+v had non-zero exit code:\n%s)", args, errB.String())
-		possiblePause()
-		lcowUVM.Terminate()
-		os.Exit(-1)
-	}
-	return outB.String()
-}
-
-func possiblePause() {
-	if pause {
-		fmt.Print("Press 'Enter' to continue...")
-		bufio.NewReader(os.Stdin).ReadBytes('\n')
-	}
-}

+ 16 - 1
vendor/github.com/Microsoft/hcsshim/internal/guestrequest/types.go

@@ -1,6 +1,8 @@
 package guestrequest
 
-import "github.com/Microsoft/hcsshim/internal/schema2"
+import (
+	"github.com/Microsoft/hcsshim/internal/schema2"
+)
 
 // Arguably, many of these (at least CombinedLayers) should have been generated
 // by swagger.
@@ -47,6 +49,19 @@ type LCOWMappedVPMemDevice struct {
 	MountPath    string `json:"MountPath,omitempty"` // /tmp/pN
 }
 
+type LCOWNetworkAdapter struct {
+	NamespaceID     string `json:",omitempty"`
+	ID              string `json:",omitempty"`
+	MacAddress      string `json:",omitempty"`
+	IPAddress       string `json:",omitempty"`
+	PrefixLength    uint8  `json:",omitempty"`
+	GatewayAddress  string `json:",omitempty"`
+	DNSSuffix       string `json:",omitempty"`
+	DNSServerList   string `json:",omitempty"`
+	EnableLowMetric bool   `json:",omitempty"`
+	EncapOverhead   uint16 `json:",omitempty"`
+}
+
 type ResourceType string
 
 const (

+ 9 - 12
vendor/github.com/Microsoft/hcsshim/internal/hcs/process.go

@@ -130,10 +130,9 @@ func (process *Process) Signal(options guestrequest.SignalProcessOptions) (err e
 	optionsStr := string(optionsb)
 
 	var resultp *uint16
-	completed := false
-	go syscallWatcher(process.logctx, &completed)
-	err = hcsSignalProcess(process.handle, optionsStr, &resultp)
-	completed = true
+	syscallWatcher(process.logctx, func() {
+		err = hcsSignalProcess(process.handle, optionsStr, &resultp)
+	})
 	events := processHcsResult(resultp)
 	if err != nil {
 		return makeProcessError(process, operation, err, events)
@@ -156,10 +155,9 @@ func (process *Process) Kill() (err error) {
 	}
 
 	var resultp *uint16
-	completed := false
-	go syscallWatcher(process.logctx, &completed)
-	err = hcsTerminateProcess(process.handle, &resultp)
-	completed = true
+	syscallWatcher(process.logctx, func() {
+		err = hcsTerminateProcess(process.handle, &resultp)
+	})
 	events := processHcsResult(resultp)
 	if err != nil {
 		return makeProcessError(process, operation, err, events)
@@ -251,10 +249,9 @@ func (process *Process) Properties() (_ *ProcessStatus, err error) {
 		resultp     *uint16
 		propertiesp *uint16
 	)
-	completed := false
-	go syscallWatcher(process.logctx, &completed)
-	err = hcsGetProcessProperties(process.handle, &propertiesp, &resultp)
-	completed = true
+	syscallWatcher(process.logctx, func() {
+		err = hcsGetProcessProperties(process.handle, &propertiesp, &resultp)
+	})
 	events := processHcsResult(resultp)
 	if err != nil {
 		return nil, makeProcessError(process, operation, err, events)

+ 61 - 53
vendor/github.com/Microsoft/hcsshim/internal/hcs/system.go

@@ -97,13 +97,13 @@ func CreateComputeSystem(id string, hcsDocumentInterface interface{}) (_ *System
 		Debug("HCS ComputeSystem Document")
 
 	var (
-		resultp  *uint16
-		identity syscall.Handle
+		resultp     *uint16
+		identity    syscall.Handle
+		createError error
 	)
-	completed := false
-	go syscallWatcher(computeSystem.logctx, &completed)
-	createError := hcsCreateComputeSystem(id, hcsDocument, identity, &computeSystem.handle, &resultp)
-	completed = true
+	syscallWatcher(computeSystem.logctx, func() {
+		createError = hcsCreateComputeSystem(id, hcsDocument, identity, &computeSystem.handle, &resultp)
+	})
 
 	if createError == nil || IsPending(createError) {
 		if err = computeSystem.registerCallback(); err != nil {
@@ -133,7 +133,13 @@ func OpenComputeSystem(id string) (_ *System, err error) {
 
 	computeSystem := newSystem(id)
 	computeSystem.logOperationBegin(operation)
-	defer func() { computeSystem.logOperationEnd(err) }()
+	defer func() {
+		if IsNotExist(err) {
+			computeSystem.logOperationEnd(nil)
+		} else {
+			computeSystem.logOperationEnd(err)
+		}
+	}()
 
 	var (
 		handle  hcsSystem
@@ -193,10 +199,10 @@ func GetComputeSystems(q schema1.ComputeSystemQuery) (_ []schema1.ContainerPrope
 		resultp         *uint16
 		computeSystemsp *uint16
 	)
-	completed := false
-	go syscallWatcher(fields, &completed)
-	err = hcsEnumerateComputeSystems(query, &computeSystemsp, &resultp)
-	completed = true
+
+	syscallWatcher(fields, func() {
+		err = hcsEnumerateComputeSystems(query, &computeSystemsp, &resultp)
+	})
 	events := processHcsResult(resultp)
 	if err != nil {
 		return nil, &HcsError{Op: operation, Err: err, Events: events}
@@ -254,10 +260,9 @@ func (computeSystem *System) Start() (err error) {
 	}
 
 	var resultp *uint16
-	completed := false
-	go syscallWatcher(computeSystem.logctx, &completed)
-	err = hcsStartComputeSystem(computeSystem.handle, "", &resultp)
-	completed = true
+	syscallWatcher(computeSystem.logctx, func() {
+		err = hcsStartComputeSystem(computeSystem.handle, "", &resultp)
+	})
 	events, err := processAsyncHcsResult(err, resultp, computeSystem.callbackNumber, hcsNotificationSystemStartCompleted, &timeout.SystemStart)
 	if err != nil {
 		return makeSystemError(computeSystem, "Start", "", err, events)
@@ -279,17 +284,22 @@ func (computeSystem *System) Shutdown() (err error) {
 
 	operation := "hcsshim::ComputeSystem::Shutdown"
 	computeSystem.logOperationBegin(operation)
-	defer func() { computeSystem.logOperationEnd(err) }()
+	defer func() {
+		if IsAlreadyStopped(err) {
+			computeSystem.logOperationEnd(nil)
+		} else {
+			computeSystem.logOperationEnd(err)
+		}
+	}()
 
 	if computeSystem.handle == 0 {
 		return makeSystemError(computeSystem, "Shutdown", "", ErrAlreadyClosed, nil)
 	}
 
 	var resultp *uint16
-	completed := false
-	go syscallWatcher(computeSystem.logctx, &completed)
-	err = hcsShutdownComputeSystem(computeSystem.handle, "", &resultp)
-	completed = true
+	syscallWatcher(computeSystem.logctx, func() {
+		err = hcsShutdownComputeSystem(computeSystem.handle, "", &resultp)
+	})
 	events := processHcsResult(resultp)
 	if err != nil {
 		return makeSystemError(computeSystem, "Shutdown", "", err, events)
@@ -306,17 +316,22 @@ func (computeSystem *System) Terminate() (err error) {
 
 	operation := "hcsshim::ComputeSystem::Terminate"
 	computeSystem.logOperationBegin(operation)
-	defer func() { computeSystem.logOperationEnd(err) }()
+	defer func() {
+		if IsPending(err) {
+			computeSystem.logOperationEnd(nil)
+		} else {
+			computeSystem.logOperationEnd(err)
+		}
+	}()
 
 	if computeSystem.handle == 0 {
 		return makeSystemError(computeSystem, "Terminate", "", ErrAlreadyClosed, nil)
 	}
 
 	var resultp *uint16
-	completed := false
-	go syscallWatcher(computeSystem.logctx, &completed)
-	err = hcsTerminateComputeSystem(computeSystem.handle, "", &resultp)
-	completed = true
+	syscallWatcher(computeSystem.logctx, func() {
+		err = hcsTerminateComputeSystem(computeSystem.handle, "", &resultp)
+	})
 	events := processHcsResult(resultp)
 	if err != nil && err != ErrVmcomputeAlreadyStopped {
 		return makeSystemError(computeSystem, "Terminate", "", err, events)
@@ -387,10 +402,9 @@ func (computeSystem *System) Properties(types ...schema1.PropertyType) (_ *schem
 		Debug("HCS ComputeSystem Properties Query")
 
 	var resultp, propertiesp *uint16
-	completed := false
-	go syscallWatcher(computeSystem.logctx, &completed)
-	err = hcsGetComputeSystemProperties(computeSystem.handle, string(queryj), &propertiesp, &resultp)
-	completed = true
+	syscallWatcher(computeSystem.logctx, func() {
+		err = hcsGetComputeSystemProperties(computeSystem.handle, string(queryj), &propertiesp, &resultp)
+	})
 	events := processHcsResult(resultp)
 	if err != nil {
 		return nil, makeSystemError(computeSystem, "Properties", "", err, events)
@@ -422,10 +436,9 @@ func (computeSystem *System) Pause() (err error) {
 	}
 
 	var resultp *uint16
-	completed := false
-	go syscallWatcher(computeSystem.logctx, &completed)
-	err = hcsPauseComputeSystem(computeSystem.handle, "", &resultp)
-	completed = true
+	syscallWatcher(computeSystem.logctx, func() {
+		err = hcsPauseComputeSystem(computeSystem.handle, "", &resultp)
+	})
 	events, err := processAsyncHcsResult(err, resultp, computeSystem.callbackNumber, hcsNotificationSystemPauseCompleted, &timeout.SystemPause)
 	if err != nil {
 		return makeSystemError(computeSystem, "Pause", "", err, events)
@@ -448,10 +461,9 @@ func (computeSystem *System) Resume() (err error) {
 	}
 
 	var resultp *uint16
-	completed := false
-	go syscallWatcher(computeSystem.logctx, &completed)
-	err = hcsResumeComputeSystem(computeSystem.handle, "", &resultp)
-	completed = true
+	syscallWatcher(computeSystem.logctx, func() {
+		err = hcsResumeComputeSystem(computeSystem.handle, "", &resultp)
+	})
 	events, err := processAsyncHcsResult(err, resultp, computeSystem.callbackNumber, hcsNotificationSystemResumeCompleted, &timeout.SystemResume)
 	if err != nil {
 		return makeSystemError(computeSystem, "Resume", "", err, events)
@@ -490,10 +502,9 @@ func (computeSystem *System) CreateProcess(c interface{}) (_ *Process, err error
 		WithField(logfields.JSON, configuration).
 		Debug("HCS ComputeSystem Process Document")
 
-	completed := false
-	go syscallWatcher(computeSystem.logctx, &completed)
-	err = hcsCreateProcess(computeSystem.handle, configuration, &processInfo, &processHandle, &resultp)
-	completed = true
+	syscallWatcher(computeSystem.logctx, func() {
+		err = hcsCreateProcess(computeSystem.handle, configuration, &processInfo, &processHandle, &resultp)
+	})
 	events := processHcsResult(resultp)
 	if err != nil {
 		return nil, makeSystemError(computeSystem, "CreateProcess", configuration, err, events)
@@ -539,10 +550,9 @@ func (computeSystem *System) OpenProcess(pid int) (_ *Process, err error) {
 		return nil, makeSystemError(computeSystem, "OpenProcess", "", ErrAlreadyClosed, nil)
 	}
 
-	completed := false
-	go syscallWatcher(computeSystem.logctx, &completed)
-	err = hcsOpenProcess(computeSystem.handle, uint32(pid), &processHandle, &resultp)
-	completed = true
+	syscallWatcher(computeSystem.logctx, func() {
+		err = hcsOpenProcess(computeSystem.handle, uint32(pid), &processHandle, &resultp)
+	})
 	events := processHcsResult(resultp)
 	if err != nil {
 		return nil, makeSystemError(computeSystem, "OpenProcess", "", err, events)
@@ -574,10 +584,9 @@ func (computeSystem *System) Close() (err error) {
 		return makeSystemError(computeSystem, "Close", "", err, nil)
 	}
 
-	completed := false
-	go syscallWatcher(computeSystem.logctx, &completed)
-	err = hcsCloseComputeSystem(computeSystem.handle)
-	completed = true
+	syscallWatcher(computeSystem.logctx, func() {
+		err = hcsCloseComputeSystem(computeSystem.handle)
+	})
 	if err != nil {
 		return makeSystemError(computeSystem, "Close", "", err, nil)
 	}
@@ -669,10 +678,9 @@ func (computeSystem *System) Modify(config interface{}) (err error) {
 		Debug("HCS ComputeSystem Modify Document")
 
 	var resultp *uint16
-	completed := false
-	go syscallWatcher(computeSystem.logctx, &completed)
-	err = hcsModifyComputeSystem(computeSystem.handle, requestString, &resultp)
-	completed = true
+	syscallWatcher(computeSystem.logctx, func() {
+		err = hcsModifyComputeSystem(computeSystem.handle, requestString, &resultp)
+	})
 	events := processHcsResult(resultp)
 	if err != nil {
 		return makeSystemError(computeSystem, "Modify", requestString, err, events)

+ 20 - 12
vendor/github.com/Microsoft/hcsshim/internal/hcs/watcher.go

@@ -1,7 +1,7 @@
 package hcs
 
 import (
-	"time"
+	"context"
 
 	"github.com/Microsoft/hcsshim/internal/logfields"
 	"github.com/Microsoft/hcsshim/internal/timeout"
@@ -17,17 +17,25 @@ import (
 //
 // Usage is:
 //
-// completed := false
-// go syscallWatcher(context, &completed)
-// <syscall>
-// completed = true
+// syscallWatcher(logContext, func() {
+//    err = <syscall>(args...)
+// })
 //
-func syscallWatcher(context logrus.Fields, syscallCompleted *bool) {
-	time.Sleep(timeout.SyscallWatcher)
-	if *syscallCompleted {
-		return
+
+func syscallWatcher(logContext logrus.Fields, syscallLambda func()) {
+	ctx, cancel := context.WithTimeout(context.Background(), timeout.SyscallWatcher)
+	defer cancel()
+	go watchFunc(ctx, logContext)
+	syscallLambda()
+}
+
+func watchFunc(ctx context.Context, logContext logrus.Fields) {
+	select {
+	case <-ctx.Done():
+		if ctx.Err() != context.Canceled {
+			logrus.WithFields(logContext).
+				WithField(logfields.Timeout, timeout.SyscallWatcher).
+				Warning("Syscall did not complete within operation timeout. This may indicate a platform issue. If it appears to be making no forward progress, obtain the stacks and see if there is a syscall stuck in the platform API for a significant length of time.")
+		}
 	}
-	logrus.WithFields(context).
-		WithField(logfields.Timeout, timeout.SyscallWatcher).
-		Warning("Syscall did not complete within operation timeout. This may indicate a platform issue. If it appears to be making no forward progress, obtain the stacks and see if there is a syscall stuck in the platform API for a significant length of time.")
 }

+ 11 - 1
vendor/github.com/Microsoft/hcsshim/internal/hcsoci/hcsdoc_lcow.go

@@ -33,8 +33,18 @@ func createLCOWSpec(coi *createOptionsInternal) (*specs.Spec, error) {
 		}
 	*/
 
-	// Linux containers don't care about Windows aspects of the spec
+	// Linux containers don't care about Windows aspects of the spec except the
+	// network namespace
 	spec.Windows = nil
+	if coi.Spec.Windows != nil &&
+		coi.Spec.Windows.Network != nil &&
+		coi.Spec.Windows.Network.NetworkNamespace != "" {
+		spec.Windows = &specs.Windows{
+			Network: &specs.WindowsNetwork{
+				NetworkNamespace: coi.Spec.Windows.Network.NetworkNamespace,
+			},
+		}
+	}
 
 	// Hooks are not supported (they should be run in the host)
 	spec.Hooks = nil

+ 2 - 0
vendor/github.com/Microsoft/hcsshim/internal/hns/hnsendpoint.go

@@ -23,7 +23,9 @@ type HNSEndpoint struct {
 	DisableICC         bool              `json:",omitempty"`
 	PrefixLength       uint8             `json:",omitempty"`
 	IsRemoteEndpoint   bool              `json:",omitempty"`
+	EnableLowMetric    bool              `json:",omitempty"`
 	Namespace          *Namespace        `json:",omitempty"`
+	EncapOverhead      uint16            `json:",omitempty"`
 }
 
 //SystemType represents the type of the system on which actions are done

+ 0 - 51
vendor/github.com/Microsoft/hcsshim/internal/osversion/osversion.go

@@ -1,51 +0,0 @@
-package osversion
-
-import (
-	"fmt"
-
-	"golang.org/x/sys/windows"
-)
-
-// OSVersion is a wrapper for Windows version information
-// https://msdn.microsoft.com/en-us/library/windows/desktop/ms724439(v=vs.85).aspx
-type OSVersion struct {
-	Version      uint32
-	MajorVersion uint8
-	MinorVersion uint8
-	Build        uint16
-}
-
-// https://msdn.microsoft.com/en-us/library/windows/desktop/ms724833(v=vs.85).aspx
-type osVersionInfoEx struct {
-	OSVersionInfoSize uint32
-	MajorVersion      uint32
-	MinorVersion      uint32
-	BuildNumber       uint32
-	PlatformID        uint32
-	CSDVersion        [128]uint16
-	ServicePackMajor  uint16
-	ServicePackMinor  uint16
-	SuiteMask         uint16
-	ProductType       byte
-	Reserve           byte
-}
-
-// Get gets the operating system version on Windows.
-// The calling application must be manifested to get the correct version information.
-func Get() OSVersion {
-	var err error
-	osv := OSVersion{}
-	osv.Version, err = windows.GetVersion()
-	if err != nil {
-		// GetVersion never fails.
-		panic(err)
-	}
-	osv.MajorVersion = uint8(osv.Version & 0xFF)
-	osv.MinorVersion = uint8(osv.Version >> 8 & 0xFF)
-	osv.Build = uint16(osv.Version >> 16)
-	return osv
-}
-
-func (osv OSVersion) ToString() string {
-	return fmt.Sprintf("%d.%d.%d", osv.MajorVersion, osv.MinorVersion, osv.Build)
-}

+ 0 - 11
vendor/github.com/Microsoft/hcsshim/internal/osversion/windowsbuilds.go

@@ -1,11 +0,0 @@
-package osversion
-
-const (
-
-	// RS2 was a client-only release in case you're asking why it's not in the list.
-	RS1 = 14393
-	RS3 = 16299
-	RS4 = 17134
-	RS5 = 17743 // TODO Bump to final RS5 build
-
-)

+ 7 - 0
vendor/github.com/Microsoft/hcsshim/internal/schema2/plan9_share.go

@@ -20,6 +20,13 @@ type Plan9Share struct {
 
 	Port int32 `json:"Port,omitempty"`
 
+	// Flags are marked private. Until they are exported correctly
+	//
+	// ReadOnly      0x00000001
+	// LinuxMetadata 0x00000004
+	// CaseSensitive 0x00000008
+	Flags int32 `json:"Flags,omitempty"`
+
 	ReadOnly bool `json:"ReadOnly,omitempty"`
 
 	UseShareRootIdentity bool `json:"UseShareRootIdentity,omitempty"`

+ 3 - 0
vendor/github.com/Microsoft/hcsshim/internal/schema2/virtual_machine.go

@@ -11,6 +11,9 @@ package hcsschema
 
 type VirtualMachine struct {
 
+	// StopOnReset is private in the schema. If regenerated need to put back.
+	StopOnReset bool `json:"StopOnReset,omitempty"`
+
 	Chipset *Chipset `json:"Chipset,omitempty"`
 
 	ComputeTopology *Topology `json:"ComputeTopology,omitempty"`

+ 1 - 1
vendor/github.com/Microsoft/hcsshim/internal/schemaversion/schemaversion_test.go

@@ -4,9 +4,9 @@ import (
 	"io/ioutil"
 	"testing"
 
-	_ "github.com/Microsoft/hcsshim/functional/manifest"
 	"github.com/Microsoft/hcsshim/internal/schema2"
 	"github.com/Microsoft/hcsshim/osversion"
+	_ "github.com/Microsoft/hcsshim/test/functional/manifest"
 	"github.com/sirupsen/logrus"
 )
 

+ 6 - 16
vendor/github.com/Microsoft/hcsshim/internal/uvm/create.go

@@ -16,11 +16,11 @@ type Options struct {
 
 	// Memory for UVM. Defaults to true. For physical backed memory, set to
 	// false.
-	AllowOvercommit *bool
+	AllowOvercommit bool
 
 	// Memory for UVM. Defaults to false. For virtual memory with deferred
 	// commit, set to true.
-	EnableDeferredCommit *bool
+	EnableDeferredCommit bool
 
 	// ProcessorCount sets the number of vCPU's. If `0` will default to platform
 	// default.
@@ -54,19 +54,9 @@ func (uvm *UtilityVM) Close() error {
 	return err
 }
 
-func normalizeMemory(m int32) int32 {
-	if m == 0 {
-		return 1024 // 1GB By Default.
+func defaultProcessorCount() int32 {
+	if runtime.NumCPU() == 1 {
+		return 1
 	}
-	return m
-}
-
-func normalizeProcessors(p int32) int32 {
-	if p == 0 {
-		if runtime.NumCPU() == 1 {
-			return 1
-		}
-		return 2
-	}
-	return p
+	return 2
 }

+ 129 - 140
vendor/github.com/Microsoft/hcsshim/internal/uvm/create_lcow.go

@@ -31,37 +31,99 @@ const (
 type OutputHandler func(io.Reader)
 
 const (
-	initrdFile = "initrd.img"
-	vhdFile    = "rootfs.vhd"
+	// InitrdFile is the default file name for an initrd.img used to boot LCOW.
+	InitrdFile = "initrd.img"
+	// VhdFile is the default file name for a rootfs.vhd used to boot LCOW.
+	VhdFile = "rootfs.vhd"
+	// KernelFile is the default file name for a kernel used to boot LCOW.
+	KernelFile = "kernel"
+	// UncompressedKernelFile is the default file name for an uncompressed
+	// kernel used to boot LCOW with KernelDirect.
+	UncompressedKernelFile = "vmlinux"
 )
 
 // OptionsLCOW are the set of options passed to CreateLCOW() to create a utility vm.
 type OptionsLCOW struct {
 	*Options
 
-	BootFilesPath         string         // Folder in which kernel and root file system reside. Defaults to \Program Files\Linux Containers
-	KernelFile            string         // Filename under BootFilesPath for the kernel. Defaults to `kernel`
-	KernelDirect          bool           // Skip UEFI and boot directly to `kernel`
-	RootFSFile            string         // Filename under BootFilesPath for the UVMs root file system. Defaults are `initrd.img` or `rootfs.vhd` based on `PreferredRootFSType`.
-	KernelBootOptions     string         // Additional boot options for the kernel
-	EnableGraphicsConsole bool           // If true, enable a graphics console for the utility VM
-	ConsolePipe           string         // The named pipe path to use for the serial console.  eg \\.\pipe\vmpipe
-	SCSIControllerCount   *uint32        // The number of SCSI controllers. Defaults to 1 if omitted. Currently we only support 0 or 1.
-	UseGuestConnection    *bool          // Whether the HCS should connect to the UVM's GCS. Defaults to true
-	ExecCommandLine       string         // The command line to exec from init. Defaults to GCS
-	ForwardStdout         *bool          // Whether stdout will be forwarded from the executed program. Defaults to false
-	ForwardStderr         *bool          // Whether stderr will be forwarded from the executed program. Defaults to true
-	OutputHandler         *OutputHandler // Controls how output received over HVSocket from the UVM is handled. Defaults to parsing output as logrus messages
-
-	// Number of VPMem devices. Limit at 128. If booting UVM from VHD, device 0 is taken. LCOW Only. io.microsoft.virtualmachine.devices.virtualpmem.maximumcount
-	VPMemDeviceCount *uint32
-
-	// Size of the VPMem devices. LCOW Only. Defaults to 4GB. io.microsoft.virtualmachine.devices.virtualpmem.maximumsizebytes
-	VPMemSizeBytes *uint64
-
-	// Controls searching for the RootFSFile. Defaults to initrd (0). Can be set to VHD (1). io.microsoft.virtualmachine.lcow.preferredrootfstype
-	// Note this uses an arbitrary annotation strict which has no direct mapping to the HCS schema.
-	PreferredRootFSType *PreferredRootFSType
+	BootFilesPath         string              // Folder in which kernel and root file system reside. Defaults to \Program Files\Linux Containers
+	KernelFile            string              // Filename under `BootFilesPath` for the kernel. Defaults to `kernel`
+	KernelDirect          bool                // Skip UEFI and boot directly to `kernel`
+	RootFSFile            string              // Filename under `BootFilesPath` for the UVMs root file system. Defaults to `InitrdFile`
+	KernelBootOptions     string              // Additional boot options for the kernel
+	EnableGraphicsConsole bool                // If true, enable a graphics console for the utility VM
+	ConsolePipe           string              // The named pipe path to use for the serial console.  eg \\.\pipe\vmpipe
+	SCSIControllerCount   uint32              // The number of SCSI controllers. Defaults to 1. Currently we only support 0 or 1.
+	UseGuestConnection    bool                // Whether the HCS should connect to the UVM's GCS. Defaults to true
+	ExecCommandLine       string              // The command line to exec from init. Defaults to GCS
+	ForwardStdout         bool                // Whether stdout will be forwarded from the executed program. Defaults to false
+	ForwardStderr         bool                // Whether stderr will be forwarded from the executed program. Defaults to true
+	OutputHandler         OutputHandler       `json:"-"` // Controls how output received over HVSocket from the UVM is handled. Defaults to parsing output as logrus messages
+	VPMemDeviceCount      uint32              // Number of VPMem devices. Defaults to `DefaultVPMEMCount`. Limit at 128. If booting UVM from VHD, device 0 is taken.
+	VPMemSizeBytes        uint64              // Size of the VPMem devices. Defaults to `DefaultVPMemSizeBytes`.
+	PreferredRootFSType   PreferredRootFSType // If `KernelFile` is `InitrdFile` use `PreferredRootFSTypeInitRd`. If `KernelFile` is `VhdFile` use `PreferredRootFSTypeVHD`
+}
+
+// NewDefaultOptionsLCOW creates the default options for a bootable version of
+// LCOW.
+//
+// `id` the ID of the compute system. If not passed will generate a new GUID.
+//
+// `owner` the owner of the compute system. If not passed will use the
+// executable files name.
+func NewDefaultOptionsLCOW(id, owner string) *OptionsLCOW {
+	// Use KernelDirect boot by default on all builds that support it.
+	kernelDirectSupported := osversion.Get().Build >= 18286
+	opts := &OptionsLCOW{
+		Options: &Options{
+			ID:                   id,
+			Owner:                owner,
+			MemorySizeInMB:       1024,
+			AllowOvercommit:      true,
+			EnableDeferredCommit: false,
+			ProcessorCount:       defaultProcessorCount(),
+		},
+		BootFilesPath:         filepath.Join(os.Getenv("ProgramFiles"), "Linux Containers"),
+		KernelFile:            KernelFile,
+		KernelDirect:          kernelDirectSupported,
+		RootFSFile:            InitrdFile,
+		KernelBootOptions:     "",
+		EnableGraphicsConsole: false,
+		ConsolePipe:           "",
+		SCSIControllerCount:   1,
+		UseGuestConnection:    true,
+		ExecCommandLine:       fmt.Sprintf("/bin/gcs -log-format json -loglevel %s", logrus.StandardLogger().Level.String()),
+		ForwardStdout:         false,
+		ForwardStderr:         true,
+		OutputHandler:         parseLogrus,
+		VPMemDeviceCount:      DefaultVPMEMCount,
+		VPMemSizeBytes:        DefaultVPMemSizeBytes,
+		PreferredRootFSType:   PreferredRootFSTypeInitRd,
+	}
+
+	if opts.ID == "" {
+		opts.ID = guid.New().String()
+	}
+	if opts.Owner == "" {
+		opts.Owner = filepath.Base(os.Args[0])
+	}
+
+	if _, err := os.Stat(filepath.Join(opts.BootFilesPath, VhdFile)); err == nil {
+		// We have a rootfs.vhd in the boot files path. Use it over an initrd.img
+		opts.RootFSFile = VhdFile
+		opts.PreferredRootFSType = PreferredRootFSTypeVHD
+	}
+
+	if kernelDirectSupported {
+		// KernelDirect supports uncompressed kernel if the kernel is present.
+		// Default to uncompressed if on box. NOTE: If `kernel` is already
+		// uncompressed and simply named 'kernel' it will still be used
+		// uncompressed automatically.
+		if _, err := os.Stat(filepath.Join(opts.BootFilesPath, UncompressedKernelFile)); err == nil {
+			opts.KernelFile = UncompressedKernelFile
+		}
+	}
+	return opts
 }
 
 const linuxLogVsockPort = 109
@@ -70,91 +132,41 @@ const linuxLogVsockPort = 109
 func CreateLCOW(opts *OptionsLCOW) (_ *UtilityVM, err error) {
 	logrus.Debugf("uvm::CreateLCOW %+v", opts)
 
-	if opts.Options == nil {
-		opts.Options = &Options{}
+	// We dont serialize OutputHandler so if it is missing we need to put it back to the default.
+	if opts.OutputHandler == nil {
+		opts.OutputHandler = parseLogrus
 	}
 
 	uvm := &UtilityVM{
 		id:                  opts.ID,
 		owner:               opts.Owner,
 		operatingSystem:     "linux",
-		scsiControllerCount: 1,
-		vpmemMaxCount:       DefaultVPMEMCount,
-		vpmemMaxSizeBytes:   DefaultVPMemSizeBytes,
+		scsiControllerCount: opts.SCSIControllerCount,
+		vpmemMaxCount:       opts.VPMemDeviceCount,
+		vpmemMaxSizeBytes:   opts.VPMemSizeBytes,
 	}
 
-	// Defaults if omitted by caller.
-	// TODO: Change this. Don't auto generate ID if omitted. Avoids the chicken-and-egg problem
-	if uvm.id == "" {
-		uvm.id = guid.New().String()
+	kernelFullPath := filepath.Join(opts.BootFilesPath, opts.KernelFile)
+	if _, err := os.Stat(kernelFullPath); os.IsNotExist(err) {
+		return nil, fmt.Errorf("kernel: '%s' not found", kernelFullPath)
 	}
-	if uvm.owner == "" {
-		uvm.owner = filepath.Base(os.Args[0])
-	}
-	if opts.UseGuestConnection == nil {
-		val := true
-		opts.UseGuestConnection = &val
+	rootfsFullPath := filepath.Join(opts.BootFilesPath, opts.RootFSFile)
+	if _, err := os.Stat(rootfsFullPath); os.IsNotExist(err) {
+		return nil, fmt.Errorf("boot file: '%s' not found", rootfsFullPath)
 	}
 
-	if opts.BootFilesPath == "" {
-		opts.BootFilesPath = filepath.Join(os.Getenv("ProgramFiles"), "Linux Containers")
-	}
-	if opts.KernelFile == "" {
-		opts.KernelFile = "kernel"
+	if opts.SCSIControllerCount > 1 {
+		return nil, fmt.Errorf("SCSI controller count must be 0 or 1") // Future extension here for up to 4
 	}
-	if _, err := os.Stat(filepath.Join(opts.BootFilesPath, opts.KernelFile)); os.IsNotExist(err) {
-		return nil, fmt.Errorf("kernel '%s' not found", filepath.Join(opts.BootFilesPath, opts.KernelFile))
-	}
-	if opts.PreferredRootFSType == nil {
-		v := PreferredRootFSTypeInitRd
-		opts.PreferredRootFSType = &v
-	}
-	if opts.RootFSFile == "" {
-		switch *opts.PreferredRootFSType {
-		case PreferredRootFSTypeInitRd:
-			opts.RootFSFile = initrdFile
-		case PreferredRootFSTypeVHD:
-			opts.RootFSFile = "rootfs.vhd"
-		}
-	}
-	if opts.ForwardStdout == nil {
-		val := false
-		opts.ForwardStdout = &val
-	}
-	if opts.ForwardStderr == nil {
-		val := true
-		opts.ForwardStderr = &val
-	}
-	if opts.OutputHandler == nil {
-		val := OutputHandler(parseLogrus)
-		opts.OutputHandler = &val
-	}
-
-	if _, err := os.Stat(filepath.Join(opts.BootFilesPath, opts.RootFSFile)); os.IsNotExist(err) {
-		return nil, fmt.Errorf("%s not found under %s", opts.RootFSFile, opts.BootFilesPath)
-	}
-
-	if opts.SCSIControllerCount != nil {
-		if *opts.SCSIControllerCount > 1 {
-			return nil, fmt.Errorf("SCSI controller count must be 0 or 1") // Future extension here for up to 4
-		}
-		uvm.scsiControllerCount = *opts.SCSIControllerCount
-	}
-	if opts.VPMemDeviceCount != nil {
-		if *opts.VPMemDeviceCount > MaxVPMEMCount {
-			return nil, fmt.Errorf("vpmem device count cannot be greater than %d", MaxVPMEMCount)
-		}
-		uvm.vpmemMaxCount = *opts.VPMemDeviceCount
+	if opts.VPMemDeviceCount > MaxVPMEMCount {
+		return nil, fmt.Errorf("vpmem device count cannot be greater than %d", MaxVPMEMCount)
 	}
 	if uvm.vpmemMaxCount > 0 {
-		if opts.VPMemSizeBytes != nil {
-			if *opts.VPMemSizeBytes%4096 != 0 {
-				return nil, fmt.Errorf("opts.VPMemSizeBytes must be a multiple of 4096")
-			}
-			uvm.vpmemMaxSizeBytes = *opts.VPMemSizeBytes
+		if opts.VPMemSizeBytes%4096 != 0 {
+			return nil, fmt.Errorf("opts.VPMemSizeBytes must be a multiple of 4096")
 		}
 	} else {
-		if *opts.PreferredRootFSType == PreferredRootFSTypeVHD {
+		if opts.PreferredRootFSType == PreferredRootFSTypeVHD {
 			return nil, fmt.Errorf("PreferredRootFSTypeVHD requires at least one VPMem device")
 		}
 	}
@@ -167,17 +179,16 @@ func CreateLCOW(opts *OptionsLCOW) (_ *UtilityVM, err error) {
 		SchemaVersion:                     schemaversion.SchemaV21(),
 		ShouldTerminateOnLastHandleClosed: true,
 		VirtualMachine: &hcsschema.VirtualMachine{
-			Chipset: &hcsschema.Chipset{},
+			StopOnReset: true,
+			Chipset:     &hcsschema.Chipset{},
 			ComputeTopology: &hcsschema.Topology{
 				Memory: &hcsschema.Memory2{
-					SizeInMB: normalizeMemory(opts.MemorySizeInMB),
-					// AllowOvercommit `true` by default if not passed.
-					AllowOvercommit: opts.AllowOvercommit == nil || *opts.AllowOvercommit,
-					// EnableDeferredCommit `false` by default if not passed.
-					EnableDeferredCommit: opts.EnableDeferredCommit != nil && *opts.EnableDeferredCommit,
+					SizeInMB:             opts.MemorySizeInMB,
+					AllowOvercommit:      opts.AllowOvercommit,
+					EnableDeferredCommit: opts.EnableDeferredCommit,
 				},
 				Processor: &hcsschema.Processor2{
-					Count: normalizeProcessors(opts.ProcessorCount),
+					Count: opts.ProcessorCount,
 				},
 			},
 			Devices: &hcsschema.Devices{
@@ -192,30 +203,13 @@ func CreateLCOW(opts *OptionsLCOW) (_ *UtilityVM, err error) {
 		},
 	}
 
-	if *opts.UseGuestConnection {
+	if opts.UseGuestConnection {
 		doc.VirtualMachine.GuestConnection = &hcsschema.GuestConnection{
 			UseVsock:            true,
 			UseConnectedSuspend: true,
 		}
 	}
 
-	if !opts.KernelDirect {
-		doc.VirtualMachine.Devices.VirtualSmb = &hcsschema.VirtualSmb{
-			Shares: []hcsschema.VirtualSmbShare{
-				{
-					Name: "os",
-					Path: opts.BootFilesPath,
-					Options: &hcsschema.VirtualSmbShareOptions{
-						ReadOnly:            true,
-						TakeBackupPrivilege: true,
-						CacheIo:             true,
-						ShareRead:           true,
-					},
-				},
-			},
-		}
-	}
-
 	if uvm.scsiControllerCount > 0 {
 		// TODO: JTERRY75 - this should enumerate scsicount and add an entry per value.
 		doc.VirtualMachine.Devices.Scsi = map[string]hcsschema.Scsi{
@@ -232,7 +226,7 @@ func CreateLCOW(opts *OptionsLCOW) (_ *UtilityVM, err error) {
 	}
 
 	var kernelArgs string
-	switch *opts.PreferredRootFSType {
+	switch opts.PreferredRootFSType {
 	case PreferredRootFSTypeInitRd:
 		if !opts.KernelDirect {
 			kernelArgs = "initrd=/" + opts.RootFSFile
@@ -246,13 +240,13 @@ func CreateLCOW(opts *OptionsLCOW) (_ *UtilityVM, err error) {
 		}
 		doc.VirtualMachine.Devices.VirtualPMem.Devices = map[string]hcsschema.VirtualPMemDevice{
 			"0": {
-				HostPath:    filepath.Join(opts.BootFilesPath, opts.RootFSFile),
+				HostPath:    rootfsFullPath,
 				ReadOnly:    true,
 				ImageFormat: imageFormat,
 			},
 		}
-		if err := wclayer.GrantVmAccess(uvm.id, filepath.Join(opts.BootFilesPath, opts.RootFSFile)); err != nil {
-			return nil, fmt.Errorf("failed to grantvmaccess to %s: %s", filepath.Join(opts.BootFilesPath, opts.RootFSFile), err)
+		if err := wclayer.GrantVmAccess(uvm.id, rootfsFullPath); err != nil {
+			return nil, fmt.Errorf("failed to grantvmaccess to %s: %s", rootfsFullPath, err)
 		}
 		// Add to our internal structure
 		uvm.vpmemDevices[0] = vpmemInfo{
@@ -296,21 +290,15 @@ func CreateLCOW(opts *OptionsLCOW) (_ *UtilityVM, err error) {
 	// created below in order to forward guest logs to logrus.
 	initArgs := "/bin/vsockexec"
 
-	if *opts.ForwardStdout {
+	if opts.ForwardStdout {
 		initArgs += fmt.Sprintf(" -o %d", linuxLogVsockPort)
 	}
 
-	if *opts.ForwardStderr {
+	if opts.ForwardStderr {
 		initArgs += fmt.Sprintf(" -e %d", linuxLogVsockPort)
 	}
 
-	initArgs += " "
-	if opts.ExecCommandLine != "" {
-		initArgs += opts.ExecCommandLine
-	} else {
-		// Default to running GCS when another command isn't specified.
-		initArgs += fmt.Sprintf("/bin/gcs -log-format json -loglevel %s", logrus.StandardLogger().Level.String())
-	}
+	initArgs += " " + opts.ExecCommandLine
 
 	if vmDebugging {
 		// Launch a shell on the console.
@@ -322,18 +310,19 @@ func CreateLCOW(opts *OptionsLCOW) (_ *UtilityVM, err error) {
 	if !opts.KernelDirect {
 		doc.VirtualMachine.Chipset.Uefi = &hcsschema.Uefi{
 			BootThis: &hcsschema.UefiBootEntry{
-				DevicePath:   `\` + opts.KernelFile,
-				DeviceType:   "VmbFs",
-				OptionalData: kernelArgs,
+				DevicePath:    `\` + opts.KernelFile,
+				DeviceType:    "VmbFs",
+				VmbFsRootPath: opts.BootFilesPath,
+				OptionalData:  kernelArgs,
 			},
 		}
 	} else {
 		doc.VirtualMachine.Chipset.LinuxKernelDirect = &hcsschema.LinuxKernelDirect{
-			KernelFilePath: filepath.Join(opts.BootFilesPath, opts.KernelFile),
+			KernelFilePath: kernelFullPath,
 			KernelCmdLine:  kernelArgs,
 		}
-		if *opts.PreferredRootFSType == PreferredRootFSTypeInitRd {
-			doc.VirtualMachine.Chipset.LinuxKernelDirect.InitRdPath = filepath.Join(opts.BootFilesPath, opts.RootFSFile)
+		if opts.PreferredRootFSType == PreferredRootFSTypeInitRd {
+			doc.VirtualMachine.Chipset.LinuxKernelDirect.InitRdPath = rootfsFullPath
 		}
 	}
 
@@ -357,8 +346,8 @@ func CreateLCOW(opts *OptionsLCOW) (_ *UtilityVM, err error) {
 
 	// Create a socket that the executed program can send to. This is usually
 	// used by GCS to send log data.
-	if *opts.ForwardStdout || *opts.ForwardStderr {
-		uvm.outputHandler = *opts.OutputHandler
+	if opts.ForwardStdout || opts.ForwardStderr {
+		uvm.outputHandler = opts.OutputHandler
 		uvm.outputProcessingDone = make(chan struct{})
 		uvm.outputListener, err = uvm.listenVsock(linuxLogVsockPort)
 		if err != nil {

+ 5 - 5
vendor/github.com/Microsoft/hcsshim/internal/uvm/create_test.go

@@ -7,17 +7,17 @@ import (
 // Unit tests for negative testing of input to uvm.Create()
 
 func TestCreateBadBootFilesPath(t *testing.T) {
-	opts := &OptionsLCOW{
-		BootFilesPath: `c:\does\not\exist\I\hope`,
-	}
+	opts := NewDefaultOptionsLCOW(t.Name(), "")
+	opts.BootFilesPath = `c:\does\not\exist\I\hope`
+
 	_, err := CreateLCOW(opts)
-	if err == nil || (err != nil && err.Error() != `kernel 'c:\does\not\exist\I\hope\kernel' not found`) {
+	if err == nil || err.Error() != `kernel: 'c:\does\not\exist\I\hope\kernel' not found` {
 		t.Fatal(err)
 	}
 }
 
 func TestCreateWCOWBadLayerFolders(t *testing.T) {
-	opts := &OptionsWCOW{}
+	opts := NewDefaultOptionsWCOW(t.Name(), "")
 	_, err := CreateWCOW(opts)
 	if err == nil || (err != nil && err.Error() != `at least 2 LayerFolders must be supplied`) {
 		t.Fatal(err)

+ 36 - 17
vendor/github.com/Microsoft/hcsshim/internal/uvm/create_wcow.go

@@ -22,6 +22,35 @@ type OptionsWCOW struct {
 	LayerFolders []string // Set of folders for base layers and scratch. Ordered from top most read-only through base read-only layer, followed by scratch
 }
 
+// NewDefaultOptionsWCOW creates the default options for a bootable version of
+// WCOW. The caller `MUST` set the `LayerFolders` path on the returned value.
+//
+// `id` the ID of the compute system. If not passed will generate a new GUID.
+//
+// `owner` the owner of the compute system. If not passed will use the
+// executable files name.
+func NewDefaultOptionsWCOW(id, owner string) *OptionsWCOW {
+	opts := &OptionsWCOW{
+		Options: &Options{
+			ID:                   id,
+			Owner:                owner,
+			MemorySizeInMB:       1024,
+			AllowOvercommit:      true,
+			EnableDeferredCommit: false,
+			ProcessorCount:       defaultProcessorCount(),
+		},
+	}
+
+	if opts.ID == "" {
+		opts.ID = guid.New().String()
+	}
+	if opts.Owner == "" {
+		opts.Owner = filepath.Base(os.Args[0])
+	}
+
+	return opts
+}
+
 // CreateWCOW creates an HCS compute system representing a utility VM.
 //
 // WCOW Notes:
@@ -42,15 +71,6 @@ func CreateWCOW(opts *OptionsWCOW) (_ *UtilityVM, err error) {
 		vsmbShares:          make(map[string]*vsmbShare),
 	}
 
-	// Defaults if omitted by caller.
-	// TODO: Change this. Don't auto generate ID if omitted. Avoids the chicken-and-egg problem
-	if uvm.id == "" {
-		uvm.id = guid.New().String()
-	}
-	if uvm.owner == "" {
-		uvm.owner = filepath.Base(os.Args[0])
-	}
-
 	if len(opts.LayerFolders) < 2 {
 		return nil, fmt.Errorf("at least 2 LayerFolders must be supplied")
 	}
@@ -89,6 +109,7 @@ func CreateWCOW(opts *OptionsWCOW) (_ *UtilityVM, err error) {
 		SchemaVersion:                     schemaversion.SchemaV21(),
 		ShouldTerminateOnLastHandleClosed: true,
 		VirtualMachine: &hcsschema.VirtualMachine{
+			StopOnReset: true,
 			Chipset: &hcsschema.Chipset{
 				Uefi: &hcsschema.Uefi{
 					BootThis: &hcsschema.UefiBootEntry{
@@ -99,16 +120,14 @@ func CreateWCOW(opts *OptionsWCOW) (_ *UtilityVM, err error) {
 			},
 			ComputeTopology: &hcsschema.Topology{
 				Memory: &hcsschema.Memory2{
-					SizeInMB: normalizeMemory(opts.MemorySizeInMB),
-					// AllowOvercommit `true` by default if not passed.
-					AllowOvercommit: opts.AllowOvercommit == nil || *opts.AllowOvercommit,
-					// EnableHotHint is not compatible with physical. Only virtual, and only Windows.
-					EnableHotHint: opts.AllowOvercommit == nil || *opts.AllowOvercommit,
-					// EnableDeferredCommit `false` by default if not passed.
-					EnableDeferredCommit: opts.EnableDeferredCommit != nil && *opts.EnableDeferredCommit,
+					SizeInMB:        opts.MemorySizeInMB,
+					AllowOvercommit: opts.AllowOvercommit,
+					// EnableHotHint is not compatible with physical.
+					EnableHotHint:        opts.AllowOvercommit,
+					EnableDeferredCommit: opts.EnableDeferredCommit,
 				},
 				Processor: &hcsschema.Processor2{
-					Count: normalizeProcessors(opts.ProcessorCount),
+					Count: defaultProcessorCount(),
 				},
 			},
 			GuestConnection: &hcsschema.GuestConnection{},

+ 32 - 12
vendor/github.com/Microsoft/hcsshim/internal/uvm/network.go

@@ -24,7 +24,8 @@ func (uvm *UtilityVM) AddNetNS(id string, endpoints []*hns.HNSEndpoint) (err err
 		ns = &namespaceInfo{}
 
 		if uvm.isNetworkNamespaceSupported() {
-			// Add a Guest Network namespace. Remove windows check when LCOW supports it
+			// Add a Guest Network namespace. On LCOW we add the adapters
+			// dynamically.
 			if uvm.operatingSystem == "windows" {
 				hcnNamespace, err := hcn.GetNamespaceByID(id)
 				if err != nil {
@@ -182,13 +183,26 @@ func (uvm *UtilityVM) addNIC(id guid.GUID, endpoint *hns.HNSEndpoint) error {
 				requesttype.Add,
 				nil),
 		}
-		// Uncomment this once we have GuestRequest support for Linux
-		//} else {
-		//	request.GuestRequest = guestrequest.GuestRequest{
-		//		ResourceType: guestrequest.ResourceTypeNetwork,
-		//		RequestType:  requesttype.Add,
-		//		Settings:     endpoint,
-		//	}
+	} else {
+		// Verify this version of LCOW supports Network HotAdd
+		if uvm.isNetworkNamespaceSupported() {
+			request.GuestRequest = guestrequest.GuestRequest{
+				ResourceType: guestrequest.ResourceTypeNetwork,
+				RequestType:  requesttype.Add,
+				Settings: &guestrequest.LCOWNetworkAdapter{
+					NamespaceID:     endpoint.Namespace.ID,
+					ID:              id.String(),
+					MacAddress:      endpoint.MacAddress,
+					IPAddress:       endpoint.IPAddress.String(),
+					PrefixLength:    endpoint.PrefixLength,
+					GatewayAddress:  endpoint.GatewayAddress,
+					DNSSuffix:       endpoint.DNSSuffix,
+					DNSServerList:   endpoint.DNSServerList,
+					EnableLowMetric: endpoint.EnableLowMetric,
+					EncapOverhead:   endpoint.EncapOverhead,
+				},
+			}
+		}
 	}
 
 	if err := uvm.Modify(&request); err != nil {
@@ -217,10 +231,16 @@ func (uvm *UtilityVM) removeNIC(id guid.GUID, endpoint *hns.HNSEndpoint) error {
 				nil),
 		}
 	} else {
-		request.GuestRequest = guestrequest.GuestRequest{
-			ResourceType: guestrequest.ResourceTypeNetwork,
-			RequestType:  requesttype.Remove,
-			Settings:     endpoint,
+		// Verify this version of LCOW supports Network HotRemove
+		if uvm.isNetworkNamespaceSupported() {
+			request.GuestRequest = guestrequest.GuestRequest{
+				ResourceType: guestrequest.ResourceTypeNetwork,
+				RequestType:  requesttype.Remove,
+				Settings: &guestrequest.LCOWNetworkAdapter{
+					NamespaceID: endpoint.Namespace.ID,
+					ID:          endpoint.Id,
+				},
+			}
 		}
 	}
 

+ 20 - 3
vendor/github.com/Microsoft/hcsshim/internal/uvm/plan9.go

@@ -27,6 +27,22 @@ func (uvm *UtilityVM) AddPlan9(hostPath string, uvmPath string, readOnly bool) e
 		return fmt.Errorf("uvmPath must be passed to AddPlan9")
 	}
 
+	// TODO: JTERRY75 - These are marked private in the schema. For now use them
+	// but when there are public variants we need to switch to them.
+	const (
+		shareFlagsReadOnly      int32 = 0x00000001
+		shareFlagsLinuxMetadata int32 = 0x00000004
+		shareFlagsCaseSensitive int32 = 0x00000008
+	)
+
+	// TODO: JTERRY75 - `shareFlagsCaseSensitive` only works if the Windows
+	// `hostPath` supports case sensitivity. We need to detect this case before
+	// forwarding this flag in all cases.
+	flags := shareFlagsLinuxMetadata // | shareFlagsCaseSensitive
+	if readOnly {
+		flags |= shareFlagsReadOnly
+	}
+
 	uvm.m.Lock()
 	defer uvm.m.Unlock()
 	if uvm.plan9Shares == nil {
@@ -38,9 +54,10 @@ func (uvm *UtilityVM) AddPlan9(hostPath string, uvmPath string, readOnly bool) e
 		modification := &hcsschema.ModifySettingRequest{
 			RequestType: requesttype.Add,
 			Settings: hcsschema.Plan9Share{
-				Name: fmt.Sprintf("%d", uvm.plan9Counter),
-				Path: hostPath,
-				Port: int32(uvm.plan9Counter), // TODO: Temporary. Will all use a single port (9999)
+				Name:  fmt.Sprintf("%d", uvm.plan9Counter),
+				Path:  hostPath,
+				Port:  int32(uvm.plan9Counter), // TODO: Temporary. Will all use a single port (9999)
+				Flags: flags,
 			},
 			ResourcePath: fmt.Sprintf("VirtualMachine/Devices/Plan9/Shares"),
 			GuestRequest: guestrequest.GuestRequest{

+ 31 - 9
vendor/github.com/Microsoft/hcsshim/internal/uvm/start.go

@@ -1,6 +1,7 @@
 package uvm
 
 import (
+	"context"
 	"encoding/json"
 	"io"
 	"io/ioutil"
@@ -12,6 +13,8 @@ import (
 
 const _ERROR_CONNECTION_ABORTED syscall.Errno = 1236
 
+var _ = (OutputHandler)(parseLogrus)
+
 func parseLogrus(r io.Reader) {
 	j := json.NewDecoder(r)
 	logger := logrus.StandardLogger()
@@ -52,24 +55,43 @@ func parseLogrus(r io.Reader) {
 	}
 }
 
-func processOutput(l net.Listener, doneChan chan struct{}, handler OutputHandler) {
+type acceptResult struct {
+	c   net.Conn
+	err error
+}
+
+func processOutput(ctx context.Context, l net.Listener, doneChan chan struct{}, handler OutputHandler) {
 	defer close(doneChan)
 
-	c, err := l.Accept()
-	l.Close()
-	if err != nil {
-		logrus.Error("accepting log socket: ", err)
+	ch := make(chan acceptResult)
+	go func() {
+		c, err := l.Accept()
+		ch <- acceptResult{c, err}
+	}()
+
+	select {
+	case <-ctx.Done():
+		l.Close()
 		return
-	}
-	defer c.Close()
+	case ar := <-ch:
+		c, err := ar.c, ar.err
+		l.Close()
+		if err != nil {
+			logrus.Error("accepting log socket: ", err)
+			return
+		}
+		defer c.Close()
 
-	handler(c)
+		handler(c)
+	}
 }
 
 // Start synchronously starts the utility VM.
 func (uvm *UtilityVM) Start() error {
 	if uvm.outputListener != nil {
-		go processOutput(uvm.outputListener, uvm.outputProcessingDone, uvm.outputHandler)
+		ctx, cancel := context.WithCancel(context.Background())
+		go processOutput(ctx, uvm.outputListener, uvm.outputProcessingDone, uvm.outputHandler)
+		uvm.outputProcessingCancel = cancel
 		uvm.outputListener = nil
 	}
 	return uvm.hcsSystem.Start()

+ 5 - 3
vendor/github.com/Microsoft/hcsshim/internal/uvm/types.go

@@ -3,6 +3,7 @@ package uvm
 // This package describes the external interface for utility VMs.
 
 import (
+	"context"
 	"net"
 	"sync"
 
@@ -97,7 +98,8 @@ type UtilityVM struct {
 
 	namespaces map[string]*namespaceInfo
 
-	outputListener       net.Listener
-	outputProcessingDone chan struct{}
-	outputHandler        OutputHandler
+	outputListener         net.Listener
+	outputProcessingDone   chan struct{}
+	outputHandler          OutputHandler
+	outputProcessingCancel context.CancelFunc
 }

+ 19 - 0
vendor/github.com/Microsoft/hcsshim/internal/uvm/wait.go

@@ -16,12 +16,31 @@ func (uvm *UtilityVM) waitForOutput() {
 // Waits synchronously waits for a utility VM to terminate.
 func (uvm *UtilityVM) Wait() error {
 	err := uvm.hcsSystem.Wait()
+
+	// outputProcessingCancel will only cancel waiting for the vsockexec
+	// connection, it won't stop output processing once the connection is
+	// established.
+	if uvm.outputProcessingCancel != nil {
+		uvm.outputProcessingCancel()
+	}
 	uvm.waitForOutput()
+
 	return err
 }
 
+// WaitExpectedError synchronously waits for a utility VM to terminate. If the
+// UVM terminates successfully, or if the given error is encountered internally
+// during the wait, this function returns nil.
 func (uvm *UtilityVM) WaitExpectedError(expected error) error {
 	err := uvm.hcsSystem.WaitExpectedError(expected)
+
+	// outputProcessingCancel will only cancel waiting for the vsockexec
+	// connection, it won't stop output processing once the connection is
+	// established.
+	if uvm.outputProcessingCancel != nil {
+		uvm.outputProcessingCancel()
+	}
 	uvm.waitForOutput()
+
 	return err
 }

+ 16 - 3
vendor/github.com/Microsoft/hcsshim/pkg/go-runhcs/runhcs.go

@@ -35,9 +35,22 @@ func getCommandPath() string {
 	if pathi == nil {
 		path, err := exec.LookPath(command)
 		if err != nil {
-			// Failed to look up command just use it directly and let the
-			// Windows loader find it.
-			path = command
+			// LookPath only finds current directory matches based on the
+			// callers current directory but the caller is not likely in the
+			// same directory as the containerd executables. Instead match the
+			// calling binaries path (a containerd shim usually) and see if they
+			// are side by side. If so execute the runhcs.exe found there.
+			if self, serr := os.Executable(); serr == nil {
+				testPath := filepath.Join(filepath.Dir(self), command)
+				if _, serr := os.Stat(testPath); serr == nil {
+					path = testPath
+				}
+			}
+			if path == "" {
+				// Failed to look up command just use it directly and let the
+				// Windows loader find it.
+				path = command
+			}
 			runhcsPath.Store(path)
 			return path
 		}

+ 0 - 65
vendor/github.com/Microsoft/hcsshim/pkg/go-runhcs/runhcs_create-scratch_test.go

@@ -1,65 +0,0 @@
-// +build integration
-
-package runhcs
-
-import (
-	"context"
-	"io/ioutil"
-	"os"
-	"path/filepath"
-	"testing"
-)
-
-func Test_CreateScratch_EmptyDestpath_Fail(t *testing.T) {
-	rhcs := Runhcs{
-		Debug: true,
-	}
-
-	ctx := context.TODO()
-	err := rhcs.CreateScratch(ctx, "")
-	if err == nil {
-		t.Fatal("Should have failed 'CreateScratch' command.")
-	}
-}
-
-func Test_CreateScratch_DirDestpath_Failure(t *testing.T) {
-	rhcs := Runhcs{
-		Debug: true,
-	}
-
-	td, err := ioutil.TempDir("", "CreateScratch")
-	if err != nil {
-		t.Fatal(err)
-	}
-	defer os.Remove(td)
-
-	ctx := context.TODO()
-	err = rhcs.CreateScratch(ctx, td)
-	if err == nil {
-		t.Fatal("Should have failed 'CreateScratch' command with dir destpath")
-	}
-}
-
-func Test_CreateScratch_ValidDestpath_Success(t *testing.T) {
-	rhcs := Runhcs{
-		Debug: true,
-	}
-
-	td, err := ioutil.TempDir("", "CreateScratch")
-	if err != nil {
-		t.Fatal(err)
-	}
-	defer os.RemoveAll(td)
-
-	scratchPath := filepath.Join(td, "scratch.vhdx")
-
-	ctx := context.TODO()
-	err = rhcs.CreateScratch(ctx, scratchPath)
-	if err != nil {
-		t.Fatalf("Failed 'CreateScratch' command with: %v", err)
-	}
-	_, err = os.Stat(scratchPath)
-	if err != nil {
-		t.Fatalf("Failed to stat scratch path with: %v", err)
-	}
-}

+ 0 - 7
vendor/github.com/Microsoft/hcsshim/pkg/go-runhcs/runhcs_integration_test.go

@@ -1,7 +0,0 @@
-// +build integration
-
-package runhcs
-
-import (
-	_ "github.com/Microsoft/hcsshim/functional/manifest"
-)

+ 0 - 23
vendor/github.com/Microsoft/hcsshim/pkg/go-runhcs/runhcs_list_test.go

@@ -1,23 +0,0 @@
-// +build integration
-
-package runhcs
-
-import (
-	"context"
-	"testing"
-)
-
-func Test_List_NoContainers(t *testing.T) {
-	rhcs := Runhcs{
-		Debug: true,
-	}
-
-	ctx := context.TODO()
-	cs, err := rhcs.List(ctx)
-	if err != nil {
-		t.Fatalf("Failed 'List' command with: %v", err)
-	}
-	if len(cs) != 0 {
-		t.Fatalf("Length of ContainerState array expected: 0, actual: %d", len(cs))
-	}
-}

+ 0 - 0
vendor/github.com/Microsoft/hcsshim/functional/assets/defaultlinuxspec.json → vendor/github.com/Microsoft/hcsshim/test/functional/assets/defaultlinuxspec.json


+ 0 - 0
vendor/github.com/Microsoft/hcsshim/functional/assets/defaultwindowsspec.json → vendor/github.com/Microsoft/hcsshim/test/functional/assets/defaultwindowsspec.json


+ 0 - 0
vendor/github.com/Microsoft/hcsshim/functional/assets/samples/config.justin.lcow.working.json → vendor/github.com/Microsoft/hcsshim/test/functional/assets/samples/config.justin.lcow.working.json


+ 0 - 0
vendor/github.com/Microsoft/hcsshim/functional/assets/samples/from-docker-linux/privileged.json → vendor/github.com/Microsoft/hcsshim/test/functional/assets/samples/from-docker-linux/privileged.json


+ 0 - 0
vendor/github.com/Microsoft/hcsshim/functional/assets/samples/from-docker-linux/sh.json → vendor/github.com/Microsoft/hcsshim/test/functional/assets/samples/from-docker-linux/sh.json


+ 25 - 31
vendor/github.com/Microsoft/hcsshim/functional/lcow_test.go → vendor/github.com/Microsoft/hcsshim/test/functional/lcow_test.go

@@ -4,6 +4,7 @@ package functional
 
 import (
 	"bytes"
+	"fmt"
 	"os"
 	"os/exec"
 	"path/filepath"
@@ -11,44 +12,35 @@ import (
 	"testing"
 	"time"
 
-	"github.com/Microsoft/hcsshim/functional/utilities"
 	"github.com/Microsoft/hcsshim/internal/hcs"
 	"github.com/Microsoft/hcsshim/internal/hcsoci"
 	"github.com/Microsoft/hcsshim/internal/lcow"
 	"github.com/Microsoft/hcsshim/internal/uvm"
 	"github.com/Microsoft/hcsshim/osversion"
+	"github.com/Microsoft/hcsshim/test/functional/utilities"
 )
 
 // TestLCOWUVMNoSCSINoVPMemInitrd starts an LCOW utility VM without a SCSI controller and
 // no VPMem device. Uses initrd.
 func TestLCOWUVMNoSCSINoVPMemInitrd(t *testing.T) {
-	var scsiCount uint32 = 0
-	var vpmemCount uint32 = 0
-	opts := &uvm.OptionsLCOW{
-		Options: &uvm.Options{
-			ID: "uvm",
-		},
-		VPMemDeviceCount:    &vpmemCount,
-		SCSIControllerCount: &scsiCount,
-	}
-	testLCOWUVMNoSCSISingleVPMem(t, opts, `Command line: initrd=/initrd.img`)
+	opts := uvm.NewDefaultOptionsLCOW(t.Name(), "")
+	opts.SCSIControllerCount = 0
+	opts.VPMemDeviceCount = 0
+	opts.PreferredRootFSType = uvm.PreferredRootFSTypeInitRd
+	opts.RootFSFile = uvm.InitrdFile
+
+	testLCOWUVMNoSCSISingleVPMem(t, opts, fmt.Sprintf("Command line: initrd=/%s", opts.RootFSFile))
 }
 
 // TestLCOWUVMNoSCSISingleVPMemVHD starts an LCOW utility VM without a SCSI controller and
 // only a single VPMem device. Uses VPMEM VHD
 func TestLCOWUVMNoSCSISingleVPMemVHD(t *testing.T) {
-	var scsiCount uint32 = 0
-	var vpmemCount uint32 = 1
-	var prfst uvm.PreferredRootFSType = uvm.PreferredRootFSTypeVHD
-	opts := &uvm.OptionsLCOW{
-		Options: &uvm.Options{
-			ID: "uvm",
-		},
-		VPMemDeviceCount:    &vpmemCount,
-		SCSIControllerCount: &scsiCount,
-		PreferredRootFSType: &prfst,
-		//ConsolePipe:         `\\.\pipe\vmpipe`,
-	}
+	opts := uvm.NewDefaultOptionsLCOW(t.Name(), "")
+	opts.SCSIControllerCount = 0
+	opts.VPMemDeviceCount = 1
+	opts.PreferredRootFSType = uvm.PreferredRootFSTypeVHD
+	opts.RootFSFile = uvm.VhdFile
+
 	testLCOWUVMNoSCSISingleVPMem(t, opts, `Command line: root=/dev/pmem0 init=/init`)
 }
 
@@ -100,16 +92,18 @@ func TestLCOWUVMStart_KernelDirect_InitRd(t *testing.T) {
 }
 
 func testLCOWTimeUVMStart(t *testing.T, kernelDirect bool, rfsType uvm.PreferredRootFSType) {
-	var vpmemCount uint32 = 32
 	for i := 0; i < 3; i++ {
-		opts := &uvm.OptionsLCOW{
-			Options: &uvm.Options{
-				ID: t.Name(),
-			},
-			VPMemDeviceCount:    &vpmemCount,
-			PreferredRootFSType: &rfsType,
-			KernelDirect:        kernelDirect,
+		opts := uvm.NewDefaultOptionsLCOW(t.Name(), "")
+		opts.KernelDirect = kernelDirect
+		opts.VPMemDeviceCount = 32
+		opts.PreferredRootFSType = rfsType
+		switch opts.PreferredRootFSType {
+		case uvm.PreferredRootFSTypeInitRd:
+			opts.RootFSFile = uvm.InitrdFile
+		case uvm.PreferredRootFSTypeVHD:
+			opts.RootFSFile = uvm.VhdFile
 		}
+
 		lcowUVM := testutilities.CreateLCOWUVMFromOpts(t, opts)
 		lcowUVM.Close()
 	}

+ 0 - 0
vendor/github.com/Microsoft/hcsshim/functional/manifest/manifest.go → vendor/github.com/Microsoft/hcsshim/test/functional/manifest/manifest.go


+ 0 - 0
vendor/github.com/Microsoft/hcsshim/functional/manifest/rsrc_amd64.syso → vendor/github.com/Microsoft/hcsshim/test/functional/manifest/rsrc_amd64.syso


+ 3 - 0
vendor/github.com/Microsoft/hcsshim/test/functional/manifest_test.go

@@ -0,0 +1,3 @@
+package functional
+
+import _ "github.com/Microsoft/hcsshim/test/functional/manifest"

+ 0 - 0
vendor/github.com/Microsoft/hcsshim/functional/test.go → vendor/github.com/Microsoft/hcsshim/test/functional/test.go


+ 3 - 12
vendor/github.com/Microsoft/hcsshim/functional/utilities/createuvm.go → vendor/github.com/Microsoft/hcsshim/test/functional/utilities/createuvm.go

@@ -4,14 +4,13 @@ import (
 	"os"
 	"testing"
 
-	"github.com/Microsoft/hcsshim/internal/guid"
 	"github.com/Microsoft/hcsshim/internal/uvm"
 )
 
 // CreateWCOWUVM creates a WCOW utility VM with all default options. Returns the
 // UtilityVM object; folder used as its scratch
 func CreateWCOWUVM(t *testing.T, id, image string) (*uvm.UtilityVM, []string, string) {
-	return CreateWCOWUVMFromOptsWithImage(t, &uvm.OptionsWCOW{Options: &uvm.Options{ID: id}}, image)
+	return CreateWCOWUVMFromOptsWithImage(t, uvm.NewDefaultOptionsWCOW(id, ""), image)
 
 }
 
@@ -20,9 +19,6 @@ func CreateWCOWUVMFromOpts(t *testing.T, opts *uvm.OptionsWCOW) *uvm.UtilityVM {
 	if opts == nil || len(opts.LayerFolders) < 2 {
 		t.Fatalf("opts must bet set with LayerFolders")
 	}
-	if opts.ID == "" {
-		opts.ID = guid.New().String()
-	}
 
 	uvm, err := uvm.CreateWCOW(opts)
 	if err != nil {
@@ -59,18 +55,13 @@ func CreateWCOWUVMFromOptsWithImage(t *testing.T, opts *uvm.OptionsWCOW, image s
 
 // CreateLCOWUVM with all default options.
 func CreateLCOWUVM(t *testing.T, id string) *uvm.UtilityVM {
-	return CreateLCOWUVMFromOpts(t, &uvm.OptionsLCOW{Options: &uvm.Options{ID: id}})
+	return CreateLCOWUVMFromOpts(t, uvm.NewDefaultOptionsLCOW(id, ""))
 }
 
 // CreateLCOWUVMFromOpts creates an LCOW utility VM with the specified options.
 func CreateLCOWUVMFromOpts(t *testing.T, opts *uvm.OptionsLCOW) *uvm.UtilityVM {
 	if opts == nil {
-		opts = &uvm.OptionsLCOW{
-			Options: &uvm.Options{},
-		}
-	}
-	if opts.ID == "" {
-		opts.ID = guid.New().String()
+		t.Fatal("opts must be set")
 	}
 
 	uvm, err := uvm.CreateLCOW(opts)

+ 0 - 0
vendor/github.com/Microsoft/hcsshim/functional/utilities/defaultlinuxspec.go → vendor/github.com/Microsoft/hcsshim/test/functional/utilities/defaultlinuxspec.go


+ 0 - 0
vendor/github.com/Microsoft/hcsshim/functional/utilities/defaultwindowsspec.go → vendor/github.com/Microsoft/hcsshim/test/functional/utilities/defaultwindowsspec.go


+ 0 - 0
vendor/github.com/Microsoft/hcsshim/functional/utilities/layerfolders.go → vendor/github.com/Microsoft/hcsshim/test/functional/utilities/layerfolders.go


+ 0 - 0
vendor/github.com/Microsoft/hcsshim/functional/utilities/requiresbuild.go → vendor/github.com/Microsoft/hcsshim/test/functional/utilities/requiresbuild.go


+ 0 - 0
vendor/github.com/Microsoft/hcsshim/functional/utilities/scratch.go → vendor/github.com/Microsoft/hcsshim/test/functional/utilities/scratch.go


+ 0 - 0
vendor/github.com/Microsoft/hcsshim/functional/utilities/tempdir.go → vendor/github.com/Microsoft/hcsshim/test/functional/utilities/tempdir.go


+ 27 - 32
vendor/github.com/Microsoft/hcsshim/functional/uvm_mem_backingtype_test.go → vendor/github.com/Microsoft/hcsshim/test/functional/uvm_mem_backingtype_test.go

@@ -7,51 +7,48 @@ import (
 	"os"
 	"testing"
 
-	"github.com/Microsoft/hcsshim/functional/utilities"
 	"github.com/Microsoft/hcsshim/internal/uvm"
 	"github.com/Microsoft/hcsshim/osversion"
+	testutilities "github.com/Microsoft/hcsshim/test/functional/utilities"
 	"github.com/sirupsen/logrus"
 )
 
-func runMemStartLCOWTest(t *testing.T, opts *uvm.Options) {
-	u := testutilities.CreateLCOWUVMFromOpts(t, &uvm.OptionsLCOW{Options: opts})
+func runMemStartLCOWTest(t *testing.T, opts *uvm.OptionsLCOW) {
+	u := testutilities.CreateLCOWUVMFromOpts(t, opts)
 	u.Close()
 }
 
-func runMemStartWCOWTest(t *testing.T, opts *uvm.Options) {
-	u, _, scratchDir := testutilities.CreateWCOWUVMFromOptsWithImage(t, &uvm.OptionsWCOW{Options: opts}, "microsoft/nanoserver")
+func runMemStartWCOWTest(t *testing.T, opts *uvm.OptionsWCOW) {
+	u, _, scratchDir := testutilities.CreateWCOWUVMFromOptsWithImage(t, opts, "microsoft/nanoserver")
 	defer os.RemoveAll(scratchDir)
 	u.Close()
 }
 
 func runMemTests(t *testing.T, os string) {
 	type testCase struct {
-		allowOvercommit      *bool
-		enableDeferredCommit *bool
+		allowOvercommit      bool
+		enableDeferredCommit bool
 	}
 
-	yes := true
-	no := false
-
 	testCases := []testCase{
-		{nil, nil}, // Implicit default - Virtual
-		{allowOvercommit: &yes, enableDeferredCommit: &no},  // Explicit default - Virtual
-		{allowOvercommit: &yes, enableDeferredCommit: &yes}, // Virtual Deferred
-		{allowOvercommit: &no, enableDeferredCommit: &no},   // Physical
+		{allowOvercommit: true, enableDeferredCommit: false},  // Explicit default - Virtual
+		{allowOvercommit: true, enableDeferredCommit: true},   // Virtual Deferred
+		{allowOvercommit: false, enableDeferredCommit: false}, // Physical
 	}
 
 	for _, bt := range testCases {
-		opts := &uvm.Options{
-			ID:                   t.Name(),
-			MemorySizeInMB:       512,
-			AllowOvercommit:      bt.allowOvercommit,
-			EnableDeferredCommit: bt.enableDeferredCommit,
-		}
-
 		if os == "windows" {
-			runMemStartWCOWTest(t, opts)
+			wopts := uvm.NewDefaultOptionsWCOW(t.Name(), "")
+			wopts.MemorySizeInMB = 512
+			wopts.AllowOvercommit = bt.allowOvercommit
+			wopts.EnableDeferredCommit = bt.enableDeferredCommit
+			runMemStartWCOWTest(t, wopts)
 		} else {
-			runMemStartLCOWTest(t, opts)
+			lopts := uvm.NewDefaultOptionsLCOW(t.Name(), "")
+			lopts.MemorySizeInMB = 512
+			lopts.AllowOvercommit = bt.allowOvercommit
+			lopts.EnableDeferredCommit = bt.enableDeferredCommit
+			runMemStartLCOWTest(t, lopts)
 		}
 	}
 }
@@ -66,9 +63,9 @@ func TestMemBackingTypeLCOW(t *testing.T) {
 	runMemTests(t, "linux")
 }
 
-func runBenchMemStartTest(b *testing.B, opts *uvm.Options) {
+func runBenchMemStartTest(b *testing.B, opts *uvm.OptionsLCOW) {
 	// Cant use testutilities here because its `testing.B` not `testing.T`
-	u, err := uvm.CreateLCOW(&uvm.OptionsLCOW{Options: opts})
+	u, err := uvm.CreateLCOW(opts)
 	if err != nil {
 		b.Fatal(err)
 	}
@@ -78,14 +75,12 @@ func runBenchMemStartTest(b *testing.B, opts *uvm.Options) {
 	}
 }
 
-func runBenchMemStartLcowTest(b *testing.B, allowOverCommit bool, enableDeferredCommit bool) {
+func runBenchMemStartLcowTest(b *testing.B, allowOvercommit bool, enableDeferredCommit bool) {
 	for i := 0; i < b.N; i++ {
-		opts := &uvm.Options{
-			ID:                   b.Name(),
-			MemorySizeInMB:       512,
-			AllowOvercommit:      &allowOverCommit,
-			EnableDeferredCommit: &enableDeferredCommit,
-		}
+		opts := uvm.NewDefaultOptionsLCOW(b.Name(), "")
+		opts.MemorySizeInMB = 512
+		opts.AllowOvercommit = allowOvercommit
+		opts.EnableDeferredCommit = enableDeferredCommit
 		runBenchMemStartTest(b, opts)
 	}
 }

+ 1 - 1
vendor/github.com/Microsoft/hcsshim/functional/uvm_plannine_test.go → vendor/github.com/Microsoft/hcsshim/test/functional/uvm_plannine_test.go

@@ -10,8 +10,8 @@ import (
 	"path/filepath"
 	"testing"
 
-	"github.com/Microsoft/hcsshim/functional/utilities"
 	"github.com/Microsoft/hcsshim/osversion"
+	"github.com/Microsoft/hcsshim/test/functional/utilities"
 )
 
 // TestPlan9 tests adding/removing Plan9 shares to/from a v2 Linux utility VM

+ 1 - 1
vendor/github.com/Microsoft/hcsshim/functional/uvm_properties_test.go → vendor/github.com/Microsoft/hcsshim/test/functional/uvm_properties_test.go

@@ -6,9 +6,9 @@ import (
 	"os"
 	"testing"
 
-	"github.com/Microsoft/hcsshim/functional/utilities"
 	"github.com/Microsoft/hcsshim/internal/schema1"
 	"github.com/Microsoft/hcsshim/osversion"
+	"github.com/Microsoft/hcsshim/test/functional/utilities"
 )
 
 func TestPropertiesGuestConnection_LCOW(t *testing.T) {

+ 1 - 1
vendor/github.com/Microsoft/hcsshim/functional/uvm_scratch_test.go → vendor/github.com/Microsoft/hcsshim/test/functional/uvm_scratch_test.go

@@ -7,9 +7,9 @@ import (
 	"path/filepath"
 	"testing"
 
-	"github.com/Microsoft/hcsshim/functional/utilities"
 	"github.com/Microsoft/hcsshim/internal/lcow"
 	"github.com/Microsoft/hcsshim/osversion"
+	"github.com/Microsoft/hcsshim/test/functional/utilities"
 )
 
 func TestScratchCreateLCOW(t *testing.T) {

+ 1 - 1
vendor/github.com/Microsoft/hcsshim/functional/uvm_scsi_test.go → vendor/github.com/Microsoft/hcsshim/test/functional/uvm_scsi_test.go

@@ -8,9 +8,9 @@ import (
 	"path/filepath"
 	"testing"
 
-	"github.com/Microsoft/hcsshim/functional/utilities"
 	"github.com/Microsoft/hcsshim/internal/uvm"
 	"github.com/Microsoft/hcsshim/osversion"
+	"github.com/Microsoft/hcsshim/test/functional/utilities"
 	"github.com/sirupsen/logrus"
 )
 

+ 1 - 1
vendor/github.com/Microsoft/hcsshim/functional/uvm_vpmem_test.go → vendor/github.com/Microsoft/hcsshim/test/functional/uvm_vpmem_test.go

@@ -7,10 +7,10 @@ import (
 	"path/filepath"
 	"testing"
 
-	"github.com/Microsoft/hcsshim/functional/utilities"
 	"github.com/Microsoft/hcsshim/internal/copyfile"
 	"github.com/Microsoft/hcsshim/internal/uvm"
 	"github.com/Microsoft/hcsshim/osversion"
+	"github.com/Microsoft/hcsshim/test/functional/utilities"
 	"github.com/sirupsen/logrus"
 )
 

+ 1 - 1
vendor/github.com/Microsoft/hcsshim/functional/uvm_vsmb_test.go → vendor/github.com/Microsoft/hcsshim/test/functional/uvm_vsmb_test.go

@@ -6,9 +6,9 @@ import (
 	"os"
 	"testing"
 
-	"github.com/Microsoft/hcsshim/functional/utilities"
 	"github.com/Microsoft/hcsshim/internal/schema2"
 	"github.com/Microsoft/hcsshim/osversion"
+	"github.com/Microsoft/hcsshim/test/functional/utilities"
 )
 
 // TestVSMB tests adding/removing VSMB layers from a v2 Windows utility VM

+ 4 - 8
vendor/github.com/Microsoft/hcsshim/functional/wcow_test.go → vendor/github.com/Microsoft/hcsshim/test/functional/wcow_test.go

@@ -10,7 +10,6 @@ import (
 	"testing"
 
 	"github.com/Microsoft/hcsshim"
-	"github.com/Microsoft/hcsshim/functional/utilities"
 	"github.com/Microsoft/hcsshim/internal/hcs"
 	"github.com/Microsoft/hcsshim/internal/hcsoci"
 	"github.com/Microsoft/hcsshim/internal/schema1"
@@ -20,6 +19,7 @@ import (
 	"github.com/Microsoft/hcsshim/internal/wclayer"
 	"github.com/Microsoft/hcsshim/internal/wcow"
 	"github.com/Microsoft/hcsshim/osversion"
+	"github.com/Microsoft/hcsshim/test/functional/utilities"
 	specs "github.com/opencontainers/runtime-spec/specs-go"
 )
 
@@ -692,13 +692,9 @@ func TestWCOWXenonOciV2(t *testing.T) {
 		t.Fatalf("failed to create scratch: %s", err)
 	}
 
-	xenonOci2UVM, err = uvm.CreateWCOW(
-		&uvm.OptionsWCOW{
-			Options: &uvm.Options{
-				ID: xenonOci2UVMId,
-			},
-			LayerFolders: append(imageLayers, xenonOci2UVMScratchDir),
-		})
+	xenonOciOpts := uvm.NewDefaultOptionsWCOW(xenonOci2UVMId, "")
+	xenonOciOpts.LayerFolders = append(imageLayers, xenonOci2UVMScratchDir)
+	xenonOci2UVM, err = uvm.CreateWCOW(xenonOciOpts)
 	if err != nil {
 		t.Fatalf("Failed create UVM: %s", err)
 	}

+ 1 - 1
vendor/github.com/Microsoft/hcsshim/functional/wcow_xenon_v2_test.go → vendor/github.com/Microsoft/hcsshim/test/functional/wcow_xenon_v2_test.go

@@ -6,7 +6,7 @@ package functional
 //	"os"
 //	"testing"
 
-//	"github.com/Microsoft/hcsshim/functional/utilities"
+//	"github.com/Microsoft/hcsshim/test/functional/utilities"
 //	"github.com/Microsoft/hcsshim/internal/guid"
 //	"github.com/Microsoft/hcsshim/internal/hcsoci"
 //	"github.com/Microsoft/hcsshim/osversion"

+ 5 - 3
vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_create-scratch_test.go → vendor/github.com/Microsoft/hcsshim/test/runhcs/create-scratch_test.go

@@ -8,10 +8,12 @@ import (
 	"os"
 	"path/filepath"
 	"testing"
+
+	runhcs "github.com/Microsoft/hcsshim/pkg/go-runhcs"
 )
 
 func Test_CreateScratch_EmptyDestpath_Fail(t *testing.T) {
-	rhcs := Runhcs{
+	rhcs := runhcs.Runhcs{
 		Debug: true,
 	}
 
@@ -23,7 +25,7 @@ func Test_CreateScratch_EmptyDestpath_Fail(t *testing.T) {
 }
 
 func Test_CreateScratch_DirDestpath_Failure(t *testing.T) {
-	rhcs := Runhcs{
+	rhcs := runhcs.Runhcs{
 		Debug: true,
 	}
 
@@ -41,7 +43,7 @@ func Test_CreateScratch_DirDestpath_Failure(t *testing.T) {
 }
 
 func Test_CreateScratch_ValidDestpath_Success(t *testing.T) {
-	rhcs := Runhcs{
+	rhcs := runhcs.Runhcs{
 		Debug: true,
 	}
 

+ 5 - 4
vendor/github.com/Microsoft/hcsshim/pkg/go-runhcs/runhcs_e2e_matrix_test.go → vendor/github.com/Microsoft/hcsshim/test/runhcs/e2e_matrix_test.go

@@ -16,8 +16,9 @@ import (
 	"testing"
 
 	"github.com/Microsoft/go-winio/vhd"
-	testutilities "github.com/Microsoft/hcsshim/functional/utilities"
 	"github.com/Microsoft/hcsshim/osversion"
+	runhcs "github.com/Microsoft/hcsshim/pkg/go-runhcs"
+	testutilities "github.com/Microsoft/hcsshim/test/functional/utilities"
 	runc "github.com/containerd/go-runc"
 	"github.com/opencontainers/runtime-tools/generate"
 	"github.com/pkg/errors"
@@ -214,7 +215,7 @@ func testWindows(t *testing.T, version int, isolated bool) {
 
 	// Create the Argon, Xenon, or UVM
 	ctx := context.TODO()
-	rhcs := Runhcs{
+	rhcs := runhcs.Runhcs{
 		Debug: true,
 	}
 	tio := newTestIO(t)
@@ -226,7 +227,7 @@ func testWindows(t *testing.T, version int, isolated bool) {
 	defer func() {
 		tio.Close()
 	}()
-	copts := &CreateOpts{
+	copts := &runhcs.CreateOpts{
 		IO:      tio,
 		PidFile: filepath.Join(bundle, "pid-file.txt"),
 		ShimLog: filepath.Join(bundle, "shim-log.txt"),
@@ -240,7 +241,7 @@ func testWindows(t *testing.T, version int, isolated bool) {
 		return
 	}
 	defer func() {
-		rhcs.Delete(ctx, t.Name(), &DeleteOpts{Force: true})
+		rhcs.Delete(ctx, t.Name(), &runhcs.DeleteOpts{Force: true})
 	}()
 
 	// Find the shim/vmshim process and begin exit wait

+ 3 - 1
vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_list_test.go → vendor/github.com/Microsoft/hcsshim/test/runhcs/list_test.go

@@ -5,10 +5,12 @@ package runhcs
 import (
 	"context"
 	"testing"
+
+	runhcs "github.com/Microsoft/hcsshim/pkg/go-runhcs"
 )
 
 func Test_List_NoContainers(t *testing.T) {
-	rhcs := Runhcs{
+	rhcs := runhcs.Runhcs{
 		Debug: true,
 	}
 

+ 7 - 0
vendor/github.com/Microsoft/hcsshim/test/runhcs/runhcs_test.go

@@ -0,0 +1,7 @@
+// +build integration
+
+package runhcs
+
+import (
+	_ "github.com/Microsoft/hcsshim/test/functional/manifest"
+)

+ 24 - 31
vendor/github.com/Microsoft/hcsshim/tools/uvmboot/main.go

@@ -32,6 +32,7 @@ const (
 	forwardStderrArgName        = "fwd-stderr"
 	debugArgName                = "debug"
 	outputHandlingArgName       = "output-handling"
+	consolePipeArgName          = "console-pipe"
 )
 
 func main() {
@@ -88,7 +89,7 @@ func main() {
 				},
 				cli.StringFlag{
 					Name:  rootFSTypeArgName,
-					Usage: "Either 'initrd' or 'vhd'. Uses hcsshim default if not specified",
+					Usage: "Either 'initrd' or 'vhd'. (default: 'vhd' if rootfs.vhd exists)",
 				},
 				cli.UintFlag{
 					Name:  vpMemMaxCountArgName,
@@ -100,7 +101,7 @@ func main() {
 				},
 				cli.BoolFlag{
 					Name:  kernelDirectArgName,
-					Usage: "Use kernel direct booting for UVM",
+					Usage: "Use kernel direct booting for UVM (default: true on builds >= 18286)",
 				},
 				cli.StringFlag{
 					Name:  execCommandLineArgName,
@@ -118,6 +119,10 @@ func main() {
 					Name:  outputHandlingArgName,
 					Usage: "Controls how output from UVM is handled. Use 'stdout' to print all output to stdout",
 				},
+				cli.StringFlag{
+					Name:  consolePipeArgName,
+					Usage: "Named pipe for serial console output (which will be enabled)",
+				},
 			},
 			Action: func(c *cli.Context) error {
 				if c.GlobalBool("debug") {
@@ -142,16 +147,8 @@ func main() {
 
 						id := fmt.Sprintf("uvmboot-%d", i)
 
-						options := uvm.OptionsLCOW{
-							Options: &uvm.Options{
-								ID: id,
-							},
-						}
-
-						{
-							val := false
-							options.UseGuestConnection = &val
-						}
+						options := uvm.NewDefaultOptionsLCOW(id, "")
+						options.UseGuestConnection = false
 
 						if c.GlobalIsSet(cpusArgName) {
 							options.ProcessorCount = int32(c.GlobalUint64(cpusArgName))
@@ -160,12 +157,10 @@ func main() {
 							options.MemorySizeInMB = int32(c.GlobalUint64(memoryArgName))
 						}
 						if c.GlobalIsSet(allowOvercommitArgName) {
-							val := c.GlobalBool(allowOvercommitArgName)
-							options.AllowOvercommit = &val
+							options.AllowOvercommit = c.GlobalBool(allowOvercommitArgName)
 						}
 						if c.GlobalIsSet(enableDeferredCommitArgName) {
-							val := c.GlobalBool(enableDeferredCommitArgName)
-							options.EnableDeferredCommit = &val
+							options.EnableDeferredCommit = c.GlobalBool(enableDeferredCommitArgName)
 						}
 
 						if c.IsSet(kernelDirectArgName) {
@@ -174,11 +169,11 @@ func main() {
 						if c.IsSet(rootFSTypeArgName) {
 							switch strings.ToLower(c.String(rootFSTypeArgName)) {
 							case "initrd":
-								val := uvm.PreferredRootFSTypeInitRd
-								options.PreferredRootFSType = &val
+								options.RootFSFile = uvm.InitrdFile
+								options.PreferredRootFSType = uvm.PreferredRootFSTypeInitRd
 							case "vhd":
-								val := uvm.PreferredRootFSTypeVHD
-								options.PreferredRootFSType = &val
+								options.RootFSFile = uvm.VhdFile
+								options.PreferredRootFSType = uvm.PreferredRootFSTypeVHD
 							default:
 								logrus.Fatalf("Unrecognized value '%s' for option %s", c.String(rootFSTypeArgName), rootFSTypeArgName)
 							}
@@ -187,35 +182,33 @@ func main() {
 							options.KernelBootOptions = c.String(kernelArgsArgName)
 						}
 						if c.IsSet(vpMemMaxCountArgName) {
-							val := uint32(c.Uint(vpMemMaxCountArgName))
-							options.VPMemDeviceCount = &val
+							options.VPMemDeviceCount = uint32(c.Uint(vpMemMaxCountArgName))
 						}
 						if c.IsSet(vpMemMaxSizeArgName) {
-							val := c.Uint64(vpMemMaxSizeArgName) * 1024 * 1024 // convert from MB to bytes
-							options.VPMemSizeBytes = &val
+							options.VPMemSizeBytes = c.Uint64(vpMemMaxSizeArgName) * 1024 * 1024 // convert from MB to bytes
 						}
 						if c.IsSet(execCommandLineArgName) {
 							options.ExecCommandLine = c.String(execCommandLineArgName)
 						}
 						if c.IsSet(forwardStdoutArgName) {
-							val := c.Bool(forwardStdoutArgName)
-							options.ForwardStdout = &val
+							options.ForwardStdout = c.Bool(forwardStdoutArgName)
 						}
 						if c.IsSet(forwardStderrArgName) {
-							val := c.Bool(forwardStderrArgName)
-							options.ForwardStderr = &val
+							options.ForwardStderr = c.Bool(forwardStderrArgName)
 						}
 						if c.IsSet(outputHandlingArgName) {
 							switch strings.ToLower(c.String(outputHandlingArgName)) {
 							case "stdout":
-								val := uvm.OutputHandler(func(r io.Reader) { io.Copy(os.Stdout, r) })
-								options.OutputHandler = &val
+								options.OutputHandler = uvm.OutputHandler(func(r io.Reader) { io.Copy(os.Stdout, r) })
 							default:
 								logrus.Fatalf("Unrecognized value '%s' for option %s", c.String(outputHandlingArgName), outputHandlingArgName)
 							}
 						}
+						if c.IsSet(consolePipeArgName) {
+							options.ConsolePipe = c.String(consolePipeArgName)
+						}
 
-						if err := run(&options); err != nil {
+						if err := run(options); err != nil {
 							logrus.WithField("uvm-id", id).Error(err)
 						}
 					}

+ 21 - 0
vendor/github.com/Microsoft/hcsshim/vendor.conf

@@ -0,0 +1,21 @@
+github.com/blang/semver v3.1.0
+github.com/containerd/console c12b1e7919c14469339a5d38f2f8ed9b64a9de23
+github.com/containerd/go-runc 5a6d9f37cfa36b15efba46dc7ea349fa9b7143c3
+github.com/hashicorp/errwrap 7554cd9344cec97297fa6649b055a8c98c2a1e55
+github.com/hashicorp/go-multierror ed905158d87462226a13fe39ddf685ea65f1c11f
+github.com/konsorten/go-windows-terminal-sequences v1.0.1
+github.com/linuxkit/virtsock 8e79449dea0735c1c056d814934dd035734cc97c
+github.com/Microsoft/go-winio 16cfc975803886a5e47c4257a24c8d8c52e178b2
+github.com/Microsoft/opengcs v0.3.9
+github.com/opencontainers/runtime-spec eba862dc2470385a233c7507392675cbeadf7353
+github.com/opencontainers/runtime-tools 1d69bd0f9c39677d0630e50664fbc3154ae61b88
+github.com/pkg/errors v0.8.1
+github.com/sirupsen/logrus v1.3.0
+github.com/syndtr/gocapability db04d3cc01c8b54962a58ec7e491717d06cfcc16
+github.com/urfave/cli 7bc6a0acffa589f415f88aca16cc1de5ffd66f9c
+github.com/xeipuuv/gojsonpointer 4e3ac2762d5f479393488629ee9370b50873b3a6
+github.com/xeipuuv/gojsonreference bd5ef7bd5415a7ac448318e64f11a24cd21e594b
+github.com/xeipuuv/gojsonschema 1d523034197ff1f222f6429836dd36a2457a1874
+golang.org/x/crypto ff983b9c42bc9fbf91556e191cc8efb585c16908
+golang.org/x/sync 37e7f081c4d4c64e13b10787722085407fe5d15f
+golang.org/x/sys e5ecc2a6747ce8d4af18ed98b3de5ae30eb3a5bb

+ 22 - 0
vendor/github.com/Microsoft/hcsshim/vendor/github.com/Microsoft/go-winio/LICENSE

@@ -0,0 +1,22 @@
+The MIT License (MIT)
+
+Copyright (c) 2015 Microsoft
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+

+ 22 - 0
vendor/github.com/Microsoft/hcsshim/vendor/github.com/Microsoft/go-winio/README.md

@@ -0,0 +1,22 @@
+# go-winio
+
+This repository contains utilities for efficiently performing Win32 IO operations in
+Go. Currently, this is focused on accessing named pipes and other file handles, and
+for using named pipes as a net transport.
+
+This code relies on IO completion ports to avoid blocking IO on system threads, allowing Go
+to reuse the thread to schedule another goroutine. This limits support to Windows Vista and
+newer operating systems. This is similar to the implementation of network sockets in Go's net
+package.
+
+Please see the LICENSE file for licensing information.
+
+This project has adopted the [Microsoft Open Source Code of
+Conduct](https://opensource.microsoft.com/codeofconduct/). For more information
+see the [Code of Conduct
+FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact
+[opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional
+questions or comments.
+
+Thanks to natefinch for the inspiration for this library. See https://github.com/natefinch/npipe
+for another named pipe implementation.

Some files were not shown because too many files changed in this diff