aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/Microsoft
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/Microsoft')
-rw-r--r--vendor/github.com/Microsoft/go-winio/.gitignore1
-rw-r--r--vendor/github.com/Microsoft/hcsshim/.gitignore1
-rw-r--r--vendor/github.com/Microsoft/hcsshim/.gometalinter.json17
-rw-r--r--vendor/github.com/Microsoft/hcsshim/appveyor.yml29
-rw-r--r--vendor/github.com/Microsoft/hcsshim/functional_tests.ps112
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/guestrequest/types.go17
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/hcs/callback.go40
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/hcs/errors.go3
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/hcs/log.go9
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/hcs/process.go54
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/hcs/system.go172
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/hcs/watcher.go32
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/hcs/zsyscall_windows.go121
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/hcserror/hcserror.go4
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/hns/hnsendpoint.go2
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/hns/zsyscall_windows.go6
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/interop/interop.go4
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/interop/zsyscall_windows.go6
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/logfields/fields.go5
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/safefile/safeopen.go2
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/plan9_share.go7
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/virtual_machine.go3
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/wclayer/activatelayer.go25
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/wclayer/createlayer.go26
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/wclayer/createscratchlayer.go23
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/wclayer/deactivatelayer.go25
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/wclayer/destroylayer.go25
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/wclayer/expandscratchsize.go26
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/wclayer/exportlayer.go24
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/wclayer/getlayermountpath.go33
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/wclayer/getsharedbaseimages.go19
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/wclayer/grantvmaccess.go28
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/wclayer/importlayer.go24
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/wclayer/layerexists.go26
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/wclayer/layerutils.go4
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/wclayer/nametoguid.go20
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/wclayer/preparelayer.go23
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/wclayer/unpreparelayer.go25
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/wclayer/zsyscall_windows.go91
-rw-r--r--vendor/github.com/Microsoft/hcsshim/mksyscall_windows.go943
-rw-r--r--vendor/github.com/Microsoft/hcsshim/vendor.conf21
-rw-r--r--vendor/github.com/Microsoft/hcsshim/zsyscall_windows.go6
42 files changed, 1653 insertions, 331 deletions
diff --git a/vendor/github.com/Microsoft/go-winio/.gitignore b/vendor/github.com/Microsoft/go-winio/.gitignore
new file mode 100644
index 000000000..b883f1fdc
--- /dev/null
+++ b/vendor/github.com/Microsoft/go-winio/.gitignore
@@ -0,0 +1 @@
+*.exe
diff --git a/vendor/github.com/Microsoft/hcsshim/.gitignore b/vendor/github.com/Microsoft/hcsshim/.gitignore
new file mode 100644
index 000000000..b883f1fdc
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/.gitignore
@@ -0,0 +1 @@
+*.exe
diff --git a/vendor/github.com/Microsoft/hcsshim/.gometalinter.json b/vendor/github.com/Microsoft/hcsshim/.gometalinter.json
new file mode 100644
index 000000000..00e9a6e2e
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/.gometalinter.json
@@ -0,0 +1,17 @@
+{
+ "Vendor": true,
+ "Deadline": "2m",
+ "Sort": [
+ "linter",
+ "severity",
+ "path",
+ "line"
+ ],
+ "Skip": [
+ "internal\\schema2"
+ ],
+ "EnableGC": true,
+ "Enable": [
+ "gofmt"
+ ]
+} \ No newline at end of file
diff --git a/vendor/github.com/Microsoft/hcsshim/appveyor.yml b/vendor/github.com/Microsoft/hcsshim/appveyor.yml
new file mode 100644
index 000000000..a8ec5a593
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/appveyor.yml
@@ -0,0 +1,29 @@
+version: 0.1.{build}
+
+image: Visual Studio 2017
+
+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;C:\gometalinter-2.0.12-windows-amd64;%PATH%
+
+stack: go 1.11
+
+build_script:
+ - 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 build ./cmd/wclayer
+ - go build ./cmd/runhcs
+ - go build ./cmd/tar2ext4
+ - go test -v ./... -tags admin
+ - go test -c ./test/functional/ -tags functional
+ - go test -c ./test/runhcs/ -tags integration
+
+artifacts:
+ - path: 'wclayer.exe'
+ - path: 'runhcs.exe'
+ - path: 'tar2ext4.exe'
+ - path: 'functional.test.exe'
+ - path: 'runhcs.test.exe' \ No newline at end of file
diff --git a/vendor/github.com/Microsoft/hcsshim/functional_tests.ps1 b/vendor/github.com/Microsoft/hcsshim/functional_tests.ps1
new file mode 100644
index 000000000..ce6edbcf3
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/functional_tests.ps1
@@ -0,0 +1,12 @@
+# Requirements so far:
+# dockerd running
+# - image microsoft/nanoserver (matching host base image) docker load -i c:\baseimages\nanoserver.tar
+# - image alpine (linux) docker pull --platform=linux alpine
+
+
+# TODO: Add this a parameter for debugging. ie "functional-tests -debug=$true"
+#$env:HCSSHIM_FUNCTIONAL_TESTS_DEBUG="yes please"
+
+#pushd uvm
+go test -v -tags "functional uvmcreate uvmscratch uvmscsi uvmvpmem uvmvsmb uvmp9" ./...
+#popd \ No newline at end of file
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/guestrequest/types.go b/vendor/github.com/Microsoft/hcsshim/internal/guestrequest/types.go
index 9f926c6be..5d3d0dfef 100644
--- a/vendor/github.com/Microsoft/hcsshim/internal/guestrequest/types.go
+++ b/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 (
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/hcs/callback.go b/vendor/github.com/Microsoft/hcsshim/internal/hcs/callback.go
index 5119c2555..f9a922a4b 100644
--- a/vendor/github.com/Microsoft/hcsshim/internal/hcs/callback.go
+++ b/vendor/github.com/Microsoft/hcsshim/internal/hcs/callback.go
@@ -16,11 +16,20 @@ var (
notificationWatcherCallback = syscall.NewCallback(notificationWatcher)
// Notifications for HCS_SYSTEM handles
- hcsNotificationSystemExited hcsNotification = 0x00000001
- hcsNotificationSystemCreateCompleted hcsNotification = 0x00000002
- hcsNotificationSystemStartCompleted hcsNotification = 0x00000003
- hcsNotificationSystemPauseCompleted hcsNotification = 0x00000004
- hcsNotificationSystemResumeCompleted hcsNotification = 0x00000005
+ hcsNotificationSystemExited hcsNotification = 0x00000001
+ hcsNotificationSystemCreateCompleted hcsNotification = 0x00000002
+ hcsNotificationSystemStartCompleted hcsNotification = 0x00000003
+ hcsNotificationSystemPauseCompleted hcsNotification = 0x00000004
+ hcsNotificationSystemResumeCompleted hcsNotification = 0x00000005
+ hcsNotificationSystemCrashReport hcsNotification = 0x00000006
+ hcsNotificationSystemSiloJobCreated hcsNotification = 0x00000007
+ hcsNotificationSystemSaveCompleted hcsNotification = 0x00000008
+ hcsNotificationSystemRdpEnhancedModeStateChanged hcsNotification = 0x00000009
+ hcsNotificationSystemShutdownFailed hcsNotification = 0x0000000A
+ hcsNotificationSystemGetPropertiesCompleted hcsNotification = 0x0000000B
+ hcsNotificationSystemModifyCompleted hcsNotification = 0x0000000C
+ hcsNotificationSystemCrashInitiated hcsNotification = 0x0000000D
+ hcsNotificationSystemGuestConnectionClosed hcsNotification = 0x0000000E
// Notifications for HCS_PROCESS handles
hcsNotificationProcessExited hcsNotification = 0x00010000
@@ -50,16 +59,23 @@ func newChannels() notificationChannels {
channels[hcsNotificationSystemResumeCompleted] = make(notificationChannel, 1)
channels[hcsNotificationProcessExited] = make(notificationChannel, 1)
channels[hcsNotificationServiceDisconnect] = make(notificationChannel, 1)
+ channels[hcsNotificationSystemCrashReport] = make(notificationChannel, 1)
+ channels[hcsNotificationSystemSiloJobCreated] = make(notificationChannel, 1)
+ channels[hcsNotificationSystemSaveCompleted] = make(notificationChannel, 1)
+ channels[hcsNotificationSystemRdpEnhancedModeStateChanged] = make(notificationChannel, 1)
+ channels[hcsNotificationSystemShutdownFailed] = make(notificationChannel, 1)
+ channels[hcsNotificationSystemGetPropertiesCompleted] = make(notificationChannel, 1)
+ channels[hcsNotificationSystemModifyCompleted] = make(notificationChannel, 1)
+ channels[hcsNotificationSystemCrashInitiated] = make(notificationChannel, 1)
+ channels[hcsNotificationSystemGuestConnectionClosed] = make(notificationChannel, 1)
+
return channels
}
+
func closeChannels(channels notificationChannels) {
- close(channels[hcsNotificationSystemExited])
- close(channels[hcsNotificationSystemCreateCompleted])
- close(channels[hcsNotificationSystemStartCompleted])
- close(channels[hcsNotificationSystemPauseCompleted])
- close(channels[hcsNotificationSystemResumeCompleted])
- close(channels[hcsNotificationProcessExited])
- close(channels[hcsNotificationServiceDisconnect])
+ for _, c := range channels {
+ close(c)
+ }
}
func notificationWatcher(notificationType hcsNotification, callbackNumber uintptr, notificationStatus uintptr, notificationData *uint16) uintptr {
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/hcs/errors.go b/vendor/github.com/Microsoft/hcsshim/internal/hcs/errors.go
index 6368b5717..079b56535 100644
--- a/vendor/github.com/Microsoft/hcsshim/internal/hcs/errors.go
+++ b/vendor/github.com/Microsoft/hcsshim/internal/hcs/errors.go
@@ -73,6 +73,9 @@ var (
// ErrVmcomputeUnknownMessage is an error encountered guest compute system doesn't support the message
ErrVmcomputeUnknownMessage = syscall.Errno(0xc037010b)
+ // ErrVmcomputeUnexpectedExit is an error encountered when the compute system terminates unexpectedly
+ ErrVmcomputeUnexpectedExit = syscall.Errno(0xC0370106)
+
// ErrNotSupported is an error encountered when hcs doesn't support the request
ErrPlatformNotSupported = errors.New("unsupported platform request")
)
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/hcs/log.go b/vendor/github.com/Microsoft/hcsshim/internal/hcs/log.go
index 90d164e35..6d03b17a2 100644
--- a/vendor/github.com/Microsoft/hcsshim/internal/hcs/log.go
+++ b/vendor/github.com/Microsoft/hcsshim/internal/hcs/log.go
@@ -7,9 +7,14 @@ func logOperationBegin(ctx logrus.Fields, msg string) {
}
func logOperationEnd(ctx logrus.Fields, msg string, err error) {
+ // Copy the log and fields first.
+ log := logrus.WithFields(ctx)
if err == nil {
- logrus.WithFields(ctx).Debug(msg)
+ log.Debug(msg)
} else {
- logrus.WithFields(ctx).WithError(err).Error(msg)
+ // Edit only the copied field data to avoid race conditions on the
+ // write.
+ log.Data[logrus.ErrorKey] = err
+ log.Error(msg)
}
}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/hcs/process.go b/vendor/github.com/Microsoft/hcsshim/internal/hcs/process.go
index 42598cf2f..41e20bbf9 100644
--- a/vendor/github.com/Microsoft/hcsshim/internal/hcs/process.go
+++ b/vendor/github.com/Microsoft/hcsshim/internal/hcs/process.go
@@ -31,9 +31,8 @@ func newProcess(process hcsProcess, processID int, computeSystem *System) *Proce
processID: processID,
system: computeSystem,
logctx: logrus.Fields{
- logfields.HCSOperation: "",
- logfields.ContainerID: computeSystem.ID(),
- logfields.ProcessID: processID,
+ logfields.ContainerID: computeSystem.ID(),
+ logfields.ProcessID: processID,
},
}
}
@@ -88,13 +87,12 @@ func (process *Process) SystemID() string {
}
func (process *Process) logOperationBegin(operation string) {
- process.logctx[logfields.HCSOperation] = operation
logOperationBegin(
process.logctx,
- "hcsshim::Process - Begin Operation")
+ operation+" - Begin Operation")
}
-func (process *Process) logOperationEnd(err error) {
+func (process *Process) logOperationEnd(operation string, err error) {
var result string
if err == nil {
result = "Success"
@@ -104,9 +102,8 @@ func (process *Process) logOperationEnd(err error) {
logOperationEnd(
process.logctx,
- "hcsshim::Process - End Operation - "+result,
+ operation+" - End Operation - "+result,
err)
- process.logctx[logfields.HCSOperation] = ""
}
// Signal signals the process with `options`.
@@ -116,7 +113,7 @@ func (process *Process) Signal(options guestrequest.SignalProcessOptions) (err e
operation := "hcsshim::Process::Signal"
process.logOperationBegin(operation)
- defer process.logOperationEnd(err)
+ defer func() { process.logOperationEnd(operation, err) }()
if process.handle == 0 {
return makeProcessError(process, operation, ErrAlreadyClosed, nil)
@@ -130,10 +127,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)
@@ -149,17 +145,16 @@ func (process *Process) Kill() (err error) {
operation := "hcsshim::Process::Kill"
process.logOperationBegin(operation)
- defer process.logOperationEnd(err)
+ defer func() { process.logOperationEnd(operation, err) }()
if process.handle == 0 {
return makeProcessError(process, operation, ErrAlreadyClosed, nil)
}
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)
@@ -172,7 +167,7 @@ func (process *Process) Kill() (err error) {
func (process *Process) Wait() (err error) {
operation := "hcsshim::Process::Wait"
process.logOperationBegin(operation)
- defer process.logOperationEnd(err)
+ defer func() { process.logOperationEnd(operation, err) }()
err = waitForNotification(process.callbackNumber, hcsNotificationProcessExited, nil)
if err != nil {
@@ -187,7 +182,7 @@ func (process *Process) Wait() (err error) {
func (process *Process) WaitTimeout(timeout time.Duration) (err error) {
operation := "hcssshim::Process::WaitTimeout"
process.logOperationBegin(operation)
- defer process.logOperationEnd(err)
+ defer func() { process.logOperationEnd(operation, err) }()
err = waitForNotification(process.callbackNumber, hcsNotificationProcessExited, &timeout)
if err != nil {
@@ -204,7 +199,7 @@ func (process *Process) ResizeConsole(width, height uint16) (err error) {
operation := "hcsshim::Process::ResizeConsole"
process.logOperationBegin(operation)
- defer process.logOperationEnd(err)
+ defer func() { process.logOperationEnd(operation, err) }()
if process.handle == 0 {
return makeProcessError(process, operation, ErrAlreadyClosed, nil)
@@ -241,7 +236,7 @@ func (process *Process) Properties() (_ *ProcessStatus, err error) {
operation := "hcsshim::Process::Properties"
process.logOperationBegin(operation)
- defer process.logOperationEnd(err)
+ defer func() { process.logOperationEnd(operation, err) }()
if process.handle == 0 {
return nil, makeProcessError(process, operation, ErrAlreadyClosed, nil)
@@ -251,10 +246,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)
@@ -278,7 +272,7 @@ func (process *Process) Properties() (_ *ProcessStatus, err error) {
func (process *Process) ExitCode() (_ int, err error) {
operation := "hcsshim::Process::ExitCode"
process.logOperationBegin(operation)
- defer process.logOperationEnd(err)
+ defer func() { process.logOperationEnd(operation, err) }()
properties, err := process.Properties()
if err != nil {
@@ -305,7 +299,7 @@ func (process *Process) Stdio() (_ io.WriteCloser, _ io.ReadCloser, _ io.ReadClo
operation := "hcsshim::Process::Stdio"
process.logOperationBegin(operation)
- defer process.logOperationEnd(err)
+ defer func() { process.logOperationEnd(operation, err) }()
if process.handle == 0 {
return nil, nil, nil, makeProcessError(process, operation, ErrAlreadyClosed, nil)
@@ -349,7 +343,7 @@ func (process *Process) CloseStdin() (err error) {
operation := "hcsshim::Process::CloseStdin"
process.logOperationBegin(operation)
- defer process.logOperationEnd(err)
+ defer func() { process.logOperationEnd(operation, err) }()
if process.handle == 0 {
return makeProcessError(process, operation, ErrAlreadyClosed, nil)
@@ -387,7 +381,7 @@ func (process *Process) Close() (err error) {
operation := "hcsshim::Process::Close"
process.logOperationBegin(operation)
- defer process.logOperationEnd(err)
+ defer func() { process.logOperationEnd(operation, err) }()
// Don't double free this
if process.handle == 0 {
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/hcs/system.go b/vendor/github.com/Microsoft/hcsshim/internal/hcs/system.go
index 2629380fd..20b242524 100644
--- a/vendor/github.com/Microsoft/hcsshim/internal/hcs/system.go
+++ b/vendor/github.com/Microsoft/hcsshim/internal/hcs/system.go
@@ -49,20 +49,18 @@ func newSystem(id string) *System {
return &System{
id: id,
logctx: logrus.Fields{
- logfields.HCSOperation: "",
- logfields.ContainerID: id,
+ logfields.ContainerID: id,
},
}
}
func (computeSystem *System) logOperationBegin(operation string) {
- computeSystem.logctx[logfields.HCSOperation] = operation
logOperationBegin(
computeSystem.logctx,
- "hcsshim::ComputeSystem - Begin Operation")
+ operation+" - Begin Operation")
}
-func (computeSystem *System) logOperationEnd(err error) {
+func (computeSystem *System) logOperationEnd(operation string, err error) {
var result string
if err == nil {
result = "Success"
@@ -72,9 +70,8 @@ func (computeSystem *System) logOperationEnd(err error) {
logOperationEnd(
computeSystem.logctx,
- "hcsshim::ComputeSystem - End Operation - "+result,
+ operation+" - End Operation - "+result,
err)
- computeSystem.logctx[logfields.HCSOperation] = ""
}
// CreateComputeSystem creates a new compute system with the given configuration but does not start it.
@@ -83,7 +80,7 @@ func CreateComputeSystem(id string, hcsDocumentInterface interface{}) (_ *System
computeSystem := newSystem(id)
computeSystem.logOperationBegin(operation)
- defer computeSystem.logOperationEnd(err)
+ defer func() { computeSystem.logOperationEnd(operation, err) }()
hcsDocumentB, err := json.Marshal(hcsDocumentInterface)
if err != nil {
@@ -97,13 +94,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 +130,13 @@ func OpenComputeSystem(id string) (_ *System, err error) {
computeSystem := newSystem(id)
computeSystem.logOperationBegin(operation)
- defer computeSystem.logOperationEnd(err)
+ defer func() {
+ if IsNotExist(err) {
+ computeSystem.logOperationEnd(operation, nil)
+ } else {
+ computeSystem.logOperationEnd(operation, err)
+ }
+ }()
var (
handle hcsSystem
@@ -157,12 +160,10 @@ func OpenComputeSystem(id string) (_ *System, err error) {
// GetComputeSystems gets a list of the compute systems on the system that match the query
func GetComputeSystems(q schema1.ComputeSystemQuery) (_ []schema1.ContainerProperties, err error) {
operation := "hcsshim::GetComputeSystems"
- fields := logrus.Fields{
- logfields.HCSOperation: operation,
- }
+ fields := logrus.Fields{}
logOperationBegin(
fields,
- "hcsshim::ComputeSystem - Begin Operation")
+ operation+" - Begin Operation")
defer func() {
var result string
@@ -174,7 +175,7 @@ func GetComputeSystems(q schema1.ComputeSystemQuery) (_ []schema1.ContainerPrope
logOperationEnd(
fields,
- "hcsshim::ComputeSystem - End Operation - "+result,
+ operation+" - End Operation - "+result,
err)
}()
@@ -193,10 +194,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}
@@ -221,7 +222,7 @@ func (computeSystem *System) Start() (err error) {
operation := "hcsshim::ComputeSystem::Start"
computeSystem.logOperationBegin(operation)
- defer computeSystem.logOperationEnd(err)
+ defer func() { computeSystem.logOperationEnd(operation, err) }()
if computeSystem.handle == 0 {
return makeSystemError(computeSystem, "Start", "", ErrAlreadyClosed, nil)
@@ -254,10 +255,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 +279,22 @@ func (computeSystem *System) Shutdown() (err error) {
operation := "hcsshim::ComputeSystem::Shutdown"
computeSystem.logOperationBegin(operation)
- defer computeSystem.logOperationEnd(err)
+ defer func() {
+ if IsAlreadyStopped(err) {
+ computeSystem.logOperationEnd(operation, nil)
+ } else {
+ computeSystem.logOperationEnd(operation, 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,19 +311,24 @@ func (computeSystem *System) Terminate() (err error) {
operation := "hcsshim::ComputeSystem::Terminate"
computeSystem.logOperationBegin(operation)
- defer computeSystem.logOperationEnd(err)
+ defer func() {
+ if IsPending(err) {
+ computeSystem.logOperationEnd(operation, nil)
+ } else {
+ computeSystem.logOperationEnd(operation, 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 {
+ if err != nil && err != ErrVmcomputeAlreadyStopped {
return makeSystemError(computeSystem, "Terminate", "", err, events)
}
@@ -329,7 +339,7 @@ func (computeSystem *System) Terminate() (err error) {
func (computeSystem *System) Wait() (err error) {
operation := "hcsshim::ComputeSystem::Wait"
computeSystem.logOperationBegin(operation)
- defer computeSystem.logOperationEnd(err)
+ defer func() { computeSystem.logOperationEnd(operation, err) }()
err = waitForNotification(computeSystem.callbackNumber, hcsNotificationSystemExited, nil)
if err != nil {
@@ -339,12 +349,27 @@ func (computeSystem *System) Wait() (err error) {
return nil
}
+// WaitExpectedError synchronously waits for the compute system to shutdown or
+// terminate, and ignores the passed error if it occurs.
+func (computeSystem *System) WaitExpectedError(expected error) (err error) {
+ operation := "hcsshim::ComputeSystem::WaitExpectedError"
+ computeSystem.logOperationBegin(operation)
+ defer func() { computeSystem.logOperationEnd(operation, err) }()
+
+ err = waitForNotification(computeSystem.callbackNumber, hcsNotificationSystemExited, nil)
+ if err != nil && getInnerError(err) != expected {
+ return makeSystemError(computeSystem, "WaitExpectedError", "", err, nil)
+ }
+
+ return nil
+}
+
// WaitTimeout synchronously waits for the compute system to terminate or the duration to elapse.
// If the timeout expires, IsTimeout(err) == true
func (computeSystem *System) WaitTimeout(timeout time.Duration) (err error) {
operation := "hcsshim::ComputeSystem::WaitTimeout"
computeSystem.logOperationBegin(operation)
- defer computeSystem.logOperationEnd(err)
+ defer func() { computeSystem.logOperationEnd(operation, err) }()
err = waitForNotification(computeSystem.callbackNumber, hcsNotificationSystemExited, &timeout)
if err != nil {
@@ -360,7 +385,7 @@ func (computeSystem *System) Properties(types ...schema1.PropertyType) (_ *schem
operation := "hcsshim::ComputeSystem::Properties"
computeSystem.logOperationBegin(operation)
- defer computeSystem.logOperationEnd(err)
+ defer func() { computeSystem.logOperationEnd(operation, err) }()
queryj, err := json.Marshal(schema1.PropertyQuery{types})
if err != nil {
@@ -372,10 +397,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)
@@ -400,17 +424,16 @@ func (computeSystem *System) Pause() (err error) {
operation := "hcsshim::ComputeSystem::Pause"
computeSystem.logOperationBegin(operation)
- defer computeSystem.logOperationEnd(err)
+ defer func() { computeSystem.logOperationEnd(operation, err) }()
if computeSystem.handle == 0 {
return makeSystemError(computeSystem, "Pause", "", ErrAlreadyClosed, nil)
}
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)
@@ -426,17 +449,16 @@ func (computeSystem *System) Resume() (err error) {
operation := "hcsshim::ComputeSystem::Resume"
computeSystem.logOperationBegin(operation)
- defer computeSystem.logOperationEnd(err)
+ defer func() { computeSystem.logOperationEnd(operation, err) }()
if computeSystem.handle == 0 {
return makeSystemError(computeSystem, "Resume", "", ErrAlreadyClosed, nil)
}
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)
@@ -452,7 +474,7 @@ func (computeSystem *System) CreateProcess(c interface{}) (_ *Process, err error
operation := "hcsshim::ComputeSystem::CreateProcess"
computeSystem.logOperationBegin(operation)
- defer computeSystem.logOperationEnd(err)
+ defer func() { computeSystem.logOperationEnd(operation, err) }()
var (
processInfo hcsProcessInformation
@@ -475,10 +497,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)
@@ -513,7 +534,7 @@ func (computeSystem *System) OpenProcess(pid int) (_ *Process, err error) {
operation := "hcsshim::ComputeSystem::OpenProcess"
computeSystem.logOperationBegin(operation)
- defer computeSystem.logOperationEnd(err)
+ defer func() { computeSystem.logOperationEnd(operation, err) }()
var (
processHandle hcsProcess
@@ -524,10 +545,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)
@@ -548,7 +568,7 @@ func (computeSystem *System) Close() (err error) {
operation := "hcsshim::ComputeSystem::Close"
computeSystem.logOperationBegin(operation)
- defer computeSystem.logOperationEnd(err)
+ defer func() { computeSystem.logOperationEnd(operation, err) }()
// Don't double free this
if computeSystem.handle == 0 {
@@ -559,10 +579,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)
}
@@ -636,7 +655,7 @@ func (computeSystem *System) Modify(config interface{}) (err error) {
operation := "hcsshim::ComputeSystem::Modify"
computeSystem.logOperationBegin(operation)
- defer computeSystem.logOperationEnd(err)
+ defer func() { computeSystem.logOperationEnd(operation, err) }()
if computeSystem.handle == 0 {
return makeSystemError(computeSystem, "Modify", "", ErrAlreadyClosed, nil)
@@ -654,10 +673,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)
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/hcs/watcher.go b/vendor/github.com/Microsoft/hcsshim/internal/hcs/watcher.go
index e09dd1334..f85ed3187 100644
--- a/vendor/github.com/Microsoft/hcsshim/internal/hcs/watcher.go
+++ b/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.")
}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/hcs/zsyscall_windows.go b/vendor/github.com/Microsoft/hcsshim/internal/hcs/zsyscall_windows.go
index 877c69a14..fcd5cdc87 100644
--- a/vendor/github.com/Microsoft/hcsshim/internal/hcs/zsyscall_windows.go
+++ b/vendor/github.com/Microsoft/hcsshim/internal/hcs/zsyscall_windows.go
@@ -6,7 +6,6 @@ import (
"syscall"
"unsafe"
- "github.com/Microsoft/hcsshim/internal/interop"
"golang.org/x/sys/windows"
)
@@ -81,7 +80,10 @@ func _hcsEnumerateComputeSystems(query *uint16, computeSystems **uint16, result
}
r0, _, _ := syscall.Syscall(procHcsEnumerateComputeSystems.Addr(), 3, uintptr(unsafe.Pointer(query)), uintptr(unsafe.Pointer(computeSystems)), uintptr(unsafe.Pointer(result)))
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
@@ -106,7 +108,10 @@ func _hcsCreateComputeSystem(id *uint16, configuration *uint16, identity syscall
}
r0, _, _ := syscall.Syscall6(procHcsCreateComputeSystem.Addr(), 5, uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(configuration)), uintptr(identity), uintptr(unsafe.Pointer(computeSystem)), uintptr(unsafe.Pointer(result)), 0)
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
@@ -126,7 +131,10 @@ func _hcsOpenComputeSystem(id *uint16, computeSystem *hcsSystem, result **uint16
}
r0, _, _ := syscall.Syscall(procHcsOpenComputeSystem.Addr(), 3, uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(computeSystem)), uintptr(unsafe.Pointer(result)))
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
@@ -137,7 +145,10 @@ func hcsCloseComputeSystem(computeSystem hcsSystem) (hr error) {
}
r0, _, _ := syscall.Syscall(procHcsCloseComputeSystem.Addr(), 1, uintptr(computeSystem), 0, 0)
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
@@ -157,7 +168,10 @@ func _hcsStartComputeSystem(computeSystem hcsSystem, options *uint16, result **u
}
r0, _, _ := syscall.Syscall(procHcsStartComputeSystem.Addr(), 3, uintptr(computeSystem), uintptr(unsafe.Pointer(options)), uintptr(unsafe.Pointer(result)))
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
@@ -177,7 +191,10 @@ func _hcsShutdownComputeSystem(computeSystem hcsSystem, options *uint16, result
}
r0, _, _ := syscall.Syscall(procHcsShutdownComputeSystem.Addr(), 3, uintptr(computeSystem), uintptr(unsafe.Pointer(options)), uintptr(unsafe.Pointer(result)))
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
@@ -197,7 +214,10 @@ func _hcsTerminateComputeSystem(computeSystem hcsSystem, options *uint16, result
}
r0, _, _ := syscall.Syscall(procHcsTerminateComputeSystem.Addr(), 3, uintptr(computeSystem), uintptr(unsafe.Pointer(options)), uintptr(unsafe.Pointer(result)))
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
@@ -217,7 +237,10 @@ func _hcsPauseComputeSystem(computeSystem hcsSystem, options *uint16, result **u
}
r0, _, _ := syscall.Syscall(procHcsPauseComputeSystem.Addr(), 3, uintptr(computeSystem), uintptr(unsafe.Pointer(options)), uintptr(unsafe.Pointer(result)))
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
@@ -237,7 +260,10 @@ func _hcsResumeComputeSystem(computeSystem hcsSystem, options *uint16, result **
}
r0, _, _ := syscall.Syscall(procHcsResumeComputeSystem.Addr(), 3, uintptr(computeSystem), uintptr(unsafe.Pointer(options)), uintptr(unsafe.Pointer(result)))
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
@@ -257,7 +283,10 @@ func _hcsGetComputeSystemProperties(computeSystem hcsSystem, propertyQuery *uint
}
r0, _, _ := syscall.Syscall6(procHcsGetComputeSystemProperties.Addr(), 4, uintptr(computeSystem), uintptr(unsafe.Pointer(propertyQuery)), uintptr(unsafe.Pointer(properties)), uintptr(unsafe.Pointer(result)), 0, 0)
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
@@ -277,7 +306,10 @@ func _hcsModifyComputeSystem(computeSystem hcsSystem, configuration *uint16, res
}
r0, _, _ := syscall.Syscall(procHcsModifyComputeSystem.Addr(), 3, uintptr(computeSystem), uintptr(unsafe.Pointer(configuration)), uintptr(unsafe.Pointer(result)))
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
@@ -288,7 +320,10 @@ func hcsRegisterComputeSystemCallback(computeSystem hcsSystem, callback uintptr,
}
r0, _, _ := syscall.Syscall6(procHcsRegisterComputeSystemCallback.Addr(), 4, uintptr(computeSystem), uintptr(callback), uintptr(context), uintptr(unsafe.Pointer(callbackHandle)), 0, 0)
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
@@ -299,7 +334,10 @@ func hcsUnregisterComputeSystemCallback(callbackHandle hcsCallback) (hr error) {
}
r0, _, _ := syscall.Syscall(procHcsUnregisterComputeSystemCallback.Addr(), 1, uintptr(callbackHandle), 0, 0)
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
@@ -319,7 +357,10 @@ func _hcsCreateProcess(computeSystem hcsSystem, processParameters *uint16, proce
}
r0, _, _ := syscall.Syscall6(procHcsCreateProcess.Addr(), 5, uintptr(computeSystem), uintptr(unsafe.Pointer(processParameters)), uintptr(unsafe.Pointer(processInformation)), uintptr(unsafe.Pointer(process)), uintptr(unsafe.Pointer(result)), 0)
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
@@ -330,7 +371,10 @@ func hcsOpenProcess(computeSystem hcsSystem, pid uint32, process *hcsProcess, re
}
r0, _, _ := syscall.Syscall6(procHcsOpenProcess.Addr(), 4, uintptr(computeSystem), uintptr(pid), uintptr(unsafe.Pointer(process)), uintptr(unsafe.Pointer(result)), 0, 0)
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
@@ -341,7 +385,10 @@ func hcsCloseProcess(process hcsProcess) (hr error) {
}
r0, _, _ := syscall.Syscall(procHcsCloseProcess.Addr(), 1, uintptr(process), 0, 0)
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
@@ -352,7 +399,10 @@ func hcsTerminateProcess(process hcsProcess, result **uint16) (hr error) {
}
r0, _, _ := syscall.Syscall(procHcsTerminateProcess.Addr(), 2, uintptr(process), uintptr(unsafe.Pointer(result)), 0)
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
@@ -372,7 +422,10 @@ func _hcsSignalProcess(process hcsProcess, options *uint16, result **uint16) (hr
}
r0, _, _ := syscall.Syscall(procHcsTerminateProcess.Addr(), 3, uintptr(process), uintptr(unsafe.Pointer(options)), uintptr(unsafe.Pointer(result)))
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
@@ -383,7 +436,10 @@ func hcsGetProcessInfo(process hcsProcess, processInformation *hcsProcessInforma
}
r0, _, _ := syscall.Syscall(procHcsGetProcessInfo.Addr(), 3, uintptr(process), uintptr(unsafe.Pointer(processInformation)), uintptr(unsafe.Pointer(result)))
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
@@ -394,7 +450,10 @@ func hcsGetProcessProperties(process hcsProcess, processProperties **uint16, res
}
r0, _, _ := syscall.Syscall(procHcsGetProcessProperties.Addr(), 3, uintptr(process), uintptr(unsafe.Pointer(processProperties)), uintptr(unsafe.Pointer(result)))
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
@@ -414,7 +473,10 @@ func _hcsModifyProcess(process hcsProcess, settings *uint16, result **uint16) (h
}
r0, _, _ := syscall.Syscall(procHcsModifyProcess.Addr(), 3, uintptr(process), uintptr(unsafe.Pointer(settings)), uintptr(unsafe.Pointer(result)))
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
@@ -434,7 +496,10 @@ func _hcsGetServiceProperties(propertyQuery *uint16, properties **uint16, result
}
r0, _, _ := syscall.Syscall(procHcsGetServiceProperties.Addr(), 3, uintptr(unsafe.Pointer(propertyQuery)), uintptr(unsafe.Pointer(properties)), uintptr(unsafe.Pointer(result)))
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
@@ -445,7 +510,10 @@ func hcsRegisterProcessCallback(process hcsProcess, callback uintptr, context ui
}
r0, _, _ := syscall.Syscall6(procHcsRegisterProcessCallback.Addr(), 4, uintptr(process), uintptr(callback), uintptr(context), uintptr(unsafe.Pointer(callbackHandle)), 0, 0)
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
@@ -456,7 +524,10 @@ func hcsUnregisterProcessCallback(callbackHandle hcsCallback) (hr error) {
}
r0, _, _ := syscall.Syscall(procHcsUnregisterProcessCallback.Addr(), 1, uintptr(callbackHandle), 0, 0)
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/hcserror/hcserror.go b/vendor/github.com/Microsoft/hcsshim/internal/hcserror/hcserror.go
index c8d362c66..921c2c855 100644
--- a/vendor/github.com/Microsoft/hcsshim/internal/hcserror/hcserror.go
+++ b/vendor/github.com/Microsoft/hcsshim/internal/hcserror/hcserror.go
@@ -36,10 +36,6 @@ func New(err error, title, rest string) error {
return &HcsError{title, rest, err}
}
-func Errorf(err error, title, format string, a ...interface{}) error {
- return New(err, title, fmt.Sprintf(format, a...))
-}
-
func Win32FromError(err error) uint32 {
if herr, ok := err.(*HcsError); ok {
return Win32FromError(herr.Err)
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/hns/hnsendpoint.go b/vendor/github.com/Microsoft/hcsshim/internal/hns/hnsendpoint.go
index ce636458c..59ec7004c 100644
--- a/vendor/github.com/Microsoft/hcsshim/internal/hns/hnsendpoint.go
+++ b/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
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/hns/zsyscall_windows.go b/vendor/github.com/Microsoft/hcsshim/internal/hns/zsyscall_windows.go
index 3a3232a06..204633a48 100644
--- a/vendor/github.com/Microsoft/hcsshim/internal/hns/zsyscall_windows.go
+++ b/vendor/github.com/Microsoft/hcsshim/internal/hns/zsyscall_windows.go
@@ -6,7 +6,6 @@ import (
"syscall"
"unsafe"
- "github.com/Microsoft/hcsshim/internal/interop"
"golang.org/x/sys/windows"
)
@@ -68,7 +67,10 @@ func __hnsCall(method *uint16, path *uint16, object *uint16, response **uint16)
}
r0, _, _ := syscall.Syscall6(procHNSCall.Addr(), 4, uintptr(unsafe.Pointer(method)), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(object)), uintptr(unsafe.Pointer(response)), 0, 0)
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/interop/interop.go b/vendor/github.com/Microsoft/hcsshim/internal/interop/interop.go
index f10c88d08..2f6ec029e 100644
--- a/vendor/github.com/Microsoft/hcsshim/internal/interop/interop.go
+++ b/vendor/github.com/Microsoft/hcsshim/internal/interop/interop.go
@@ -5,9 +5,9 @@ import (
"unsafe"
)
-//go:generate go run $GOROOT/src/syscall/mksyscall_windows.go -output zsyscall_windows.go interop.go
+//go:generate go run ../../mksyscall_windows.go -output zsyscall_windows.go interop.go
-//sys coTaskMemFree(buffer unsafe.Pointer) = ole32.CoTaskMemFree
+//sys coTaskMemFree(buffer unsafe.Pointer) = api_ms_win_core_com_l1_1_0.CoTaskMemFree
func ConvertAndFreeCoTaskMemString(buffer *uint16) string {
str := syscall.UTF16ToString((*[1 << 29]uint16)(unsafe.Pointer(buffer))[:])
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/interop/zsyscall_windows.go b/vendor/github.com/Microsoft/hcsshim/internal/interop/zsyscall_windows.go
index 2f5bf8f55..12b0c71c5 100644
--- a/vendor/github.com/Microsoft/hcsshim/internal/interop/zsyscall_windows.go
+++ b/vendor/github.com/Microsoft/hcsshim/internal/interop/zsyscall_windows.go
@@ -1,4 +1,4 @@
-// Code generated by 'go generate'; DO NOT EDIT.
+// Code generated mksyscall_windows.exe DO NOT EDIT
package interop
@@ -37,9 +37,9 @@ func errnoErr(e syscall.Errno) error {
}
var (
- modole32 = windows.NewLazySystemDLL("ole32.dll")
+ modapi_ms_win_core_com_l1_1_0 = windows.NewLazySystemDLL("api-ms-win-core-com-l1-1-0.dll")
- procCoTaskMemFree = modole32.NewProc("CoTaskMemFree")
+ procCoTaskMemFree = modapi_ms_win_core_com_l1_1_0.NewProc("CoTaskMemFree")
)
func coTaskMemFree(buffer unsafe.Pointer) {
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/logfields/fields.go b/vendor/github.com/Microsoft/hcsshim/internal/logfields/fields.go
index a1527d706..cf2c166d9 100644
--- a/vendor/github.com/Microsoft/hcsshim/internal/logfields/fields.go
+++ b/vendor/github.com/Microsoft/hcsshim/internal/logfields/fields.go
@@ -26,11 +26,6 @@ const (
Uint32 = "uint32"
Uint64 = "uint64"
- // HCS
-
- HCSOperation = "hcs-op"
- HCSOperationResult = "hcs-op-result"
-
// runhcs
VMShimOperation = "vmshim-op"
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/safefile/safeopen.go b/vendor/github.com/Microsoft/hcsshim/internal/safefile/safeopen.go
index 0c0b1159f..f31edfaf8 100644
--- a/vendor/github.com/Microsoft/hcsshim/internal/safefile/safeopen.go
+++ b/vendor/github.com/Microsoft/hcsshim/internal/safefile/safeopen.go
@@ -87,7 +87,7 @@ func OpenRoot(path string) (*os.File, error) {
func ntRelativePath(path string) ([]uint16, error) {
path = filepath.Clean(path)
- if strings.Contains(":", path) {
+ if strings.Contains(path, ":") {
// Since alternate data streams must follow the file they
// are attached to, finding one here (out of order) is invalid.
return nil, errors.New("path contains invalid character `:`")
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/plan9_share.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/plan9_share.go
index b2bc58b83..eb171817a 100644
--- a/vendor/github.com/Microsoft/hcsshim/internal/schema2/plan9_share.go
+++ b/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"`
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/virtual_machine.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/virtual_machine.go
index 11f39eea7..2d22b1bcb 100644
--- a/vendor/github.com/Microsoft/hcsshim/internal/schema2/virtual_machine.go
+++ b/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"`
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/activatelayer.go b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/activatelayer.go
index 3a0d4bc58..dcb919268 100644
--- a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/activatelayer.go
+++ b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/activatelayer.go
@@ -9,17 +9,24 @@ import (
// For a read/write layer, the mounted filesystem will appear as a volume on the
// host, while a read-only layer is generally expected to be a no-op.
// An activated layer must later be deactivated via DeactivateLayer.
-func ActivateLayer(path string) error {
- title := "hcsshim::ActivateLayer "
- logrus.Debugf(title+"path %s", path)
+func ActivateLayer(path string) (err error) {
+ title := "hcsshim::ActivateLayer"
+ fields := logrus.Fields{
+ "path": path,
+ }
+ logrus.WithFields(fields).Debug(title)
+ defer func() {
+ if err != nil {
+ fields[logrus.ErrorKey] = err
+ logrus.WithFields(fields).Error(err)
+ } else {
+ logrus.WithFields(fields).Debug(title + " - succeeded")
+ }
+ }()
- err := activateLayer(&stdDriverInfo, path)
+ err = activateLayer(&stdDriverInfo, path)
if err != nil {
- err = hcserror.Errorf(err, title, "path=%s", path)
- logrus.Error(err)
- return err
+ return hcserror.New(err, title+" - failed", "")
}
-
- logrus.Debugf(title+" - succeeded path=%s", path)
return nil
}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/createlayer.go b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/createlayer.go
index d15817730..be2bc3fd6 100644
--- a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/createlayer.go
+++ b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/createlayer.go
@@ -7,17 +7,25 @@ import (
// CreateLayer creates a new, empty, read-only layer on the filesystem based on
// the parent layer provided.
-func CreateLayer(path, parent string) error {
- title := "hcsshim::CreateLayer "
- logrus.Debugf(title+"ID %s parent %s", path, parent)
+func CreateLayer(path, parent string) (err error) {
+ title := "hcsshim::CreateLayer"
+ fields := logrus.Fields{
+ "parent": parent,
+ "path": path,
+ }
+ logrus.WithFields(fields).Debug(title)
+ defer func() {
+ if err != nil {
+ fields[logrus.ErrorKey] = err
+ logrus.WithFields(fields).Error(err)
+ } else {
+ logrus.WithFields(fields).Debug(title + " - succeeded")
+ }
+ }()
- err := createLayer(&stdDriverInfo, path, parent)
+ err = createLayer(&stdDriverInfo, path, parent)
if err != nil {
- err = hcserror.Errorf(err, title, "path=%s parent=%s", path, parent)
- logrus.Error(err)
- return err
+ return hcserror.New(err, title+" - failed", "")
}
-
- logrus.Debugf(title+"- succeeded path=%s parent=%s", path, parent)
return nil
}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/createscratchlayer.go b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/createscratchlayer.go
index bf2fece19..7e3351289 100644
--- a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/createscratchlayer.go
+++ b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/createscratchlayer.go
@@ -9,9 +9,20 @@ import (
// This requires both the id of the direct parent layer, as well as the full list
// of paths to all parent layers up to the base (and including the direct parent
// whose id was provided).
-func CreateScratchLayer(path string, parentLayerPaths []string) error {
- title := "hcsshim::CreateScratchLayer "
- logrus.Debugf(title+"path %s", path)
+func CreateScratchLayer(path string, parentLayerPaths []string) (err error) {
+ title := "hcsshim::CreateScratchLayer"
+ fields := logrus.Fields{
+ "path": path,
+ }
+ logrus.WithFields(fields).Debug(title)
+ defer func() {
+ if err != nil {
+ fields[logrus.ErrorKey] = err
+ logrus.WithFields(fields).Error(err)
+ } else {
+ logrus.WithFields(fields).Debug(title + " - succeeded")
+ }
+ }()
// Generate layer descriptors
layers, err := layerPathsToDescriptors(parentLayerPaths)
@@ -21,11 +32,7 @@ func CreateScratchLayer(path string, parentLayerPaths []string) error {
err = createSandboxLayer(&stdDriverInfo, path, 0, layers)
if err != nil {
- err = hcserror.Errorf(err, title, "path=%s", path)
- logrus.Error(err)
- return err
+ return hcserror.New(err, title+" - failed", "")
}
-
- logrus.Debugf(title+"- succeeded path=%s", path)
return nil
}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/deactivatelayer.go b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/deactivatelayer.go
index b998f8a19..2dd5d5715 100644
--- a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/deactivatelayer.go
+++ b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/deactivatelayer.go
@@ -6,17 +6,24 @@ import (
)
// DeactivateLayer will dismount a layer that was mounted via ActivateLayer.
-func DeactivateLayer(path string) error {
- title := "hcsshim::DeactivateLayer "
- logrus.Debugf(title+"path %s", path)
+func DeactivateLayer(path string) (err error) {
+ title := "hcsshim::DeactivateLayer"
+ fields := logrus.Fields{
+ "path": path,
+ }
+ logrus.WithFields(fields).Debug(title)
+ defer func() {
+ if err != nil {
+ fields[logrus.ErrorKey] = err
+ logrus.WithFields(fields).Error(err)
+ } else {
+ logrus.WithFields(fields).Debug(title + " - succeeded")
+ }
+ }()
- err := deactivateLayer(&stdDriverInfo, path)
+ err = deactivateLayer(&stdDriverInfo, path)
if err != nil {
- err = hcserror.Errorf(err, title, "path=%s", path)
- logrus.Error(err)
- return err
+ return hcserror.New(err, title+"- failed", "")
}
-
- logrus.Debugf(title+"succeeded path=%s", path)
return nil
}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/destroylayer.go b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/destroylayer.go
index dc14cecc4..4da690c20 100644
--- a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/destroylayer.go
+++ b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/destroylayer.go
@@ -7,17 +7,24 @@ import (
// DestroyLayer will remove the on-disk files representing the layer with the given
// path, including that layer's containing folder, if any.
-func DestroyLayer(path string) error {
- title := "hcsshim::DestroyLayer "
- logrus.Debugf(title+"path %s", path)
+func DestroyLayer(path string) (err error) {
+ title := "hcsshim::DestroyLayer"
+ fields := logrus.Fields{
+ "path": path,
+ }
+ logrus.WithFields(fields).Debug(title)
+ defer func() {
+ if err != nil {
+ fields[logrus.ErrorKey] = err
+ logrus.WithFields(fields).Error(err)
+ } else {
+ logrus.WithFields(fields).Debug(title + " - succeeded")
+ }
+ }()
- err := destroyLayer(&stdDriverInfo, path)
+ err = destroyLayer(&stdDriverInfo, path)
if err != nil {
- err = hcserror.Errorf(err, title, "path=%s", path)
- logrus.Error(err)
- return err
+ return hcserror.New(err, title+" - failed", "")
}
-
- logrus.Debugf(title+"succeeded path=%s", path)
return nil
}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/expandscratchsize.go b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/expandscratchsize.go
index 7832bb452..651676fb2 100644
--- a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/expandscratchsize.go
+++ b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/expandscratchsize.go
@@ -6,17 +6,25 @@ import (
)
// ExpandScratchSize expands the size of a layer to at least size bytes.
-func ExpandScratchSize(path string, size uint64) error {
- title := "hcsshim::ExpandScratchSize "
- logrus.Debugf(title+"path=%s size=%d", path, size)
+func ExpandScratchSize(path string, size uint64) (err error) {
+ title := "hcsshim::ExpandScratchSize"
+ fields := logrus.Fields{
+ "path": path,
+ "size": size,
+ }
+ logrus.WithFields(fields).Debug(title)
+ defer func() {
+ if err != nil {
+ fields[logrus.ErrorKey] = err
+ logrus.WithFields(fields).Error(err)
+ } else {
+ logrus.WithFields(fields).Debug(title + " - succeeded")
+ }
+ }()
- err := expandSandboxSize(&stdDriverInfo, path, size)
+ err = expandSandboxSize(&stdDriverInfo, path, size)
if err != nil {
- err = hcserror.Errorf(err, title, "path=%s size=%d", path, size)
- logrus.Error(err)
- return err
+ return hcserror.New(err, title+" - failed", "")
}
-
- logrus.Debugf(title+"- succeeded path=%s size=%d", path, size)
return nil
}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/exportlayer.go b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/exportlayer.go
index d43e941ee..0425b3395 100644
--- a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/exportlayer.go
+++ b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/exportlayer.go
@@ -14,9 +14,21 @@ import (
// format includes any metadata required for later importing the layer (using
// ImportLayer), and requires the full list of parent layer paths in order to
// perform the export.
-func ExportLayer(path string, exportFolderPath string, parentLayerPaths []string) error {
- title := "hcsshim::ExportLayer "
- logrus.Debugf(title+"path %s folder %s", path, exportFolderPath)
+func ExportLayer(path string, exportFolderPath string, parentLayerPaths []string) (err error) {
+ title := "hcsshim::ExportLayer"
+ fields := logrus.Fields{
+ "path": path,
+ "exportFolderPath": exportFolderPath,
+ }
+ logrus.WithFields(fields).Debug(title)
+ defer func() {
+ if err != nil {
+ fields[logrus.ErrorKey] = err
+ logrus.WithFields(fields).Error(err)
+ } else {
+ logrus.WithFields(fields).Debug(title + " - succeeded")
+ }
+ }()
// Generate layer descriptors
layers, err := layerPathsToDescriptors(parentLayerPaths)
@@ -26,12 +38,8 @@ func ExportLayer(path string, exportFolderPath string, parentLayerPaths []string
err = exportLayer(&stdDriverInfo, path, exportFolderPath, layers)
if err != nil {
- err = hcserror.Errorf(err, title, "path=%s folder=%s", path, exportFolderPath)
- logrus.Error(err)
- return err
+ return hcserror.New(err, title+" - failed", "")
}
-
- logrus.Debugf(title+"succeeded path=%s folder=%s", path, exportFolderPath)
return nil
}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/getlayermountpath.go b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/getlayermountpath.go
index 8c37549a0..d60b6ed53 100644
--- a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/getlayermountpath.go
+++ b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/getlayermountpath.go
@@ -11,20 +11,29 @@ import (
// the path at which that layer can be accessed. This path may be a volume path
// if the layer is a mounted read-write layer, otherwise it is expected to be the
// folder path at which the layer is stored.
-func GetLayerMountPath(path string) (string, error) {
- title := "hcsshim::GetLayerMountPath "
- logrus.Debugf(title+"path %s", path)
+func GetLayerMountPath(path string) (_ string, err error) {
+ title := "hcsshim::GetLayerMountPath"
+ fields := logrus.Fields{
+ "path": path,
+ }
+ logrus.WithFields(fields).Debug(title)
+ defer func() {
+ if err != nil {
+ fields[logrus.ErrorKey] = err
+ logrus.WithFields(fields).Error(err)
+ } else {
+ logrus.WithFields(fields).Debug(title + " - succeeded")
+ }
+ }()
var mountPathLength uintptr
mountPathLength = 0
// Call the procedure itself.
- logrus.Debugf("Calling proc (1)")
- err := getLayerMountPath(&stdDriverInfo, path, &mountPathLength, nil)
+ logrus.WithFields(fields).Debug("Calling proc (1)")
+ err = getLayerMountPath(&stdDriverInfo, path, &mountPathLength, nil)
if err != nil {
- err = hcserror.Errorf(err, title, "(first call) path=%s", path)
- logrus.Error(err)
- return "", err
+ return "", hcserror.New(err, title+" - failed", "(first call)")
}
// Allocate a mount path of the returned length.
@@ -35,15 +44,13 @@ func GetLayerMountPath(path string) (string, error) {
mountPathp[0] = 0
// Call the procedure again
- logrus.Debugf("Calling proc (2)")
+ logrus.WithFields(fields).Debug("Calling proc (2)")
err = getLayerMountPath(&stdDriverInfo, path, &mountPathLength, &mountPathp[0])
if err != nil {
- err = hcserror.Errorf(err, title, "(second call) path=%s", path)
- logrus.Error(err)
- return "", err
+ return "", hcserror.New(err, title+" - failed", "(second call)")
}
mountPath := syscall.UTF16ToString(mountPathp[0:])
- logrus.Debugf(title+"succeeded path=%s mountPath=%s", path, mountPath)
+ fields["mountPath"] = mountPath
return mountPath, nil
}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/getsharedbaseimages.go b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/getsharedbaseimages.go
index 10899c68a..dbd83ef2b 100644
--- a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/getsharedbaseimages.go
+++ b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/getsharedbaseimages.go
@@ -10,17 +10,20 @@ import (
// image store and return descriptive info about those images for the purpose
// of registering them with the graphdriver, graph, and tagstore.
func GetSharedBaseImages() (imageData string, err error) {
- title := "hcsshim::GetSharedBaseImages "
+ title := "hcsshim::GetSharedBaseImages"
+ logrus.Debug(title)
+ defer func() {
+ if err != nil {
+ logrus.WithError(err).Error(err)
+ } else {
+ logrus.WithField("imageData", imageData).Debug(title + " - succeeded")
+ }
+ }()
- logrus.Debugf("Calling proc")
var buffer *uint16
err = getBaseImages(&buffer)
if err != nil {
- err = hcserror.New(err, title, "")
- logrus.Error(err)
- return
+ return "", hcserror.New(err, title+" - failed", "")
}
- imageData = interop.ConvertAndFreeCoTaskMemString(buffer)
- logrus.Debugf(title+" - succeeded output=%s", imageData)
- return
+ return interop.ConvertAndFreeCoTaskMemString(buffer), nil
}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/grantvmaccess.go b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/grantvmaccess.go
index d86e67827..05735df6c 100644
--- a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/grantvmaccess.go
+++ b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/grantvmaccess.go
@@ -1,24 +1,30 @@
package wclayer
import (
- "fmt"
-
"github.com/Microsoft/hcsshim/internal/hcserror"
"github.com/sirupsen/logrus"
)
// GrantVmAccess adds access to a file for a given VM
-func GrantVmAccess(vmid string, filepath string) error {
- title := fmt.Sprintf("hcsshim::GrantVmAccess id:%s path:%s ", vmid, filepath)
- logrus.Debugf(title)
+func GrantVmAccess(vmid string, filepath string) (err error) {
+ title := "hcsshim::GrantVmAccess"
+ fields := logrus.Fields{
+ "vm-id": vmid,
+ "path": filepath,
+ }
+ logrus.WithFields(fields).Debug(title)
+ defer func() {
+ if err != nil {
+ fields[logrus.ErrorKey] = err
+ logrus.WithFields(fields).Error(err)
+ } else {
+ logrus.WithFields(fields).Debug(title + " - succeeded")
+ }
+ }()
- err := grantVmAccess(vmid, filepath)
+ err = grantVmAccess(vmid, filepath)
if err != nil {
- err = hcserror.Errorf(err, title, "path=%s", filepath)
- logrus.Error(err)
- return err
+ return hcserror.New(err, title+" - failed", "")
}
-
- logrus.Debugf(title + " - succeeded")
return nil
}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/importlayer.go b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/importlayer.go
index 486d55470..76a804f2a 100644
--- a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/importlayer.go
+++ b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/importlayer.go
@@ -15,9 +15,21 @@ import (
// that into a layer with the id layerId. Note that in order to correctly populate
// the layer and interperet the transport format, all parent layers must already
// be present on the system at the paths provided in parentLayerPaths.
-func ImportLayer(path string, importFolderPath string, parentLayerPaths []string) error {
- title := "hcsshim::ImportLayer "
- logrus.Debugf(title+"path %s folder %s", path, importFolderPath)
+func ImportLayer(path string, importFolderPath string, parentLayerPaths []string) (err error) {
+ title := "hcsshim::ImportLayer"
+ fields := logrus.Fields{
+ "path": path,
+ "importFolderPath": importFolderPath,
+ }
+ logrus.WithFields(fields).Debug(title)
+ defer func() {
+ if err != nil {
+ fields[logrus.ErrorKey] = err
+ logrus.WithFields(fields).Error(err)
+ } else {
+ logrus.WithFields(fields).Debug(title + " - succeeded")
+ }
+ }()
// Generate layer descriptors
layers, err := layerPathsToDescriptors(parentLayerPaths)
@@ -27,12 +39,8 @@ func ImportLayer(path string, importFolderPath string, parentLayerPaths []string
err = importLayer(&stdDriverInfo, path, importFolderPath, layers)
if err != nil {
- err = hcserror.Errorf(err, title, "path=%s folder=%s", path, importFolderPath)
- logrus.Error(err)
- return err
+ return hcserror.New(err, title+" - failed", "")
}
-
- logrus.Debugf(title+"succeeded path=%s folder=%s", path, importFolderPath)
return nil
}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/layerexists.go b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/layerexists.go
index 71287ff8a..258167a57 100644
--- a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/layerexists.go
+++ b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/layerexists.go
@@ -7,19 +7,27 @@ import (
// LayerExists will return true if a layer with the given id exists and is known
// to the system.
-func LayerExists(path string) (bool, error) {
- title := "hcsshim::LayerExists "
- logrus.Debugf(title+"path %s", path)
+func LayerExists(path string) (_ bool, err error) {
+ title := "hcsshim::LayerExists"
+ fields := logrus.Fields{
+ "path": path,
+ }
+ logrus.WithFields(fields).Debug(title)
+ defer func() {
+ if err != nil {
+ fields[logrus.ErrorKey] = err
+ logrus.WithFields(fields).Error(err)
+ } else {
+ logrus.WithFields(fields).Debug(title + " - succeeded")
+ }
+ }()
// Call the procedure itself.
var exists uint32
- err := layerExists(&stdDriverInfo, path, &exists)
+ err = layerExists(&stdDriverInfo, path, &exists)
if err != nil {
- err = hcserror.Errorf(err, title, "path=%s", path)
- logrus.Error(err)
- return false, err
+ return false, hcserror.New(err, title+" - failed", "")
}
-
- logrus.Debugf(title+"succeeded path=%s exists=%d", path, exists)
+ fields["layer-exists"] = exists != 0
return exists != 0, nil
}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/layerutils.go b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/layerutils.go
index a1b8b9882..6d0ae8a07 100644
--- a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/layerutils.go
+++ b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/layerutils.go
@@ -75,13 +75,13 @@ func layerPathsToDescriptors(parentLayerPaths []string) ([]WC_LAYER_DESCRIPTOR,
for i := 0; i < len(parentLayerPaths); i++ {
g, err := LayerID(parentLayerPaths[i])
if err != nil {
- logrus.Debugf("Failed to convert name to guid %s", err)
+ logrus.WithError(err).Debug("Failed to convert name to guid")
return nil, err
}
p, err := syscall.UTF16PtrFromString(parentLayerPaths[i])
if err != nil {
- logrus.Debugf("Failed conversion of parentLayerPath to pointer %s", err)
+ logrus.WithError(err).Debug("Failed conversion of parentLayerPath to pointer")
return nil, err
}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/nametoguid.go b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/nametoguid.go
index 741994ba4..45a63cf65 100644
--- a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/nametoguid.go
+++ b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/nametoguid.go
@@ -10,15 +10,25 @@ import (
// Host Compute Service, ensuring GUIDs generated with the same string are common
// across all clients.
func NameToGuid(name string) (id guid.GUID, err error) {
- title := "hcsshim::NameToGuid "
+ title := "hcsshim::NameToGuid"
+ fields := logrus.Fields{
+ "name": name,
+ }
+ logrus.WithFields(fields).Debug(title)
+ defer func() {
+ if err != nil {
+ fields[logrus.ErrorKey] = err
+ logrus.WithFields(fields).Error(err)
+ } else {
+ logrus.WithFields(fields).Debug(title + " - succeeded")
+ }
+ }()
err = nameToGuid(name, &id)
if err != nil {
- err = hcserror.Errorf(err, title, "name=%s", name)
- logrus.Error(err)
+ err = hcserror.New(err, title+" - failed", "")
return
}
-
- logrus.Debugf(title+"name:%s guid:%s", name, id.String())
+ fields["guid"] = id.String()
return
}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/preparelayer.go b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/preparelayer.go
index bd4005dc4..2b65b0186 100644
--- a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/preparelayer.go
+++ b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/preparelayer.go
@@ -14,9 +14,20 @@ var prepareLayerLock sync.Mutex
// parent layers, and is necessary in order to view or interact with the layer
// as an actual filesystem (reading and writing files, creating directories, etc).
// Disabling the filter must be done via UnprepareLayer.
-func PrepareLayer(path string, parentLayerPaths []string) error {
- title := "hcsshim::PrepareLayer "
- logrus.Debugf(title+"path %s", path)
+func PrepareLayer(path string, parentLayerPaths []string) (err error) {
+ title := "hcsshim::PrepareLayer"
+ fields := logrus.Fields{
+ "path": path,
+ }
+ logrus.WithFields(fields).Debug(title)
+ defer func() {
+ if err != nil {
+ fields[logrus.ErrorKey] = err
+ logrus.WithFields(fields).Error(err)
+ } else {
+ logrus.WithFields(fields).Debug(title + " - succeeded")
+ }
+ }()
// Generate layer descriptors
layers, err := layerPathsToDescriptors(parentLayerPaths)
@@ -30,11 +41,7 @@ func PrepareLayer(path string, parentLayerPaths []string) error {
defer prepareLayerLock.Unlock()
err = prepareLayer(&stdDriverInfo, path, layers)
if err != nil {
- err = hcserror.Errorf(err, title, "path=%s", path)
- logrus.Error(err)
- return err
+ return hcserror.New(err, title+" - failed", "")
}
-
- logrus.Debugf(title+"succeeded path=%s", path)
return nil
}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/unpreparelayer.go b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/unpreparelayer.go
index 5f1b4f4f4..bccd45969 100644
--- a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/unpreparelayer.go
+++ b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/unpreparelayer.go
@@ -7,17 +7,24 @@ import (
// UnprepareLayer disables the filesystem filter for the read-write layer with
// the given id.
-func UnprepareLayer(path string) error {
- title := "hcsshim::UnprepareLayer "
- logrus.Debugf(title+"path %s", path)
+func UnprepareLayer(path string) (err error) {
+ title := "hcsshim::UnprepareLayer"
+ fields := logrus.Fields{
+ "path": path,
+ }
+ logrus.WithFields(fields).Debug(title)
+ defer func() {
+ if err != nil {
+ fields[logrus.ErrorKey] = err
+ logrus.WithFields(fields).Error(err)
+ } else {
+ logrus.WithFields(fields).Debug(title + " - succeeded")
+ }
+ }()
- err := unprepareLayer(&stdDriverInfo, path)
+ err = unprepareLayer(&stdDriverInfo, path)
if err != nil {
- err = hcserror.Errorf(err, title, "path=%s", path)
- logrus.Error(err)
- return err
+ return hcserror.New(err, title+" - failed", "")
}
-
- logrus.Debugf(title+"succeeded path=%s", path)
return nil
}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/zsyscall_windows.go b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/zsyscall_windows.go
index 2105703dc..d853ab259 100644
--- a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/zsyscall_windows.go
+++ b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/zsyscall_windows.go
@@ -6,7 +6,6 @@ import (
"syscall"
"unsafe"
- "github.com/Microsoft/hcsshim/internal/interop"
"golang.org/x/sys/windows"
)
@@ -75,7 +74,10 @@ func _activateLayer(info *driverInfo, id *uint16) (hr error) {
}
r0, _, _ := syscall.Syscall(procActivateLayer.Addr(), 2, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), 0)
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
@@ -104,7 +106,10 @@ func _copyLayer(info *driverInfo, srcId *uint16, dstId *uint16, descriptors []WC
}
r0, _, _ := syscall.Syscall6(procCopyLayer.Addr(), 5, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(srcId)), uintptr(unsafe.Pointer(dstId)), uintptr(unsafe.Pointer(_p2)), uintptr(len(descriptors)), 0)
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
@@ -129,7 +134,10 @@ func _createLayer(info *driverInfo, id *uint16, parent *uint16) (hr error) {
}
r0, _, _ := syscall.Syscall(procCreateLayer.Addr(), 3, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(parent)))
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
@@ -153,7 +161,10 @@ func _createSandboxLayer(info *driverInfo, id *uint16, parent uintptr, descripto
}
r0, _, _ := syscall.Syscall6(procCreateSandboxLayer.Addr(), 5, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), uintptr(parent), uintptr(unsafe.Pointer(_p1)), uintptr(len(descriptors)), 0)
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
@@ -173,7 +184,10 @@ func _expandSandboxSize(info *driverInfo, id *uint16, size uint64) (hr error) {
}
r0, _, _ := syscall.Syscall(procExpandSandboxSize.Addr(), 3, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), uintptr(size))
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
@@ -193,7 +207,10 @@ func _deactivateLayer(info *driverInfo, id *uint16) (hr error) {
}
r0, _, _ := syscall.Syscall(procDeactivateLayer.Addr(), 2, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), 0)
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
@@ -213,7 +230,10 @@ func _destroyLayer(info *driverInfo, id *uint16) (hr error) {
}
r0, _, _ := syscall.Syscall(procDestroyLayer.Addr(), 2, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), 0)
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
@@ -242,7 +262,10 @@ func _exportLayer(info *driverInfo, id *uint16, path *uint16, descriptors []WC_L
}
r0, _, _ := syscall.Syscall6(procExportLayer.Addr(), 5, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(_p2)), uintptr(len(descriptors)), 0)
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
@@ -262,7 +285,10 @@ func _getLayerMountPath(info *driverInfo, id *uint16, length *uintptr, buffer *u
}
r0, _, _ := syscall.Syscall6(procGetLayerMountPath.Addr(), 4, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(length)), uintptr(unsafe.Pointer(buffer)), 0, 0)
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
@@ -273,7 +299,10 @@ func getBaseImages(buffer **uint16) (hr error) {
}
r0, _, _ := syscall.Syscall(procGetBaseImages.Addr(), 1, uintptr(unsafe.Pointer(buffer)), 0, 0)
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
@@ -302,7 +331,10 @@ func _importLayer(info *driverInfo, id *uint16, path *uint16, descriptors []WC_L
}
r0, _, _ := syscall.Syscall6(procImportLayer.Addr(), 5, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(_p2)), uintptr(len(descriptors)), 0)
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
@@ -322,7 +354,10 @@ func _layerExists(info *driverInfo, id *uint16, exists *uint32) (hr error) {
}
r0, _, _ := syscall.Syscall(procLayerExists.Addr(), 3, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(exists)))
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
@@ -342,7 +377,10 @@ func _nameToGuid(name *uint16, guid *_guid) (hr error) {
}
r0, _, _ := syscall.Syscall(procNameToGuid.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(guid)), 0)
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
@@ -366,7 +404,10 @@ func _prepareLayer(info *driverInfo, id *uint16, descriptors []WC_LAYER_DESCRIPT
}
r0, _, _ := syscall.Syscall6(procPrepareLayer.Addr(), 4, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(_p1)), uintptr(len(descriptors)), 0, 0)
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
@@ -386,7 +427,10 @@ func _unprepareLayer(info *driverInfo, id *uint16) (hr error) {
}
r0, _, _ := syscall.Syscall(procUnprepareLayer.Addr(), 2, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), 0)
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
@@ -406,7 +450,10 @@ func _processBaseImage(path *uint16) (hr error) {
}
r0, _, _ := syscall.Syscall(procProcessBaseImage.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
@@ -426,7 +473,10 @@ func _processUtilityImage(path *uint16) (hr error) {
}
r0, _, _ := syscall.Syscall(procProcessUtilityImage.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
@@ -451,7 +501,10 @@ func _grantVmAccess(vmid *uint16, filepath *uint16) (hr error) {
}
r0, _, _ := syscall.Syscall(procGrantVmAccess.Addr(), 2, uintptr(unsafe.Pointer(vmid)), uintptr(unsafe.Pointer(filepath)), 0)
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}
diff --git a/vendor/github.com/Microsoft/hcsshim/mksyscall_windows.go b/vendor/github.com/Microsoft/hcsshim/mksyscall_windows.go
new file mode 100644
index 000000000..7647734de
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/mksyscall_windows.go
@@ -0,0 +1,943 @@
+// Copyright 2013 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build ignore
+
+/*
+mksyscall_windows generates windows system call bodies
+
+It parses all files specified on command line containing function
+prototypes (like syscall_windows.go) and prints system call bodies
+to standard output.
+
+The prototypes are marked by lines beginning with "//sys" and read
+like func declarations if //sys is replaced by func, but:
+
+* The parameter lists must give a name for each argument. This
+ includes return parameters.
+
+* The parameter lists must give a type for each argument:
+ the (x, y, z int) shorthand is not allowed.
+
+* If the return parameter is an error number, it must be named err.
+
+* If go func name needs to be different from it's winapi dll name,
+ the winapi name could be specified at the end, after "=" sign, like
+ //sys LoadLibrary(libname string) (handle uint32, err error) = LoadLibraryA
+
+* Each function that returns err needs to supply a condition, that
+ return value of winapi will be tested against to detect failure.
+ This would set err to windows "last-error", otherwise it will be nil.
+ The value can be provided at end of //sys declaration, like
+ //sys LoadLibrary(libname string) (handle uint32, err error) [failretval==-1] = LoadLibraryA
+ and is [failretval==0] by default.
+
+Usage:
+ mksyscall_windows [flags] [path ...]
+
+The flags are:
+ -output
+ Specify output file name (outputs to console if blank).
+ -trace
+ Generate print statement after every syscall.
+*/
+package main
+
+import (
+ "bufio"
+ "bytes"
+ "errors"
+ "flag"
+ "fmt"
+ "go/format"
+ "go/parser"
+ "go/token"
+ "io"
+ "io/ioutil"
+ "log"
+ "os"
+ "path/filepath"
+ "runtime"
+ "sort"
+ "strconv"
+ "strings"
+ "text/template"
+)
+
+var (
+ filename = flag.String("output", "", "output file name (standard output if omitted)")
+ printTraceFlag = flag.Bool("trace", false, "generate print statement after every syscall")
+ systemDLL = flag.Bool("systemdll", true, "whether all DLLs should be loaded from the Windows system directory")
+ winio = flag.Bool("winio", false, "import go-winio")
+)
+
+func trim(s string) string {
+ return strings.Trim(s, " \t")
+}
+
+var packageName string
+
+func packagename() string {
+ return packageName
+}
+
+func syscalldot() string {
+ if packageName == "syscall" {
+ return ""
+ }
+ return "syscall."
+}
+
+// Param is function parameter
+type Param struct {
+ Name string
+ Type string
+ fn *Fn
+ tmpVarIdx int
+}
+
+// tmpVar returns temp variable name that will be used to represent p during syscall.
+func (p *Param) tmpVar() string {
+ if p.tmpVarIdx < 0 {
+ p.tmpVarIdx = p.fn.curTmpVarIdx
+ p.fn.curTmpVarIdx++
+ }
+ return fmt.Sprintf("_p%d", p.tmpVarIdx)
+}
+
+// BoolTmpVarCode returns source code for bool temp variable.
+func (p *Param) BoolTmpVarCode() string {
+ const code = `var %s uint32
+ if %s {
+ %s = 1
+ } else {
+ %s = 0
+ }`
+ tmp := p.tmpVar()
+ return fmt.Sprintf(code, tmp, p.Name, tmp, tmp)
+}
+
+// SliceTmpVarCode returns source code for slice temp variable.
+func (p *Param) SliceTmpVarCode() string {
+ const code = `var %s *%s
+ if len(%s) > 0 {
+ %s = &%s[0]
+ }`
+ tmp := p.tmpVar()
+ return fmt.Sprintf(code, tmp, p.Type[2:], p.Name, tmp, p.Name)
+}
+
+// StringTmpVarCode returns source code for string temp variable.
+func (p *Param) StringTmpVarCode() string {
+ errvar := p.fn.Rets.ErrorVarName()
+ if errvar == "" {
+ errvar = "_"
+ }
+ tmp := p.tmpVar()
+ const code = `var %s %s
+ %s, %s = %s(%s)`
+ s := fmt.Sprintf(code, tmp, p.fn.StrconvType(), tmp, errvar, p.fn.StrconvFunc(), p.Name)
+ if errvar == "-" {
+ return s
+ }
+ const morecode = `
+ if %s != nil {
+ return
+ }`
+ return s + fmt.Sprintf(morecode, errvar)
+}
+
+// TmpVarCode returns source code for temp variable.
+func (p *Param) TmpVarCode() string {
+ switch {
+ case p.Type == "bool":
+ return p.BoolTmpVarCode()
+ case strings.HasPrefix(p.Type, "[]"):
+ return p.SliceTmpVarCode()
+ default:
+ return ""
+ }
+}
+
+// TmpVarHelperCode returns source code for helper's temp variable.
+func (p *Param) TmpVarHelperCode() string {
+ if p.Type != "string" {
+ return ""
+ }
+ return p.StringTmpVarCode()
+}
+
+// SyscallArgList returns source code fragments representing p parameter
+// in syscall. Slices are translated into 2 syscall parameters: pointer to
+// the first element and length.
+func (p *Param) SyscallArgList() []string {
+ t := p.HelperType()
+ var s string
+ switch {
+ case t[0] == '*':
+ s = fmt.Sprintf("unsafe.Pointer(%s)", p.Name)
+ case t == "bool":
+ s = p.tmpVar()
+ case strings.HasPrefix(t, "[]"):
+ return []string{
+ fmt.Sprintf("uintptr(unsafe.Pointer(%s))", p.tmpVar()),
+ fmt.Sprintf("uintptr(len(%s))", p.Name),
+ }
+ default:
+ s = p.Name
+ }
+ return []string{fmt.Sprintf("uintptr(%s)", s)}
+}
+
+// IsError determines if p parameter is used to return error.
+func (p *Param) IsError() bool {
+ return p.Name == "err" && p.Type == "error"
+}
+
+// HelperType returns type of parameter p used in helper function.
+func (p *Param) HelperType() string {
+ if p.Type == "string" {
+ return p.fn.StrconvType()
+ }
+ return p.Type
+}
+
+// join concatenates parameters ps into a string with sep separator.
+// Each parameter is converted into string by applying fn to it
+// before conversion.
+func join(ps []*Param, fn func(*Param) string, sep string) string {
+ if len(ps) == 0 {
+ return ""
+ }
+ a := make([]string, 0)
+ for _, p := range ps {
+ a = append(a, fn(p))
+ }
+ return strings.Join(a, sep)
+}
+
+// Rets describes function return parameters.
+type Rets struct {
+ Name string
+ Type string
+ ReturnsError bool
+ FailCond string
+}
+
+// ErrorVarName returns error variable name for r.
+func (r *Rets) ErrorVarName() string {
+ if r.ReturnsError {
+ return "err"
+ }
+ if r.Type == "error" {
+ return r.Name
+ }
+ return ""
+}
+
+// ToParams converts r into slice of *Param.
+func (r *Rets) ToParams() []*Param {
+ ps := make([]*Param, 0)
+ if len(r.Name) > 0 {
+ ps = append(ps, &Param{Name: r.Name, Type: r.Type})
+ }
+ if r.ReturnsError {
+ ps = append(ps, &Param{Name: "err", Type: "error"})
+ }
+ return ps
+}
+
+// List returns source code of syscall return parameters.
+func (r *Rets) List() string {
+ s := join(r.ToParams(), func(p *Param) string { return p.Name + " " + p.Type }, ", ")
+ if len(s) > 0 {
+ s = "(" + s + ")"
+ }
+ return s
+}
+
+// PrintList returns source code of trace printing part correspondent
+// to syscall return values.
+func (r *Rets) PrintList() string {
+ return join(r.ToParams(), func(p *Param) string { return fmt.Sprintf(`"%s=", %s, `, p.Name, p.Name) }, `", ", `)
+}
+
+// SetReturnValuesCode returns source code that accepts syscall return values.
+func (r *Rets) SetReturnValuesCode() string {
+ if r.Name == "" && !r.ReturnsError {
+ return ""
+ }
+ retvar := "r0"
+ if r.Name == "" {
+ retvar = "r1"
+ }
+ errvar := "_"
+ if r.ReturnsError {
+ errvar = "e1"
+ }
+ return fmt.Sprintf("%s, _, %s := ", retvar, errvar)
+}
+
+func (r *Rets) useLongHandleErrorCode(retvar string) string {
+ const code = `if %s {
+ if e1 != 0 {
+ err = errnoErr(e1)
+ } else {
+ err = %sEINVAL
+ }
+ }`
+ cond := retvar + " == 0"
+ if r.FailCond != "" {
+ cond = strings.Replace(r.FailCond, "failretval", retvar, 1)
+ }
+ return fmt.Sprintf(code, cond, syscalldot())
+}
+
+// SetErrorCode returns source code that sets return parameters.
+func (r *Rets) SetErrorCode() string {
+ const code = `if r0 != 0 {
+ %s = %sErrno(r0)
+ }`
+ const hrCode = `if int32(r0) < 0 {
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ %s = %sErrno(r0)
+ }`
+ if r.Name == "" && !r.ReturnsError {
+ return ""
+ }
+ if r.Name == "" {
+ return r.useLongHandleErrorCode("r1")
+ }
+ if r.Type == "error" {
+ if r.Name == "hr" {
+ return fmt.Sprintf(hrCode, r.Name, syscalldot())
+ } else {
+ return fmt.Sprintf(code, r.Name, syscalldot())
+ }
+ }
+ s := ""
+ switch {
+ case r.Type[0] == '*':
+ s = fmt.Sprintf("%s = (%s)(unsafe.Pointer(r0))", r.Name, r.Type)
+ case r.Type == "bool":
+ s = fmt.Sprintf("%s = r0 != 0", r.Name)
+ default:
+ s = fmt.Sprintf("%s = %s(r0)", r.Name, r.Type)
+ }
+ if !r.ReturnsError {
+ return s
+ }
+ return s + "\n\t" + r.useLongHandleErrorCode(r.Name)
+}
+
+// Fn describes syscall function.
+type Fn struct {
+ Name string
+ Params []*Param
+ Rets *Rets
+ PrintTrace bool
+ confirmproc bool
+ dllname string
+ dllfuncname string
+ src string
+ // TODO: get rid of this field and just use parameter index instead
+ curTmpVarIdx int // insure tmp variables have uniq names
+}
+
+// extractParams parses s to extract function parameters.
+func extractParams(s string, f *Fn) ([]*Param, error) {
+ s = trim(s)
+ if s == "" {
+ return nil, nil
+ }
+ a := strings.Split(s, ",")
+ ps := make([]*Param, len(a))
+ for i := range ps {
+ s2 := trim(a[i])
+ b := strings.Split(s2, " ")
+ if len(b) != 2 {
+ b = strings.Split(s2, "\t")
+ if len(b) != 2 {
+ return nil, errors.New("Could not extract function parameter from \"" + s2 + "\"")
+ }
+ }
+ ps[i] = &Param{
+ Name: trim(b[0]),
+ Type: trim(b[1]),
+ fn: f,
+ tmpVarIdx: -1,
+ }
+ }
+ return ps, nil
+}
+
+// extractSection extracts text out of string s starting after start
+// and ending just before end. found return value will indicate success,
+// and prefix, body and suffix will contain correspondent parts of string s.
+func extractSection(s string, start, end rune) (prefix, body, suffix string, found bool) {
+ s = trim(s)
+ if strings.HasPrefix(s, string(start)) {
+ // no prefix
+ body = s[1:]
+ } else {
+ a := strings.SplitN(s, string(start), 2)
+ if len(a) != 2 {
+ return "", "", s, false
+ }
+ prefix = a[0]
+ body = a[1]
+ }
+ a := strings.SplitN(body, string(end), 2)
+ if len(a) != 2 {
+ return "", "", "", false
+ }
+ return prefix, a[0], a[1], true
+}
+
+// newFn parses string s and return created function Fn.
+func newFn(s string) (*Fn, error) {
+ s = trim(s)
+ f := &Fn{
+ Rets: &Rets{},
+ src: s,
+ PrintTrace: *printTraceFlag,
+ }
+ // function name and args
+ prefix, body, s, found := extractSection(s, '(', ')')
+ if !found || prefix == "" {
+ return nil, errors.New("Could not extract function name and parameters from \"" + f.src + "\"")
+ }
+ f.Name = prefix
+ var err error
+ f.Params, err = extractParams(body, f)
+ if err != nil {
+ return nil, err
+ }
+ // return values
+ _, body, s, found = extractSection(s, '(', ')')
+ if found {
+ r, err := extractParams(body, f)
+ if err != nil {
+ return nil, err
+ }
+ switch len(r) {
+ case 0:
+ case 1:
+ if r[0].IsError() {
+ f.Rets.ReturnsError = true
+ } else {
+ f.Rets.Name = r[0].Name
+ f.Rets.Type = r[0].Type
+ }
+ case 2:
+ if !r[1].IsError() {
+ return nil, errors.New("Only last windows error is allowed as second return value in \"" + f.src + "\"")
+ }
+ f.Rets.ReturnsError = true
+ f.Rets.Name = r[0].Name
+ f.Rets.Type = r[0].Type
+ default:
+ return nil, errors.New("Too many return values in \"" + f.src + "\"")
+ }
+ }
+ // fail condition
+ _, body, s, found = extractSection(s, '[', ']')
+ if found {
+ f.Rets.FailCond = body
+ }
+ // dll and dll function names
+ s = trim(s)
+ if s == "" {
+ return f, nil
+ }
+ if !strings.HasPrefix(s, "=") {
+ return nil, errors.New("Could not extract dll name from \"" + f.src + "\"")
+ }
+ s = trim(s[1:])
+ a := strings.Split(s, ".")
+ switch len(a) {
+ case 1:
+ f.dllfuncname = a[0]
+ case 2:
+ f.dllname = a[0]
+ f.dllfuncname = a[1]
+ default:
+ return nil, errors.New("Could not extract dll name from \"" + f.src + "\"")
+ }
+ if f.dllfuncname[len(f.dllfuncname)-1] == '?' {
+ f.confirmproc = true
+ f.dllfuncname = f.dllfuncname[0 : len(f.dllfuncname)-1]
+ }
+ return f, nil
+}
+
+// DLLName returns DLL name for function f.
+func (f *Fn) DLLName() string {
+ if f.dllname == "" {
+ return "kernel32"
+ }
+ return f.dllname
+}
+
+// DLLName returns DLL function name for function f.
+func (f *Fn) DLLFuncName() string {
+ if f.dllfuncname == "" {
+ return f.Name
+ }
+ return f.dllfuncname
+}
+
+func (f *Fn) ConfirmProc() bool {
+ return f.confirmproc
+}
+
+// ParamList returns source code for function f parameters.
+func (f *Fn) ParamList() string {
+ return join(f.Params, func(p *Param) string { return p.Name + " " + p.Type }, ", ")
+}
+
+// HelperParamList returns source code for helper function f parameters.
+func (f *Fn) HelperParamList() string {
+ return join(f.Params, func(p *Param) string { return p.Name + " " + p.HelperType() }, ", ")
+}
+
+// ParamPrintList returns source code of trace printing part correspondent
+// to syscall input parameters.
+func (f *Fn) ParamPrintList() string {
+ return join(f.Params, func(p *Param) string { return fmt.Sprintf(`"%s=", %s, `, p.Name, p.Name) }, `", ", `)
+}
+
+// ParamCount return number of syscall parameters for function f.
+func (f *Fn) ParamCount() int {
+ n := 0
+ for _, p := range f.Params {
+ n += len(p.SyscallArgList())
+ }
+ return n
+}
+
+// SyscallParamCount determines which version of Syscall/Syscall6/Syscall9/...
+// to use. It returns parameter count for correspondent SyscallX function.
+func (f *Fn) SyscallParamCount() int {
+ n := f.ParamCount()
+ switch {
+ case n <= 3:
+ return 3
+ case n <= 6:
+ return 6
+ case n <= 9:
+ return 9
+ case n <= 12:
+ return 12
+ case n <= 15:
+ return 15
+ default:
+ panic("too many arguments to system call")
+ }
+}
+
+// Syscall determines which SyscallX function to use for function f.
+func (f *Fn) Syscall() string {
+ c := f.SyscallParamCount()
+ if c == 3 {
+ return syscalldot() + "Syscall"
+ }
+ return syscalldot() + "Syscall" + strconv.Itoa(c)
+}
+
+// SyscallParamList returns source code for SyscallX parameters for function f.
+func (f *Fn) SyscallParamList() string {
+ a := make([]string, 0)
+ for _, p := range f.Params {
+ a = append(a, p.SyscallArgList()...)
+ }
+ for len(a) < f.SyscallParamCount() {
+ a = append(a, "0")
+ }
+ return strings.Join(a, ", ")
+}
+
+// HelperCallParamList returns source code of call into function f helper.
+func (f *Fn) HelperCallParamList() string {
+ a := make([]string, 0, len(f.Params))
+ for _, p := range f.Params {
+ s := p.Name
+ if p.Type == "string" {
+ s = p.tmpVar()
+ }
+ a = append(a, s)
+ }
+ return strings.Join(a, ", ")
+}
+
+// IsUTF16 is true, if f is W (utf16) function. It is false
+// for all A (ascii) functions.
+func (_ *Fn) IsUTF16() bool {
+ return true
+}
+
+// StrconvFunc returns name of Go string to OS string function for f.
+func (f *Fn) StrconvFunc() string {
+ if f.IsUTF16() {
+ return syscalldot() + "UTF16PtrFromString"
+ }
+ return syscalldot() + "BytePtrFromString"
+}
+
+// StrconvType returns Go type name used for OS string for f.
+func (f *Fn) StrconvType() string {
+ if f.IsUTF16() {
+ return "*uint16"
+ }
+ return "*byte"
+}
+
+// HasStringParam is true, if f has at least one string parameter.
+// Otherwise it is false.
+func (f *Fn) HasStringParam() bool {
+ for _, p := range f.Params {
+ if p.Type == "string" {
+ return true
+ }
+ }
+ return false
+}
+
+var uniqDllFuncName = make(map[string]bool)
+
+// IsNotDuplicate is true if f is not a duplicated function
+func (f *Fn) IsNotDuplicate() bool {
+ funcName := f.DLLFuncName()
+ if uniqDllFuncName[funcName] == false {
+ uniqDllFuncName[funcName] = true
+ return true
+ }
+ return false
+}
+
+// HelperName returns name of function f helper.
+func (f *Fn) HelperName() string {
+ if !f.HasStringParam() {
+ return f.Name
+ }
+ return "_" + f.Name
+}
+
+// Source files and functions.
+type Source struct {
+ Funcs []*Fn
+ Files []string
+ StdLibImports []string
+ ExternalImports []string
+}
+
+func (src *Source) Import(pkg string) {
+ src.StdLibImports = append(src.StdLibImports, pkg)
+ sort.Strings(src.StdLibImports)
+}
+
+func (src *Source) ExternalImport(pkg string) {
+ src.ExternalImports = append(src.ExternalImports, pkg)
+ sort.Strings(src.ExternalImports)
+}
+
+// ParseFiles parses files listed in fs and extracts all syscall
+// functions listed in sys comments. It returns source files
+// and functions collection *Source if successful.
+func ParseFiles(fs []string) (*Source, error) {
+ src := &Source{
+ Funcs: make([]*Fn, 0),
+ Files: make([]string, 0),
+ StdLibImports: []string{
+ "unsafe",
+ },
+ ExternalImports: make([]string, 0),
+ }
+ for _, file := range fs {
+ if err := src.ParseFile(file); err != nil {
+ return nil, err
+ }
+ }
+ return src, nil
+}
+
+// DLLs return dll names for a source set src.
+func (src *Source) DLLs() []string {
+ uniq := make(map[string]bool)
+ r := make([]string, 0)
+ for _, f := range src.Funcs {
+ name := f.DLLName()
+ if _, found := uniq[name]; !found {
+ uniq[name] = true
+ r = append(r, name)
+ }
+ }
+ return r
+}
+
+// ParseFile adds additional file path to a source set src.
+func (src *Source) ParseFile(path string) error {
+ file, err := os.Open(path)
+ if err != nil {
+ return err
+ }
+ defer file.Close()
+
+ s := bufio.NewScanner(file)
+ for s.Scan() {
+ t := trim(s.Text())
+ if len(t) < 7 {
+ continue
+ }
+ if !strings.HasPrefix(t, "//sys") {
+ continue
+ }
+ t = t[5:]
+ if !(t[0] == ' ' || t[0] == '\t') {
+ continue
+ }
+ f, err := newFn(t[1:])
+ if err != nil {
+ return err
+ }
+ src.Funcs = append(src.Funcs, f)
+ }
+ if err := s.Err(); err != nil {
+ return err
+ }
+ src.Files = append(src.Files, path)
+
+ // get package name
+ fset := token.NewFileSet()
+ _, err = file.Seek(0, 0)
+ if err != nil {
+ return err
+ }
+ pkg, err := parser.ParseFile(fset, "", file, parser.PackageClauseOnly)
+ if err != nil {
+ return err
+ }
+ packageName = pkg.Name.Name
+
+ return nil
+}
+
+// IsStdRepo returns true if src is part of standard library.
+func (src *Source) IsStdRepo() (bool, error) {
+ if len(src.Files) == 0 {
+ return false, errors.New("no input files provided")
+ }
+ abspath, err := filepath.Abs(src.Files[0])
+ if err != nil {
+ return false, err
+ }
+ goroot := runtime.GOROOT()
+ if runtime.GOOS == "windows" {
+ abspath = strings.ToLower(abspath)
+ goroot = strings.ToLower(goroot)
+ }
+ sep := string(os.PathSeparator)
+ if !strings.HasSuffix(goroot, sep) {
+ goroot += sep
+ }
+ return strings.HasPrefix(abspath, goroot), nil
+}
+
+// Generate output source file from a source set src.
+func (src *Source) Generate(w io.Writer) error {
+ const (
+ pkgStd = iota // any package in std library
+ pkgXSysWindows // x/sys/windows package
+ pkgOther
+ )
+ isStdRepo, err := src.IsStdRepo()
+ if err != nil {
+ return err
+ }
+ var pkgtype int
+ switch {
+ case isStdRepo:
+ pkgtype = pkgStd
+ case packageName == "windows":
+ // TODO: this needs better logic than just using package name
+ pkgtype = pkgXSysWindows
+ default:
+ pkgtype = pkgOther
+ }
+ if *systemDLL {
+ switch pkgtype {
+ case pkgStd:
+ src.Import("internal/syscall/windows/sysdll")
+ case pkgXSysWindows:
+ default:
+ src.ExternalImport("golang.org/x/sys/windows")
+ }
+ }
+ if *winio {
+ src.ExternalImport("github.com/Microsoft/go-winio")
+ }
+ if packageName != "syscall" {
+ src.Import("syscall")
+ }
+ funcMap := template.FuncMap{
+ "packagename": packagename,
+ "syscalldot": syscalldot,
+ "newlazydll": func(dll string) string {
+ arg := "\"" + dll + ".dll\""
+ if !*systemDLL {
+ return syscalldot() + "NewLazyDLL(" + arg + ")"
+ }
+ if strings.HasPrefix(dll, "api_") || strings.HasPrefix(dll, "ext_") {
+ arg = strings.Replace(arg, "_", "-", -1)
+ }
+ switch pkgtype {
+ case pkgStd:
+ return syscalldot() + "NewLazyDLL(sysdll.Add(" + arg + "))"
+ case pkgXSysWindows:
+ return "NewLazySystemDLL(" + arg + ")"
+ default:
+ return "windows.NewLazySystemDLL(" + arg + ")"
+ }
+ },
+ }
+ t := template.Must(template.New("main").Funcs(funcMap).Parse(srcTemplate))
+ err = t.Execute(w, src)
+ if err != nil {
+ return errors.New("Failed to execute template: " + err.Error())
+ }
+ return nil
+}
+
+func usage() {
+ fmt.Fprintf(os.Stderr, "usage: mksyscall_windows [flags] [path ...]\n")
+ flag.PrintDefaults()
+ os.Exit(1)
+}
+
+func main() {
+ flag.Usage = usage
+ flag.Parse()
+ if len(flag.Args()) <= 0 {
+ fmt.Fprintf(os.Stderr, "no files to parse provided\n")
+ usage()
+ }
+
+ src, err := ParseFiles(flag.Args())
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ var buf bytes.Buffer
+ if err := src.Generate(&buf); err != nil {
+ log.Fatal(err)
+ }
+
+ data, err := format.Source(buf.Bytes())
+ if err != nil {
+ log.Fatal(err)
+ }
+ if *filename == "" {
+ _, err = os.Stdout.Write(data)
+ } else {
+ err = ioutil.WriteFile(*filename, data, 0644)
+ }
+ if err != nil {
+ log.Fatal(err)
+ }
+}
+
+// TODO: use println instead to print in the following template
+const srcTemplate = `
+
+{{define "main"}}// Code generated mksyscall_windows.exe DO NOT EDIT
+
+package {{packagename}}
+
+import (
+{{range .StdLibImports}}"{{.}}"
+{{end}}
+
+{{range .ExternalImports}}"{{.}}"
+{{end}}
+)
+
+var _ unsafe.Pointer
+
+// Do the interface allocations only once for common
+// Errno values.
+const (
+ errnoERROR_IO_PENDING = 997
+)
+
+var (
+ errERROR_IO_PENDING error = {{syscalldot}}Errno(errnoERROR_IO_PENDING)
+)
+
+// errnoErr returns common boxed Errno values, to prevent
+// allocations at runtime.
+func errnoErr(e {{syscalldot}}Errno) error {
+ switch e {
+ case 0:
+ return nil
+ case errnoERROR_IO_PENDING:
+ return errERROR_IO_PENDING
+ }
+ // TODO: add more here, after collecting data on the common
+ // error values see on Windows. (perhaps when running
+ // all.bat?)
+ return e
+}
+
+var (
+{{template "dlls" .}}
+{{template "funcnames" .}})
+{{range .Funcs}}{{if .HasStringParam}}{{template "helperbody" .}}{{end}}{{template "funcbody" .}}{{end}}
+{{end}}
+
+{{/* help functions */}}
+
+{{define "dlls"}}{{range .DLLs}} mod{{.}} = {{newlazydll .}}
+{{end}}{{end}}
+
+{{define "funcnames"}}{{range .Funcs}}{{if .IsNotDuplicate}} proc{{.DLLFuncName}} = mod{{.DLLName}}.NewProc("{{.DLLFuncName}}"){{end}}
+{{end}}{{end}}
+
+{{define "helperbody"}}
+func {{.Name}}({{.ParamList}}) {{template "results" .}}{
+{{template "helpertmpvars" .}} return {{.HelperName}}({{.HelperCallParamList}})
+}
+{{end}}
+
+{{define "funcbody"}}
+func {{.HelperName}}({{.HelperParamList}}) {{template "results" .}}{
+{{template "tmpvars" .}} {{template "syscallcheck" .}}{{template "syscall" .}}
+{{template "seterror" .}}{{template "printtrace" .}} return
+}
+{{end}}
+
+{{define "helpertmpvars"}}{{range .Params}}{{if .TmpVarHelperCode}} {{.TmpVarHelperCode}}
+{{end}}{{end}}{{end}}
+
+{{define "tmpvars"}}{{range .Params}}{{if .TmpVarCode}} {{.TmpVarCode}}
+{{end}}{{end}}{{end}}
+
+{{define "results"}}{{if .Rets.List}}{{.Rets.List}} {{end}}{{end}}
+
+{{define "syscall"}}{{.Rets.SetReturnValuesCode}}{{.Syscall}}(proc{{.DLLFuncName}}.Addr(), {{.ParamCount}}, {{.SyscallParamList}}){{end}}
+
+{{define "syscallcheck"}}{{if .ConfirmProc}}if {{.Rets.ErrorVarName}} = proc{{.DLLFuncName}}.Find(); {{.Rets.ErrorVarName}} != nil {
+ return
+}
+{{end}}{{end}}
+
+
+{{define "seterror"}}{{if .Rets.SetErrorCode}} {{.Rets.SetErrorCode}}
+{{end}}{{end}}
+
+{{define "printtrace"}}{{if .PrintTrace}} print("SYSCALL: {{.Name}}(", {{.ParamPrintList}}") (", {{.Rets.PrintList}}")\n")
+{{end}}{{end}}
+
+`
diff --git a/vendor/github.com/Microsoft/hcsshim/vendor.conf b/vendor/github.com/Microsoft/hcsshim/vendor.conf
new file mode 100644
index 000000000..6e0ed1566
--- /dev/null
+++ b/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 \ No newline at end of file
diff --git a/vendor/github.com/Microsoft/hcsshim/zsyscall_windows.go b/vendor/github.com/Microsoft/hcsshim/zsyscall_windows.go
index d2dff9cb0..8bed84857 100644
--- a/vendor/github.com/Microsoft/hcsshim/zsyscall_windows.go
+++ b/vendor/github.com/Microsoft/hcsshim/zsyscall_windows.go
@@ -6,7 +6,6 @@ import (
"syscall"
"unsafe"
- "github.com/Microsoft/hcsshim/internal/interop"
"golang.org/x/sys/windows"
)
@@ -46,7 +45,10 @@ var (
func SetCurrentThreadCompartmentId(compartmentId uint32) (hr error) {
r0, _, _ := syscall.Syscall(procSetCurrentThreadCompartmentId.Addr(), 1, uintptr(compartmentId), 0, 0)
if int32(r0) < 0 {
- hr = interop.Win32FromHresult(r0)
+ if r0&0x1fff0000 == 0x00070000 {
+ r0 &= 0xffff
+ }
+ hr = syscall.Errno(r0)
}
return
}