summaryrefslogtreecommitdiff
path: root/vendor/github.com/Microsoft/hcsshim/internal
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2019-01-08 14:52:57 +0100
committerValentin Rothberg <rothberg@redhat.com>2019-01-11 13:38:11 +0100
commitbd40dcfc2bc7c9014ea1f33482fb63aacbcdfe87 (patch)
tree5f06e4e289f16d9164d692590a3fe6541b5384cf /vendor/github.com/Microsoft/hcsshim/internal
parent545f24421247c9f6251a634764db3f8f8070a812 (diff)
downloadpodman-bd40dcfc2bc7c9014ea1f33482fb63aacbcdfe87.tar.gz
podman-bd40dcfc2bc7c9014ea1f33482fb63aacbcdfe87.tar.bz2
podman-bd40dcfc2bc7c9014ea1f33482fb63aacbcdfe87.zip
vendor: update everything
* If possible, update each dependency to the latest available version. * Use releases over commit IDs and avoid vendoring branches. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'vendor/github.com/Microsoft/hcsshim/internal')
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/guestrequest/types.go85
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/guid/guid.go69
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/hcs/callback.go88
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/hcs/cgo.go7
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/hcs/errors.go284
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/hcs/hcs.go48
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/hcs/log.go15
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/hcs/process.go465
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/hcs/system.go667
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/hcs/utils.go33
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/hcs/waithelper.go63
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/hcs/watcher.go33
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/hcs/zsyscall_windows.go462
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/hcserror/hcserror.go51
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/hns/hns.go23
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/hns/hnsendpoint.go260
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/hns/hnsfuncs.go42
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/hns/hnsglobals.go28
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/hns/hnsnetwork.go141
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/hns/hnspolicy.go98
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/hns/hnspolicylist.go201
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/hns/hnssupport.go49
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/hns/namespace.go110
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/hns/zsyscall_windows.go74
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/interop/interop.go27
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/interop/zsyscall_windows.go48
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/logfields/fields.go37
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/longpath/longpath.go24
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/mergemaps/merge.go52
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/safefile/safeopen.go431
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/safefile/zsyscall_windows.go79
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema1/schema1.go245
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/attachment.go31
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/battery.go13
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/cache_query_stats_response.go19
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/chipset.go27
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/close_handle.go15
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/com_port.go18
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/compute_system.go27
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/configuration.go72
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/console_size.go17
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/container.go35
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/container_credential_guard_state.go25
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/container_memory_information.go26
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/device.go16
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/devices.go43
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/enhanced_mode_video.go15
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/flexible_io_device.go19
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/guest_connection.go19
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/guest_connection_info.go21
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/guest_crash_reporting.go15
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/guest_os.go15
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/guest_state.go22
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/hosted_system.go17
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/hv_socket.go17
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/hv_socket_2.go16
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/hv_socket_service_config.go22
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/hv_socket_system_config.go22
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/keyboard.go13
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/layer.go22
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/linux_kernel_direct.go18
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/mapped_directory.go21
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/mapped_pipe.go19
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/memory.go15
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/memory_2.go25
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/memory_information_for_vm.go19
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/memory_stats.go20
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/modify_setting_request.go20
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/mouse.go13
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/network_adapter.go17
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/networking.go24
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/pause_notification.go16
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/pause_options.go18
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/plan9.go15
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/plan9_share.go26
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/process_details.go34
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/process_modify_request.go20
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/process_parameters.go47
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/process_status.go22
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/processor.go19
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/processor_2.go21
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/processor_stats.go20
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/properties.go47
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/property_query.go16
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/rdp_connection_options.go17
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/registry_changes.go17
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/registry_key.go19
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/registry_value.go31
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/restore_state.go19
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/save_options.go19
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/scsi.go16
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/shared_memory_configuration.go15
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/shared_memory_region.go23
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/shared_memory_region_info.go17
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/silo_properties.go18
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/statistics.go30
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/storage.go21
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/storage_qo_s.go17
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/storage_stats.go22
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/topology.go17
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/uefi.go21
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/uefi_boot_entry.go23
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/version.go17
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/video_monitor.go19
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/virtual_machine.go29
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/virtual_node_info.go21
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/virtual_p_mem_controller.go20
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/virtual_p_mem_device.go19
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/virtual_smb.go17
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/virtual_smb_share.go21
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/virtual_smb_share_options.go63
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/vm_memory.go27
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/schema2/windows_crash_reporting.go17
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/timeout/timeout.go70
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/wclayer/activatelayer.go25
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/wclayer/baselayer.go173
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/wclayer/createlayer.go23
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/wclayer/createscratchlayer.go31
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/wclayer/deactivatelayer.go22
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/wclayer/destroylayer.go23
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/wclayer/expandscratchsize.go22
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/wclayer/exportlayer.go68
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/wclayer/getlayermountpath.go49
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/wclayer/getsharedbaseimages.go26
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/wclayer/grantvmaccess.go24
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/wclayer/importlayer.go127
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/wclayer/layerexists.go25
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/wclayer/layerid.go13
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/wclayer/layerutils.go96
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/wclayer/legacy.go815
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/wclayer/nametoguid.go24
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/wclayer/preparelayer.go40
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/wclayer/processimage.go23
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/wclayer/unpreparelayer.go23
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/wclayer/wclayer.go27
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/wclayer/zsyscall_windows.go457
136 files changed, 8368 insertions, 0 deletions
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/guestrequest/types.go b/vendor/github.com/Microsoft/hcsshim/internal/guestrequest/types.go
new file mode 100644
index 000000000..9f926c6be
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/guestrequest/types.go
@@ -0,0 +1,85 @@
+package guestrequest
+
+import "github.com/Microsoft/hcsshim/internal/schema2"
+
+// Arguably, many of these (at least CombinedLayers) should have been generated
+// by swagger.
+//
+// This will also change package name due to an inbound breaking change.
+
+// This class is used by a modify request to add or remove a combined layers
+// structure in the guest. For windows, the GCS applies a filter in ContainerRootPath
+// using the specified layers as the parent content. Ignores property ScratchPath
+// since the container path is already the scratch path. For linux, the GCS unions
+// the specified layers and ScratchPath together, placing the resulting union
+// filesystem at ContainerRootPath.
+type CombinedLayers struct {
+ ContainerRootPath string `json:"ContainerRootPath,omitempty"`
+ Layers []hcsschema.Layer `json:"Layers,omitempty"`
+ ScratchPath string `json:"ScratchPath,omitempty"`
+}
+
+// Defines the schema for hosted settings passed to GCS and/or OpenGCS
+
+// SCSI. Scratch space for remote file-system commands, or R/W layer for containers
+type LCOWMappedVirtualDisk struct {
+ MountPath string `json:"MountPath,omitempty"` // /tmp/scratch for an LCOW utility VM being used as a service VM
+ Lun uint8 `json:"Lun,omitempty"`
+ Controller uint8 `json:"Controller,omitempty"`
+ ReadOnly bool `json:"ReadOnly,omitempty"`
+}
+
+type WCOWMappedVirtualDisk struct {
+ ContainerPath string `json:"ContainerPath,omitempty"`
+ Lun int32 `json:"Lun,omitempty"`
+}
+
+type LCOWMappedDirectory struct {
+ MountPath string `json:"MountPath,omitempty"`
+ Port int32 `json:"Port,omitempty"`
+ ShareName string `json:"ShareName,omitempty"` // If empty not using ANames (not currently supported)
+ ReadOnly bool `json:"ReadOnly,omitempty"`
+}
+
+// Read-only layers over VPMem
+type LCOWMappedVPMemDevice struct {
+ DeviceNumber uint32 `json:"DeviceNumber,omitempty"`
+ MountPath string `json:"MountPath,omitempty"` // /tmp/pN
+}
+
+type ResourceType string
+
+const (
+ // These are constants for v2 schema modify guest requests.
+ ResourceTypeMappedDirectory ResourceType = "MappedDirectory"
+ ResourceTypeMappedVirtualDisk ResourceType = "MappedVirtualDisk"
+ ResourceTypeNetwork ResourceType = "Network"
+ ResourceTypeNetworkNamespace ResourceType = "NetworkNamespace"
+ ResourceTypeCombinedLayers ResourceType = "CombinedLayers"
+ ResourceTypeVPMemDevice ResourceType = "VPMemDevice"
+)
+
+// GuestRequest is for modify commands passed to the guest.
+type GuestRequest struct {
+ RequestType string `json:"RequestType,omitempty"`
+ ResourceType ResourceType `json:"ResourceType,omitempty"`
+ Settings interface{} `json:"Settings,omitempty"`
+}
+
+type NetworkModifyRequest struct {
+ AdapterId string `json:"AdapterId,omitempty"`
+ RequestType string `json:"RequestType,omitempty"`
+ Settings interface{} `json:"Settings,omitempty"`
+}
+
+type RS4NetworkModifyRequest struct {
+ AdapterInstanceId string `json:"AdapterInstanceId,omitempty"`
+ RequestType string `json:"RequestType,omitempty"`
+ Settings interface{} `json:"Settings,omitempty"`
+}
+
+// SignalProcessOptions is the options passed to either WCOW or LCOW
+// to signal a given process.
+type SignalProcessOptions struct {
+ Signal int `json:,omitempty`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/guid/guid.go b/vendor/github.com/Microsoft/hcsshim/internal/guid/guid.go
new file mode 100644
index 000000000..e9e45c030
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/guid/guid.go
@@ -0,0 +1,69 @@
+package guid
+
+import (
+ "crypto/rand"
+ "encoding/json"
+ "fmt"
+ "io"
+ "strconv"
+ "strings"
+)
+
+var _ = (json.Marshaler)(&GUID{})
+var _ = (json.Unmarshaler)(&GUID{})
+
+type GUID [16]byte
+
+func New() GUID {
+ g := GUID{}
+ _, err := io.ReadFull(rand.Reader, g[:])
+ if err != nil {
+ panic(err)
+ }
+ return g
+}
+
+func (g GUID) String() string {
+ return fmt.Sprintf("%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x-%02x", g[3], g[2], g[1], g[0], g[5], g[4], g[7], g[6], g[8:10], g[10:])
+}
+
+func FromString(s string) GUID {
+ if len(s) != 36 {
+ panic(fmt.Sprintf("invalid GUID length: %d", len(s)))
+ }
+ if s[8] != '-' || s[13] != '-' || s[18] != '-' || s[23] != '-' {
+ panic("invalid GUID format")
+ }
+ indexOrder := [16]int{
+ 0, 2, 4, 6,
+ 9, 11,
+ 14, 16,
+ 19, 21,
+ 24, 26, 28, 30, 32, 34,
+ }
+ byteOrder := [16]int{
+ 3, 2, 1, 0,
+ 5, 4,
+ 7, 6,
+ 8, 9,
+ 10, 11, 12, 13, 14, 15,
+ }
+ var g GUID
+ for i, x := range indexOrder {
+ b, err := strconv.ParseInt(s[x:x+2], 16, 16)
+ if err != nil {
+ panic(err)
+ }
+ g[byteOrder[i]] = byte(b)
+ }
+ return g
+}
+
+func (g GUID) MarshalJSON() ([]byte, error) {
+ return json.Marshal(g.String())
+}
+
+func (g *GUID) UnmarshalJSON(data []byte) error {
+ *g = FromString(strings.Trim(string(data), "\""))
+ return nil
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/hcs/callback.go b/vendor/github.com/Microsoft/hcsshim/internal/hcs/callback.go
new file mode 100644
index 000000000..5119c2555
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/hcs/callback.go
@@ -0,0 +1,88 @@
+package hcs
+
+import (
+ "sync"
+ "syscall"
+
+ "github.com/Microsoft/hcsshim/internal/interop"
+ "github.com/sirupsen/logrus"
+)
+
+var (
+ nextCallback uintptr
+ callbackMap = map[uintptr]*notifcationWatcherContext{}
+ callbackMapLock = sync.RWMutex{}
+
+ notificationWatcherCallback = syscall.NewCallback(notificationWatcher)
+
+ // Notifications for HCS_SYSTEM handles
+ hcsNotificationSystemExited hcsNotification = 0x00000001
+ hcsNotificationSystemCreateCompleted hcsNotification = 0x00000002
+ hcsNotificationSystemStartCompleted hcsNotification = 0x00000003
+ hcsNotificationSystemPauseCompleted hcsNotification = 0x00000004
+ hcsNotificationSystemResumeCompleted hcsNotification = 0x00000005
+
+ // Notifications for HCS_PROCESS handles
+ hcsNotificationProcessExited hcsNotification = 0x00010000
+
+ // Common notifications
+ hcsNotificationInvalid hcsNotification = 0x00000000
+ hcsNotificationServiceDisconnect hcsNotification = 0x01000000
+)
+
+type hcsNotification uint32
+type notificationChannel chan error
+
+type notifcationWatcherContext struct {
+ channels notificationChannels
+ handle hcsCallback
+}
+
+type notificationChannels map[hcsNotification]notificationChannel
+
+func newChannels() notificationChannels {
+ channels := make(notificationChannels)
+
+ channels[hcsNotificationSystemExited] = make(notificationChannel, 1)
+ channels[hcsNotificationSystemCreateCompleted] = make(notificationChannel, 1)
+ channels[hcsNotificationSystemStartCompleted] = make(notificationChannel, 1)
+ channels[hcsNotificationSystemPauseCompleted] = make(notificationChannel, 1)
+ channels[hcsNotificationSystemResumeCompleted] = make(notificationChannel, 1)
+ channels[hcsNotificationProcessExited] = make(notificationChannel, 1)
+ channels[hcsNotificationServiceDisconnect] = 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])
+}
+
+func notificationWatcher(notificationType hcsNotification, callbackNumber uintptr, notificationStatus uintptr, notificationData *uint16) uintptr {
+ var result error
+ if int32(notificationStatus) < 0 {
+ result = interop.Win32FromHresult(notificationStatus)
+ }
+
+ callbackMapLock.RLock()
+ context := callbackMap[callbackNumber]
+ callbackMapLock.RUnlock()
+
+ if context == nil {
+ return 0
+ }
+
+ if channel, ok := context.channels[notificationType]; ok {
+ channel <- result
+ } else {
+ logrus.WithFields(logrus.Fields{
+ "notification-type": notificationType,
+ }).Warn("Received a callback of an unsupported type")
+ }
+
+ return 0
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/hcs/cgo.go b/vendor/github.com/Microsoft/hcsshim/internal/hcs/cgo.go
new file mode 100644
index 000000000..3669c34aa
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/hcs/cgo.go
@@ -0,0 +1,7 @@
+package hcs
+
+import "C"
+
+// This import is needed to make the library compile as CGO because HCSSHIM
+// only works with CGO due to callbacks from HCS comming back from a C thread
+// which is not supported without CGO. See https://github.com/golang/go/issues/10973
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/hcs/errors.go b/vendor/github.com/Microsoft/hcsshim/internal/hcs/errors.go
new file mode 100644
index 000000000..6368b5717
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/hcs/errors.go
@@ -0,0 +1,284 @@
+package hcs
+
+import (
+ "encoding/json"
+ "errors"
+ "fmt"
+ "syscall"
+
+ "github.com/Microsoft/hcsshim/internal/interop"
+ "github.com/Microsoft/hcsshim/internal/logfields"
+ "github.com/sirupsen/logrus"
+)
+
+var (
+ // ErrComputeSystemDoesNotExist is an error encountered when the container being operated on no longer exists
+ ErrComputeSystemDoesNotExist = syscall.Errno(0xc037010e)
+
+ // ErrElementNotFound is an error encountered when the object being referenced does not exist
+ ErrElementNotFound = syscall.Errno(0x490)
+
+ // ErrElementNotFound is an error encountered when the object being referenced does not exist
+ ErrNotSupported = syscall.Errno(0x32)
+
+ // ErrInvalidData is an error encountered when the request being sent to hcs is invalid/unsupported
+ // decimal -2147024883 / hex 0x8007000d
+ ErrInvalidData = syscall.Errno(0xd)
+
+ // ErrHandleClose is an error encountered when the handle generating the notification being waited on has been closed
+ ErrHandleClose = errors.New("hcsshim: the handle generating this notification has been closed")
+
+ // ErrAlreadyClosed is an error encountered when using a handle that has been closed by the Close method
+ ErrAlreadyClosed = errors.New("hcsshim: the handle has already been closed")
+
+ // ErrInvalidNotificationType is an error encountered when an invalid notification type is used
+ ErrInvalidNotificationType = errors.New("hcsshim: invalid notification type")
+
+ // ErrInvalidProcessState is an error encountered when the process is not in a valid state for the requested operation
+ ErrInvalidProcessState = errors.New("the process is in an invalid state for the attempted operation")
+
+ // ErrTimeout is an error encountered when waiting on a notification times out
+ ErrTimeout = errors.New("hcsshim: timeout waiting for notification")
+
+ // ErrUnexpectedContainerExit is the error encountered when a container exits while waiting for
+ // a different expected notification
+ ErrUnexpectedContainerExit = errors.New("unexpected container exit")
+
+ // ErrUnexpectedProcessAbort is the error encountered when communication with the compute service
+ // is lost while waiting for a notification
+ ErrUnexpectedProcessAbort = errors.New("lost communication with compute service")
+
+ // ErrUnexpectedValue is an error encountered when hcs returns an invalid value
+ ErrUnexpectedValue = errors.New("unexpected value returned from hcs")
+
+ // ErrVmcomputeAlreadyStopped is an error encountered when a shutdown or terminate request is made on a stopped container
+ ErrVmcomputeAlreadyStopped = syscall.Errno(0xc0370110)
+
+ // ErrVmcomputeOperationPending is an error encountered when the operation is being completed asynchronously
+ ErrVmcomputeOperationPending = syscall.Errno(0xC0370103)
+
+ // ErrVmcomputeOperationInvalidState is an error encountered when the compute system is not in a valid state for the requested operation
+ ErrVmcomputeOperationInvalidState = syscall.Errno(0xc0370105)
+
+ // ErrProcNotFound is an error encountered when the the process cannot be found
+ ErrProcNotFound = syscall.Errno(0x7f)
+
+ // ErrVmcomputeOperationAccessIsDenied is an error which can be encountered when enumerating compute systems in RS1/RS2
+ // builds when the underlying silo might be in the process of terminating. HCS was fixed in RS3.
+ ErrVmcomputeOperationAccessIsDenied = syscall.Errno(0x5)
+
+ // ErrVmcomputeInvalidJSON is an error encountered when the compute system does not support/understand the messages sent by management
+ ErrVmcomputeInvalidJSON = syscall.Errno(0xc037010d)
+
+ // ErrVmcomputeUnknownMessage is an error encountered guest compute system doesn't support the message
+ ErrVmcomputeUnknownMessage = syscall.Errno(0xc037010b)
+
+ // ErrNotSupported is an error encountered when hcs doesn't support the request
+ ErrPlatformNotSupported = errors.New("unsupported platform request")
+)
+
+type ErrorEvent struct {
+ Message string `json:"Message,omitempty"` // Fully formated error message
+ StackTrace string `json:"StackTrace,omitempty"` // Stack trace in string form
+ Provider string `json:"Provider,omitempty"`
+ EventID uint16 `json:"EventId,omitempty"`
+ Flags uint32 `json:"Flags,omitempty"`
+ Source string `json:"Source,omitempty"`
+ //Data []EventData `json:"Data,omitempty"` // Omit this as HCS doesn't encode this well. It's more confusing to include. It is however logged in debug mode (see processHcsResult function)
+}
+
+type hcsResult struct {
+ Error int32
+ ErrorMessage string
+ ErrorEvents []ErrorEvent `json:"ErrorEvents,omitempty"`
+}
+
+func (ev *ErrorEvent) String() string {
+ evs := "[Event Detail: " + ev.Message
+ if ev.StackTrace != "" {
+ evs += " Stack Trace: " + ev.StackTrace
+ }
+ if ev.Provider != "" {
+ evs += " Provider: " + ev.Provider
+ }
+ if ev.EventID != 0 {
+ evs = fmt.Sprintf("%s EventID: %d", evs, ev.EventID)
+ }
+ if ev.Flags != 0 {
+ evs = fmt.Sprintf("%s flags: %d", evs, ev.Flags)
+ }
+ if ev.Source != "" {
+ evs += " Source: " + ev.Source
+ }
+ evs += "]"
+ return evs
+}
+
+func processHcsResult(resultp *uint16) []ErrorEvent {
+ if resultp != nil {
+ resultj := interop.ConvertAndFreeCoTaskMemString(resultp)
+ logrus.WithField(logfields.JSON, resultj).
+ Debug("HCS Result")
+ result := &hcsResult{}
+ if err := json.Unmarshal([]byte(resultj), result); err != nil {
+ logrus.WithFields(logrus.Fields{
+ logfields.JSON: resultj,
+ logrus.ErrorKey: err,
+ }).Warning("Could not unmarshal HCS result")
+ return nil
+ }
+ return result.ErrorEvents
+ }
+ return nil
+}
+
+type HcsError struct {
+ Op string
+ Err error
+ Events []ErrorEvent
+}
+
+func (e *HcsError) Error() string {
+ s := e.Op + ": " + e.Err.Error()
+ for _, ev := range e.Events {
+ s += "\n" + ev.String()
+ }
+ return s
+}
+
+// ProcessError is an error encountered in HCS during an operation on a Process object
+type ProcessError struct {
+ SystemID string
+ Pid int
+ Op string
+ Err error
+ Events []ErrorEvent
+}
+
+// SystemError is an error encountered in HCS during an operation on a Container object
+type SystemError struct {
+ ID string
+ Op string
+ Err error
+ Extra string
+ Events []ErrorEvent
+}
+
+func (e *SystemError) Error() string {
+ s := e.Op + " " + e.ID + ": " + e.Err.Error()
+ for _, ev := range e.Events {
+ s += "\n" + ev.String()
+ }
+ if e.Extra != "" {
+ s += "\n(extra info: " + e.Extra + ")"
+ }
+ return s
+}
+
+func makeSystemError(system *System, op string, extra string, err error, events []ErrorEvent) error {
+ // Don't double wrap errors
+ if _, ok := err.(*SystemError); ok {
+ return err
+ }
+ return &SystemError{
+ ID: system.ID(),
+ Op: op,
+ Extra: extra,
+ Err: err,
+ Events: events,
+ }
+}
+
+func (e *ProcessError) Error() string {
+ s := fmt.Sprintf("%s %s:%d: %s", e.Op, e.SystemID, e.Pid, e.Err.Error())
+ for _, ev := range e.Events {
+ s += "\n" + ev.String()
+ }
+ return s
+}
+
+func makeProcessError(process *Process, op string, err error, events []ErrorEvent) error {
+ // Don't double wrap errors
+ if _, ok := err.(*ProcessError); ok {
+ return err
+ }
+ return &ProcessError{
+ Pid: process.Pid(),
+ SystemID: process.SystemID(),
+ Op: op,
+ Err: err,
+ Events: events,
+ }
+}
+
+// IsNotExist checks if an error is caused by the Container or Process not existing.
+// Note: Currently, ErrElementNotFound can mean that a Process has either
+// already exited, or does not exist. Both IsAlreadyStopped and IsNotExist
+// will currently return true when the error is ErrElementNotFound or ErrProcNotFound.
+func IsNotExist(err error) bool {
+ err = getInnerError(err)
+ return err == ErrComputeSystemDoesNotExist ||
+ err == ErrElementNotFound ||
+ err == ErrProcNotFound
+}
+
+// IsAlreadyClosed checks if an error is caused by the Container or Process having been
+// already closed by a call to the Close() method.
+func IsAlreadyClosed(err error) bool {
+ err = getInnerError(err)
+ return err == ErrAlreadyClosed
+}
+
+// IsPending returns a boolean indicating whether the error is that
+// the requested operation is being completed in the background.
+func IsPending(err error) bool {
+ err = getInnerError(err)
+ return err == ErrVmcomputeOperationPending
+}
+
+// IsTimeout returns a boolean indicating whether the error is caused by
+// a timeout waiting for the operation to complete.
+func IsTimeout(err error) bool {
+ err = getInnerError(err)
+ return err == ErrTimeout
+}
+
+// IsAlreadyStopped returns a boolean indicating whether the error is caused by
+// a Container or Process being already stopped.
+// Note: Currently, ErrElementNotFound can mean that a Process has either
+// already exited, or does not exist. Both IsAlreadyStopped and IsNotExist
+// will currently return true when the error is ErrElementNotFound or ErrProcNotFound.
+func IsAlreadyStopped(err error) bool {
+ err = getInnerError(err)
+ return err == ErrVmcomputeAlreadyStopped ||
+ err == ErrElementNotFound ||
+ err == ErrProcNotFound
+}
+
+// IsNotSupported returns a boolean indicating whether the error is caused by
+// unsupported platform requests
+// Note: Currently Unsupported platform requests can be mean either
+// ErrVmcomputeInvalidJSON, ErrInvalidData, ErrNotSupported or ErrVmcomputeUnknownMessage
+// is thrown from the Platform
+func IsNotSupported(err error) bool {
+ err = getInnerError(err)
+ // If Platform doesn't recognize or support the request sent, below errors are seen
+ return err == ErrVmcomputeInvalidJSON ||
+ err == ErrInvalidData ||
+ err == ErrNotSupported ||
+ err == ErrVmcomputeUnknownMessage
+}
+
+func getInnerError(err error) error {
+ switch pe := err.(type) {
+ case nil:
+ return nil
+ case *HcsError:
+ err = pe.Err
+ case *SystemError:
+ err = pe.Err
+ case *ProcessError:
+ err = pe.Err
+ }
+ return err
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/hcs/hcs.go b/vendor/github.com/Microsoft/hcsshim/internal/hcs/hcs.go
new file mode 100644
index 000000000..b0d49cbcf
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/hcs/hcs.go
@@ -0,0 +1,48 @@
+// Shim for the Host Compute Service (HCS) to manage Windows Server
+// containers and Hyper-V containers.
+
+package hcs
+
+import (
+ "syscall"
+)
+
+//go:generate go run ../../mksyscall_windows.go -output zsyscall_windows.go hcs.go
+
+//sys hcsEnumerateComputeSystems(query string, computeSystems **uint16, result **uint16) (hr error) = vmcompute.HcsEnumerateComputeSystems?
+//sys hcsCreateComputeSystem(id string, configuration string, identity syscall.Handle, computeSystem *hcsSystem, result **uint16) (hr error) = vmcompute.HcsCreateComputeSystem?
+//sys hcsOpenComputeSystem(id string, computeSystem *hcsSystem, result **uint16) (hr error) = vmcompute.HcsOpenComputeSystem?
+//sys hcsCloseComputeSystem(computeSystem hcsSystem) (hr error) = vmcompute.HcsCloseComputeSystem?
+//sys hcsStartComputeSystem(computeSystem hcsSystem, options string, result **uint16) (hr error) = vmcompute.HcsStartComputeSystem?
+//sys hcsShutdownComputeSystem(computeSystem hcsSystem, options string, result **uint16) (hr error) = vmcompute.HcsShutdownComputeSystem?
+//sys hcsTerminateComputeSystem(computeSystem hcsSystem, options string, result **uint16) (hr error) = vmcompute.HcsTerminateComputeSystem?
+//sys hcsPauseComputeSystem(computeSystem hcsSystem, options string, result **uint16) (hr error) = vmcompute.HcsPauseComputeSystem?
+//sys hcsResumeComputeSystem(computeSystem hcsSystem, options string, result **uint16) (hr error) = vmcompute.HcsResumeComputeSystem?
+//sys hcsGetComputeSystemProperties(computeSystem hcsSystem, propertyQuery string, properties **uint16, result **uint16) (hr error) = vmcompute.HcsGetComputeSystemProperties?
+//sys hcsModifyComputeSystem(computeSystem hcsSystem, configuration string, result **uint16) (hr error) = vmcompute.HcsModifyComputeSystem?
+//sys hcsRegisterComputeSystemCallback(computeSystem hcsSystem, callback uintptr, context uintptr, callbackHandle *hcsCallback) (hr error) = vmcompute.HcsRegisterComputeSystemCallback?
+//sys hcsUnregisterComputeSystemCallback(callbackHandle hcsCallback) (hr error) = vmcompute.HcsUnregisterComputeSystemCallback?
+
+//sys hcsCreateProcess(computeSystem hcsSystem, processParameters string, processInformation *hcsProcessInformation, process *hcsProcess, result **uint16) (hr error) = vmcompute.HcsCreateProcess?
+//sys hcsOpenProcess(computeSystem hcsSystem, pid uint32, process *hcsProcess, result **uint16) (hr error) = vmcompute.HcsOpenProcess?
+//sys hcsCloseProcess(process hcsProcess) (hr error) = vmcompute.HcsCloseProcess?
+//sys hcsTerminateProcess(process hcsProcess, result **uint16) (hr error) = vmcompute.HcsTerminateProcess?
+//sys hcsSignalProcess(process hcsProcess, options string, result **uint16) (hr error) = vmcompute.HcsTerminateProcess?
+//sys hcsGetProcessInfo(process hcsProcess, processInformation *hcsProcessInformation, result **uint16) (hr error) = vmcompute.HcsGetProcessInfo?
+//sys hcsGetProcessProperties(process hcsProcess, processProperties **uint16, result **uint16) (hr error) = vmcompute.HcsGetProcessProperties?
+//sys hcsModifyProcess(process hcsProcess, settings string, result **uint16) (hr error) = vmcompute.HcsModifyProcess?
+//sys hcsGetServiceProperties(propertyQuery string, properties **uint16, result **uint16) (hr error) = vmcompute.HcsGetServiceProperties?
+//sys hcsRegisterProcessCallback(process hcsProcess, callback uintptr, context uintptr, callbackHandle *hcsCallback) (hr error) = vmcompute.HcsRegisterProcessCallback?
+//sys hcsUnregisterProcessCallback(callbackHandle hcsCallback) (hr error) = vmcompute.HcsUnregisterProcessCallback?
+
+type hcsSystem syscall.Handle
+type hcsProcess syscall.Handle
+type hcsCallback syscall.Handle
+
+type hcsProcessInformation struct {
+ ProcessId uint32
+ Reserved uint32
+ StdInput syscall.Handle
+ StdOutput syscall.Handle
+ StdError syscall.Handle
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/hcs/log.go b/vendor/github.com/Microsoft/hcsshim/internal/hcs/log.go
new file mode 100644
index 000000000..90d164e35
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/hcs/log.go
@@ -0,0 +1,15 @@
+package hcs
+
+import "github.com/sirupsen/logrus"
+
+func logOperationBegin(ctx logrus.Fields, msg string) {
+ logrus.WithFields(ctx).Debug(msg)
+}
+
+func logOperationEnd(ctx logrus.Fields, msg string, err error) {
+ if err == nil {
+ logrus.WithFields(ctx).Debug(msg)
+ } else {
+ logrus.WithFields(ctx).WithError(err).Error(msg)
+ }
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/hcs/process.go b/vendor/github.com/Microsoft/hcsshim/internal/hcs/process.go
new file mode 100644
index 000000000..42598cf2f
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/hcs/process.go
@@ -0,0 +1,465 @@
+package hcs
+
+import (
+ "encoding/json"
+ "io"
+ "sync"
+ "syscall"
+ "time"
+
+ "github.com/Microsoft/hcsshim/internal/guestrequest"
+ "github.com/Microsoft/hcsshim/internal/interop"
+ "github.com/Microsoft/hcsshim/internal/logfields"
+ "github.com/sirupsen/logrus"
+)
+
+// ContainerError is an error encountered in HCS
+type Process struct {
+ handleLock sync.RWMutex
+ handle hcsProcess
+ processID int
+ system *System
+ cachedPipes *cachedPipes
+ callbackNumber uintptr
+
+ logctx logrus.Fields
+}
+
+func newProcess(process hcsProcess, processID int, computeSystem *System) *Process {
+ return &Process{
+ handle: process,
+ processID: processID,
+ system: computeSystem,
+ logctx: logrus.Fields{
+ logfields.HCSOperation: "",
+ logfields.ContainerID: computeSystem.ID(),
+ logfields.ProcessID: processID,
+ },
+ }
+}
+
+type cachedPipes struct {
+ stdIn syscall.Handle
+ stdOut syscall.Handle
+ stdErr syscall.Handle
+}
+
+type processModifyRequest struct {
+ Operation string
+ ConsoleSize *consoleSize `json:",omitempty"`
+ CloseHandle *closeHandle `json:",omitempty"`
+}
+
+type consoleSize struct {
+ Height uint16
+ Width uint16
+}
+
+type closeHandle struct {
+ Handle string
+}
+
+type ProcessStatus struct {
+ ProcessID uint32
+ Exited bool
+ ExitCode uint32
+ LastWaitResult int32
+}
+
+const (
+ stdIn string = "StdIn"
+ stdOut string = "StdOut"
+ stdErr string = "StdErr"
+)
+
+const (
+ modifyConsoleSize string = "ConsoleSize"
+ modifyCloseHandle string = "CloseHandle"
+)
+
+// Pid returns the process ID of the process within the container.
+func (process *Process) Pid() int {
+ return process.processID
+}
+
+// SystemID returns the ID of the process's compute system.
+func (process *Process) SystemID() string {
+ return process.system.ID()
+}
+
+func (process *Process) logOperationBegin(operation string) {
+ process.logctx[logfields.HCSOperation] = operation
+ logOperationBegin(
+ process.logctx,
+ "hcsshim::Process - Begin Operation")
+}
+
+func (process *Process) logOperationEnd(err error) {
+ var result string
+ if err == nil {
+ result = "Success"
+ } else {
+ result = "Error"
+ }
+
+ logOperationEnd(
+ process.logctx,
+ "hcsshim::Process - End Operation - "+result,
+ err)
+ process.logctx[logfields.HCSOperation] = ""
+}
+
+// Signal signals the process with `options`.
+func (process *Process) Signal(options guestrequest.SignalProcessOptions) (err error) {
+ process.handleLock.RLock()
+ defer process.handleLock.RUnlock()
+
+ operation := "hcsshim::Process::Signal"
+ process.logOperationBegin(operation)
+ defer process.logOperationEnd(err)
+
+ if process.handle == 0 {
+ return makeProcessError(process, operation, ErrAlreadyClosed, nil)
+ }
+
+ optionsb, err := json.Marshal(options)
+ if err != nil {
+ return err
+ }
+
+ optionsStr := string(optionsb)
+
+ var resultp *uint16
+ completed := false
+ go syscallWatcher(process.logctx, &completed)
+ err = hcsSignalProcess(process.handle, optionsStr, &resultp)
+ completed = true
+ events := processHcsResult(resultp)
+ if err != nil {
+ return makeProcessError(process, operation, err, events)
+ }
+
+ return nil
+}
+
+// Kill signals the process to terminate but does not wait for it to finish terminating.
+func (process *Process) Kill() (err error) {
+ process.handleLock.RLock()
+ defer process.handleLock.RUnlock()
+
+ operation := "hcsshim::Process::Kill"
+ process.logOperationBegin(operation)
+ defer process.logOperationEnd(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
+ events := processHcsResult(resultp)
+ if err != nil {
+ return makeProcessError(process, operation, err, events)
+ }
+
+ return nil
+}
+
+// Wait waits for the process to exit.
+func (process *Process) Wait() (err error) {
+ operation := "hcsshim::Process::Wait"
+ process.logOperationBegin(operation)
+ defer process.logOperationEnd(err)
+
+ err = waitForNotification(process.callbackNumber, hcsNotificationProcessExited, nil)
+ if err != nil {
+ return makeProcessError(process, operation, err, nil)
+ }
+
+ return nil
+}
+
+// WaitTimeout waits for the process to exit or the duration to elapse. It returns
+// false if timeout occurs.
+func (process *Process) WaitTimeout(timeout time.Duration) (err error) {
+ operation := "hcssshim::Process::WaitTimeout"
+ process.logOperationBegin(operation)
+ defer process.logOperationEnd(err)
+
+ err = waitForNotification(process.callbackNumber, hcsNotificationProcessExited, &timeout)
+ if err != nil {
+ return makeProcessError(process, operation, err, nil)
+ }
+
+ return nil
+}
+
+// ResizeConsole resizes the console of the process.
+func (process *Process) ResizeConsole(width, height uint16) (err error) {
+ process.handleLock.RLock()
+ defer process.handleLock.RUnlock()
+
+ operation := "hcsshim::Process::ResizeConsole"
+ process.logOperationBegin(operation)
+ defer process.logOperationEnd(err)
+
+ if process.handle == 0 {
+ return makeProcessError(process, operation, ErrAlreadyClosed, nil)
+ }
+
+ modifyRequest := processModifyRequest{
+ Operation: modifyConsoleSize,
+ ConsoleSize: &consoleSize{
+ Height: height,
+ Width: width,
+ },
+ }
+
+ modifyRequestb, err := json.Marshal(modifyRequest)
+ if err != nil {
+ return err
+ }
+
+ modifyRequestStr := string(modifyRequestb)
+
+ var resultp *uint16
+ err = hcsModifyProcess(process.handle, modifyRequestStr, &resultp)
+ events := processHcsResult(resultp)
+ if err != nil {
+ return makeProcessError(process, operation, err, events)
+ }
+
+ return nil
+}
+
+func (process *Process) Properties() (_ *ProcessStatus, err error) {
+ process.handleLock.RLock()
+ defer process.handleLock.RUnlock()
+
+ operation := "hcsshim::Process::Properties"
+ process.logOperationBegin(operation)
+ defer process.logOperationEnd(err)
+
+ if process.handle == 0 {
+ return nil, makeProcessError(process, operation, ErrAlreadyClosed, nil)
+ }
+
+ var (
+ resultp *uint16
+ propertiesp *uint16
+ )
+ completed := false
+ go syscallWatcher(process.logctx, &completed)
+ err = hcsGetProcessProperties(process.handle, &propertiesp, &resultp)
+ completed = true
+ events := processHcsResult(resultp)
+ if err != nil {
+ return nil, makeProcessError(process, operation, err, events)
+ }
+
+ if propertiesp == nil {
+ return nil, ErrUnexpectedValue
+ }
+ propertiesRaw := interop.ConvertAndFreeCoTaskMemBytes(propertiesp)
+
+ properties := &ProcessStatus{}
+ if err := json.Unmarshal(propertiesRaw, properties); err != nil {
+ return nil, makeProcessError(process, operation, err, nil)
+ }
+
+ return properties, nil
+}
+
+// ExitCode returns the exit code of the process. The process must have
+// already terminated.
+func (process *Process) ExitCode() (_ int, err error) {
+ operation := "hcsshim::Process::ExitCode"
+ process.logOperationBegin(operation)
+ defer process.logOperationEnd(err)
+
+ properties, err := process.Properties()
+ if err != nil {
+ return 0, makeProcessError(process, operation, err, nil)
+ }
+
+ if properties.Exited == false {
+ return 0, makeProcessError(process, operation, ErrInvalidProcessState, nil)
+ }
+
+ if properties.LastWaitResult != 0 {
+ return 0, makeProcessError(process, operation, syscall.Errno(properties.LastWaitResult), nil)
+ }
+
+ return int(properties.ExitCode), nil
+}
+
+// Stdio returns the stdin, stdout, and stderr pipes, respectively. Closing
+// these pipes does not close the underlying pipes; it should be possible to
+// call this multiple times to get multiple interfaces.
+func (process *Process) Stdio() (_ io.WriteCloser, _ io.ReadCloser, _ io.ReadCloser, err error) {
+ process.handleLock.RLock()
+ defer process.handleLock.RUnlock()
+
+ operation := "hcsshim::Process::Stdio"
+ process.logOperationBegin(operation)
+ defer process.logOperationEnd(err)
+
+ if process.handle == 0 {
+ return nil, nil, nil, makeProcessError(process, operation, ErrAlreadyClosed, nil)
+ }
+
+ var stdIn, stdOut, stdErr syscall.Handle
+
+ if process.cachedPipes == nil {
+ var (
+ processInfo hcsProcessInformation
+ resultp *uint16
+ )
+ err = hcsGetProcessInfo(process.handle, &processInfo, &resultp)
+ events := processHcsResult(resultp)
+ if err != nil {
+ return nil, nil, nil, makeProcessError(process, operation, err, events)
+ }
+
+ stdIn, stdOut, stdErr = processInfo.StdInput, processInfo.StdOutput, processInfo.StdError
+ } else {
+ // Use cached pipes
+ stdIn, stdOut, stdErr = process.cachedPipes.stdIn, process.cachedPipes.stdOut, process.cachedPipes.stdErr
+
+ // Invalidate the cache
+ process.cachedPipes = nil
+ }
+
+ pipes, err := makeOpenFiles([]syscall.Handle{stdIn, stdOut, stdErr})
+ if err != nil {
+ return nil, nil, nil, makeProcessError(process, operation, err, nil)
+ }
+
+ return pipes[0], pipes[1], pipes[2], nil
+}
+
+// CloseStdin closes the write side of the stdin pipe so that the process is
+// notified on the read side that there is no more data in stdin.
+func (process *Process) CloseStdin() (err error) {
+ process.handleLock.RLock()
+ defer process.handleLock.RUnlock()
+
+ operation := "hcsshim::Process::CloseStdin"
+ process.logOperationBegin(operation)
+ defer process.logOperationEnd(err)
+
+ if process.handle == 0 {
+ return makeProcessError(process, operation, ErrAlreadyClosed, nil)
+ }
+
+ modifyRequest := processModifyRequest{
+ Operation: modifyCloseHandle,
+ CloseHandle: &closeHandle{
+ Handle: stdIn,
+ },
+ }
+
+ modifyRequestb, err := json.Marshal(modifyRequest)
+ if err != nil {
+ return err
+ }
+
+ modifyRequestStr := string(modifyRequestb)
+
+ var resultp *uint16
+ err = hcsModifyProcess(process.handle, modifyRequestStr, &resultp)
+ events := processHcsResult(resultp)
+ if err != nil {
+ return makeProcessError(process, operation, err, events)
+ }
+
+ return nil
+}
+
+// Close cleans up any state associated with the process but does not kill
+// or wait on it.
+func (process *Process) Close() (err error) {
+ process.handleLock.Lock()
+ defer process.handleLock.Unlock()
+
+ operation := "hcsshim::Process::Close"
+ process.logOperationBegin(operation)
+ defer process.logOperationEnd(err)
+
+ // Don't double free this
+ if process.handle == 0 {
+ return nil
+ }
+
+ if err = process.unregisterCallback(); err != nil {
+ return makeProcessError(process, operation, err, nil)
+ }
+
+ if err = hcsCloseProcess(process.handle); err != nil {
+ return makeProcessError(process, operation, err, nil)
+ }
+
+ process.handle = 0
+
+ return nil
+}
+
+func (process *Process) registerCallback() error {
+ context := &notifcationWatcherContext{
+ channels: newChannels(),
+ }
+
+ callbackMapLock.Lock()
+ callbackNumber := nextCallback
+ nextCallback++
+ callbackMap[callbackNumber] = context
+ callbackMapLock.Unlock()
+
+ var callbackHandle hcsCallback
+ err := hcsRegisterProcessCallback(process.handle, notificationWatcherCallback, callbackNumber, &callbackHandle)
+ if err != nil {
+ return err
+ }
+ context.handle = callbackHandle
+ process.callbackNumber = callbackNumber
+
+ return nil
+}
+
+func (process *Process) unregisterCallback() error {
+ callbackNumber := process.callbackNumber
+
+ callbackMapLock.RLock()
+ context := callbackMap[callbackNumber]
+ callbackMapLock.RUnlock()
+
+ if context == nil {
+ return nil
+ }
+
+ handle := context.handle
+
+ if handle == 0 {
+ return nil
+ }
+
+ // hcsUnregisterProcessCallback has its own syncronization
+ // to wait for all callbacks to complete. We must NOT hold the callbackMapLock.
+ err := hcsUnregisterProcessCallback(handle)
+ if err != nil {
+ return err
+ }
+
+ closeChannels(context.channels)
+
+ callbackMapLock.Lock()
+ callbackMap[callbackNumber] = nil
+ callbackMapLock.Unlock()
+
+ handle = 0
+
+ return nil
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/hcs/system.go b/vendor/github.com/Microsoft/hcsshim/internal/hcs/system.go
new file mode 100644
index 000000000..2629380fd
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/hcs/system.go
@@ -0,0 +1,667 @@
+package hcs
+
+import (
+ "encoding/json"
+ "os"
+ "strconv"
+ "sync"
+ "syscall"
+ "time"
+
+ "github.com/Microsoft/hcsshim/internal/interop"
+ "github.com/Microsoft/hcsshim/internal/logfields"
+ "github.com/Microsoft/hcsshim/internal/schema1"
+ "github.com/Microsoft/hcsshim/internal/timeout"
+ "github.com/sirupsen/logrus"
+)
+
+// currentContainerStarts is used to limit the number of concurrent container
+// starts.
+var currentContainerStarts containerStarts
+
+type containerStarts struct {
+ maxParallel int
+ inProgress int
+ sync.Mutex
+}
+
+func init() {
+ mpsS := os.Getenv("HCSSHIM_MAX_PARALLEL_START")
+ if len(mpsS) > 0 {
+ mpsI, err := strconv.Atoi(mpsS)
+ if err != nil || mpsI < 0 {
+ return
+ }
+ currentContainerStarts.maxParallel = mpsI
+ }
+}
+
+type System struct {
+ handleLock sync.RWMutex
+ handle hcsSystem
+ id string
+ callbackNumber uintptr
+
+ logctx logrus.Fields
+}
+
+func newSystem(id string) *System {
+ return &System{
+ id: id,
+ logctx: logrus.Fields{
+ logfields.HCSOperation: "",
+ logfields.ContainerID: id,
+ },
+ }
+}
+
+func (computeSystem *System) logOperationBegin(operation string) {
+ computeSystem.logctx[logfields.HCSOperation] = operation
+ logOperationBegin(
+ computeSystem.logctx,
+ "hcsshim::ComputeSystem - Begin Operation")
+}
+
+func (computeSystem *System) logOperationEnd(err error) {
+ var result string
+ if err == nil {
+ result = "Success"
+ } else {
+ result = "Error"
+ }
+
+ logOperationEnd(
+ computeSystem.logctx,
+ "hcsshim::ComputeSystem - End Operation - "+result,
+ err)
+ computeSystem.logctx[logfields.HCSOperation] = ""
+}
+
+// CreateComputeSystem creates a new compute system with the given configuration but does not start it.
+func CreateComputeSystem(id string, hcsDocumentInterface interface{}) (_ *System, err error) {
+ operation := "hcsshim::CreateComputeSystem"
+
+ computeSystem := newSystem(id)
+ computeSystem.logOperationBegin(operation)
+ defer computeSystem.logOperationEnd(err)
+
+ hcsDocumentB, err := json.Marshal(hcsDocumentInterface)
+ if err != nil {
+ return nil, err
+ }
+
+ hcsDocument := string(hcsDocumentB)
+
+ logrus.WithFields(computeSystem.logctx).
+ WithField(logfields.JSON, hcsDocument).
+ Debug("HCS ComputeSystem Document")
+
+ var (
+ resultp *uint16
+ identity syscall.Handle
+ )
+ completed := false
+ go syscallWatcher(computeSystem.logctx, &completed)
+ createError := hcsCreateComputeSystem(id, hcsDocument, identity, &computeSystem.handle, &resultp)
+ completed = true
+
+ if createError == nil || IsPending(createError) {
+ if err = computeSystem.registerCallback(); err != nil {
+ // Terminate the compute system if it still exists. We're okay to
+ // ignore a failure here.
+ computeSystem.Terminate()
+ return nil, makeSystemError(computeSystem, operation, "", err, nil)
+ }
+ }
+
+ events, err := processAsyncHcsResult(createError, resultp, computeSystem.callbackNumber, hcsNotificationSystemCreateCompleted, &timeout.SystemCreate)
+ if err != nil {
+ if err == ErrTimeout {
+ // Terminate the compute system if it still exists. We're okay to
+ // ignore a failure here.
+ computeSystem.Terminate()
+ }
+ return nil, makeSystemError(computeSystem, operation, hcsDocument, err, events)
+ }
+
+ return computeSystem, nil
+}
+
+// OpenComputeSystem opens an existing compute system by ID.
+func OpenComputeSystem(id string) (_ *System, err error) {
+ operation := "hcsshim::OpenComputeSystem"
+
+ computeSystem := newSystem(id)
+ computeSystem.logOperationBegin(operation)
+ defer computeSystem.logOperationEnd(err)
+
+ var (
+ handle hcsSystem
+ resultp *uint16
+ )
+ err = hcsOpenComputeSystem(id, &handle, &resultp)
+ events := processHcsResult(resultp)
+ if err != nil {
+ return nil, makeSystemError(computeSystem, operation, "", err, events)
+ }
+
+ computeSystem.handle = handle
+
+ if err = computeSystem.registerCallback(); err != nil {
+ return nil, makeSystemError(computeSystem, operation, "", err, nil)
+ }
+
+ return computeSystem, nil
+}
+
+// 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,
+ }
+ logOperationBegin(
+ fields,
+ "hcsshim::ComputeSystem - Begin Operation")
+
+ defer func() {
+ var result string
+ if err == nil {
+ result = "Success"
+ } else {
+ result = "Error"
+ }
+
+ logOperationEnd(
+ fields,
+ "hcsshim::ComputeSystem - End Operation - "+result,
+ err)
+ }()
+
+ queryb, err := json.Marshal(q)
+ if err != nil {
+ return nil, err
+ }
+
+ query := string(queryb)
+
+ logrus.WithFields(fields).
+ WithField(logfields.JSON, query).
+ Debug("HCS ComputeSystem Query")
+
+ var (
+ resultp *uint16
+ computeSystemsp *uint16
+ )
+ completed := false
+ go syscallWatcher(fields, &completed)
+ err = hcsEnumerateComputeSystems(query, &computeSystemsp, &resultp)
+ completed = true
+ events := processHcsResult(resultp)
+ if err != nil {
+ return nil, &HcsError{Op: operation, Err: err, Events: events}
+ }
+
+ if computeSystemsp == nil {
+ return nil, ErrUnexpectedValue
+ }
+ computeSystemsRaw := interop.ConvertAndFreeCoTaskMemBytes(computeSystemsp)
+ computeSystems := []schema1.ContainerProperties{}
+ if err = json.Unmarshal(computeSystemsRaw, &computeSystems); err != nil {
+ return nil, err
+ }
+
+ return computeSystems, nil
+}
+
+// Start synchronously starts the computeSystem.
+func (computeSystem *System) Start() (err error) {
+ computeSystem.handleLock.RLock()
+ defer computeSystem.handleLock.RUnlock()
+
+ operation := "hcsshim::ComputeSystem::Start"
+ computeSystem.logOperationBegin(operation)
+ defer computeSystem.logOperationEnd(err)
+
+ if computeSystem.handle == 0 {
+ return makeSystemError(computeSystem, "Start", "", ErrAlreadyClosed, nil)
+ }
+
+ // This is a very simple backoff-retry loop to limit the number
+ // of parallel container starts if environment variable
+ // HCSSHIM_MAX_PARALLEL_START is set to a positive integer.
+ // It should generally only be used as a workaround to various
+ // platform issues that exist between RS1 and RS4 as of Aug 2018
+ if currentContainerStarts.maxParallel > 0 {
+ for {
+ currentContainerStarts.Lock()
+ if currentContainerStarts.inProgress < currentContainerStarts.maxParallel {
+ currentContainerStarts.inProgress++
+ currentContainerStarts.Unlock()
+ break
+ }
+ if currentContainerStarts.inProgress == currentContainerStarts.maxParallel {
+ currentContainerStarts.Unlock()
+ time.Sleep(100 * time.Millisecond)
+ }
+ }
+ // Make sure we decrement the count when we are done.
+ defer func() {
+ currentContainerStarts.Lock()
+ currentContainerStarts.inProgress--
+ currentContainerStarts.Unlock()
+ }()
+ }
+
+ var resultp *uint16
+ completed := false
+ go syscallWatcher(computeSystem.logctx, &completed)
+ err = hcsStartComputeSystem(computeSystem.handle, "", &resultp)
+ completed = true
+ events, err := processAsyncHcsResult(err, resultp, computeSystem.callbackNumber, hcsNotificationSystemStartCompleted, &timeout.SystemStart)
+ if err != nil {
+ return makeSystemError(computeSystem, "Start", "", err, events)
+ }
+
+ return nil
+}
+
+// ID returns the compute system's identifier.
+func (computeSystem *System) ID() string {
+ return computeSystem.id
+}
+
+// Shutdown requests a compute system shutdown, if IsPending() on the error returned is true,
+// it may not actually be shut down until Wait() succeeds.
+func (computeSystem *System) Shutdown() (err error) {
+ computeSystem.handleLock.RLock()
+ defer computeSystem.handleLock.RUnlock()
+
+ operation := "hcsshim::ComputeSystem::Shutdown"
+ computeSystem.logOperationBegin(operation)
+ defer computeSystem.logOperationEnd(err)
+
+ if computeSystem.handle == 0 {
+ return makeSystemError(computeSystem, "Shutdown", "", ErrAlreadyClosed, nil)
+ }
+
+ var resultp *uint16
+ completed := false
+ go syscallWatcher(computeSystem.logctx, &completed)
+ err = hcsShutdownComputeSystem(computeSystem.handle, "", &resultp)
+ completed = true
+ events := processHcsResult(resultp)
+ if err != nil {
+ return makeSystemError(computeSystem, "Shutdown", "", err, events)
+ }
+
+ return nil
+}
+
+// Terminate requests a compute system terminate, if IsPending() on the error returned is true,
+// it may not actually be shut down until Wait() succeeds.
+func (computeSystem *System) Terminate() (err error) {
+ computeSystem.handleLock.RLock()
+ defer computeSystem.handleLock.RUnlock()
+
+ operation := "hcsshim::ComputeSystem::Terminate"
+ computeSystem.logOperationBegin(operation)
+ defer computeSystem.logOperationEnd(err)
+
+ if computeSystem.handle == 0 {
+ return makeSystemError(computeSystem, "Terminate", "", ErrAlreadyClosed, nil)
+ }
+
+ var resultp *uint16
+ completed := false
+ go syscallWatcher(computeSystem.logctx, &completed)
+ err = hcsTerminateComputeSystem(computeSystem.handle, "", &resultp)
+ completed = true
+ events := processHcsResult(resultp)
+ if err != nil {
+ return makeSystemError(computeSystem, "Terminate", "", err, events)
+ }
+
+ return nil
+}
+
+// Wait synchronously waits for the compute system to shutdown or terminate.
+func (computeSystem *System) Wait() (err error) {
+ operation := "hcsshim::ComputeSystem::Wait"
+ computeSystem.logOperationBegin(operation)
+ defer computeSystem.logOperationEnd(err)
+
+ err = waitForNotification(computeSystem.callbackNumber, hcsNotificationSystemExited, nil)
+ if err != nil {
+ return makeSystemError(computeSystem, "Wait", "", 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)
+
+ err = waitForNotification(computeSystem.callbackNumber, hcsNotificationSystemExited, &timeout)
+ if err != nil {
+ return makeSystemError(computeSystem, "WaitTimeout", "", err, nil)
+ }
+
+ return nil
+}
+
+func (computeSystem *System) Properties(types ...schema1.PropertyType) (_ *schema1.ContainerProperties, err error) {
+ computeSystem.handleLock.RLock()
+ defer computeSystem.handleLock.RUnlock()
+
+ operation := "hcsshim::ComputeSystem::Properties"
+ computeSystem.logOperationBegin(operation)
+ defer computeSystem.logOperationEnd(err)
+
+ queryj, err := json.Marshal(schema1.PropertyQuery{types})
+ if err != nil {
+ return nil, makeSystemError(computeSystem, "Properties", "", err, nil)
+ }
+
+ logrus.WithFields(computeSystem.logctx).
+ WithField(logfields.JSON, queryj).
+ 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
+ events := processHcsResult(resultp)
+ if err != nil {
+ return nil, makeSystemError(computeSystem, "Properties", "", err, events)
+ }
+
+ if propertiesp == nil {
+ return nil, ErrUnexpectedValue
+ }
+ propertiesRaw := interop.ConvertAndFreeCoTaskMemBytes(propertiesp)
+ properties := &schema1.ContainerProperties{}
+ if err := json.Unmarshal(propertiesRaw, properties); err != nil {
+ return nil, makeSystemError(computeSystem, "Properties", "", err, nil)
+ }
+
+ return properties, nil
+}
+
+// Pause pauses the execution of the computeSystem. This feature is not enabled in TP5.
+func (computeSystem *System) Pause() (err error) {
+ computeSystem.handleLock.RLock()
+ defer computeSystem.handleLock.RUnlock()
+
+ operation := "hcsshim::ComputeSystem::Pause"
+ computeSystem.logOperationBegin(operation)
+ defer computeSystem.logOperationEnd(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
+ events, err := processAsyncHcsResult(err, resultp, computeSystem.callbackNumber, hcsNotificationSystemPauseCompleted, &timeout.SystemPause)
+ if err != nil {
+ return makeSystemError(computeSystem, "Pause", "", err, events)
+ }
+
+ return nil
+}
+
+// Resume resumes the execution of the computeSystem. This feature is not enabled in TP5.
+func (computeSystem *System) Resume() (err error) {
+ computeSystem.handleLock.RLock()
+ defer computeSystem.handleLock.RUnlock()
+
+ operation := "hcsshim::ComputeSystem::Resume"
+ computeSystem.logOperationBegin(operation)
+ defer computeSystem.logOperationEnd(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
+ events, err := processAsyncHcsResult(err, resultp, computeSystem.callbackNumber, hcsNotificationSystemResumeCompleted, &timeout.SystemResume)
+ if err != nil {
+ return makeSystemError(computeSystem, "Resume", "", err, events)
+ }
+
+ return nil
+}
+
+// CreateProcess launches a new process within the computeSystem.
+func (computeSystem *System) CreateProcess(c interface{}) (_ *Process, err error) {
+ computeSystem.handleLock.RLock()
+ defer computeSystem.handleLock.RUnlock()
+
+ operation := "hcsshim::ComputeSystem::CreateProcess"
+ computeSystem.logOperationBegin(operation)
+ defer computeSystem.logOperationEnd(err)
+
+ var (
+ processInfo hcsProcessInformation
+ processHandle hcsProcess
+ resultp *uint16
+ )
+
+ if computeSystem.handle == 0 {
+ return nil, makeSystemError(computeSystem, "CreateProcess", "", ErrAlreadyClosed, nil)
+ }
+
+ configurationb, err := json.Marshal(c)
+ if err != nil {
+ return nil, makeSystemError(computeSystem, "CreateProcess", "", err, nil)
+ }
+
+ configuration := string(configurationb)
+
+ logrus.WithFields(computeSystem.logctx).
+ 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
+ events := processHcsResult(resultp)
+ if err != nil {
+ return nil, makeSystemError(computeSystem, "CreateProcess", configuration, err, events)
+ }
+
+ logrus.WithFields(computeSystem.logctx).
+ WithField(logfields.ProcessID, processInfo.ProcessId).
+ Debug("HCS ComputeSystem CreateProcess PID")
+
+ process := newProcess(processHandle, int(processInfo.ProcessId), computeSystem)
+ process.cachedPipes = &cachedPipes{
+ stdIn: processInfo.StdInput,
+ stdOut: processInfo.StdOutput,
+ stdErr: processInfo.StdError,
+ }
+
+ if err = process.registerCallback(); err != nil {
+ return nil, makeSystemError(computeSystem, "CreateProcess", "", err, nil)
+ }
+
+ return process, nil
+}
+
+// OpenProcess gets an interface to an existing process within the computeSystem.
+func (computeSystem *System) OpenProcess(pid int) (_ *Process, err error) {
+ computeSystem.handleLock.RLock()
+ defer computeSystem.handleLock.RUnlock()
+
+ // Add PID for the context of this operation
+ computeSystem.logctx[logfields.ProcessID] = pid
+ defer delete(computeSystem.logctx, logfields.ProcessID)
+
+ operation := "hcsshim::ComputeSystem::OpenProcess"
+ computeSystem.logOperationBegin(operation)
+ defer computeSystem.logOperationEnd(err)
+
+ var (
+ processHandle hcsProcess
+ resultp *uint16
+ )
+
+ if computeSystem.handle == 0 {
+ return nil, makeSystemError(computeSystem, "OpenProcess", "", ErrAlreadyClosed, nil)
+ }
+
+ completed := false
+ go syscallWatcher(computeSystem.logctx, &completed)
+ err = hcsOpenProcess(computeSystem.handle, uint32(pid), &processHandle, &resultp)
+ completed = true
+ events := processHcsResult(resultp)
+ if err != nil {
+ return nil, makeSystemError(computeSystem, "OpenProcess", "", err, events)
+ }
+
+ process := newProcess(processHandle, pid, computeSystem)
+ if err = process.registerCallback(); err != nil {
+ return nil, makeSystemError(computeSystem, "OpenProcess", "", err, nil)
+ }
+
+ return process, nil
+}
+
+// Close cleans up any state associated with the compute system but does not terminate or wait for it.
+func (computeSystem *System) Close() (err error) {
+ computeSystem.handleLock.Lock()
+ defer computeSystem.handleLock.Unlock()
+
+ operation := "hcsshim::ComputeSystem::Close"
+ computeSystem.logOperationBegin(operation)
+ defer computeSystem.logOperationEnd(err)
+
+ // Don't double free this
+ if computeSystem.handle == 0 {
+ return nil
+ }
+
+ if err = computeSystem.unregisterCallback(); err != nil {
+ return makeSystemError(computeSystem, "Close", "", err, nil)
+ }
+
+ completed := false
+ go syscallWatcher(computeSystem.logctx, &completed)
+ err = hcsCloseComputeSystem(computeSystem.handle)
+ completed = true
+ if err != nil {
+ return makeSystemError(computeSystem, "Close", "", err, nil)
+ }
+
+ computeSystem.handle = 0
+
+ return nil
+}
+
+func (computeSystem *System) registerCallback() error {
+ context := &notifcationWatcherContext{
+ channels: newChannels(),
+ }
+
+ callbackMapLock.Lock()
+ callbackNumber := nextCallback
+ nextCallback++
+ callbackMap[callbackNumber] = context
+ callbackMapLock.Unlock()
+
+ var callbackHandle hcsCallback
+ err := hcsRegisterComputeSystemCallback(computeSystem.handle, notificationWatcherCallback, callbackNumber, &callbackHandle)
+ if err != nil {
+ return err
+ }
+ context.handle = callbackHandle
+ computeSystem.callbackNumber = callbackNumber
+
+ return nil
+}
+
+func (computeSystem *System) unregisterCallback() error {
+ callbackNumber := computeSystem.callbackNumber
+
+ callbackMapLock.RLock()
+ context := callbackMap[callbackNumber]
+ callbackMapLock.RUnlock()
+
+ if context == nil {
+ return nil
+ }
+
+ handle := context.handle
+
+ if handle == 0 {
+ return nil
+ }
+
+ // hcsUnregisterComputeSystemCallback has its own syncronization
+ // to wait for all callbacks to complete. We must NOT hold the callbackMapLock.
+ err := hcsUnregisterComputeSystemCallback(handle)
+ if err != nil {
+ return err
+ }
+
+ closeChannels(context.channels)
+
+ callbackMapLock.Lock()
+ callbackMap[callbackNumber] = nil
+ callbackMapLock.Unlock()
+
+ handle = 0
+
+ return nil
+}
+
+// Modify the System by sending a request to HCS
+func (computeSystem *System) Modify(config interface{}) (err error) {
+ computeSystem.handleLock.RLock()
+ defer computeSystem.handleLock.RUnlock()
+
+ operation := "hcsshim::ComputeSystem::Modify"
+ computeSystem.logOperationBegin(operation)
+ defer computeSystem.logOperationEnd(err)
+
+ if computeSystem.handle == 0 {
+ return makeSystemError(computeSystem, "Modify", "", ErrAlreadyClosed, nil)
+ }
+
+ requestJSON, err := json.Marshal(config)
+ if err != nil {
+ return err
+ }
+
+ requestString := string(requestJSON)
+
+ logrus.WithFields(computeSystem.logctx).
+ WithField(logfields.JSON, requestString).
+ Debug("HCS ComputeSystem Modify Document")
+
+ var resultp *uint16
+ completed := false
+ go syscallWatcher(computeSystem.logctx, &completed)
+ err = hcsModifyComputeSystem(computeSystem.handle, requestString, &resultp)
+ completed = true
+ events := processHcsResult(resultp)
+ if err != nil {
+ return makeSystemError(computeSystem, "Modify", requestString, err, events)
+ }
+
+ return nil
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/hcs/utils.go b/vendor/github.com/Microsoft/hcsshim/internal/hcs/utils.go
new file mode 100644
index 000000000..a638677ed
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/hcs/utils.go
@@ -0,0 +1,33 @@
+package hcs
+
+import (
+ "io"
+ "syscall"
+
+ "github.com/Microsoft/go-winio"
+)
+
+// makeOpenFiles calls winio.MakeOpenFile for each handle in a slice but closes all the handles
+// if there is an error.
+func makeOpenFiles(hs []syscall.Handle) (_ []io.ReadWriteCloser, err error) {
+ fs := make([]io.ReadWriteCloser, len(hs))
+ for i, h := range hs {
+ if h != syscall.Handle(0) {
+ if err == nil {
+ fs[i], err = winio.MakeOpenFile(h)
+ }
+ if err != nil {
+ syscall.Close(h)
+ }
+ }
+ }
+ if err != nil {
+ for _, f := range fs {
+ if f != nil {
+ f.Close()
+ }
+ }
+ return nil, err
+ }
+ return fs, nil
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/hcs/waithelper.go b/vendor/github.com/Microsoft/hcsshim/internal/hcs/waithelper.go
new file mode 100644
index 000000000..91e212c57
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/hcs/waithelper.go
@@ -0,0 +1,63 @@
+package hcs
+
+import (
+ "time"
+
+ "github.com/sirupsen/logrus"
+)
+
+func processAsyncHcsResult(err error, resultp *uint16, callbackNumber uintptr, expectedNotification hcsNotification, timeout *time.Duration) ([]ErrorEvent, error) {
+ events := processHcsResult(resultp)
+ if IsPending(err) {
+ return nil, waitForNotification(callbackNumber, expectedNotification, timeout)
+ }
+
+ return events, err
+}
+
+func waitForNotification(callbackNumber uintptr, expectedNotification hcsNotification, timeout *time.Duration) error {
+ callbackMapLock.RLock()
+ channels := callbackMap[callbackNumber].channels
+ callbackMapLock.RUnlock()
+
+ expectedChannel := channels[expectedNotification]
+ if expectedChannel == nil {
+ logrus.Errorf("unknown notification type in waitForNotification %x", expectedNotification)
+ return ErrInvalidNotificationType
+ }
+
+ var c <-chan time.Time
+ if timeout != nil {
+ timer := time.NewTimer(*timeout)
+ c = timer.C
+ defer timer.Stop()
+ }
+
+ select {
+ case err, ok := <-expectedChannel:
+ if !ok {
+ return ErrHandleClose
+ }
+ return err
+ case err, ok := <-channels[hcsNotificationSystemExited]:
+ if !ok {
+ return ErrHandleClose
+ }
+ // If the expected notification is hcsNotificationSystemExited which of the two selects
+ // chosen is random. Return the raw error if hcsNotificationSystemExited is expected
+ if channels[hcsNotificationSystemExited] == expectedChannel {
+ return err
+ }
+ return ErrUnexpectedContainerExit
+ case _, ok := <-channels[hcsNotificationServiceDisconnect]:
+ if !ok {
+ return ErrHandleClose
+ }
+ // hcsNotificationServiceDisconnect should never be an expected notification
+ // it does not need the same handling as hcsNotificationSystemExited
+ return ErrUnexpectedProcessAbort
+ case <-c:
+ return ErrTimeout
+ }
+ return nil
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/hcs/watcher.go b/vendor/github.com/Microsoft/hcsshim/internal/hcs/watcher.go
new file mode 100644
index 000000000..e09dd1334
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/hcs/watcher.go
@@ -0,0 +1,33 @@
+package hcs
+
+import (
+ "time"
+
+ "github.com/Microsoft/hcsshim/internal/logfields"
+ "github.com/Microsoft/hcsshim/internal/timeout"
+ "github.com/sirupsen/logrus"
+)
+
+// syscallWatcher is used as a very simple goroutine around calls into
+// the platform. In some cases, we have seen HCS APIs not returning due to
+// various bugs, and the goroutine making the syscall ends up not returning,
+// prior to its async callback. By spinning up a syscallWatcher, it allows
+// us to at least log a warning if a syscall doesn't complete in a reasonable
+// amount of time.
+//
+// Usage is:
+//
+// completed := false
+// go syscallWatcher(context, &completed)
+// <syscall>
+// completed = true
+//
+func syscallWatcher(context logrus.Fields, syscallCompleted *bool) {
+ time.Sleep(timeout.SyscallWatcher)
+ if *syscallCompleted {
+ return
+ }
+ 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
new file mode 100644
index 000000000..877c69a14
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/hcs/zsyscall_windows.go
@@ -0,0 +1,462 @@
+// Code generated mksyscall_windows.exe DO NOT EDIT
+
+package hcs
+
+import (
+ "syscall"
+ "unsafe"
+
+ "github.com/Microsoft/hcsshim/internal/interop"
+ "golang.org/x/sys/windows"
+)
+
+var _ unsafe.Pointer
+
+// Do the interface allocations only once for common
+// Errno values.
+const (
+ errnoERROR_IO_PENDING = 997
+)
+
+var (
+ errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING)
+)
+
+// errnoErr returns common boxed Errno values, to prevent
+// allocations at runtime.
+func errnoErr(e syscall.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 (
+ modvmcompute = windows.NewLazySystemDLL("vmcompute.dll")
+
+ procHcsEnumerateComputeSystems = modvmcompute.NewProc("HcsEnumerateComputeSystems")
+ procHcsCreateComputeSystem = modvmcompute.NewProc("HcsCreateComputeSystem")
+ procHcsOpenComputeSystem = modvmcompute.NewProc("HcsOpenComputeSystem")
+ procHcsCloseComputeSystem = modvmcompute.NewProc("HcsCloseComputeSystem")
+ procHcsStartComputeSystem = modvmcompute.NewProc("HcsStartComputeSystem")
+ procHcsShutdownComputeSystem = modvmcompute.NewProc("HcsShutdownComputeSystem")
+ procHcsTerminateComputeSystem = modvmcompute.NewProc("HcsTerminateComputeSystem")
+ procHcsPauseComputeSystem = modvmcompute.NewProc("HcsPauseComputeSystem")
+ procHcsResumeComputeSystem = modvmcompute.NewProc("HcsResumeComputeSystem")
+ procHcsGetComputeSystemProperties = modvmcompute.NewProc("HcsGetComputeSystemProperties")
+ procHcsModifyComputeSystem = modvmcompute.NewProc("HcsModifyComputeSystem")
+ procHcsRegisterComputeSystemCallback = modvmcompute.NewProc("HcsRegisterComputeSystemCallback")
+ procHcsUnregisterComputeSystemCallback = modvmcompute.NewProc("HcsUnregisterComputeSystemCallback")
+ procHcsCreateProcess = modvmcompute.NewProc("HcsCreateProcess")
+ procHcsOpenProcess = modvmcompute.NewProc("HcsOpenProcess")
+ procHcsCloseProcess = modvmcompute.NewProc("HcsCloseProcess")
+ procHcsTerminateProcess = modvmcompute.NewProc("HcsTerminateProcess")
+
+ procHcsGetProcessInfo = modvmcompute.NewProc("HcsGetProcessInfo")
+ procHcsGetProcessProperties = modvmcompute.NewProc("HcsGetProcessProperties")
+ procHcsModifyProcess = modvmcompute.NewProc("HcsModifyProcess")
+ procHcsGetServiceProperties = modvmcompute.NewProc("HcsGetServiceProperties")
+ procHcsRegisterProcessCallback = modvmcompute.NewProc("HcsRegisterProcessCallback")
+ procHcsUnregisterProcessCallback = modvmcompute.NewProc("HcsUnregisterProcessCallback")
+)
+
+func hcsEnumerateComputeSystems(query string, computeSystems **uint16, result **uint16) (hr error) {
+ var _p0 *uint16
+ _p0, hr = syscall.UTF16PtrFromString(query)
+ if hr != nil {
+ return
+ }
+ return _hcsEnumerateComputeSystems(_p0, computeSystems, result)
+}
+
+func _hcsEnumerateComputeSystems(query *uint16, computeSystems **uint16, result **uint16) (hr error) {
+ if hr = procHcsEnumerateComputeSystems.Find(); hr != nil {
+ return
+ }
+ 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)
+ }
+ return
+}
+
+func hcsCreateComputeSystem(id string, configuration string, identity syscall.Handle, computeSystem *hcsSystem, result **uint16) (hr error) {
+ var _p0 *uint16
+ _p0, hr = syscall.UTF16PtrFromString(id)
+ if hr != nil {
+ return
+ }
+ var _p1 *uint16
+ _p1, hr = syscall.UTF16PtrFromString(configuration)
+ if hr != nil {
+ return
+ }
+ return _hcsCreateComputeSystem(_p0, _p1, identity, computeSystem, result)
+}
+
+func _hcsCreateComputeSystem(id *uint16, configuration *uint16, identity syscall.Handle, computeSystem *hcsSystem, result **uint16) (hr error) {
+ if hr = procHcsCreateComputeSystem.Find(); hr != nil {
+ return
+ }
+ 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)
+ }
+ return
+}
+
+func hcsOpenComputeSystem(id string, computeSystem *hcsSystem, result **uint16) (hr error) {
+ var _p0 *uint16
+ _p0, hr = syscall.UTF16PtrFromString(id)
+ if hr != nil {
+ return
+ }
+ return _hcsOpenComputeSystem(_p0, computeSystem, result)
+}
+
+func _hcsOpenComputeSystem(id *uint16, computeSystem *hcsSystem, result **uint16) (hr error) {
+ if hr = procHcsOpenComputeSystem.Find(); hr != nil {
+ return
+ }
+ 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)
+ }
+ return
+}
+
+func hcsCloseComputeSystem(computeSystem hcsSystem) (hr error) {
+ if hr = procHcsCloseComputeSystem.Find(); hr != nil {
+ return
+ }
+ r0, _, _ := syscall.Syscall(procHcsCloseComputeSystem.Addr(), 1, uintptr(computeSystem), 0, 0)
+ if int32(r0) < 0 {
+ hr = interop.Win32FromHresult(r0)
+ }
+ return
+}
+
+func hcsStartComputeSystem(computeSystem hcsSystem, options string, result **uint16) (hr error) {
+ var _p0 *uint16
+ _p0, hr = syscall.UTF16PtrFromString(options)
+ if hr != nil {
+ return
+ }
+ return _hcsStartComputeSystem(computeSystem, _p0, result)
+}
+
+func _hcsStartComputeSystem(computeSystem hcsSystem, options *uint16, result **uint16) (hr error) {
+ if hr = procHcsStartComputeSystem.Find(); hr != nil {
+ return
+ }
+ r0, _, _ := syscall.Syscall(procHcsStartComputeSystem.Addr(), 3, uintptr(computeSystem), uintptr(unsafe.Pointer(options)), uintptr(unsafe.Pointer(result)))
+ if int32(r0) < 0 {
+ hr = interop.Win32FromHresult(r0)
+ }
+ return
+}
+
+func hcsShutdownComputeSystem(computeSystem hcsSystem, options string, result **uint16) (hr error) {
+ var _p0 *uint16
+ _p0, hr = syscall.UTF16PtrFromString(options)
+ if hr != nil {
+ return
+ }
+ return _hcsShutdownComputeSystem(computeSystem, _p0, result)
+}
+
+func _hcsShutdownComputeSystem(computeSystem hcsSystem, options *uint16, result **uint16) (hr error) {
+ if hr = procHcsShutdownComputeSystem.Find(); hr != nil {
+ return
+ }
+ r0, _, _ := syscall.Syscall(procHcsShutdownComputeSystem.Addr(), 3, uintptr(computeSystem), uintptr(unsafe.Pointer(options)), uintptr(unsafe.Pointer(result)))
+ if int32(r0) < 0 {
+ hr = interop.Win32FromHresult(r0)
+ }
+ return
+}
+
+func hcsTerminateComputeSystem(computeSystem hcsSystem, options string, result **uint16) (hr error) {
+ var _p0 *uint16
+ _p0, hr = syscall.UTF16PtrFromString(options)
+ if hr != nil {
+ return
+ }
+ return _hcsTerminateComputeSystem(computeSystem, _p0, result)
+}
+
+func _hcsTerminateComputeSystem(computeSystem hcsSystem, options *uint16, result **uint16) (hr error) {
+ if hr = procHcsTerminateComputeSystem.Find(); hr != nil {
+ return
+ }
+ r0, _, _ := syscall.Syscall(procHcsTerminateComputeSystem.Addr(), 3, uintptr(computeSystem), uintptr(unsafe.Pointer(options)), uintptr(unsafe.Pointer(result)))
+ if int32(r0) < 0 {
+ hr = interop.Win32FromHresult(r0)
+ }
+ return
+}
+
+func hcsPauseComputeSystem(computeSystem hcsSystem, options string, result **uint16) (hr error) {
+ var _p0 *uint16
+ _p0, hr = syscall.UTF16PtrFromString(options)
+ if hr != nil {
+ return
+ }
+ return _hcsPauseComputeSystem(computeSystem, _p0, result)
+}
+
+func _hcsPauseComputeSystem(computeSystem hcsSystem, options *uint16, result **uint16) (hr error) {
+ if hr = procHcsPauseComputeSystem.Find(); hr != nil {
+ return
+ }
+ r0, _, _ := syscall.Syscall(procHcsPauseComputeSystem.Addr(), 3, uintptr(computeSystem), uintptr(unsafe.Pointer(options)), uintptr(unsafe.Pointer(result)))
+ if int32(r0) < 0 {
+ hr = interop.Win32FromHresult(r0)
+ }
+ return
+}
+
+func hcsResumeComputeSystem(computeSystem hcsSystem, options string, result **uint16) (hr error) {
+ var _p0 *uint16
+ _p0, hr = syscall.UTF16PtrFromString(options)
+ if hr != nil {
+ return
+ }
+ return _hcsResumeComputeSystem(computeSystem, _p0, result)
+}
+
+func _hcsResumeComputeSystem(computeSystem hcsSystem, options *uint16, result **uint16) (hr error) {
+ if hr = procHcsResumeComputeSystem.Find(); hr != nil {
+ return
+ }
+ r0, _, _ := syscall.Syscall(procHcsResumeComputeSystem.Addr(), 3, uintptr(computeSystem), uintptr(unsafe.Pointer(options)), uintptr(unsafe.Pointer(result)))
+ if int32(r0) < 0 {
+ hr = interop.Win32FromHresult(r0)
+ }
+ return
+}
+
+func hcsGetComputeSystemProperties(computeSystem hcsSystem, propertyQuery string, properties **uint16, result **uint16) (hr error) {
+ var _p0 *uint16
+ _p0, hr = syscall.UTF16PtrFromString(propertyQuery)
+ if hr != nil {
+ return
+ }
+ return _hcsGetComputeSystemProperties(computeSystem, _p0, properties, result)
+}
+
+func _hcsGetComputeSystemProperties(computeSystem hcsSystem, propertyQuery *uint16, properties **uint16, result **uint16) (hr error) {
+ if hr = procHcsGetComputeSystemProperties.Find(); hr != nil {
+ return
+ }
+ 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)
+ }
+ return
+}
+
+func hcsModifyComputeSystem(computeSystem hcsSystem, configuration string, result **uint16) (hr error) {
+ var _p0 *uint16
+ _p0, hr = syscall.UTF16PtrFromString(configuration)
+ if hr != nil {
+ return
+ }
+ return _hcsModifyComputeSystem(computeSystem, _p0, result)
+}
+
+func _hcsModifyComputeSystem(computeSystem hcsSystem, configuration *uint16, result **uint16) (hr error) {
+ if hr = procHcsModifyComputeSystem.Find(); hr != nil {
+ return
+ }
+ r0, _, _ := syscall.Syscall(procHcsModifyComputeSystem.Addr(), 3, uintptr(computeSystem), uintptr(unsafe.Pointer(configuration)), uintptr(unsafe.Pointer(result)))
+ if int32(r0) < 0 {
+ hr = interop.Win32FromHresult(r0)
+ }
+ return
+}
+
+func hcsRegisterComputeSystemCallback(computeSystem hcsSystem, callback uintptr, context uintptr, callbackHandle *hcsCallback) (hr error) {
+ if hr = procHcsRegisterComputeSystemCallback.Find(); hr != nil {
+ return
+ }
+ 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)
+ }
+ return
+}
+
+func hcsUnregisterComputeSystemCallback(callbackHandle hcsCallback) (hr error) {
+ if hr = procHcsUnregisterComputeSystemCallback.Find(); hr != nil {
+ return
+ }
+ r0, _, _ := syscall.Syscall(procHcsUnregisterComputeSystemCallback.Addr(), 1, uintptr(callbackHandle), 0, 0)
+ if int32(r0) < 0 {
+ hr = interop.Win32FromHresult(r0)
+ }
+ return
+}
+
+func hcsCreateProcess(computeSystem hcsSystem, processParameters string, processInformation *hcsProcessInformation, process *hcsProcess, result **uint16) (hr error) {
+ var _p0 *uint16
+ _p0, hr = syscall.UTF16PtrFromString(processParameters)
+ if hr != nil {
+ return
+ }
+ return _hcsCreateProcess(computeSystem, _p0, processInformation, process, result)
+}
+
+func _hcsCreateProcess(computeSystem hcsSystem, processParameters *uint16, processInformation *hcsProcessInformation, process *hcsProcess, result **uint16) (hr error) {
+ if hr = procHcsCreateProcess.Find(); hr != nil {
+ return
+ }
+ 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)
+ }
+ return
+}
+
+func hcsOpenProcess(computeSystem hcsSystem, pid uint32, process *hcsProcess, result **uint16) (hr error) {
+ if hr = procHcsOpenProcess.Find(); hr != nil {
+ return
+ }
+ 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)
+ }
+ return
+}
+
+func hcsCloseProcess(process hcsProcess) (hr error) {
+ if hr = procHcsCloseProcess.Find(); hr != nil {
+ return
+ }
+ r0, _, _ := syscall.Syscall(procHcsCloseProcess.Addr(), 1, uintptr(process), 0, 0)
+ if int32(r0) < 0 {
+ hr = interop.Win32FromHresult(r0)
+ }
+ return
+}
+
+func hcsTerminateProcess(process hcsProcess, result **uint16) (hr error) {
+ if hr = procHcsTerminateProcess.Find(); hr != nil {
+ return
+ }
+ r0, _, _ := syscall.Syscall(procHcsTerminateProcess.Addr(), 2, uintptr(process), uintptr(unsafe.Pointer(result)), 0)
+ if int32(r0) < 0 {
+ hr = interop.Win32FromHresult(r0)
+ }
+ return
+}
+
+func hcsSignalProcess(process hcsProcess, options string, result **uint16) (hr error) {
+ var _p0 *uint16
+ _p0, hr = syscall.UTF16PtrFromString(options)
+ if hr != nil {
+ return
+ }
+ return _hcsSignalProcess(process, _p0, result)
+}
+
+func _hcsSignalProcess(process hcsProcess, options *uint16, result **uint16) (hr error) {
+ if hr = procHcsTerminateProcess.Find(); hr != nil {
+ return
+ }
+ r0, _, _ := syscall.Syscall(procHcsTerminateProcess.Addr(), 3, uintptr(process), uintptr(unsafe.Pointer(options)), uintptr(unsafe.Pointer(result)))
+ if int32(r0) < 0 {
+ hr = interop.Win32FromHresult(r0)
+ }
+ return
+}
+
+func hcsGetProcessInfo(process hcsProcess, processInformation *hcsProcessInformation, result **uint16) (hr error) {
+ if hr = procHcsGetProcessInfo.Find(); hr != nil {
+ return
+ }
+ r0, _, _ := syscall.Syscall(procHcsGetProcessInfo.Addr(), 3, uintptr(process), uintptr(unsafe.Pointer(processInformation)), uintptr(unsafe.Pointer(result)))
+ if int32(r0) < 0 {
+ hr = interop.Win32FromHresult(r0)
+ }
+ return
+}
+
+func hcsGetProcessProperties(process hcsProcess, processProperties **uint16, result **uint16) (hr error) {
+ if hr = procHcsGetProcessProperties.Find(); hr != nil {
+ return
+ }
+ r0, _, _ := syscall.Syscall(procHcsGetProcessProperties.Addr(), 3, uintptr(process), uintptr(unsafe.Pointer(processProperties)), uintptr(unsafe.Pointer(result)))
+ if int32(r0) < 0 {
+ hr = interop.Win32FromHresult(r0)
+ }
+ return
+}
+
+func hcsModifyProcess(process hcsProcess, settings string, result **uint16) (hr error) {
+ var _p0 *uint16
+ _p0, hr = syscall.UTF16PtrFromString(settings)
+ if hr != nil {
+ return
+ }
+ return _hcsModifyProcess(process, _p0, result)
+}
+
+func _hcsModifyProcess(process hcsProcess, settings *uint16, result **uint16) (hr error) {
+ if hr = procHcsModifyProcess.Find(); hr != nil {
+ return
+ }
+ r0, _, _ := syscall.Syscall(procHcsModifyProcess.Addr(), 3, uintptr(process), uintptr(unsafe.Pointer(settings)), uintptr(unsafe.Pointer(result)))
+ if int32(r0) < 0 {
+ hr = interop.Win32FromHresult(r0)
+ }
+ return
+}
+
+func hcsGetServiceProperties(propertyQuery string, properties **uint16, result **uint16) (hr error) {
+ var _p0 *uint16
+ _p0, hr = syscall.UTF16PtrFromString(propertyQuery)
+ if hr != nil {
+ return
+ }
+ return _hcsGetServiceProperties(_p0, properties, result)
+}
+
+func _hcsGetServiceProperties(propertyQuery *uint16, properties **uint16, result **uint16) (hr error) {
+ if hr = procHcsGetServiceProperties.Find(); hr != nil {
+ return
+ }
+ 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)
+ }
+ return
+}
+
+func hcsRegisterProcessCallback(process hcsProcess, callback uintptr, context uintptr, callbackHandle *hcsCallback) (hr error) {
+ if hr = procHcsRegisterProcessCallback.Find(); hr != nil {
+ return
+ }
+ 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)
+ }
+ return
+}
+
+func hcsUnregisterProcessCallback(callbackHandle hcsCallback) (hr error) {
+ if hr = procHcsUnregisterProcessCallback.Find(); hr != nil {
+ return
+ }
+ r0, _, _ := syscall.Syscall(procHcsUnregisterProcessCallback.Addr(), 1, uintptr(callbackHandle), 0, 0)
+ if int32(r0) < 0 {
+ hr = interop.Win32FromHresult(r0)
+ }
+ return
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/hcserror/hcserror.go b/vendor/github.com/Microsoft/hcsshim/internal/hcserror/hcserror.go
new file mode 100644
index 000000000..c8d362c66
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/hcserror/hcserror.go
@@ -0,0 +1,51 @@
+package hcserror
+
+import (
+ "fmt"
+ "syscall"
+)
+
+const ERROR_GEN_FAILURE = syscall.Errno(31)
+
+type HcsError struct {
+ title string
+ rest string
+ Err error
+}
+
+func (e *HcsError) Error() string {
+ s := e.title
+ if len(s) > 0 && s[len(s)-1] != ' ' {
+ s += " "
+ }
+ s += fmt.Sprintf("failed in Win32: %s (0x%x)", e.Err, Win32FromError(e.Err))
+ if e.rest != "" {
+ if e.rest[0] != ' ' {
+ s += " "
+ }
+ s += e.rest
+ }
+ return s
+}
+
+func New(err error, title, rest string) error {
+ // Pass through DLL errors directly since they do not originate from HCS.
+ if _, ok := err.(*syscall.DLLError); ok {
+ return err
+ }
+ 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)
+ }
+ if code, ok := err.(syscall.Errno); ok {
+ return uint32(code)
+ }
+ return uint32(ERROR_GEN_FAILURE)
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/hns/hns.go b/vendor/github.com/Microsoft/hcsshim/internal/hns/hns.go
new file mode 100644
index 000000000..b2e475f53
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/hns/hns.go
@@ -0,0 +1,23 @@
+package hns
+
+import "fmt"
+
+//go:generate go run ../../mksyscall_windows.go -output zsyscall_windows.go hns.go
+
+//sys _hnsCall(method string, path string, object string, response **uint16) (hr error) = vmcompute.HNSCall?
+
+type EndpointNotFoundError struct {
+ EndpointName string
+}
+
+func (e EndpointNotFoundError) Error() string {
+ return fmt.Sprintf("Endpoint %s not found", e.EndpointName)
+}
+
+type NetworkNotFoundError struct {
+ NetworkName string
+}
+
+func (e NetworkNotFoundError) Error() string {
+ return fmt.Sprintf("Network %s not found", e.NetworkName)
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/hns/hnsendpoint.go b/vendor/github.com/Microsoft/hcsshim/internal/hns/hnsendpoint.go
new file mode 100644
index 000000000..ce636458c
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/hns/hnsendpoint.go
@@ -0,0 +1,260 @@
+package hns
+
+import (
+ "encoding/json"
+ "net"
+
+ "github.com/sirupsen/logrus"
+)
+
+// HNSEndpoint represents a network endpoint in HNS
+type HNSEndpoint struct {
+ Id string `json:"ID,omitempty"`
+ Name string `json:",omitempty"`
+ VirtualNetwork string `json:",omitempty"`
+ VirtualNetworkName string `json:",omitempty"`
+ Policies []json.RawMessage `json:",omitempty"`
+ MacAddress string `json:",omitempty"`
+ IPAddress net.IP `json:",omitempty"`
+ DNSSuffix string `json:",omitempty"`
+ DNSServerList string `json:",omitempty"`
+ GatewayAddress string `json:",omitempty"`
+ EnableInternalDNS bool `json:",omitempty"`
+ DisableICC bool `json:",omitempty"`
+ PrefixLength uint8 `json:",omitempty"`
+ IsRemoteEndpoint bool `json:",omitempty"`
+ Namespace *Namespace `json:",omitempty"`
+}
+
+//SystemType represents the type of the system on which actions are done
+type SystemType string
+
+// SystemType const
+const (
+ ContainerType SystemType = "Container"
+ VirtualMachineType SystemType = "VirtualMachine"
+ HostType SystemType = "Host"
+)
+
+// EndpointAttachDetachRequest is the structure used to send request to the container to modify the system
+// Supported resource types are Network and Request Types are Add/Remove
+type EndpointAttachDetachRequest struct {
+ ContainerID string `json:"ContainerId,omitempty"`
+ SystemType SystemType `json:"SystemType"`
+ CompartmentID uint16 `json:"CompartmentId,omitempty"`
+ VirtualNICName string `json:"VirtualNicName,omitempty"`
+}
+
+// EndpointResquestResponse is object to get the endpoint request response
+type EndpointResquestResponse struct {
+ Success bool
+ Error string
+}
+
+// HNSEndpointRequest makes a HNS call to modify/query a network endpoint
+func HNSEndpointRequest(method, path, request string) (*HNSEndpoint, error) {
+ endpoint := &HNSEndpoint{}
+ err := hnsCall(method, "/endpoints/"+path, request, &endpoint)
+ if err != nil {
+ return nil, err
+ }
+
+ return endpoint, nil
+}
+
+// HNSListEndpointRequest makes a HNS call to query the list of available endpoints
+func HNSListEndpointRequest() ([]HNSEndpoint, error) {
+ var endpoint []HNSEndpoint
+ err := hnsCall("GET", "/endpoints/", "", &endpoint)
+ if err != nil {
+ return nil, err
+ }
+
+ return endpoint, nil
+}
+
+// GetHNSEndpointByID get the Endpoint by ID
+func GetHNSEndpointByID(endpointID string) (*HNSEndpoint, error) {
+ return HNSEndpointRequest("GET", endpointID, "")
+}
+
+// GetHNSEndpointByName gets the endpoint filtered by Name
+func GetHNSEndpointByName(endpointName string) (*HNSEndpoint, error) {
+ hnsResponse, err := HNSListEndpointRequest()
+ if err != nil {
+ return nil, err
+ }
+ for _, hnsEndpoint := range hnsResponse {
+ if hnsEndpoint.Name == endpointName {
+ return &hnsEndpoint, nil
+ }
+ }
+ return nil, EndpointNotFoundError{EndpointName: endpointName}
+}
+
+// Create Endpoint by sending EndpointRequest to HNS. TODO: Create a separate HNS interface to place all these methods
+func (endpoint *HNSEndpoint) Create() (*HNSEndpoint, error) {
+ operation := "Create"
+ title := "hcsshim::HNSEndpoint::" + operation
+ logrus.Debugf(title+" id=%s", endpoint.Id)
+
+ jsonString, err := json.Marshal(endpoint)
+ if err != nil {
+ return nil, err
+ }
+ return HNSEndpointRequest("POST", "", string(jsonString))
+}
+
+// Delete Endpoint by sending EndpointRequest to HNS
+func (endpoint *HNSEndpoint) Delete() (*HNSEndpoint, error) {
+ operation := "Delete"
+ title := "hcsshim::HNSEndpoint::" + operation
+ logrus.Debugf(title+" id=%s", endpoint.Id)
+
+ return HNSEndpointRequest("DELETE", endpoint.Id, "")
+}
+
+// Update Endpoint
+func (endpoint *HNSEndpoint) Update() (*HNSEndpoint, error) {
+ operation := "Update"
+ title := "hcsshim::HNSEndpoint::" + operation
+ logrus.Debugf(title+" id=%s", endpoint.Id)
+ jsonString, err := json.Marshal(endpoint)
+ if err != nil {
+ return nil, err
+ }
+ err = hnsCall("POST", "/endpoints/"+endpoint.Id, string(jsonString), &endpoint)
+
+ return endpoint, err
+}
+
+// ApplyACLPolicy applies a set of ACL Policies on the Endpoint
+func (endpoint *HNSEndpoint) ApplyACLPolicy(policies ...*ACLPolicy) error {
+ operation := "ApplyACLPolicy"
+ title := "hcsshim::HNSEndpoint::" + operation
+ logrus.Debugf(title+" id=%s", endpoint.Id)
+
+ for _, policy := range policies {
+ if policy == nil {
+ continue
+ }
+ jsonString, err := json.Marshal(policy)
+ if err != nil {
+ return err
+ }
+ endpoint.Policies = append(endpoint.Policies, jsonString)
+ }
+
+ _, err := endpoint.Update()
+ return err
+}
+
+// ContainerAttach attaches an endpoint to container
+func (endpoint *HNSEndpoint) ContainerAttach(containerID string, compartmentID uint16) error {
+ operation := "ContainerAttach"
+ title := "hcsshim::HNSEndpoint::" + operation
+ logrus.Debugf(title+" id=%s", endpoint.Id)
+
+ requestMessage := &EndpointAttachDetachRequest{
+ ContainerID: containerID,
+ CompartmentID: compartmentID,
+ SystemType: ContainerType,
+ }
+ response := &EndpointResquestResponse{}
+ jsonString, err := json.Marshal(requestMessage)
+ if err != nil {
+ return err
+ }
+ return hnsCall("POST", "/endpoints/"+endpoint.Id+"/attach", string(jsonString), &response)
+}
+
+// ContainerDetach detaches an endpoint from container
+func (endpoint *HNSEndpoint) ContainerDetach(containerID string) error {
+ operation := "ContainerDetach"
+ title := "hcsshim::HNSEndpoint::" + operation
+ logrus.Debugf(title+" id=%s", endpoint.Id)
+
+ requestMessage := &EndpointAttachDetachRequest{
+ ContainerID: containerID,
+ SystemType: ContainerType,
+ }
+ response := &EndpointResquestResponse{}
+
+ jsonString, err := json.Marshal(requestMessage)
+ if err != nil {
+ return err
+ }
+ return hnsCall("POST", "/endpoints/"+endpoint.Id+"/detach", string(jsonString), &response)
+}
+
+// HostAttach attaches a nic on the host
+func (endpoint *HNSEndpoint) HostAttach(compartmentID uint16) error {
+ operation := "HostAttach"
+ title := "hcsshim::HNSEndpoint::" + operation
+ logrus.Debugf(title+" id=%s", endpoint.Id)
+ requestMessage := &EndpointAttachDetachRequest{
+ CompartmentID: compartmentID,
+ SystemType: HostType,
+ }
+ response := &EndpointResquestResponse{}
+
+ jsonString, err := json.Marshal(requestMessage)
+ if err != nil {
+ return err
+ }
+ return hnsCall("POST", "/endpoints/"+endpoint.Id+"/attach", string(jsonString), &response)
+
+}
+
+// HostDetach detaches a nic on the host
+func (endpoint *HNSEndpoint) HostDetach() error {
+ operation := "HostDetach"
+ title := "hcsshim::HNSEndpoint::" + operation
+ logrus.Debugf(title+" id=%s", endpoint.Id)
+ requestMessage := &EndpointAttachDetachRequest{
+ SystemType: HostType,
+ }
+ response := &EndpointResquestResponse{}
+
+ jsonString, err := json.Marshal(requestMessage)
+ if err != nil {
+ return err
+ }
+ return hnsCall("POST", "/endpoints/"+endpoint.Id+"/detach", string(jsonString), &response)
+}
+
+// VirtualMachineNICAttach attaches a endpoint to a virtual machine
+func (endpoint *HNSEndpoint) VirtualMachineNICAttach(virtualMachineNICName string) error {
+ operation := "VirtualMachineNicAttach"
+ title := "hcsshim::HNSEndpoint::" + operation
+ logrus.Debugf(title+" id=%s", endpoint.Id)
+ requestMessage := &EndpointAttachDetachRequest{
+ VirtualNICName: virtualMachineNICName,
+ SystemType: VirtualMachineType,
+ }
+ response := &EndpointResquestResponse{}
+
+ jsonString, err := json.Marshal(requestMessage)
+ if err != nil {
+ return err
+ }
+ return hnsCall("POST", "/endpoints/"+endpoint.Id+"/attach", string(jsonString), &response)
+}
+
+// VirtualMachineNICDetach detaches a endpoint from a virtual machine
+func (endpoint *HNSEndpoint) VirtualMachineNICDetach() error {
+ operation := "VirtualMachineNicDetach"
+ title := "hcsshim::HNSEndpoint::" + operation
+ logrus.Debugf(title+" id=%s", endpoint.Id)
+
+ requestMessage := &EndpointAttachDetachRequest{
+ SystemType: VirtualMachineType,
+ }
+ response := &EndpointResquestResponse{}
+
+ jsonString, err := json.Marshal(requestMessage)
+ if err != nil {
+ return err
+ }
+ return hnsCall("POST", "/endpoints/"+endpoint.Id+"/detach", string(jsonString), &response)
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/hns/hnsfuncs.go b/vendor/github.com/Microsoft/hcsshim/internal/hns/hnsfuncs.go
new file mode 100644
index 000000000..969d1b263
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/hns/hnsfuncs.go
@@ -0,0 +1,42 @@
+package hns
+
+import (
+ "encoding/json"
+ "fmt"
+
+ "github.com/Microsoft/hcsshim/internal/hcserror"
+ "github.com/Microsoft/hcsshim/internal/interop"
+ "github.com/sirupsen/logrus"
+)
+
+func hnsCall(method, path, request string, returnResponse interface{}) error {
+ var responseBuffer *uint16
+ logrus.Debugf("[%s]=>[%s] Request : %s", method, path, request)
+
+ err := _hnsCall(method, path, request, &responseBuffer)
+ if err != nil {
+ return hcserror.New(err, "hnsCall ", "")
+ }
+ response := interop.ConvertAndFreeCoTaskMemString(responseBuffer)
+
+ hnsresponse := &hnsResponse{}
+ if err = json.Unmarshal([]byte(response), &hnsresponse); err != nil {
+ return err
+ }
+
+ if !hnsresponse.Success {
+ return fmt.Errorf("HNS failed with error : %s", hnsresponse.Error)
+ }
+
+ if len(hnsresponse.Output) == 0 {
+ return nil
+ }
+
+ logrus.Debugf("Network Response : %s", hnsresponse.Output)
+ err = json.Unmarshal(hnsresponse.Output, returnResponse)
+ if err != nil {
+ return err
+ }
+
+ return nil
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/hns/hnsglobals.go b/vendor/github.com/Microsoft/hcsshim/internal/hns/hnsglobals.go
new file mode 100644
index 000000000..a8d8cc56a
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/hns/hnsglobals.go
@@ -0,0 +1,28 @@
+package hns
+
+type HNSGlobals struct {
+ Version HNSVersion `json:"Version"`
+}
+
+type HNSVersion struct {
+ Major int `json:"Major"`
+ Minor int `json:"Minor"`
+}
+
+var (
+ HNSVersion1803 = HNSVersion{Major: 7, Minor: 2}
+)
+
+func GetHNSGlobals() (*HNSGlobals, error) {
+ var version HNSVersion
+ err := hnsCall("GET", "/globals/version", "", &version)
+ if err != nil {
+ return nil, err
+ }
+
+ globals := &HNSGlobals{
+ Version: version,
+ }
+
+ return globals, nil
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/hns/hnsnetwork.go b/vendor/github.com/Microsoft/hcsshim/internal/hns/hnsnetwork.go
new file mode 100644
index 000000000..7e859de91
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/hns/hnsnetwork.go
@@ -0,0 +1,141 @@
+package hns
+
+import (
+ "encoding/json"
+ "net"
+
+ "github.com/sirupsen/logrus"
+)
+
+// Subnet is assoicated with a network and represents a list
+// of subnets available to the network
+type Subnet struct {
+ AddressPrefix string `json:",omitempty"`
+ GatewayAddress string `json:",omitempty"`
+ Policies []json.RawMessage `json:",omitempty"`
+}
+
+// MacPool is assoicated with a network and represents a list
+// of macaddresses available to the network
+type MacPool struct {
+ StartMacAddress string `json:",omitempty"`
+ EndMacAddress string `json:",omitempty"`
+}
+
+// HNSNetwork represents a network in HNS
+type HNSNetwork struct {
+ Id string `json:"ID,omitempty"`
+ Name string `json:",omitempty"`
+ Type string `json:",omitempty"`
+ NetworkAdapterName string `json:",omitempty"`
+ SourceMac string `json:",omitempty"`
+ Policies []json.RawMessage `json:",omitempty"`
+ MacPools []MacPool `json:",omitempty"`
+ Subnets []Subnet `json:",omitempty"`
+ DNSSuffix string `json:",omitempty"`
+ DNSServerList string `json:",omitempty"`
+ DNSServerCompartment uint32 `json:",omitempty"`
+ ManagementIP string `json:",omitempty"`
+ AutomaticDNS bool `json:",omitempty"`
+}
+
+type hnsNetworkResponse struct {
+ Success bool
+ Error string
+ Output HNSNetwork
+}
+
+type hnsResponse struct {
+ Success bool
+ Error string
+ Output json.RawMessage
+}
+
+// HNSNetworkRequest makes a call into HNS to update/query a single network
+func HNSNetworkRequest(method, path, request string) (*HNSNetwork, error) {
+ var network HNSNetwork
+ err := hnsCall(method, "/networks/"+path, request, &network)
+ if err != nil {
+ return nil, err
+ }
+
+ return &network, nil
+}
+
+// HNSListNetworkRequest makes a HNS call to query the list of available networks
+func HNSListNetworkRequest(method, path, request string) ([]HNSNetwork, error) {
+ var network []HNSNetwork
+ err := hnsCall(method, "/networks/"+path, request, &network)
+ if err != nil {
+ return nil, err
+ }
+
+ return network, nil
+}
+
+// GetHNSNetworkByID
+func GetHNSNetworkByID(networkID string) (*HNSNetwork, error) {
+ return HNSNetworkRequest("GET", networkID, "")
+}
+
+// GetHNSNetworkName filtered by Name
+func GetHNSNetworkByName(networkName string) (*HNSNetwork, error) {
+ hsnnetworks, err := HNSListNetworkRequest("GET", "", "")
+ if err != nil {
+ return nil, err
+ }
+ for _, hnsnetwork := range hsnnetworks {
+ if hnsnetwork.Name == networkName {
+ return &hnsnetwork, nil
+ }
+ }
+ return nil, NetworkNotFoundError{NetworkName: networkName}
+}
+
+// Create Network by sending NetworkRequest to HNS.
+func (network *HNSNetwork) Create() (*HNSNetwork, error) {
+ operation := "Create"
+ title := "hcsshim::HNSNetwork::" + operation
+ logrus.Debugf(title+" id=%s", network.Id)
+
+ jsonString, err := json.Marshal(network)
+ if err != nil {
+ return nil, err
+ }
+ return HNSNetworkRequest("POST", "", string(jsonString))
+}
+
+// Delete Network by sending NetworkRequest to HNS
+func (network *HNSNetwork) Delete() (*HNSNetwork, error) {
+ operation := "Delete"
+ title := "hcsshim::HNSNetwork::" + operation
+ logrus.Debugf(title+" id=%s", network.Id)
+
+ return HNSNetworkRequest("DELETE", network.Id, "")
+}
+
+// Creates an endpoint on the Network.
+func (network *HNSNetwork) NewEndpoint(ipAddress net.IP, macAddress net.HardwareAddr) *HNSEndpoint {
+ return &HNSEndpoint{
+ VirtualNetwork: network.Id,
+ IPAddress: ipAddress,
+ MacAddress: string(macAddress),
+ }
+}
+
+func (network *HNSNetwork) CreateEndpoint(endpoint *HNSEndpoint) (*HNSEndpoint, error) {
+ operation := "CreateEndpoint"
+ title := "hcsshim::HNSNetwork::" + operation
+ logrus.Debugf(title+" id=%s, endpointId=%s", network.Id, endpoint.Id)
+
+ endpoint.VirtualNetwork = network.Id
+ return endpoint.Create()
+}
+
+func (network *HNSNetwork) CreateRemoteEndpoint(endpoint *HNSEndpoint) (*HNSEndpoint, error) {
+ operation := "CreateRemoteEndpoint"
+ title := "hcsshim::HNSNetwork::" + operation
+ logrus.Debugf(title+" id=%s", network.Id)
+ endpoint.IsRemoteEndpoint = true
+ return network.CreateEndpoint(endpoint)
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/hns/hnspolicy.go b/vendor/github.com/Microsoft/hcsshim/internal/hns/hnspolicy.go
new file mode 100644
index 000000000..2318a4fce
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/hns/hnspolicy.go
@@ -0,0 +1,98 @@
+package hns
+
+// Type of Request Support in ModifySystem
+type PolicyType string
+
+// RequestType const
+const (
+ Nat PolicyType = "NAT"
+ ACL PolicyType = "ACL"
+ PA PolicyType = "PA"
+ VLAN PolicyType = "VLAN"
+ VSID PolicyType = "VSID"
+ VNet PolicyType = "VNET"
+ L2Driver PolicyType = "L2Driver"
+ Isolation PolicyType = "Isolation"
+ QOS PolicyType = "QOS"
+ OutboundNat PolicyType = "OutBoundNAT"
+ ExternalLoadBalancer PolicyType = "ELB"
+ Route PolicyType = "ROUTE"
+)
+
+type NatPolicy struct {
+ Type PolicyType `json:"Type"`
+ Protocol string
+ InternalPort uint16
+ ExternalPort uint16
+}
+
+type QosPolicy struct {
+ Type PolicyType `json:"Type"`
+ MaximumOutgoingBandwidthInBytes uint64
+}
+
+type IsolationPolicy struct {
+ Type PolicyType `json:"Type"`
+ VLAN uint
+ VSID uint
+ InDefaultIsolation bool
+}
+
+type VlanPolicy struct {
+ Type PolicyType `json:"Type"`
+ VLAN uint
+}
+
+type VsidPolicy struct {
+ Type PolicyType `json:"Type"`
+ VSID uint
+}
+
+type PaPolicy struct {
+ Type PolicyType `json:"Type"`
+ PA string `json:"PA"`
+}
+
+type OutboundNatPolicy struct {
+ Policy
+ VIP string `json:"VIP,omitempty"`
+ Exceptions []string `json:"ExceptionList,omitempty"`
+}
+
+type ActionType string
+type DirectionType string
+type RuleType string
+
+const (
+ Allow ActionType = "Allow"
+ Block ActionType = "Block"
+
+ In DirectionType = "In"
+ Out DirectionType = "Out"
+
+ Host RuleType = "Host"
+ Switch RuleType = "Switch"
+)
+
+type ACLPolicy struct {
+ Type PolicyType `json:"Type"`
+ Id string `json:"Id,omitempty"`
+ Protocol uint16
+ Protocols string `json:"Protocols,omitempty"`
+ InternalPort uint16
+ Action ActionType
+ Direction DirectionType
+ LocalAddresses string
+ RemoteAddresses string
+ LocalPorts string `json:"LocalPorts,omitempty"`
+ LocalPort uint16
+ RemotePorts string `json:"RemotePorts,omitempty"`
+ RemotePort uint16
+ RuleType RuleType `json:"RuleType,omitempty"`
+ Priority uint16
+ ServiceName string
+}
+
+type Policy struct {
+ Type PolicyType `json:"Type"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/hns/hnspolicylist.go b/vendor/github.com/Microsoft/hcsshim/internal/hns/hnspolicylist.go
new file mode 100644
index 000000000..31322a681
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/hns/hnspolicylist.go
@@ -0,0 +1,201 @@
+package hns
+
+import (
+ "encoding/json"
+
+ "github.com/sirupsen/logrus"
+)
+
+// RoutePolicy is a structure defining schema for Route based Policy
+type RoutePolicy struct {
+ Policy
+ DestinationPrefix string `json:"DestinationPrefix,omitempty"`
+ NextHop string `json:"NextHop,omitempty"`
+ EncapEnabled bool `json:"NeedEncap,omitempty"`
+}
+
+// ELBPolicy is a structure defining schema for ELB LoadBalancing based Policy
+type ELBPolicy struct {
+ LBPolicy
+ SourceVIP string `json:"SourceVIP,omitempty"`
+ VIPs []string `json:"VIPs,omitempty"`
+ ILB bool `json:"ILB,omitempty"`
+ DSR bool `json:"IsDSR,omitempty"`
+}
+
+// LBPolicy is a structure defining schema for LoadBalancing based Policy
+type LBPolicy struct {
+ Policy
+ Protocol uint16 `json:"Protocol,omitempty"`
+ InternalPort uint16
+ ExternalPort uint16
+}
+
+// PolicyList is a structure defining schema for Policy list request
+type PolicyList struct {
+ ID string `json:"ID,omitempty"`
+ EndpointReferences []string `json:"References,omitempty"`
+ Policies []json.RawMessage `json:"Policies,omitempty"`
+}
+
+// HNSPolicyListRequest makes a call into HNS to update/query a single network
+func HNSPolicyListRequest(method, path, request string) (*PolicyList, error) {
+ var policy PolicyList
+ err := hnsCall(method, "/policylists/"+path, request, &policy)
+ if err != nil {
+ return nil, err
+ }
+
+ return &policy, nil
+}
+
+// HNSListPolicyListRequest gets all the policy list
+func HNSListPolicyListRequest() ([]PolicyList, error) {
+ var plist []PolicyList
+ err := hnsCall("GET", "/policylists/", "", &plist)
+ if err != nil {
+ return nil, err
+ }
+
+ return plist, nil
+}
+
+// PolicyListRequest makes a HNS call to modify/query a network policy list
+func PolicyListRequest(method, path, request string) (*PolicyList, error) {
+ policylist := &PolicyList{}
+ err := hnsCall(method, "/policylists/"+path, request, &policylist)
+ if err != nil {
+ return nil, err
+ }
+
+ return policylist, nil
+}
+
+// GetPolicyListByID get the policy list by ID
+func GetPolicyListByID(policyListID string) (*PolicyList, error) {
+ return PolicyListRequest("GET", policyListID, "")
+}
+
+// Create PolicyList by sending PolicyListRequest to HNS.
+func (policylist *PolicyList) Create() (*PolicyList, error) {
+ operation := "Create"
+ title := "hcsshim::PolicyList::" + operation
+ logrus.Debugf(title+" id=%s", policylist.ID)
+ jsonString, err := json.Marshal(policylist)
+ if err != nil {
+ return nil, err
+ }
+ return PolicyListRequest("POST", "", string(jsonString))
+}
+
+// Delete deletes PolicyList
+func (policylist *PolicyList) Delete() (*PolicyList, error) {
+ operation := "Delete"
+ title := "hcsshim::PolicyList::" + operation
+ logrus.Debugf(title+" id=%s", policylist.ID)
+
+ return PolicyListRequest("DELETE", policylist.ID, "")
+}
+
+// AddEndpoint add an endpoint to a Policy List
+func (policylist *PolicyList) AddEndpoint(endpoint *HNSEndpoint) (*PolicyList, error) {
+ operation := "AddEndpoint"
+ title := "hcsshim::PolicyList::" + operation
+ logrus.Debugf(title+" id=%s, endpointId:%s", policylist.ID, endpoint.Id)
+
+ _, err := policylist.Delete()
+ if err != nil {
+ return nil, err
+ }
+
+ // Add Endpoint to the Existing List
+ policylist.EndpointReferences = append(policylist.EndpointReferences, "/endpoints/"+endpoint.Id)
+
+ return policylist.Create()
+}
+
+// RemoveEndpoint removes an endpoint from the Policy List
+func (policylist *PolicyList) RemoveEndpoint(endpoint *HNSEndpoint) (*PolicyList, error) {
+ operation := "RemoveEndpoint"
+ title := "hcsshim::PolicyList::" + operation
+ logrus.Debugf(title+" id=%s, endpointId:%s", policylist.ID, endpoint.Id)
+
+ _, err := policylist.Delete()
+ if err != nil {
+ return nil, err
+ }
+
+ elementToRemove := "/endpoints/" + endpoint.Id
+
+ var references []string
+
+ for _, endpointReference := range policylist.EndpointReferences {
+ if endpointReference == elementToRemove {
+ continue
+ }
+ references = append(references, endpointReference)
+ }
+ policylist.EndpointReferences = references
+ return policylist.Create()
+}
+
+// AddLoadBalancer policy list for the specified endpoints
+func AddLoadBalancer(endpoints []HNSEndpoint, isILB bool, sourceVIP, vip string, protocol uint16, internalPort uint16, externalPort uint16) (*PolicyList, error) {
+ operation := "AddLoadBalancer"
+ title := "hcsshim::PolicyList::" + operation
+ logrus.Debugf(title+" endpointId=%v, isILB=%v, sourceVIP=%s, vip=%s, protocol=%v, internalPort=%v, externalPort=%v", endpoints, isILB, sourceVIP, vip, protocol, internalPort, externalPort)
+
+ policylist := &PolicyList{}
+
+ elbPolicy := &ELBPolicy{
+ SourceVIP: sourceVIP,
+ ILB: isILB,
+ }
+
+ if len(vip) > 0 {
+ elbPolicy.VIPs = []string{vip}
+ }
+ elbPolicy.Type = ExternalLoadBalancer
+ elbPolicy.Protocol = protocol
+ elbPolicy.InternalPort = internalPort
+ elbPolicy.ExternalPort = externalPort
+
+ for _, endpoint := range endpoints {
+ policylist.EndpointReferences = append(policylist.EndpointReferences, "/endpoints/"+endpoint.Id)
+ }
+
+ jsonString, err := json.Marshal(elbPolicy)
+ if err != nil {
+ return nil, err
+ }
+ policylist.Policies = append(policylist.Policies, jsonString)
+ return policylist.Create()
+}
+
+// AddRoute adds route policy list for the specified endpoints
+func AddRoute(endpoints []HNSEndpoint, destinationPrefix string, nextHop string, encapEnabled bool) (*PolicyList, error) {
+ operation := "AddRoute"
+ title := "hcsshim::PolicyList::" + operation
+ logrus.Debugf(title+" destinationPrefix:%s", destinationPrefix)
+
+ policylist := &PolicyList{}
+
+ rPolicy := &RoutePolicy{
+ DestinationPrefix: destinationPrefix,
+ NextHop: nextHop,
+ EncapEnabled: encapEnabled,
+ }
+ rPolicy.Type = Route
+
+ for _, endpoint := range endpoints {
+ policylist.EndpointReferences = append(policylist.EndpointReferences, "/endpoints/"+endpoint.Id)
+ }
+
+ jsonString, err := json.Marshal(rPolicy)
+ if err != nil {
+ return nil, err
+ }
+
+ policylist.Policies = append(policylist.Policies, jsonString)
+ return policylist.Create()
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/hns/hnssupport.go b/vendor/github.com/Microsoft/hcsshim/internal/hns/hnssupport.go
new file mode 100644
index 000000000..d5efba7f2
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/hns/hnssupport.go
@@ -0,0 +1,49 @@
+package hns
+
+import (
+ "github.com/sirupsen/logrus"
+)
+
+type HNSSupportedFeatures struct {
+ Acl HNSAclFeatures `json:"ACL"`
+}
+
+type HNSAclFeatures struct {
+ AclAddressLists bool `json:"AclAddressLists"`
+ AclNoHostRulePriority bool `json:"AclHostRulePriority"`
+ AclPortRanges bool `json:"AclPortRanges"`
+ AclRuleId bool `json:"AclRuleId"`
+}
+
+func GetHNSSupportedFeatures() HNSSupportedFeatures {
+ var hnsFeatures HNSSupportedFeatures
+
+ globals, err := GetHNSGlobals()
+ if err != nil {
+ // Expected on pre-1803 builds, all features will be false/unsupported
+ logrus.Debugf("Unable to obtain HNS globals: %s", err)
+ return hnsFeatures
+ }
+
+ hnsFeatures.Acl = HNSAclFeatures{
+ AclAddressLists: isHNSFeatureSupported(globals.Version, HNSVersion1803),
+ AclNoHostRulePriority: isHNSFeatureSupported(globals.Version, HNSVersion1803),
+ AclPortRanges: isHNSFeatureSupported(globals.Version, HNSVersion1803),
+ AclRuleId: isHNSFeatureSupported(globals.Version, HNSVersion1803),
+ }
+
+ return hnsFeatures
+}
+
+func isHNSFeatureSupported(currentVersion HNSVersion, minVersionSupported HNSVersion) bool {
+ if currentVersion.Major < minVersionSupported.Major {
+ return false
+ }
+ if currentVersion.Major > minVersionSupported.Major {
+ return true
+ }
+ if currentVersion.Minor < minVersionSupported.Minor {
+ return false
+ }
+ return true
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/hns/namespace.go b/vendor/github.com/Microsoft/hcsshim/internal/hns/namespace.go
new file mode 100644
index 000000000..45e2281b0
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/hns/namespace.go
@@ -0,0 +1,110 @@
+package hns
+
+import (
+ "encoding/json"
+ "fmt"
+ "os"
+ "path"
+ "strings"
+)
+
+type namespaceRequest struct {
+ IsDefault bool `json:",omitempty"`
+}
+
+type namespaceEndpointRequest struct {
+ ID string `json:"Id"`
+}
+
+type NamespaceResource struct {
+ Type string
+ Data json.RawMessage
+}
+
+type namespaceResourceRequest struct {
+ Type string
+ Data interface{}
+}
+
+type Namespace struct {
+ ID string
+ IsDefault bool `json:",omitempty"`
+ ResourceList []NamespaceResource `json:",omitempty"`
+}
+
+func issueNamespaceRequest(id *string, method, subpath string, request interface{}) (*Namespace, error) {
+ var err error
+ hnspath := "/namespaces/"
+ if id != nil {
+ hnspath = path.Join(hnspath, *id)
+ }
+ if subpath != "" {
+ hnspath = path.Join(hnspath, subpath)
+ }
+ var reqJSON []byte
+ if request != nil {
+ if reqJSON, err = json.Marshal(request); err != nil {
+ return nil, err
+ }
+ }
+ var ns Namespace
+ err = hnsCall(method, hnspath, string(reqJSON), &ns)
+ if err != nil {
+ if strings.Contains(err.Error(), "Element not found.") {
+ return nil, os.ErrNotExist
+ }
+ return nil, fmt.Errorf("%s %s: %s", method, hnspath, err)
+ }
+ return &ns, err
+}
+
+func CreateNamespace() (string, error) {
+ req := namespaceRequest{}
+ ns, err := issueNamespaceRequest(nil, "POST", "", &req)
+ if err != nil {
+ return "", err
+ }
+ return ns.ID, nil
+}
+
+func RemoveNamespace(id string) error {
+ _, err := issueNamespaceRequest(&id, "DELETE", "", nil)
+ return err
+}
+
+func GetNamespaceEndpoints(id string) ([]string, error) {
+ ns, err := issueNamespaceRequest(&id, "GET", "", nil)
+ if err != nil {
+ return nil, err
+ }
+ var endpoints []string
+ for _, rsrc := range ns.ResourceList {
+ if rsrc.Type == "Endpoint" {
+ var endpoint namespaceEndpointRequest
+ err = json.Unmarshal(rsrc.Data, &endpoint)
+ if err != nil {
+ return nil, fmt.Errorf("unmarshal endpoint: %s", err)
+ }
+ endpoints = append(endpoints, endpoint.ID)
+ }
+ }
+ return endpoints, nil
+}
+
+func AddNamespaceEndpoint(id string, endpointID string) error {
+ resource := namespaceResourceRequest{
+ Type: "Endpoint",
+ Data: namespaceEndpointRequest{endpointID},
+ }
+ _, err := issueNamespaceRequest(&id, "POST", "addresource", &resource)
+ return err
+}
+
+func RemoveNamespaceEndpoint(id string, endpointID string) error {
+ resource := namespaceResourceRequest{
+ Type: "Endpoint",
+ Data: namespaceEndpointRequest{endpointID},
+ }
+ _, err := issueNamespaceRequest(&id, "POST", "removeresource", &resource)
+ return err
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/hns/zsyscall_windows.go b/vendor/github.com/Microsoft/hcsshim/internal/hns/zsyscall_windows.go
new file mode 100644
index 000000000..3a3232a06
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/hns/zsyscall_windows.go
@@ -0,0 +1,74 @@
+// Code generated mksyscall_windows.exe DO NOT EDIT
+
+package hns
+
+import (
+ "syscall"
+ "unsafe"
+
+ "github.com/Microsoft/hcsshim/internal/interop"
+ "golang.org/x/sys/windows"
+)
+
+var _ unsafe.Pointer
+
+// Do the interface allocations only once for common
+// Errno values.
+const (
+ errnoERROR_IO_PENDING = 997
+)
+
+var (
+ errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING)
+)
+
+// errnoErr returns common boxed Errno values, to prevent
+// allocations at runtime.
+func errnoErr(e syscall.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 (
+ modvmcompute = windows.NewLazySystemDLL("vmcompute.dll")
+
+ procHNSCall = modvmcompute.NewProc("HNSCall")
+)
+
+func _hnsCall(method string, path string, object string, response **uint16) (hr error) {
+ var _p0 *uint16
+ _p0, hr = syscall.UTF16PtrFromString(method)
+ if hr != nil {
+ return
+ }
+ var _p1 *uint16
+ _p1, hr = syscall.UTF16PtrFromString(path)
+ if hr != nil {
+ return
+ }
+ var _p2 *uint16
+ _p2, hr = syscall.UTF16PtrFromString(object)
+ if hr != nil {
+ return
+ }
+ return __hnsCall(_p0, _p1, _p2, response)
+}
+
+func __hnsCall(method *uint16, path *uint16, object *uint16, response **uint16) (hr error) {
+ if hr = procHNSCall.Find(); hr != nil {
+ return
+ }
+ 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)
+ }
+ return
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/interop/interop.go b/vendor/github.com/Microsoft/hcsshim/internal/interop/interop.go
new file mode 100644
index 000000000..f10c88d08
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/interop/interop.go
@@ -0,0 +1,27 @@
+package interop
+
+import (
+ "syscall"
+ "unsafe"
+)
+
+//go:generate go run $GOROOT/src/syscall/mksyscall_windows.go -output zsyscall_windows.go interop.go
+
+//sys coTaskMemFree(buffer unsafe.Pointer) = ole32.CoTaskMemFree
+
+func ConvertAndFreeCoTaskMemString(buffer *uint16) string {
+ str := syscall.UTF16ToString((*[1 << 29]uint16)(unsafe.Pointer(buffer))[:])
+ coTaskMemFree(unsafe.Pointer(buffer))
+ return str
+}
+
+func ConvertAndFreeCoTaskMemBytes(buffer *uint16) []byte {
+ return []byte(ConvertAndFreeCoTaskMemString(buffer))
+}
+
+func Win32FromHresult(hr uintptr) syscall.Errno {
+ if hr&0x1fff0000 == 0x00070000 {
+ return syscall.Errno(hr & 0xffff)
+ }
+ return syscall.Errno(hr)
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/interop/zsyscall_windows.go b/vendor/github.com/Microsoft/hcsshim/internal/interop/zsyscall_windows.go
new file mode 100644
index 000000000..2f5bf8f55
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/interop/zsyscall_windows.go
@@ -0,0 +1,48 @@
+// Code generated by 'go generate'; DO NOT EDIT.
+
+package interop
+
+import (
+ "syscall"
+ "unsafe"
+
+ "golang.org/x/sys/windows"
+)
+
+var _ unsafe.Pointer
+
+// Do the interface allocations only once for common
+// Errno values.
+const (
+ errnoERROR_IO_PENDING = 997
+)
+
+var (
+ errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING)
+)
+
+// errnoErr returns common boxed Errno values, to prevent
+// allocations at runtime.
+func errnoErr(e syscall.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 (
+ modole32 = windows.NewLazySystemDLL("ole32.dll")
+
+ procCoTaskMemFree = modole32.NewProc("CoTaskMemFree")
+)
+
+func coTaskMemFree(buffer unsafe.Pointer) {
+ syscall.Syscall(procCoTaskMemFree.Addr(), 1, uintptr(buffer), 0, 0)
+ return
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/logfields/fields.go b/vendor/github.com/Microsoft/hcsshim/internal/logfields/fields.go
new file mode 100644
index 000000000..a1527d706
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/logfields/fields.go
@@ -0,0 +1,37 @@
+package logfields
+
+const (
+ // Identifiers
+
+ ContainerID = "cid"
+ UVMID = "uvm-id"
+ ProcessID = "pid"
+
+ // Common Misc
+
+ // Timeout represents an operation timeout.
+ Timeout = "timeout"
+ JSON = "json"
+
+ // Keys/values
+
+ Field = "field"
+ OCIAnnotation = "oci-annotation"
+ Value = "value"
+
+ // Golang type's
+
+ ExpectedType = "expected-type"
+ Bool = "bool"
+ 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/longpath/longpath.go b/vendor/github.com/Microsoft/hcsshim/internal/longpath/longpath.go
new file mode 100644
index 000000000..e5b8b85e0
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/longpath/longpath.go
@@ -0,0 +1,24 @@
+package longpath
+
+import (
+ "path/filepath"
+ "strings"
+)
+
+// LongAbs makes a path absolute and returns it in NT long path form.
+func LongAbs(path string) (string, error) {
+ if strings.HasPrefix(path, `\\?\`) || strings.HasPrefix(path, `\\.\`) {
+ return path, nil
+ }
+ if !filepath.IsAbs(path) {
+ absPath, err := filepath.Abs(path)
+ if err != nil {
+ return "", err
+ }
+ path = absPath
+ }
+ if strings.HasPrefix(path, `\\`) {
+ return `\\?\UNC\` + path[2:], nil
+ }
+ return `\\?\` + path, nil
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/mergemaps/merge.go b/vendor/github.com/Microsoft/hcsshim/internal/mergemaps/merge.go
new file mode 100644
index 000000000..7e95efb30
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/mergemaps/merge.go
@@ -0,0 +1,52 @@
+package mergemaps
+
+import "encoding/json"
+
+// Merge recursively merges map `fromMap` into map `ToMap`. Any pre-existing values
+// in ToMap are overwritten. Values in fromMap are added to ToMap.
+// From http://stackoverflow.com/questions/40491438/merging-two-json-strings-in-golang
+func Merge(fromMap, ToMap interface{}) interface{} {
+ switch fromMap := fromMap.(type) {
+ case map[string]interface{}:
+ ToMap, ok := ToMap.(map[string]interface{})
+ if !ok {
+ return fromMap
+ }
+ for keyToMap, valueToMap := range ToMap {
+ if valueFromMap, ok := fromMap[keyToMap]; ok {
+ fromMap[keyToMap] = Merge(valueFromMap, valueToMap)
+ } else {
+ fromMap[keyToMap] = valueToMap
+ }
+ }
+ case nil:
+ // merge(nil, map[string]interface{...}) -> map[string]interface{...}
+ ToMap, ok := ToMap.(map[string]interface{})
+ if ok {
+ return ToMap
+ }
+ }
+ return fromMap
+}
+
+// MergeJSON merges the contents of a JSON string into an object representation,
+// returning a new object suitable for translating to JSON.
+func MergeJSON(object interface{}, additionalJSON []byte) (interface{}, error) {
+ if len(additionalJSON) == 0 {
+ return object, nil
+ }
+ objectJSON, err := json.Marshal(object)
+ if err != nil {
+ return nil, err
+ }
+ var objectMap, newMap map[string]interface{}
+ err = json.Unmarshal(objectJSON, &objectMap)
+ if err != nil {
+ return nil, err
+ }
+ err = json.Unmarshal(additionalJSON, &newMap)
+ if err != nil {
+ return nil, err
+ }
+ return Merge(newMap, objectMap), nil
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/safefile/safeopen.go b/vendor/github.com/Microsoft/hcsshim/internal/safefile/safeopen.go
new file mode 100644
index 000000000..0c0b1159f
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/safefile/safeopen.go
@@ -0,0 +1,431 @@
+package safefile
+
+import (
+ "errors"
+ "io"
+ "os"
+ "path/filepath"
+ "strings"
+ "syscall"
+ "unicode/utf16"
+ "unsafe"
+
+ "github.com/Microsoft/hcsshim/internal/longpath"
+
+ winio "github.com/Microsoft/go-winio"
+)
+
+//go:generate go run $GOROOT\src\syscall\mksyscall_windows.go -output zsyscall_windows.go safeopen.go
+
+//sys ntCreateFile(handle *uintptr, accessMask uint32, oa *objectAttributes, iosb *ioStatusBlock, allocationSize *uint64, fileAttributes uint32, shareAccess uint32, createDisposition uint32, createOptions uint32, eaBuffer *byte, eaLength uint32) (status uint32) = ntdll.NtCreateFile
+//sys ntSetInformationFile(handle uintptr, iosb *ioStatusBlock, information uintptr, length uint32, class uint32) (status uint32) = ntdll.NtSetInformationFile
+//sys rtlNtStatusToDosError(status uint32) (winerr error) = ntdll.RtlNtStatusToDosErrorNoTeb
+//sys localAlloc(flags uint32, size int) (ptr uintptr) = kernel32.LocalAlloc
+//sys localFree(ptr uintptr) = kernel32.LocalFree
+
+type ioStatusBlock struct {
+ Status, Information uintptr
+}
+
+type objectAttributes struct {
+ Length uintptr
+ RootDirectory uintptr
+ ObjectName uintptr
+ Attributes uintptr
+ SecurityDescriptor uintptr
+ SecurityQoS uintptr
+}
+
+type unicodeString struct {
+ Length uint16
+ MaximumLength uint16
+ Buffer uintptr
+}
+
+type fileLinkInformation struct {
+ ReplaceIfExists bool
+ RootDirectory uintptr
+ FileNameLength uint32
+ FileName [1]uint16
+}
+
+type fileDispositionInformationEx struct {
+ Flags uintptr
+}
+
+const (
+ _FileLinkInformation = 11
+ _FileDispositionInformationEx = 64
+
+ FILE_READ_ATTRIBUTES = 0x0080
+ FILE_WRITE_ATTRIBUTES = 0x0100
+ DELETE = 0x10000
+
+ FILE_OPEN = 1
+ FILE_CREATE = 2
+
+ FILE_DIRECTORY_FILE = 0x00000001
+ FILE_SYNCHRONOUS_IO_NONALERT = 0x00000020
+ FILE_DELETE_ON_CLOSE = 0x00001000
+ FILE_OPEN_FOR_BACKUP_INTENT = 0x00004000
+ FILE_OPEN_REPARSE_POINT = 0x00200000
+
+ FILE_DISPOSITION_DELETE = 0x00000001
+
+ _OBJ_DONT_REPARSE = 0x1000
+
+ _STATUS_REPARSE_POINT_ENCOUNTERED = 0xC000050B
+)
+
+func OpenRoot(path string) (*os.File, error) {
+ longpath, err := longpath.LongAbs(path)
+ if err != nil {
+ return nil, err
+ }
+ return winio.OpenForBackup(longpath, syscall.GENERIC_READ, syscall.FILE_SHARE_READ|syscall.FILE_SHARE_WRITE|syscall.FILE_SHARE_DELETE, syscall.OPEN_EXISTING)
+}
+
+func ntRelativePath(path string) ([]uint16, error) {
+ path = filepath.Clean(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 `:`")
+ }
+ fspath := filepath.FromSlash(path)
+ if len(fspath) > 0 && fspath[0] == '\\' {
+ return nil, errors.New("expected relative path")
+ }
+
+ path16 := utf16.Encode(([]rune)(fspath))
+ if len(path16) > 32767 {
+ return nil, syscall.ENAMETOOLONG
+ }
+
+ return path16, nil
+}
+
+// openRelativeInternal opens a relative path from the given root, failing if
+// any of the intermediate path components are reparse points.
+func openRelativeInternal(path string, root *os.File, accessMask uint32, shareFlags uint32, createDisposition uint32, flags uint32) (*os.File, error) {
+ var (
+ h uintptr
+ iosb ioStatusBlock
+ oa objectAttributes
+ )
+
+ path16, err := ntRelativePath(path)
+ if err != nil {
+ return nil, err
+ }
+
+ if root == nil || root.Fd() == 0 {
+ return nil, errors.New("missing root directory")
+ }
+
+ upathBuffer := localAlloc(0, int(unsafe.Sizeof(unicodeString{}))+len(path16)*2)
+ defer localFree(upathBuffer)
+
+ upath := (*unicodeString)(unsafe.Pointer(upathBuffer))
+ upath.Length = uint16(len(path16) * 2)
+ upath.MaximumLength = upath.Length
+ upath.Buffer = upathBuffer + unsafe.Sizeof(*upath)
+ copy((*[32768]uint16)(unsafe.Pointer(upath.Buffer))[:], path16)
+
+ oa.Length = unsafe.Sizeof(oa)
+ oa.ObjectName = upathBuffer
+ oa.RootDirectory = uintptr(root.Fd())
+ oa.Attributes = _OBJ_DONT_REPARSE
+ status := ntCreateFile(
+ &h,
+ accessMask|syscall.SYNCHRONIZE,
+ &oa,
+ &iosb,
+ nil,
+ 0,
+ shareFlags,
+ createDisposition,
+ FILE_OPEN_FOR_BACKUP_INTENT|FILE_SYNCHRONOUS_IO_NONALERT|flags,
+ nil,
+ 0,
+ )
+ if status != 0 {
+ return nil, rtlNtStatusToDosError(status)
+ }
+
+ fullPath, err := longpath.LongAbs(filepath.Join(root.Name(), path))
+ if err != nil {
+ syscall.Close(syscall.Handle(h))
+ return nil, err
+ }
+
+ return os.NewFile(h, fullPath), nil
+}
+
+// OpenRelative opens a relative path from the given root, failing if
+// any of the intermediate path components are reparse points.
+func OpenRelative(path string, root *os.File, accessMask uint32, shareFlags uint32, createDisposition uint32, flags uint32) (*os.File, error) {
+ f, err := openRelativeInternal(path, root, accessMask, shareFlags, createDisposition, flags)
+ if err != nil {
+ err = &os.PathError{Op: "open", Path: filepath.Join(root.Name(), path), Err: err}
+ }
+ return f, err
+}
+
+// LinkRelative creates a hard link from oldname to newname (relative to oldroot
+// and newroot), failing if any of the intermediate path components are reparse
+// points.
+func LinkRelative(oldname string, oldroot *os.File, newname string, newroot *os.File) error {
+ // Open the old file.
+ oldf, err := openRelativeInternal(
+ oldname,
+ oldroot,
+ syscall.FILE_WRITE_ATTRIBUTES,
+ syscall.FILE_SHARE_READ|syscall.FILE_SHARE_WRITE|syscall.FILE_SHARE_DELETE,
+ FILE_OPEN,
+ 0,
+ )
+ if err != nil {
+ return &os.LinkError{Op: "link", Old: filepath.Join(oldroot.Name(), oldname), New: filepath.Join(newroot.Name(), newname), Err: err}
+ }
+ defer oldf.Close()
+
+ // Open the parent of the new file.
+ var parent *os.File
+ parentPath := filepath.Dir(newname)
+ if parentPath != "." {
+ parent, err = openRelativeInternal(
+ parentPath,
+ newroot,
+ syscall.GENERIC_READ,
+ syscall.FILE_SHARE_READ|syscall.FILE_SHARE_WRITE|syscall.FILE_SHARE_DELETE,
+ FILE_OPEN,
+ FILE_DIRECTORY_FILE)
+ if err != nil {
+ return &os.LinkError{Op: "link", Old: oldf.Name(), New: filepath.Join(newroot.Name(), newname), Err: err}
+ }
+ defer parent.Close()
+
+ fi, err := winio.GetFileBasicInfo(parent)
+ if err != nil {
+ return err
+ }
+ if (fi.FileAttributes & syscall.FILE_ATTRIBUTE_REPARSE_POINT) != 0 {
+ return &os.LinkError{Op: "link", Old: oldf.Name(), New: filepath.Join(newroot.Name(), newname), Err: rtlNtStatusToDosError(_STATUS_REPARSE_POINT_ENCOUNTERED)}
+ }
+
+ } else {
+ parent = newroot
+ }
+
+ // Issue an NT call to create the link. This will be safe because NT will
+ // not open any more directories to create the link, so it cannot walk any
+ // more reparse points.
+ newbase := filepath.Base(newname)
+ newbase16, err := ntRelativePath(newbase)
+ if err != nil {
+ return err
+ }
+
+ size := int(unsafe.Offsetof(fileLinkInformation{}.FileName)) + len(newbase16)*2
+ linkinfoBuffer := localAlloc(0, size)
+ defer localFree(linkinfoBuffer)
+ linkinfo := (*fileLinkInformation)(unsafe.Pointer(linkinfoBuffer))
+ linkinfo.RootDirectory = parent.Fd()
+ linkinfo.FileNameLength = uint32(len(newbase16) * 2)
+ copy((*[32768]uint16)(unsafe.Pointer(&linkinfo.FileName[0]))[:], newbase16)
+
+ var iosb ioStatusBlock
+ status := ntSetInformationFile(
+ oldf.Fd(),
+ &iosb,
+ linkinfoBuffer,
+ uint32(size),
+ _FileLinkInformation,
+ )
+ if status != 0 {
+ return &os.LinkError{Op: "link", Old: oldf.Name(), New: filepath.Join(parent.Name(), newbase), Err: rtlNtStatusToDosError(status)}
+ }
+
+ return nil
+}
+
+// deleteOnClose marks a file to be deleted when the handle is closed.
+func deleteOnClose(f *os.File) error {
+ disposition := fileDispositionInformationEx{Flags: FILE_DISPOSITION_DELETE}
+ var iosb ioStatusBlock
+ status := ntSetInformationFile(
+ f.Fd(),
+ &iosb,
+ uintptr(unsafe.Pointer(&disposition)),
+ uint32(unsafe.Sizeof(disposition)),
+ _FileDispositionInformationEx,
+ )
+ if status != 0 {
+ return rtlNtStatusToDosError(status)
+ }
+ return nil
+}
+
+// clearReadOnly clears the readonly attribute on a file.
+func clearReadOnly(f *os.File) error {
+ bi, err := winio.GetFileBasicInfo(f)
+ if err != nil {
+ return err
+ }
+ if bi.FileAttributes&syscall.FILE_ATTRIBUTE_READONLY == 0 {
+ return nil
+ }
+ sbi := winio.FileBasicInfo{
+ FileAttributes: bi.FileAttributes &^ syscall.FILE_ATTRIBUTE_READONLY,
+ }
+ if sbi.FileAttributes == 0 {
+ sbi.FileAttributes = syscall.FILE_ATTRIBUTE_NORMAL
+ }
+ return winio.SetFileBasicInfo(f, &sbi)
+}
+
+// RemoveRelative removes a file or directory relative to a root, failing if any
+// intermediate path components are reparse points.
+func RemoveRelative(path string, root *os.File) error {
+ f, err := openRelativeInternal(
+ path,
+ root,
+ FILE_READ_ATTRIBUTES|FILE_WRITE_ATTRIBUTES|DELETE,
+ syscall.FILE_SHARE_READ|syscall.FILE_SHARE_WRITE|syscall.FILE_SHARE_DELETE,
+ FILE_OPEN,
+ FILE_OPEN_REPARSE_POINT)
+ if err == nil {
+ defer f.Close()
+ err = deleteOnClose(f)
+ if err == syscall.ERROR_ACCESS_DENIED {
+ // Maybe the file is marked readonly. Clear the bit and retry.
+ clearReadOnly(f)
+ err = deleteOnClose(f)
+ }
+ }
+ if err != nil {
+ return &os.PathError{Op: "remove", Path: filepath.Join(root.Name(), path), Err: err}
+ }
+ return nil
+}
+
+// RemoveAllRelative removes a directory tree relative to a root, failing if any
+// intermediate path components are reparse points.
+func RemoveAllRelative(path string, root *os.File) error {
+ fi, err := LstatRelative(path, root)
+ if err != nil {
+ if os.IsNotExist(err) {
+ return nil
+ }
+ return err
+ }
+ fileAttributes := fi.Sys().(*syscall.Win32FileAttributeData).FileAttributes
+ if fileAttributes&syscall.FILE_ATTRIBUTE_DIRECTORY == 0 || fileAttributes&syscall.FILE_ATTRIBUTE_REPARSE_POINT != 0 {
+ // If this is a reparse point, it can't have children. Simple remove will do.
+ err := RemoveRelative(path, root)
+ if err == nil || os.IsNotExist(err) {
+ return nil
+ }
+ return err
+ }
+
+ // It is necessary to use os.Open as Readdirnames does not work with
+ // OpenRelative. This is safe because the above lstatrelative fails
+ // if the target is outside the root, and we know this is not a
+ // symlink from the above FILE_ATTRIBUTE_REPARSE_POINT check.
+ fd, err := os.Open(filepath.Join(root.Name(), path))
+ if err != nil {
+ if os.IsNotExist(err) {
+ // Race. It was deleted between the Lstat and Open.
+ // Return nil per RemoveAll's docs.
+ return nil
+ }
+ return err
+ }
+
+ // Remove contents & return first error.
+ for {
+ names, err1 := fd.Readdirnames(100)
+ for _, name := range names {
+ err1 := RemoveAllRelative(path+string(os.PathSeparator)+name, root)
+ if err == nil {
+ err = err1
+ }
+ }
+ if err1 == io.EOF {
+ break
+ }
+ // If Readdirnames returned an error, use it.
+ if err == nil {
+ err = err1
+ }
+ if len(names) == 0 {
+ break
+ }
+ }
+ fd.Close()
+
+ // Remove directory.
+ err1 := RemoveRelative(path, root)
+ if err1 == nil || os.IsNotExist(err1) {
+ return nil
+ }
+ if err == nil {
+ err = err1
+ }
+ return err
+}
+
+// MkdirRelative creates a directory relative to a root, failing if any
+// intermediate path components are reparse points.
+func MkdirRelative(path string, root *os.File) error {
+ f, err := openRelativeInternal(
+ path,
+ root,
+ 0,
+ syscall.FILE_SHARE_READ|syscall.FILE_SHARE_WRITE|syscall.FILE_SHARE_DELETE,
+ FILE_CREATE,
+ FILE_DIRECTORY_FILE)
+ if err == nil {
+ f.Close()
+ } else {
+ err = &os.PathError{Op: "mkdir", Path: filepath.Join(root.Name(), path), Err: err}
+ }
+ return err
+}
+
+// LstatRelative performs a stat operation on a file relative to a root, failing
+// if any intermediate path components are reparse points.
+func LstatRelative(path string, root *os.File) (os.FileInfo, error) {
+ f, err := openRelativeInternal(
+ path,
+ root,
+ FILE_READ_ATTRIBUTES,
+ syscall.FILE_SHARE_READ|syscall.FILE_SHARE_WRITE|syscall.FILE_SHARE_DELETE,
+ FILE_OPEN,
+ FILE_OPEN_REPARSE_POINT)
+ if err != nil {
+ return nil, &os.PathError{Op: "stat", Path: filepath.Join(root.Name(), path), Err: err}
+ }
+ defer f.Close()
+ return f.Stat()
+}
+
+// EnsureNotReparsePointRelative validates that a given file (relative to a
+// root) and all intermediate path components are not a reparse points.
+func EnsureNotReparsePointRelative(path string, root *os.File) error {
+ // Perform an open with OBJ_DONT_REPARSE but without specifying FILE_OPEN_REPARSE_POINT.
+ f, err := OpenRelative(
+ path,
+ root,
+ 0,
+ syscall.FILE_SHARE_READ|syscall.FILE_SHARE_WRITE|syscall.FILE_SHARE_DELETE,
+ FILE_OPEN,
+ 0)
+ if err != nil {
+ return err
+ }
+ f.Close()
+ return nil
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/safefile/zsyscall_windows.go b/vendor/github.com/Microsoft/hcsshim/internal/safefile/zsyscall_windows.go
new file mode 100644
index 000000000..709b9d347
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/safefile/zsyscall_windows.go
@@ -0,0 +1,79 @@
+// Code generated by 'go generate'; DO NOT EDIT.
+
+package safefile
+
+import (
+ "syscall"
+ "unsafe"
+
+ "golang.org/x/sys/windows"
+)
+
+var _ unsafe.Pointer
+
+// Do the interface allocations only once for common
+// Errno values.
+const (
+ errnoERROR_IO_PENDING = 997
+)
+
+var (
+ errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING)
+)
+
+// errnoErr returns common boxed Errno values, to prevent
+// allocations at runtime.
+func errnoErr(e syscall.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 (
+ modntdll = windows.NewLazySystemDLL("ntdll.dll")
+ modkernel32 = windows.NewLazySystemDLL("kernel32.dll")
+
+ procNtCreateFile = modntdll.NewProc("NtCreateFile")
+ procNtSetInformationFile = modntdll.NewProc("NtSetInformationFile")
+ procRtlNtStatusToDosErrorNoTeb = modntdll.NewProc("RtlNtStatusToDosErrorNoTeb")
+ procLocalAlloc = modkernel32.NewProc("LocalAlloc")
+ procLocalFree = modkernel32.NewProc("LocalFree")
+)
+
+func ntCreateFile(handle *uintptr, accessMask uint32, oa *objectAttributes, iosb *ioStatusBlock, allocationSize *uint64, fileAttributes uint32, shareAccess uint32, createDisposition uint32, createOptions uint32, eaBuffer *byte, eaLength uint32) (status uint32) {
+ r0, _, _ := syscall.Syscall12(procNtCreateFile.Addr(), 11, uintptr(unsafe.Pointer(handle)), uintptr(accessMask), uintptr(unsafe.Pointer(oa)), uintptr(unsafe.Pointer(iosb)), uintptr(unsafe.Pointer(allocationSize)), uintptr(fileAttributes), uintptr(shareAccess), uintptr(createDisposition), uintptr(createOptions), uintptr(unsafe.Pointer(eaBuffer)), uintptr(eaLength), 0)
+ status = uint32(r0)
+ return
+}
+
+func ntSetInformationFile(handle uintptr, iosb *ioStatusBlock, information uintptr, length uint32, class uint32) (status uint32) {
+ r0, _, _ := syscall.Syscall6(procNtSetInformationFile.Addr(), 5, uintptr(handle), uintptr(unsafe.Pointer(iosb)), uintptr(information), uintptr(length), uintptr(class), 0)
+ status = uint32(r0)
+ return
+}
+
+func rtlNtStatusToDosError(status uint32) (winerr error) {
+ r0, _, _ := syscall.Syscall(procRtlNtStatusToDosErrorNoTeb.Addr(), 1, uintptr(status), 0, 0)
+ if r0 != 0 {
+ winerr = syscall.Errno(r0)
+ }
+ return
+}
+
+func localAlloc(flags uint32, size int) (ptr uintptr) {
+ r0, _, _ := syscall.Syscall(procLocalAlloc.Addr(), 2, uintptr(flags), uintptr(size), 0)
+ ptr = uintptr(r0)
+ return
+}
+
+func localFree(ptr uintptr) {
+ syscall.Syscall(procLocalFree.Addr(), 1, uintptr(ptr), 0, 0)
+ return
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema1/schema1.go b/vendor/github.com/Microsoft/hcsshim/internal/schema1/schema1.go
new file mode 100644
index 000000000..995433ace
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema1/schema1.go
@@ -0,0 +1,245 @@
+package schema1
+
+import (
+ "encoding/json"
+ "time"
+
+ "github.com/Microsoft/hcsshim/internal/schema2"
+)
+
+// ProcessConfig is used as both the input of Container.CreateProcess
+// and to convert the parameters to JSON for passing onto the HCS
+type ProcessConfig struct {
+ ApplicationName string `json:",omitempty"`
+ CommandLine string `json:",omitempty"`
+ CommandArgs []string `json:",omitempty"` // Used by Linux Containers on Windows
+ User string `json:",omitempty"`
+ WorkingDirectory string `json:",omitempty"`
+ Environment map[string]string `json:",omitempty"`
+ EmulateConsole bool `json:",omitempty"`
+ CreateStdInPipe bool `json:",omitempty"`
+ CreateStdOutPipe bool `json:",omitempty"`
+ CreateStdErrPipe bool `json:",omitempty"`
+ ConsoleSize [2]uint `json:",omitempty"`
+ CreateInUtilityVm bool `json:",omitempty"` // Used by Linux Containers on Windows
+ OCISpecification *json.RawMessage `json:",omitempty"` // Used by Linux Containers on Windows
+}
+
+type Layer struct {
+ ID string
+ Path string
+}
+
+type MappedDir struct {
+ HostPath string
+ ContainerPath string
+ ReadOnly bool
+ BandwidthMaximum uint64
+ IOPSMaximum uint64
+ CreateInUtilityVM bool
+ // LinuxMetadata - Support added in 1803/RS4+.
+ LinuxMetadata bool `json:",omitempty"`
+}
+
+type MappedPipe struct {
+ HostPath string
+ ContainerPipeName string
+}
+
+type HvRuntime struct {
+ ImagePath string `json:",omitempty"`
+ SkipTemplate bool `json:",omitempty"`
+ LinuxInitrdFile string `json:",omitempty"` // File under ImagePath on host containing an initrd image for starting a Linux utility VM
+ LinuxKernelFile string `json:",omitempty"` // File under ImagePath on host containing a kernel for starting a Linux utility VM
+ LinuxBootParameters string `json:",omitempty"` // Additional boot parameters for starting a Linux Utility VM in initrd mode
+ BootSource string `json:",omitempty"` // "Vhd" for Linux Utility VM booting from VHD
+ WritableBootSource bool `json:",omitempty"` // Linux Utility VM booting from VHD
+}
+
+type MappedVirtualDisk struct {
+ HostPath string `json:",omitempty"` // Path to VHD on the host
+ ContainerPath string // Platform-specific mount point path in the container
+ CreateInUtilityVM bool `json:",omitempty"`
+ ReadOnly bool `json:",omitempty"`
+ Cache string `json:",omitempty"` // "" (Unspecified); "Disabled"; "Enabled"; "Private"; "PrivateAllowSharing"
+ AttachOnly bool `json:",omitempty:`
+}
+
+// AssignedDevice represents a device that has been directly assigned to a container
+//
+// NOTE: Support added in RS5
+type AssignedDevice struct {
+ // InterfaceClassGUID of the device to assign to container.
+ InterfaceClassGUID string `json:"InterfaceClassGuid,omitempty"`
+}
+
+// ContainerConfig is used as both the input of CreateContainer
+// and to convert the parameters to JSON for passing onto the HCS
+type ContainerConfig struct {
+ SystemType string // HCS requires this to be hard-coded to "Container"
+ Name string // Name of the container. We use the docker ID.
+ Owner string `json:",omitempty"` // The management platform that created this container
+ VolumePath string `json:",omitempty"` // Windows volume path for scratch space. Used by Windows Server Containers only. Format \\?\\Volume{GUID}
+ IgnoreFlushesDuringBoot bool `json:",omitempty"` // Optimization hint for container startup in Windows
+ LayerFolderPath string `json:",omitempty"` // Where the layer folders are located. Used by Windows Server Containers only. Format %root%\windowsfilter\containerID
+ Layers []Layer // List of storage layers. Required for Windows Server and Hyper-V Containers. Format ID=GUID;Path=%root%\windowsfilter\layerID
+ Credentials string `json:",omitempty"` // Credentials information
+ ProcessorCount uint32 `json:",omitempty"` // Number of processors to assign to the container.
+ ProcessorWeight uint64 `json:",omitempty"` // CPU shares (relative weight to other containers with cpu shares). Range is from 1 to 10000. A value of 0 results in default shares.
+ ProcessorMaximum int64 `json:",omitempty"` // Specifies the portion of processor cycles that this container can use as a percentage times 100. Range is from 1 to 10000. A value of 0 results in no limit.
+ StorageIOPSMaximum uint64 `json:",omitempty"` // Maximum Storage IOPS
+ StorageBandwidthMaximum uint64 `json:",omitempty"` // Maximum Storage Bandwidth in bytes per second
+ StorageSandboxSize uint64 `json:",omitempty"` // Size in bytes that the container system drive should be expanded to if smaller
+ MemoryMaximumInMB int64 `json:",omitempty"` // Maximum memory available to the container in Megabytes
+ HostName string `json:",omitempty"` // Hostname
+ MappedDirectories []MappedDir `json:",omitempty"` // List of mapped directories (volumes/mounts)
+ MappedPipes []MappedPipe `json:",omitempty"` // List of mapped Windows named pipes
+ HvPartition bool // True if it a Hyper-V Container
+ NetworkSharedContainerName string `json:",omitempty"` // Name (ID) of the container that we will share the network stack with.
+ EndpointList []string `json:",omitempty"` // List of networking endpoints to be attached to container
+ HvRuntime *HvRuntime `json:",omitempty"` // Hyper-V container settings. Used by Hyper-V containers only. Format ImagePath=%root%\BaseLayerID\UtilityVM
+ Servicing bool `json:",omitempty"` // True if this container is for servicing
+ AllowUnqualifiedDNSQuery bool `json:",omitempty"` // True to allow unqualified DNS name resolution
+ DNSSearchList string `json:",omitempty"` // Comma seperated list of DNS suffixes to use for name resolution
+ ContainerType string `json:",omitempty"` // "Linux" for Linux containers on Windows. Omitted otherwise.
+ TerminateOnLastHandleClosed bool `json:",omitempty"` // Should HCS terminate the container once all handles have been closed
+ MappedVirtualDisks []MappedVirtualDisk `json:",omitempty"` // Array of virtual disks to mount at start
+ AssignedDevices []AssignedDevice `json:",omitempty"` // Array of devices to assign. NOTE: Support added in RS5
+}
+
+type ComputeSystemQuery struct {
+ IDs []string `json:"Ids,omitempty"`
+ Types []string `json:",omitempty"`
+ Names []string `json:",omitempty"`
+ Owners []string `json:",omitempty"`
+}
+
+type PropertyType string
+
+const (
+ PropertyTypeStatistics PropertyType = "Statistics" // V1 and V2
+ PropertyTypeProcessList = "ProcessList" // V1 and V2
+ PropertyTypeMappedVirtualDisk = "MappedVirtualDisk" // Not supported in V2 schema call
+ PropertyTypeGuestConnection = "GuestConnection" // V1 and V2. Nil return from HCS before RS5
+)
+
+type PropertyQuery struct {
+ PropertyTypes []PropertyType `json:",omitempty"`
+}
+
+// ContainerProperties holds the properties for a container and the processes running in that container
+type ContainerProperties struct {
+ ID string `json:"Id"`
+ State string
+ Name string
+ SystemType string
+ Owner string
+ SiloGUID string `json:"SiloGuid,omitempty"`
+ RuntimeID string `json:"RuntimeId,omitempty"`
+ IsRuntimeTemplate bool `json:",omitempty"`
+ RuntimeImagePath string `json:",omitempty"`
+ Stopped bool `json:",omitempty"`
+ ExitType string `json:",omitempty"`
+ AreUpdatesPending bool `json:",omitempty"`
+ ObRoot string `json:",omitempty"`
+ Statistics Statistics `json:",omitempty"`
+ ProcessList []ProcessListItem `json:",omitempty"`
+ MappedVirtualDiskControllers map[int]MappedVirtualDiskController `json:",omitempty"`
+ GuestConnectionInfo GuestConnectionInfo `json:",omitempty"`
+}
+
+// MemoryStats holds the memory statistics for a container
+type MemoryStats struct {
+ UsageCommitBytes uint64 `json:"MemoryUsageCommitBytes,omitempty"`
+ UsageCommitPeakBytes uint64 `json:"MemoryUsageCommitPeakBytes,omitempty"`
+ UsagePrivateWorkingSetBytes uint64 `json:"MemoryUsagePrivateWorkingSetBytes,omitempty"`
+}
+
+// ProcessorStats holds the processor statistics for a container
+type ProcessorStats struct {
+ TotalRuntime100ns uint64 `json:",omitempty"`
+ RuntimeUser100ns uint64 `json:",omitempty"`
+ RuntimeKernel100ns uint64 `json:",omitempty"`
+}
+
+// StorageStats holds the storage statistics for a container
+type StorageStats struct {
+ ReadCountNormalized uint64 `json:",omitempty"`
+ ReadSizeBytes uint64 `json:",omitempty"`
+ WriteCountNormalized uint64 `json:",omitempty"`
+ WriteSizeBytes uint64 `json:",omitempty"`
+}
+
+// NetworkStats holds the network statistics for a container
+type NetworkStats struct {
+ BytesReceived uint64 `json:",omitempty"`
+ BytesSent uint64 `json:",omitempty"`
+ PacketsReceived uint64 `json:",omitempty"`
+ PacketsSent uint64 `json:",omitempty"`
+ DroppedPacketsIncoming uint64 `json:",omitempty"`
+ DroppedPacketsOutgoing uint64 `json:",omitempty"`
+ EndpointId string `json:",omitempty"`
+ InstanceId string `json:",omitempty"`
+}
+
+// Statistics is the structure returned by a statistics call on a container
+type Statistics struct {
+ Timestamp time.Time `json:",omitempty"`
+ ContainerStartTime time.Time `json:",omitempty"`
+ Uptime100ns uint64 `json:",omitempty"`
+ Memory MemoryStats `json:",omitempty"`
+ Processor ProcessorStats `json:",omitempty"`
+ Storage StorageStats `json:",omitempty"`
+ Network []NetworkStats `json:",omitempty"`
+}
+
+// ProcessList is the structure of an item returned by a ProcessList call on a container
+type ProcessListItem struct {
+ CreateTimestamp time.Time `json:",omitempty"`
+ ImageName string `json:",omitempty"`
+ KernelTime100ns uint64 `json:",omitempty"`
+ MemoryCommitBytes uint64 `json:",omitempty"`
+ MemoryWorkingSetPrivateBytes uint64 `json:",omitempty"`
+ MemoryWorkingSetSharedBytes uint64 `json:",omitempty"`
+ ProcessId uint32 `json:",omitempty"`
+ UserTime100ns uint64 `json:",omitempty"`
+}
+
+// MappedVirtualDiskController is the structure of an item returned by a MappedVirtualDiskList call on a container
+type MappedVirtualDiskController struct {
+ MappedVirtualDisks map[int]MappedVirtualDisk `json:",omitempty"`
+}
+
+// GuestDefinedCapabilities is part of the GuestConnectionInfo returned by a GuestConnection call on a utility VM
+type GuestDefinedCapabilities struct {
+ NamespaceAddRequestSupported bool `json:",omitempty"`
+ SignalProcessSupported bool `json:",omitempty"`
+}
+
+// GuestConnectionInfo is the structure of an iterm return by a GuestConnection call on a utility VM
+type GuestConnectionInfo struct {
+ SupportedSchemaVersions []hcsschema.Version `json:",omitempty"`
+ ProtocolVersion uint32 `json:",omitempty"`
+ GuestDefinedCapabilities GuestDefinedCapabilities `json:",omitempty"`
+}
+
+// Type of Request Support in ModifySystem
+type RequestType string
+
+// Type of Resource Support in ModifySystem
+type ResourceType string
+
+// RequestType const
+const (
+ Add RequestType = "Add"
+ Remove RequestType = "Remove"
+ Network ResourceType = "Network"
+)
+
+// ResourceModificationRequestResponse is the structure used to send request to the container to modify the system
+// Supported resource types are Network and Request Types are Add/Remove
+type ResourceModificationRequestResponse struct {
+ Resource ResourceType `json:"ResourceType"`
+ Data interface{} `json:"Settings"`
+ Request RequestType `json:"RequestType,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/attachment.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/attachment.go
new file mode 100644
index 000000000..09456cbc2
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/attachment.go
@@ -0,0 +1,31 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type Attachment struct {
+
+ Type_ string `json:"Type,omitempty"`
+
+ Path string `json:"Path,omitempty"`
+
+ IgnoreFlushes bool `json:"IgnoreFlushes,omitempty"`
+
+ CachingMode string `json:"CachingMode,omitempty"`
+
+ NoWriteHardening bool `json:"NoWriteHardening,omitempty"`
+
+ DisableExpansionOptimization bool `json:"DisableExpansionOptimization,omitempty"`
+
+ IgnoreRelativeLocator bool `json:"IgnoreRelativeLocator,omitempty"`
+
+ CaptureIoAttributionContext bool `json:"CaptureIoAttributionContext,omitempty"`
+
+ ReadOnly bool `json:"ReadOnly,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/battery.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/battery.go
new file mode 100644
index 000000000..ecbbed4c2
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/battery.go
@@ -0,0 +1,13 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type Battery struct {
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/cache_query_stats_response.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/cache_query_stats_response.go
new file mode 100644
index 000000000..243779eab
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/cache_query_stats_response.go
@@ -0,0 +1,19 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type CacheQueryStatsResponse struct {
+
+ L3OccupancyBytes int32 `json:"L3OccupancyBytes,omitempty"`
+
+ L3TotalBwBytes int32 `json:"L3TotalBwBytes,omitempty"`
+
+ L3LocalBwBytes int32 `json:"L3LocalBwBytes,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/chipset.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/chipset.go
new file mode 100644
index 000000000..ca75277a3
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/chipset.go
@@ -0,0 +1,27 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type Chipset struct {
+ Uefi *Uefi `json:"Uefi,omitempty"`
+
+ IsNumLockDisabled bool `json:"IsNumLockDisabled,omitempty"`
+
+ BaseBoardSerialNumber string `json:"BaseBoardSerialNumber,omitempty"`
+
+ ChassisSerialNumber string `json:"ChassisSerialNumber,omitempty"`
+
+ ChassisAssetTag string `json:"ChassisAssetTag,omitempty"`
+
+ UseUtc bool `json:"UseUtc,omitempty"`
+
+ // LinuxKernelDirect - Added in v2.2 Builds >=181117
+ LinuxKernelDirect *LinuxKernelDirect `json:"LinuxKernelDirect,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/close_handle.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/close_handle.go
new file mode 100644
index 000000000..88f01707a
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/close_handle.go
@@ -0,0 +1,15 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type CloseHandle struct {
+
+ Handle string `json:"Handle,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/com_port.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/com_port.go
new file mode 100644
index 000000000..c665be3d5
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/com_port.go
@@ -0,0 +1,18 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+// ComPort specifies the named pipe that will be used for the port, with empty string indicating a disconnected port.
+type ComPort struct {
+
+ NamedPipe string `json:"NamedPipe,omitempty"`
+
+ OptimizeForDebugger bool `json:"OptimizeForDebugger,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/compute_system.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/compute_system.go
new file mode 100644
index 000000000..85785d285
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/compute_system.go
@@ -0,0 +1,27 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type ComputeSystem struct {
+
+ Owner string `json:"Owner,omitempty"`
+
+ SchemaVersion *Version `json:"SchemaVersion,omitempty"`
+
+ HostingSystemId string `json:"HostingSystemId,omitempty"`
+
+ HostedSystem *HostedSystem `json:"HostedSystem,omitempty"`
+
+ Container *Container `json:"Container,omitempty"`
+
+ VirtualMachine *VirtualMachine `json:"VirtualMachine,omitempty"`
+
+ ShouldTerminateOnLastHandleClosed bool `json:"ShouldTerminateOnLastHandleClosed,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/configuration.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/configuration.go
new file mode 100644
index 000000000..1a47db7d9
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/configuration.go
@@ -0,0 +1,72 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+import (
+ "net/http"
+)
+
+// contextKeys are used to identify the type of value in the context.
+// Since these are string, it is possible to get a short description of the
+// context key for logging and debugging using key.String().
+
+type contextKey string
+
+func (c contextKey) String() string {
+ return "auth " + string(c)
+}
+
+var (
+ // ContextOAuth2 takes a oauth2.TokenSource as authentication for the request.
+ ContextOAuth2 = contextKey("token")
+
+ // ContextBasicAuth takes BasicAuth as authentication for the request.
+ ContextBasicAuth = contextKey("basic")
+
+ // ContextAccessToken takes a string oauth2 access token as authentication for the request.
+ ContextAccessToken = contextKey("accesstoken")
+
+ // ContextAPIKey takes an APIKey as authentication for the request
+ ContextAPIKey = contextKey("apikey")
+)
+
+// BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth
+type BasicAuth struct {
+ UserName string `json:"userName,omitempty"`
+ Password string `json:"password,omitempty"`
+}
+
+// APIKey provides API key based authentication to a request passed via context using ContextAPIKey
+type APIKey struct {
+ Key string
+ Prefix string
+}
+
+type Configuration struct {
+ BasePath string `json:"basePath,omitempty"`
+ Host string `json:"host,omitempty"`
+ Scheme string `json:"scheme,omitempty"`
+ DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
+ UserAgent string `json:"userAgent,omitempty"`
+ HTTPClient *http.Client
+}
+
+func NewConfiguration() *Configuration {
+ cfg := &Configuration{
+ BasePath: "https://localhost",
+ DefaultHeader: make(map[string]string),
+ UserAgent: "Swagger-Codegen/2.1.0/go",
+ }
+ return cfg
+}
+
+func (c *Configuration) AddDefaultHeader(key string, value string) {
+ c.DefaultHeader[key] = value
+} \ No newline at end of file
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/console_size.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/console_size.go
new file mode 100644
index 000000000..adbe07fe5
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/console_size.go
@@ -0,0 +1,17 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type ConsoleSize struct {
+
+ Height int32 `json:"Height,omitempty"`
+
+ Width int32 `json:"Width,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/container.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/container.go
new file mode 100644
index 000000000..17dce28bc
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/container.go
@@ -0,0 +1,35 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type Container struct {
+
+ GuestOs *GuestOs `json:"GuestOs,omitempty"`
+
+ Storage *Storage `json:"Storage,omitempty"`
+
+ MappedDirectories []MappedDirectory `json:"MappedDirectories,omitempty"`
+
+ MappedPipes []MappedPipe `json:"MappedPipes,omitempty"`
+
+ Memory *Memory `json:"Memory,omitempty"`
+
+ Processor *Processor `json:"Processor,omitempty"`
+
+ Networking *Networking `json:"Networking,omitempty"`
+
+ HvSocket *HvSocket `json:"HvSocket,omitempty"`
+
+ ContainerCredentialGuard *ContainerCredentialGuardState `json:"ContainerCredentialGuard,omitempty"`
+
+ RegistryChanges *RegistryChanges `json:"RegistryChanges,omitempty"`
+
+ AssignedDevices []Device `json:"AssignedDevices,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/container_credential_guard_state.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/container_credential_guard_state.go
new file mode 100644
index 000000000..0f8f64437
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/container_credential_guard_state.go
@@ -0,0 +1,25 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type ContainerCredentialGuardState struct {
+
+ // Authentication cookie for calls to a Container Credential Guard instance.
+ Cookie string `json:"Cookie,omitempty"`
+
+ // Name of the RPC endpoint of the Container Credential Guard instance.
+ RpcEndpoint string `json:"RpcEndpoint,omitempty"`
+
+ // Transport used for the configured Container Credential Guard instance.
+ Transport string `json:"Transport,omitempty"`
+
+ // Credential spec used for the configured Container Credential Guard instance.
+ CredentialSpec string `json:"CredentialSpec,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/container_memory_information.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/container_memory_information.go
new file mode 100644
index 000000000..754797e21
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/container_memory_information.go
@@ -0,0 +1,26 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+// memory usage as viewed from within the container
+type ContainerMemoryInformation struct {
+
+ TotalPhysicalBytes int32 `json:"TotalPhysicalBytes,omitempty"`
+
+ TotalUsage int32 `json:"TotalUsage,omitempty"`
+
+ CommittedBytes int32 `json:"CommittedBytes,omitempty"`
+
+ SharedCommittedBytes int32 `json:"SharedCommittedBytes,omitempty"`
+
+ CommitLimitBytes int32 `json:"CommitLimitBytes,omitempty"`
+
+ PeakCommitmentBytes int32 `json:"PeakCommitmentBytes,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/device.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/device.go
new file mode 100644
index 000000000..ca319bbbc
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/device.go
@@ -0,0 +1,16 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type Device struct {
+
+ // The interface class guid of the device to assign to container.
+ InterfaceClassGuid string `json:"InterfaceClassGuid,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/devices.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/devices.go
new file mode 100644
index 000000000..b2191c571
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/devices.go
@@ -0,0 +1,43 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type Devices struct {
+
+ ComPorts map[string]ComPort `json:"ComPorts,omitempty"`
+
+ Scsi map[string]Scsi `json:"Scsi,omitempty"`
+
+ VirtualPMem *VirtualPMemController `json:"VirtualPMem,omitempty"`
+
+ NetworkAdapters map[string]NetworkAdapter `json:"NetworkAdapters,omitempty"`
+
+ VideoMonitor *VideoMonitor `json:"VideoMonitor,omitempty"`
+
+ Keyboard *Keyboard `json:"Keyboard,omitempty"`
+
+ Mouse *Mouse `json:"Mouse,omitempty"`
+
+ HvSocket *HvSocket2 `json:"HvSocket,omitempty"`
+
+ EnhancedModeVideo *EnhancedModeVideo `json:"EnhancedModeVideo,omitempty"`
+
+ GuestCrashReporting *GuestCrashReporting `json:"GuestCrashReporting,omitempty"`
+
+ VirtualSmb *VirtualSmb `json:"VirtualSmb,omitempty"`
+
+ Plan9 *Plan9 `json:"Plan9,omitempty"`
+
+ Battery *Battery `json:"Battery,omitempty"`
+
+ FlexibleIov map[string]FlexibleIoDevice `json:"FlexibleIov,omitempty"`
+
+ SharedMemory *SharedMemoryConfiguration `json:"SharedMemory,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/enhanced_mode_video.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/enhanced_mode_video.go
new file mode 100644
index 000000000..4fe592f71
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/enhanced_mode_video.go
@@ -0,0 +1,15 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type EnhancedModeVideo struct {
+
+ ConnectionOptions *RdpConnectionOptions `json:"ConnectionOptions,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/flexible_io_device.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/flexible_io_device.go
new file mode 100644
index 000000000..51011afe4
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/flexible_io_device.go
@@ -0,0 +1,19 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type FlexibleIoDevice struct {
+
+ EmulatorId string `json:"EmulatorId,omitempty"`
+
+ HostingModel string `json:"HostingModel,omitempty"`
+
+ Configuration []string `json:"Configuration,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/guest_connection.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/guest_connection.go
new file mode 100644
index 000000000..7db29495b
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/guest_connection.go
@@ -0,0 +1,19 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type GuestConnection struct {
+
+ // Use Vsock rather than Hyper-V sockets to communicate with the guest service.
+ UseVsock bool `json:"UseVsock,omitempty"`
+
+ // Don't disconnect the guest connection when pausing the virtual machine.
+ UseConnectedSuspend bool `json:"UseConnectedSuspend,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/guest_connection_info.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/guest_connection_info.go
new file mode 100644
index 000000000..8a369bab7
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/guest_connection_info.go
@@ -0,0 +1,21 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+// Information about the guest.
+type GuestConnectionInfo struct {
+
+ // Each schema version x.y stands for the range of versions a.b where a==x and b<=y. This list comes from the SupportedSchemaVersions field in GcsCapabilities.
+ SupportedSchemaVersions []Version `json:"SupportedSchemaVersions,omitempty"`
+
+ ProtocolVersion int32 `json:"ProtocolVersion,omitempty"`
+
+ GuestDefinedCapabilities *interface{} `json:"GuestDefinedCapabilities,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/guest_crash_reporting.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/guest_crash_reporting.go
new file mode 100644
index 000000000..c5fa76735
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/guest_crash_reporting.go
@@ -0,0 +1,15 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type GuestCrashReporting struct {
+
+ WindowsCrashSettings *WindowsCrashReporting `json:"WindowsCrashSettings,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/guest_os.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/guest_os.go
new file mode 100644
index 000000000..c708fc7c3
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/guest_os.go
@@ -0,0 +1,15 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type GuestOs struct {
+
+ HostName string `json:"HostName,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/guest_state.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/guest_state.go
new file mode 100644
index 000000000..ef1eec886
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/guest_state.go
@@ -0,0 +1,22 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type GuestState struct {
+
+ // The path to an existing file uses for persistent guest state storage. An empty string indicates the system should initialize new transient, in-memory guest state.
+ GuestStateFilePath string `json:"GuestStateFilePath,omitempty"`
+
+ // The path to an existing file for persistent runtime state storage. An empty string indicates the system should initialize new transient, in-memory runtime state.
+ RuntimeStateFilePath string `json:"RuntimeStateFilePath,omitempty"`
+
+ // If true, the guest state and runtime state files will be used as templates to populate transient, in-memory state instead of using the files as persistent backing store.
+ ForceTransientState bool `json:"ForceTransientState,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/hosted_system.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/hosted_system.go
new file mode 100644
index 000000000..0797584c5
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/hosted_system.go
@@ -0,0 +1,17 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type HostedSystem struct {
+
+ SchemaVersion *Version `json:"SchemaVersion,omitempty"`
+
+ Container *Container `json:"Container,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/hv_socket.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/hv_socket.go
new file mode 100644
index 000000000..ef9ffb8dd
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/hv_socket.go
@@ -0,0 +1,17 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type HvSocket struct {
+
+ Config *HvSocketSystemConfig `json:"Config,omitempty"`
+
+ EnablePowerShellDirect bool `json:"EnablePowerShellDirect,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/hv_socket_2.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/hv_socket_2.go
new file mode 100644
index 000000000..a19ba15c1
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/hv_socket_2.go
@@ -0,0 +1,16 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+// HvSocket configuration for a VM
+type HvSocket2 struct {
+
+ HvSocketConfig *HvSocketSystemConfig `json:"HvSocketConfig,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/hv_socket_service_config.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/hv_socket_service_config.go
new file mode 100644
index 000000000..a848e91e6
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/hv_socket_service_config.go
@@ -0,0 +1,22 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type HvSocketServiceConfig struct {
+
+ // SDDL string that HvSocket will check before allowing a host process to bind to this specific service. If not specified, defaults to the system DefaultBindSecurityDescriptor, defined in HvSocketSystemWpConfig in V1.
+ BindSecurityDescriptor string `json:"BindSecurityDescriptor,omitempty"`
+
+ // SDDL string that HvSocket will check before allowing a host process to connect to this specific service. If not specified, defaults to the system DefaultConnectSecurityDescriptor, defined in HvSocketSystemWpConfig in V1.
+ ConnectSecurityDescriptor string `json:"ConnectSecurityDescriptor,omitempty"`
+
+ // If true, HvSocket will process wildcard binds for this service/system combination. Wildcard binds are secured in the registry at SOFTWARE/Microsoft/Windows NT/CurrentVersion/Virtualization/HvSocket/WildcardDescriptors
+ AllowWildcardBinds bool `json:"AllowWildcardBinds,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/hv_socket_system_config.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/hv_socket_system_config.go
new file mode 100644
index 000000000..69f4f9d39
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/hv_socket_system_config.go
@@ -0,0 +1,22 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+// This is the HCS Schema version of the HvSocket configuration. The VMWP version is located in Config.Devices.IC in V1.
+type HvSocketSystemConfig struct {
+
+ // SDDL string that HvSocket will check before allowing a host process to bind to an unlisted service for this specific container/VM (not wildcard binds).
+ DefaultBindSecurityDescriptor string `json:"DefaultBindSecurityDescriptor,omitempty"`
+
+ // SDDL string that HvSocket will check before allowing a host process to connect to an unlisted service in the VM/container.
+ DefaultConnectSecurityDescriptor string `json:"DefaultConnectSecurityDescriptor,omitempty"`
+
+ ServiceTable map[string]HvSocketServiceConfig `json:"ServiceTable,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/keyboard.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/keyboard.go
new file mode 100644
index 000000000..3d3fa3b1c
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/keyboard.go
@@ -0,0 +1,13 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type Keyboard struct {
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/layer.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/layer.go
new file mode 100644
index 000000000..b63b8ef12
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/layer.go
@@ -0,0 +1,22 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type Layer struct {
+
+ Id string `json:"Id,omitempty"`
+
+ Path string `json:"Path,omitempty"`
+
+ PathType string `json:"PathType,omitempty"`
+
+ // Unspecified defaults to Enabled
+ Cache string `json:"Cache,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/linux_kernel_direct.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/linux_kernel_direct.go
new file mode 100644
index 000000000..0ab6c280f
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/linux_kernel_direct.go
@@ -0,0 +1,18 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.2
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type LinuxKernelDirect struct {
+ KernelFilePath string `json:"KernelFilePath,omitempty"`
+
+ InitRdPath string `json:"InitRdPath,omitempty"`
+
+ KernelCmdLine string `json:"KernelCmdLine,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/mapped_directory.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/mapped_directory.go
new file mode 100644
index 000000000..a823a6d3b
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/mapped_directory.go
@@ -0,0 +1,21 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type MappedDirectory struct {
+
+ HostPath string `json:"HostPath,omitempty"`
+
+ HostPathType string `json:"HostPathType,omitempty"`
+
+ ContainerPath string `json:"ContainerPath,omitempty"`
+
+ ReadOnly bool `json:"ReadOnly,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/mapped_pipe.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/mapped_pipe.go
new file mode 100644
index 000000000..2d1d2604a
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/mapped_pipe.go
@@ -0,0 +1,19 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type MappedPipe struct {
+
+ ContainerPipeName string `json:"ContainerPipeName,omitempty"`
+
+ HostPath string `json:"HostPath,omitempty"`
+
+ HostPathType string `json:"HostPathType,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/memory.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/memory.go
new file mode 100644
index 000000000..e1d135a3a
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/memory.go
@@ -0,0 +1,15 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type Memory struct {
+
+ SizeInMB int32 `json:"SizeInMB,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/memory_2.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/memory_2.go
new file mode 100644
index 000000000..27d0b8c48
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/memory_2.go
@@ -0,0 +1,25 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type Memory2 struct {
+ SizeInMB int32 `json:"SizeInMB,omitempty"`
+
+ AllowOvercommit bool `json:"AllowOvercommit,omitempty"`
+
+ EnableHotHint bool `json:"EnableHotHint,omitempty"`
+
+ EnableColdHint bool `json:"EnableColdHint,omitempty"`
+
+ EnableEpf bool `json:"EnableEpf,omitempty"`
+
+ // EnableDeferredCommit is private in the schema. If regenerated need to add back.
+ EnableDeferredCommit bool `json:"EnableDeferredCommit,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/memory_information_for_vm.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/memory_information_for_vm.go
new file mode 100644
index 000000000..bdd87dffd
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/memory_information_for_vm.go
@@ -0,0 +1,19 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type MemoryInformationForVm struct {
+
+ VirtualNodeCount int32 `json:"VirtualNodeCount,omitempty"`
+
+ VirtualMachineMemory *VmMemory `json:"VirtualMachineMemory,omitempty"`
+
+ VirtualNodes []VirtualNodeInfo `json:"VirtualNodes,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/memory_stats.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/memory_stats.go
new file mode 100644
index 000000000..6214970f6
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/memory_stats.go
@@ -0,0 +1,20 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+// Memory runtime statistics
+type MemoryStats struct {
+
+ MemoryUsageCommitBytes int32 `json:"MemoryUsageCommitBytes,omitempty"`
+
+ MemoryUsageCommitPeakBytes int32 `json:"MemoryUsageCommitPeakBytes,omitempty"`
+
+ MemoryUsagePrivateWorkingSetBytes int32 `json:"MemoryUsagePrivateWorkingSetBytes,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/modify_setting_request.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/modify_setting_request.go
new file mode 100644
index 000000000..d29455a3e
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/modify_setting_request.go
@@ -0,0 +1,20 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type ModifySettingRequest struct {
+ ResourcePath string `json:"ResourcePath,omitempty"`
+
+ RequestType string `json:"RequestType,omitempty"`
+
+ Settings interface{} `json:"Settings,omitempty"` // NOTE: Swagger generated as *interface{}. Locally updated
+
+ GuestRequest interface{} `json:"GuestRequest,omitempty"` // NOTE: Swagger generated as *interface{}. Locally updated
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/mouse.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/mouse.go
new file mode 100644
index 000000000..ccf8b938f
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/mouse.go
@@ -0,0 +1,13 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type Mouse struct {
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/network_adapter.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/network_adapter.go
new file mode 100644
index 000000000..c586f66c2
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/network_adapter.go
@@ -0,0 +1,17 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type NetworkAdapter struct {
+
+ EndpointId string `json:"EndpointId,omitempty"`
+
+ MacAddress string `json:"MacAddress,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/networking.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/networking.go
new file mode 100644
index 000000000..12c47827c
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/networking.go
@@ -0,0 +1,24 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type Networking struct {
+
+ AllowUnqualifiedDnsQuery bool `json:"AllowUnqualifiedDnsQuery,omitempty"`
+
+ DnsSearchList string `json:"DnsSearchList,omitempty"`
+
+ NetworkSharedContainerName string `json:"NetworkSharedContainerName,omitempty"`
+
+ // Guid in windows; string in linux
+ Namespace string `json:"Namespace,omitempty"`
+
+ NetworkAdapters []string `json:"NetworkAdapters,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/pause_notification.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/pause_notification.go
new file mode 100644
index 000000000..1cd70d179
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/pause_notification.go
@@ -0,0 +1,16 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+// Notification data that is indicated to components running in the Virtual Machine.
+type PauseNotification struct {
+
+ Reason string `json:"Reason,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/pause_options.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/pause_options.go
new file mode 100644
index 000000000..780a5cae2
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/pause_options.go
@@ -0,0 +1,18 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+// Options for HcsPauseComputeSystem
+type PauseOptions struct {
+
+ SuspensionLevel string `json:"SuspensionLevel,omitempty"`
+
+ HostedNotification *PauseNotification `json:"HostedNotification,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/plan9.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/plan9.go
new file mode 100644
index 000000000..705c677e1
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/plan9.go
@@ -0,0 +1,15 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type Plan9 struct {
+
+ Shares []Plan9Share `json:"Shares,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/plan9_share.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/plan9_share.go
new file mode 100644
index 000000000..b2bc58b83
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/plan9_share.go
@@ -0,0 +1,26 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type Plan9Share struct {
+
+ Name string `json:"Name,omitempty"`
+
+ // The name by which the guest operation system can access this share, via the aname parameter in the Plan9 protocol.
+ AccessName string `json:"AccessName,omitempty"`
+
+ Path string `json:"Path,omitempty"`
+
+ Port int32 `json:"Port,omitempty"`
+
+ ReadOnly bool `json:"ReadOnly,omitempty"`
+
+ UseShareRootIdentity bool `json:"UseShareRootIdentity,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/process_details.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/process_details.go
new file mode 100644
index 000000000..63e0b7f8f
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/process_details.go
@@ -0,0 +1,34 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+import (
+ "time"
+)
+
+// Information about a process running in a container
+type ProcessDetails struct {
+
+ ProcessId int32 `json:"ProcessId,omitempty"`
+
+ ImageName string `json:"ImageName,omitempty"`
+
+ CreateTimestamp time.Time `json:"CreateTimestamp,omitempty"`
+
+ UserTime100ns int32 `json:"UserTime100ns,omitempty"`
+
+ KernelTime100ns int32 `json:"KernelTime100ns,omitempty"`
+
+ MemoryCommitBytes int32 `json:"MemoryCommitBytes,omitempty"`
+
+ MemoryWorkingSetPrivateBytes int32 `json:"MemoryWorkingSetPrivateBytes,omitempty"`
+
+ MemoryWorkingSetSharedBytes int32 `json:"MemoryWorkingSetSharedBytes,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/process_modify_request.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/process_modify_request.go
new file mode 100644
index 000000000..29bc2e3d0
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/process_modify_request.go
@@ -0,0 +1,20 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+// Passed to HcsRpc_ModifyProcess
+type ProcessModifyRequest struct {
+
+ Operation string `json:"Operation,omitempty"`
+
+ ConsoleSize *ConsoleSize `json:"ConsoleSize,omitempty"`
+
+ CloseHandle *CloseHandle `json:"CloseHandle,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/process_parameters.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/process_parameters.go
new file mode 100644
index 000000000..470c55734
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/process_parameters.go
@@ -0,0 +1,47 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type ProcessParameters struct {
+
+ ApplicationName string `json:"ApplicationName,omitempty"`
+
+ CommandLine string `json:"CommandLine,omitempty"`
+
+ // optional alternative to CommandLine, currently only supported by Linux GCS
+ CommandArgs []string `json:"CommandArgs,omitempty"`
+
+ User string `json:"User,omitempty"`
+
+ WorkingDirectory string `json:"WorkingDirectory,omitempty"`
+
+ Environment map[string]string `json:"Environment,omitempty"`
+
+ // if set, will run as low-privilege process
+ RestrictedToken bool `json:"RestrictedToken,omitempty"`
+
+ // if set, ignore StdErrPipe
+ EmulateConsole bool `json:"EmulateConsole,omitempty"`
+
+ CreateStdInPipe bool `json:"CreateStdInPipe,omitempty"`
+
+ CreateStdOutPipe bool `json:"CreateStdOutPipe,omitempty"`
+
+ CreateStdErrPipe bool `json:"CreateStdErrPipe,omitempty"`
+
+ // height then width
+ ConsoleSize []int32 `json:"ConsoleSize,omitempty"`
+
+ // if set, find an existing session for the user and create the process in it
+ UseExistingLogin bool `json:"UseExistingLogin,omitempty"`
+
+ // if set, use the legacy console instead of conhost
+ UseLegacyConsole bool `json:"UseLegacyConsole,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/process_status.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/process_status.go
new file mode 100644
index 000000000..20793d150
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/process_status.go
@@ -0,0 +1,22 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+// Status of a process running in a container
+type ProcessStatus struct {
+
+ ProcessId int32 `json:"ProcessId,omitempty"`
+
+ Exited bool `json:"Exited,omitempty"`
+
+ ExitCode int32 `json:"ExitCode,omitempty"`
+
+ LastWaitResult int32 `json:"LastWaitResult,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/processor.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/processor.go
new file mode 100644
index 000000000..7a60b0245
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/processor.go
@@ -0,0 +1,19 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type Processor struct {
+
+ Count int32 `json:"Count,omitempty"`
+
+ Maximum int32 `json:"Maximum,omitempty"`
+
+ Weight int32 `json:"Weight,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/processor_2.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/processor_2.go
new file mode 100644
index 000000000..40d3e7356
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/processor_2.go
@@ -0,0 +1,21 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type Processor2 struct {
+
+ Count int32 `json:"Count,omitempty"`
+
+ Limit int32 `json:"Limit,omitempty"`
+
+ Weight int32 `json:"Weight,omitempty"`
+
+ ExposeVirtualizationExtensions bool `json:"ExposeVirtualizationExtensions,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/processor_stats.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/processor_stats.go
new file mode 100644
index 000000000..9d3b77e57
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/processor_stats.go
@@ -0,0 +1,20 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+// CPU runtime statistics
+type ProcessorStats struct {
+
+ TotalRuntime100ns int32 `json:"TotalRuntime100ns,omitempty"`
+
+ RuntimeUser100ns int32 `json:"RuntimeUser100ns,omitempty"`
+
+ RuntimeKernel100ns int32 `json:"RuntimeKernel100ns,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/properties.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/properties.go
new file mode 100644
index 000000000..6db2a48f6
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/properties.go
@@ -0,0 +1,47 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type Properties struct {
+
+ Id string `json:"Id,omitempty"`
+
+ SystemType string `json:"SystemType,omitempty"`
+
+ RuntimeOsType string `json:"RuntimeOsType,omitempty"`
+
+ Name string `json:"Name,omitempty"`
+
+ Owner string `json:"Owner,omitempty"`
+
+ RuntimeId string `json:"RuntimeId,omitempty"`
+
+ RuntimeTemplateId string `json:"RuntimeTemplateId,omitempty"`
+
+ State string `json:"State,omitempty"`
+
+ Stopped bool `json:"Stopped,omitempty"`
+
+ ExitType string `json:"ExitType,omitempty"`
+
+ Memory *MemoryInformationForVm `json:"Memory,omitempty"`
+
+ Statistics *Statistics `json:"Statistics,omitempty"`
+
+ ProcessList []ProcessDetails `json:"ProcessList,omitempty"`
+
+ TerminateOnLastHandleClosed bool `json:"TerminateOnLastHandleClosed,omitempty"`
+
+ HostingSystemId string `json:"HostingSystemId,omitempty"`
+
+ SharedMemoryRegionInfo []SharedMemoryRegionInfo `json:"SharedMemoryRegionInfo,omitempty"`
+
+ GuestConnectionInfo *GuestConnectionInfo `json:"GuestConnectionInfo,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/property_query.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/property_query.go
new file mode 100644
index 000000000..22b92ffdf
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/property_query.go
@@ -0,0 +1,16 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+// By default the basic properties will be returned. This query provides a way to request specific properties.
+type PropertyQuery struct {
+
+ PropertyTypes []string `json:"PropertyTypes,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/rdp_connection_options.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/rdp_connection_options.go
new file mode 100644
index 000000000..97e453128
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/rdp_connection_options.go
@@ -0,0 +1,17 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type RdpConnectionOptions struct {
+
+ AccessSids []string `json:"AccessSids,omitempty"`
+
+ NamedPipe string `json:"NamedPipe,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/registry_changes.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/registry_changes.go
new file mode 100644
index 000000000..fa574ccc8
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/registry_changes.go
@@ -0,0 +1,17 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type RegistryChanges struct {
+
+ AddValues []RegistryValue `json:"AddValues,omitempty"`
+
+ DeleteKeys []RegistryKey `json:"DeleteKeys,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/registry_key.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/registry_key.go
new file mode 100644
index 000000000..fab03bc60
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/registry_key.go
@@ -0,0 +1,19 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type RegistryKey struct {
+
+ Hive string `json:"Hive,omitempty"`
+
+ Name string `json:"Name,omitempty"`
+
+ Volatile bool `json:"Volatile,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/registry_value.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/registry_value.go
new file mode 100644
index 000000000..1589f4841
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/registry_value.go
@@ -0,0 +1,31 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type RegistryValue struct {
+
+ Key *RegistryKey `json:"Key,omitempty"`
+
+ Name string `json:"Name,omitempty"`
+
+ Type_ string `json:"Type,omitempty"`
+
+ // One and only one value type must be set.
+ StringValue string `json:"StringValue,omitempty"`
+
+ BinaryValue string `json:"BinaryValue,omitempty"`
+
+ DWordValue int32 `json:"DWordValue,omitempty"`
+
+ QWordValue int32 `json:"QWordValue,omitempty"`
+
+ // Only used if RegistryValueType is CustomType The data is in BinaryValue
+ CustomType int32 `json:"CustomType,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/restore_state.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/restore_state.go
new file mode 100644
index 000000000..778ff5873
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/restore_state.go
@@ -0,0 +1,19 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type RestoreState struct {
+
+ // The path to the save state file to restore the system from.
+ SaveStateFilePath string `json:"SaveStateFilePath,omitempty"`
+
+ // The ID of the template system to clone this new system off of. An empty string indicates the system should not be cloned from a template.
+ TemplateSystemId string `json:"TemplateSystemId,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/save_options.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/save_options.go
new file mode 100644
index 000000000..e55fa1d98
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/save_options.go
@@ -0,0 +1,19 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type SaveOptions struct {
+
+ // The type of save operation to be performed.
+ SaveType string `json:"SaveType,omitempty"`
+
+ // The path to the file that will container the saved state.
+ SaveStateFilePath string `json:"SaveStateFilePath,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/scsi.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/scsi.go
new file mode 100644
index 000000000..bf253a470
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/scsi.go
@@ -0,0 +1,16 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type Scsi struct {
+
+ // Map of attachments, where the key is the integer LUN number on the controller.
+ Attachments map[string]Attachment `json:"Attachments,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/shared_memory_configuration.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/shared_memory_configuration.go
new file mode 100644
index 000000000..bd573f6cd
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/shared_memory_configuration.go
@@ -0,0 +1,15 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type SharedMemoryConfiguration struct {
+
+ Regions []SharedMemoryRegion `json:"Regions,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/shared_memory_region.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/shared_memory_region.go
new file mode 100644
index 000000000..a57b2cba7
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/shared_memory_region.go
@@ -0,0 +1,23 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type SharedMemoryRegion struct {
+
+ SectionName string `json:"SectionName,omitempty"`
+
+ StartOffset int32 `json:"StartOffset,omitempty"`
+
+ Length int32 `json:"Length,omitempty"`
+
+ AllowGuestWrite bool `json:"AllowGuestWrite,omitempty"`
+
+ HiddenFromGuest bool `json:"HiddenFromGuest,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/shared_memory_region_info.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/shared_memory_region_info.go
new file mode 100644
index 000000000..d9a50cc7d
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/shared_memory_region_info.go
@@ -0,0 +1,17 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type SharedMemoryRegionInfo struct {
+
+ SectionName string `json:"SectionName,omitempty"`
+
+ GuestPhysicalAddress int32 `json:"GuestPhysicalAddress,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/silo_properties.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/silo_properties.go
new file mode 100644
index 000000000..599c06e8a
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/silo_properties.go
@@ -0,0 +1,18 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+// Silo job information
+type SiloProperties struct {
+
+ Enabled bool `json:"Enabled,omitempty"`
+
+ JobName string `json:"JobName,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/statistics.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/statistics.go
new file mode 100644
index 000000000..5cb3ed93b
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/statistics.go
@@ -0,0 +1,30 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+import (
+ "time"
+)
+
+// Runtime statistics for a container
+type Statistics struct {
+
+ Timestamp time.Time `json:"Timestamp,omitempty"`
+
+ ContainerStartTime time.Time `json:"ContainerStartTime,omitempty"`
+
+ Uptime100ns int32 `json:"Uptime100ns,omitempty"`
+
+ Processor *ProcessorStats `json:"Processor,omitempty"`
+
+ Memory *MemoryStats `json:"Memory,omitempty"`
+
+ Storage *StorageStats `json:"Storage,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/storage.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/storage.go
new file mode 100644
index 000000000..2627af913
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/storage.go
@@ -0,0 +1,21 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type Storage struct {
+
+ // List of layers that describe the parent hierarchy for a container's storage. These layers combined together, presented as a disposable and/or committable working storage, are used by the container to record all changes done to the parent layers.
+ Layers []Layer `json:"Layers,omitempty"`
+
+ // Path that points to the scratch space of a container, where parent layers are combined together to present a new disposable and/or committable layer with the changes done during its runtime.
+ Path string `json:"Path,omitempty"`
+
+ QoS *StorageQoS `json:"QoS,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/storage_qo_s.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/storage_qo_s.go
new file mode 100644
index 000000000..8c5255df1
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/storage_qo_s.go
@@ -0,0 +1,17 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type StorageQoS struct {
+
+ IopsMaximum int32 `json:"IopsMaximum,omitempty"`
+
+ BandwidthMaximum int32 `json:"BandwidthMaximum,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/storage_stats.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/storage_stats.go
new file mode 100644
index 000000000..198ea57d7
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/storage_stats.go
@@ -0,0 +1,22 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+// Storage runtime statistics
+type StorageStats struct {
+
+ ReadCountNormalized int32 `json:"ReadCountNormalized,omitempty"`
+
+ ReadSizeBytes int32 `json:"ReadSizeBytes,omitempty"`
+
+ WriteCountNormalized int32 `json:"WriteCountNormalized,omitempty"`
+
+ WriteSizeBytes int32 `json:"WriteSizeBytes,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/topology.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/topology.go
new file mode 100644
index 000000000..af2e3c823
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/topology.go
@@ -0,0 +1,17 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type Topology struct {
+
+ Memory *Memory2 `json:"Memory,omitempty"`
+
+ Processor *Processor2 `json:"Processor,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/uefi.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/uefi.go
new file mode 100644
index 000000000..ba91178f9
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/uefi.go
@@ -0,0 +1,21 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type Uefi struct {
+
+ EnableDebugger bool `json:"EnableDebugger,omitempty"`
+
+ SecureBootTemplateId string `json:"SecureBootTemplateId,omitempty"`
+
+ BootThis *UefiBootEntry `json:"BootThis,omitempty"`
+
+ Console string `json:"Console,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/uefi_boot_entry.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/uefi_boot_entry.go
new file mode 100644
index 000000000..6620fb2bc
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/uefi_boot_entry.go
@@ -0,0 +1,23 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type UefiBootEntry struct {
+
+ DeviceType string `json:"DeviceType,omitempty"`
+
+ DevicePath string `json:"DevicePath,omitempty"`
+
+ DiskNumber int32 `json:"DiskNumber,omitempty"`
+
+ OptionalData string `json:"OptionalData,omitempty"`
+
+ VmbFsRootPath string `json:"VmbFsRootPath,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/version.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/version.go
new file mode 100644
index 000000000..62c0e4d12
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/version.go
@@ -0,0 +1,17 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type Version struct {
+
+ Major int32 `json:"Major,omitempty"`
+
+ Minor int32 `json:"Minor,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/video_monitor.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/video_monitor.go
new file mode 100644
index 000000000..0958e5606
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/video_monitor.go
@@ -0,0 +1,19 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type VideoMonitor struct {
+
+ HorizontalResolution int32 `json:"HorizontalResolution,omitempty"`
+
+ VerticalResolution int32 `json:"VerticalResolution,omitempty"`
+
+ ConnectionOptions *RdpConnectionOptions `json:"ConnectionOptions,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
new file mode 100644
index 000000000..11f39eea7
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/virtual_machine.go
@@ -0,0 +1,29 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type VirtualMachine struct {
+
+ Chipset *Chipset `json:"Chipset,omitempty"`
+
+ ComputeTopology *Topology `json:"ComputeTopology,omitempty"`
+
+ Devices *Devices `json:"Devices,omitempty"`
+
+ GuestState *GuestState `json:"GuestState,omitempty"`
+
+ RestoreState *RestoreState `json:"RestoreState,omitempty"`
+
+ RegistryChanges *RegistryChanges `json:"RegistryChanges,omitempty"`
+
+ StorageQoS *StorageQoS `json:"StorageQoS,omitempty"`
+
+ GuestConnection *GuestConnection `json:"GuestConnection,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/virtual_node_info.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/virtual_node_info.go
new file mode 100644
index 000000000..48402d8ec
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/virtual_node_info.go
@@ -0,0 +1,21 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type VirtualNodeInfo struct {
+
+ VirtualNodeIndex int32 `json:"VirtualNodeIndex,omitempty"`
+
+ PhysicalNodeNumber int32 `json:"PhysicalNodeNumber,omitempty"`
+
+ VirtualProcessorCount int32 `json:"VirtualProcessorCount,omitempty"`
+
+ MemoryUsageInPages int32 `json:"MemoryUsageInPages,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/virtual_p_mem_controller.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/virtual_p_mem_controller.go
new file mode 100644
index 000000000..f5b7f3e38
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/virtual_p_mem_controller.go
@@ -0,0 +1,20 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type VirtualPMemController struct {
+ Devices map[string]VirtualPMemDevice `json:"Devices,omitempty"`
+
+ MaximumCount uint32 `json:"MaximumCount,omitempty"`
+
+ MaximumSizeBytes uint64 `json:"MaximumSizeBytes,omitempty"`
+
+ Backing string `json:"Backing,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/virtual_p_mem_device.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/virtual_p_mem_device.go
new file mode 100644
index 000000000..47714444a
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/virtual_p_mem_device.go
@@ -0,0 +1,19 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type VirtualPMemDevice struct {
+
+ HostPath string `json:"HostPath,omitempty"`
+
+ ReadOnly bool `json:"ReadOnly,omitempty"`
+
+ ImageFormat string `json:"ImageFormat,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/virtual_smb.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/virtual_smb.go
new file mode 100644
index 000000000..76131b3a7
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/virtual_smb.go
@@ -0,0 +1,17 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type VirtualSmb struct {
+
+ Shares []VirtualSmbShare `json:"Shares,omitempty"`
+
+ DirectFileMappingInMB int64 `json:"DirectFileMappingInMB,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/virtual_smb_share.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/virtual_smb_share.go
new file mode 100644
index 000000000..b50098a42
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/virtual_smb_share.go
@@ -0,0 +1,21 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type VirtualSmbShare struct {
+
+ Name string `json:"Name,omitempty"`
+
+ Path string `json:"Path,omitempty"`
+
+ AllowedFiles []string `json:"AllowedFiles,omitempty"`
+
+ Options *VirtualSmbShareOptions `json:"Options,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/virtual_smb_share_options.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/virtual_smb_share_options.go
new file mode 100644
index 000000000..c1894279d
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/virtual_smb_share_options.go
@@ -0,0 +1,63 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type VirtualSmbShareOptions struct {
+
+ ReadOnly bool `json:"ReadOnly,omitempty"`
+
+ // convert exclusive access to shared read access
+ ShareRead bool `json:"ShareRead,omitempty"`
+
+ // all opens will use cached I/O
+ CacheIo bool `json:"CacheIo,omitempty"`
+
+ // disable oplock support
+ NoOplocks bool `json:"NoOplocks,omitempty"`
+
+ // Acquire the backup privilege when attempting to open
+ TakeBackupPrivilege bool `json:"TakeBackupPrivilege,omitempty"`
+
+ // Use the identity of the share root when opening
+ UseShareRootIdentity bool `json:"UseShareRootIdentity,omitempty"`
+
+ // disable Direct Mapping
+ NoDirectmap bool `json:"NoDirectmap,omitempty"`
+
+ // disable Byterange locks
+ NoLocks bool `json:"NoLocks,omitempty"`
+
+ // disable Directory CHange Notifications
+ NoDirnotify bool `json:"NoDirnotify,omitempty"`
+
+ // share is use for VM shared memory
+ VmSharedMemory bool `json:"VmSharedMemory,omitempty"`
+
+ // allow access only to the files specified in AllowedFiles
+ RestrictFileAccess bool `json:"RestrictFileAccess,omitempty"`
+
+ // disable all oplocks except Level II
+ ForceLevelIIOplocks bool `json:"ForceLevelIIOplocks,omitempty"`
+
+ // Allow the host to reparse this base layer
+ ReparseBaseLayer bool `json:"ReparseBaseLayer,omitempty"`
+
+ // Enable pseudo-oplocks
+ PseudoOplocks bool `json:"PseudoOplocks,omitempty"`
+
+ // All opens will use non-cached IO
+ NonCacheIo bool `json:"NonCacheIo,omitempty"`
+
+ // Enable pseudo directory change notifications
+ PseudoDirnotify bool `json:"PseudoDirnotify,omitempty"`
+
+ // Block directory enumeration, renames, and deletes.
+ SingleFileMapping bool `json:"SingleFileMapping,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/vm_memory.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/vm_memory.go
new file mode 100644
index 000000000..39f628667
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/vm_memory.go
@@ -0,0 +1,27 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type VmMemory struct {
+
+ AvailableMemory int32 `json:"AvailableMemory,omitempty"`
+
+ AvailableMemoryBuffer int32 `json:"AvailableMemoryBuffer,omitempty"`
+
+ ReservedMemory int32 `json:"ReservedMemory,omitempty"`
+
+ AssignedMemory int32 `json:"AssignedMemory,omitempty"`
+
+ SlpActive bool `json:"SlpActive,omitempty"`
+
+ BalancingEnabled bool `json:"BalancingEnabled,omitempty"`
+
+ DmOperationInProgress bool `json:"DmOperationInProgress,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/schema2/windows_crash_reporting.go b/vendor/github.com/Microsoft/hcsshim/internal/schema2/windows_crash_reporting.go
new file mode 100644
index 000000000..cf632bbc8
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/schema2/windows_crash_reporting.go
@@ -0,0 +1,17 @@
+/*
+ * HCS API
+ *
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
+ *
+ * API version: 2.1
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
+ */
+
+package hcsschema
+
+type WindowsCrashReporting struct {
+
+ DumpFileName string `json:"DumpFileName,omitempty"`
+
+ MaxDumpSize int64 `json:"MaxDumpSize,omitempty"`
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/timeout/timeout.go b/vendor/github.com/Microsoft/hcsshim/internal/timeout/timeout.go
new file mode 100644
index 000000000..ff3b6572e
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/timeout/timeout.go
@@ -0,0 +1,70 @@
+package timeout
+
+import (
+ "os"
+ "strconv"
+ "time"
+)
+
+var (
+ // defaultTimeout is the timeout for most operations that is not overridden.
+ defaultTimeout = 4 * time.Minute
+
+ // defaultTimeoutTestdRetry is the retry loop timeout for testd to respond
+ // for a disk to come online in LCOW.
+ defaultTimeoutTestdRetry = 5 * time.Second
+)
+
+// External variables for HCSShim consumers to use.
+var (
+ // SystemCreate is the timeout for creating a compute system
+ SystemCreate time.Duration = defaultTimeout
+
+ // SystemStart is the timeout for starting a compute system
+ SystemStart time.Duration = defaultTimeout
+
+ // SystemPause is the timeout for pausing a compute system
+ SystemPause time.Duration = defaultTimeout
+
+ // SystemResume is the timeout for resuming a compute system
+ SystemResume time.Duration = defaultTimeout
+
+ // SyscallWatcher is the timeout before warning of a potential stuck platform syscall.
+ SyscallWatcher time.Duration = defaultTimeout
+
+ // Tar2VHD is the timeout for the tar2vhd operation to complete
+ Tar2VHD time.Duration = defaultTimeout
+
+ // ExternalCommandToStart is the timeout for external commands to start
+ ExternalCommandToStart = defaultTimeout
+
+ // ExternalCommandToComplete is the timeout for external commands to complete.
+ // Generally this means copying data from their stdio pipes.
+ ExternalCommandToComplete = defaultTimeout
+
+ // TestDRetryLoop is the timeout for testd retry loop when onlining a SCSI disk in LCOW
+ TestDRetryLoop = defaultTimeoutTestdRetry
+)
+
+func init() {
+ SystemCreate = durationFromEnvironment("HCSSHIM_TIMEOUT_SYSTEMCREATE", SystemCreate)
+ SystemStart = durationFromEnvironment("HCSSHIM_TIMEOUT_SYSTEMSTART", SystemStart)
+ SystemPause = durationFromEnvironment("HCSSHIM_TIMEOUT_SYSTEMPAUSE", SystemPause)
+ SystemResume = durationFromEnvironment("HCSSHIM_TIMEOUT_SYSTEMRESUME", SystemResume)
+ SyscallWatcher = durationFromEnvironment("HCSSHIM_TIMEOUT_SYSCALLWATCHER", SyscallWatcher)
+ Tar2VHD = durationFromEnvironment("HCSSHIM_TIMEOUT_TAR2VHD", Tar2VHD)
+ ExternalCommandToStart = durationFromEnvironment("HCSSHIM_TIMEOUT_EXTERNALCOMMANDSTART", ExternalCommandToStart)
+ ExternalCommandToComplete = durationFromEnvironment("HCSSHIM_TIMEOUT_EXTERNALCOMMANDCOMPLETE", ExternalCommandToComplete)
+ TestDRetryLoop = durationFromEnvironment("HCSSHIM_TIMEOUT_TESTDRETRYLOOP", TestDRetryLoop)
+}
+
+func durationFromEnvironment(env string, defaultValue time.Duration) time.Duration {
+ envTimeout := os.Getenv(env)
+ if len(envTimeout) > 0 {
+ e, err := strconv.Atoi(envTimeout)
+ if err == nil && e > 0 {
+ return time.Second * time.Duration(e)
+ }
+ }
+ return defaultValue
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/activatelayer.go b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/activatelayer.go
new file mode 100644
index 000000000..3a0d4bc58
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/activatelayer.go
@@ -0,0 +1,25 @@
+package wclayer
+
+import (
+ "github.com/Microsoft/hcsshim/internal/hcserror"
+ "github.com/sirupsen/logrus"
+)
+
+// ActivateLayer will find the layer with the given id and mount it's filesystem.
+// 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)
+
+ err := activateLayer(&stdDriverInfo, path)
+ if err != nil {
+ err = hcserror.Errorf(err, title, "path=%s", path)
+ logrus.Error(err)
+ return err
+ }
+
+ logrus.Debugf(title+" - succeeded path=%s", path)
+ return nil
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/baselayer.go b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/baselayer.go
new file mode 100644
index 000000000..5784241df
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/baselayer.go
@@ -0,0 +1,173 @@
+package wclayer
+
+import (
+ "errors"
+ "os"
+ "path/filepath"
+ "syscall"
+
+ "github.com/Microsoft/go-winio"
+ "github.com/Microsoft/hcsshim/internal/hcserror"
+ "github.com/Microsoft/hcsshim/internal/safefile"
+)
+
+type baseLayerWriter struct {
+ root *os.File
+ f *os.File
+ bw *winio.BackupFileWriter
+ err error
+ hasUtilityVM bool
+ dirInfo []dirInfo
+}
+
+type dirInfo struct {
+ path string
+ fileInfo winio.FileBasicInfo
+}
+
+// reapplyDirectoryTimes reapplies directory modification, creation, etc. times
+// after processing of the directory tree has completed. The times are expected
+// to be ordered such that parent directories come before child directories.
+func reapplyDirectoryTimes(root *os.File, dis []dirInfo) error {
+ for i := range dis {
+ di := &dis[len(dis)-i-1] // reverse order: process child directories first
+ f, err := safefile.OpenRelative(di.path, root, syscall.GENERIC_READ|syscall.GENERIC_WRITE, syscall.FILE_SHARE_READ, safefile.FILE_OPEN, safefile.FILE_DIRECTORY_FILE)
+ if err != nil {
+ return err
+ }
+
+ err = winio.SetFileBasicInfo(f, &di.fileInfo)
+ f.Close()
+ if err != nil {
+ return err
+ }
+ }
+ return nil
+}
+
+func (w *baseLayerWriter) closeCurrentFile() error {
+ if w.f != nil {
+ err := w.bw.Close()
+ err2 := w.f.Close()
+ w.f = nil
+ w.bw = nil
+ if err != nil {
+ return err
+ }
+ if err2 != nil {
+ return err2
+ }
+ }
+ return nil
+}
+
+func (w *baseLayerWriter) Add(name string, fileInfo *winio.FileBasicInfo) (err error) {
+ defer func() {
+ if err != nil {
+ w.err = err
+ }
+ }()
+
+ err = w.closeCurrentFile()
+ if err != nil {
+ return err
+ }
+
+ if filepath.ToSlash(name) == `UtilityVM/Files` {
+ w.hasUtilityVM = true
+ }
+
+ var f *os.File
+ defer func() {
+ if f != nil {
+ f.Close()
+ }
+ }()
+
+ extraFlags := uint32(0)
+ if fileInfo.FileAttributes&syscall.FILE_ATTRIBUTE_DIRECTORY != 0 {
+ extraFlags |= safefile.FILE_DIRECTORY_FILE
+ if fileInfo.FileAttributes&syscall.FILE_ATTRIBUTE_REPARSE_POINT == 0 {
+ w.dirInfo = append(w.dirInfo, dirInfo{name, *fileInfo})
+ }
+ }
+
+ mode := uint32(syscall.GENERIC_READ | syscall.GENERIC_WRITE | winio.WRITE_DAC | winio.WRITE_OWNER | winio.ACCESS_SYSTEM_SECURITY)
+ f, err = safefile.OpenRelative(name, w.root, mode, syscall.FILE_SHARE_READ, safefile.FILE_CREATE, extraFlags)
+ if err != nil {
+ return hcserror.New(err, "Failed to safefile.OpenRelative", name)
+ }
+
+ err = winio.SetFileBasicInfo(f, fileInfo)
+ if err != nil {
+ return hcserror.New(err, "Failed to SetFileBasicInfo", name)
+ }
+
+ w.f = f
+ w.bw = winio.NewBackupFileWriter(f, true)
+ f = nil
+ return nil
+}
+
+func (w *baseLayerWriter) AddLink(name string, target string) (err error) {
+ defer func() {
+ if err != nil {
+ w.err = err
+ }
+ }()
+
+ err = w.closeCurrentFile()
+ if err != nil {
+ return err
+ }
+
+ return safefile.LinkRelative(target, w.root, name, w.root)
+}
+
+func (w *baseLayerWriter) Remove(name string) error {
+ return errors.New("base layer cannot have tombstones")
+}
+
+func (w *baseLayerWriter) Write(b []byte) (int, error) {
+ n, err := w.bw.Write(b)
+ if err != nil {
+ w.err = err
+ }
+ return n, err
+}
+
+func (w *baseLayerWriter) Close() error {
+ defer func() {
+ w.root.Close()
+ w.root = nil
+ }()
+ err := w.closeCurrentFile()
+ if err != nil {
+ return err
+ }
+ if w.err == nil {
+ // Restore the file times of all the directories, since they may have
+ // been modified by creating child directories.
+ err = reapplyDirectoryTimes(w.root, w.dirInfo)
+ if err != nil {
+ return err
+ }
+
+ err = ProcessBaseLayer(w.root.Name())
+ if err != nil {
+ return err
+ }
+
+ if w.hasUtilityVM {
+ err := safefile.EnsureNotReparsePointRelative("UtilityVM", w.root)
+ if err != nil {
+ return err
+ }
+ err = ProcessUtilityVMImage(filepath.Join(w.root.Name(), "UtilityVM"))
+ if err != nil {
+ return err
+ }
+ }
+ }
+ return w.err
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/createlayer.go b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/createlayer.go
new file mode 100644
index 000000000..d15817730
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/createlayer.go
@@ -0,0 +1,23 @@
+package wclayer
+
+import (
+ "github.com/Microsoft/hcsshim/internal/hcserror"
+ "github.com/sirupsen/logrus"
+)
+
+// 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)
+
+ err := createLayer(&stdDriverInfo, path, parent)
+ if err != nil {
+ err = hcserror.Errorf(err, title, "path=%s parent=%s", path, parent)
+ logrus.Error(err)
+ return err
+ }
+
+ 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
new file mode 100644
index 000000000..bf2fece19
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/createscratchlayer.go
@@ -0,0 +1,31 @@
+package wclayer
+
+import (
+ "github.com/Microsoft/hcsshim/internal/hcserror"
+ "github.com/sirupsen/logrus"
+)
+
+// CreateScratchLayer creates and populates new read-write layer for use by a container.
+// 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)
+
+ // Generate layer descriptors
+ layers, err := layerPathsToDescriptors(parentLayerPaths)
+ if err != nil {
+ return err
+ }
+
+ err = createSandboxLayer(&stdDriverInfo, path, 0, layers)
+ if err != nil {
+ err = hcserror.Errorf(err, title, "path=%s", path)
+ logrus.Error(err)
+ return err
+ }
+
+ 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
new file mode 100644
index 000000000..b998f8a19
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/deactivatelayer.go
@@ -0,0 +1,22 @@
+package wclayer
+
+import (
+ "github.com/Microsoft/hcsshim/internal/hcserror"
+ "github.com/sirupsen/logrus"
+)
+
+// DeactivateLayer will dismount a layer that was mounted via ActivateLayer.
+func DeactivateLayer(path string) error {
+ title := "hcsshim::DeactivateLayer "
+ logrus.Debugf(title+"path %s", path)
+
+ err := deactivateLayer(&stdDriverInfo, path)
+ if err != nil {
+ err = hcserror.Errorf(err, title, "path=%s", path)
+ logrus.Error(err)
+ return err
+ }
+
+ 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
new file mode 100644
index 000000000..dc14cecc4
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/destroylayer.go
@@ -0,0 +1,23 @@
+package wclayer
+
+import (
+ "github.com/Microsoft/hcsshim/internal/hcserror"
+ "github.com/sirupsen/logrus"
+)
+
+// 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)
+
+ err := destroyLayer(&stdDriverInfo, path)
+ if err != nil {
+ err = hcserror.Errorf(err, title, "path=%s", path)
+ logrus.Error(err)
+ return err
+ }
+
+ 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
new file mode 100644
index 000000000..7832bb452
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/expandscratchsize.go
@@ -0,0 +1,22 @@
+package wclayer
+
+import (
+ "github.com/Microsoft/hcsshim/internal/hcserror"
+ "github.com/sirupsen/logrus"
+)
+
+// 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)
+
+ err := expandSandboxSize(&stdDriverInfo, path, size)
+ if err != nil {
+ err = hcserror.Errorf(err, title, "path=%s size=%d", path, size)
+ logrus.Error(err)
+ return err
+ }
+
+ 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
new file mode 100644
index 000000000..d43e941ee
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/exportlayer.go
@@ -0,0 +1,68 @@
+package wclayer
+
+import (
+ "io/ioutil"
+ "os"
+
+ "github.com/Microsoft/go-winio"
+ "github.com/Microsoft/hcsshim/internal/hcserror"
+ "github.com/sirupsen/logrus"
+)
+
+// ExportLayer will create a folder at exportFolderPath and fill that folder with
+// the transport format version of the layer identified by layerId. This transport
+// 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)
+
+ // Generate layer descriptors
+ layers, err := layerPathsToDescriptors(parentLayerPaths)
+ if err != nil {
+ return err
+ }
+
+ 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
+ }
+
+ logrus.Debugf(title+"succeeded path=%s folder=%s", path, exportFolderPath)
+ return nil
+}
+
+type LayerReader interface {
+ Next() (string, int64, *winio.FileBasicInfo, error)
+ Read(b []byte) (int, error)
+ Close() error
+}
+
+// NewLayerReader returns a new layer reader for reading the contents of an on-disk layer.
+// The caller must have taken the SeBackupPrivilege privilege
+// to call this and any methods on the resulting LayerReader.
+func NewLayerReader(path string, parentLayerPaths []string) (LayerReader, error) {
+ exportPath, err := ioutil.TempDir("", "hcs")
+ if err != nil {
+ return nil, err
+ }
+ err = ExportLayer(path, exportPath, parentLayerPaths)
+ if err != nil {
+ os.RemoveAll(exportPath)
+ return nil, err
+ }
+ return &legacyLayerReaderWrapper{newLegacyLayerReader(exportPath)}, nil
+}
+
+type legacyLayerReaderWrapper struct {
+ *legacyLayerReader
+}
+
+func (r *legacyLayerReaderWrapper) Close() error {
+ err := r.legacyLayerReader.Close()
+ os.RemoveAll(r.root)
+ return err
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/getlayermountpath.go b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/getlayermountpath.go
new file mode 100644
index 000000000..8c37549a0
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/getlayermountpath.go
@@ -0,0 +1,49 @@
+package wclayer
+
+import (
+ "syscall"
+
+ "github.com/Microsoft/hcsshim/internal/hcserror"
+ "github.com/sirupsen/logrus"
+)
+
+// GetLayerMountPath will look for a mounted layer with the given path and return
+// 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)
+
+ var mountPathLength uintptr
+ mountPathLength = 0
+
+ // Call the procedure itself.
+ logrus.Debugf("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
+ }
+
+ // Allocate a mount path of the returned length.
+ if mountPathLength == 0 {
+ return "", nil
+ }
+ mountPathp := make([]uint16, mountPathLength)
+ mountPathp[0] = 0
+
+ // Call the procedure again
+ logrus.Debugf("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
+ }
+
+ mountPath := syscall.UTF16ToString(mountPathp[0:])
+ logrus.Debugf(title+"succeeded path=%s mountPath=%s", path, 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
new file mode 100644
index 000000000..10899c68a
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/getsharedbaseimages.go
@@ -0,0 +1,26 @@
+package wclayer
+
+import (
+ "github.com/Microsoft/hcsshim/internal/hcserror"
+ "github.com/Microsoft/hcsshim/internal/interop"
+ "github.com/sirupsen/logrus"
+)
+
+// GetSharedBaseImages will enumerate the images stored in the common central
+// 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 "
+
+ logrus.Debugf("Calling proc")
+ var buffer *uint16
+ err = getBaseImages(&buffer)
+ if err != nil {
+ err = hcserror.New(err, title, "")
+ logrus.Error(err)
+ return
+ }
+ imageData = interop.ConvertAndFreeCoTaskMemString(buffer)
+ logrus.Debugf(title+" - succeeded output=%s", imageData)
+ return
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/grantvmaccess.go b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/grantvmaccess.go
new file mode 100644
index 000000000..d86e67827
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/grantvmaccess.go
@@ -0,0 +1,24 @@
+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)
+
+ err := grantVmAccess(vmid, filepath)
+ if err != nil {
+ err = hcserror.Errorf(err, title, "path=%s", filepath)
+ logrus.Error(err)
+ return err
+ }
+
+ 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
new file mode 100644
index 000000000..486d55470
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/importlayer.go
@@ -0,0 +1,127 @@
+package wclayer
+
+import (
+ "io/ioutil"
+ "os"
+ "path/filepath"
+
+ "github.com/Microsoft/go-winio"
+ "github.com/Microsoft/hcsshim/internal/hcserror"
+ "github.com/Microsoft/hcsshim/internal/safefile"
+ "github.com/sirupsen/logrus"
+)
+
+// ImportLayer will take the contents of the folder at importFolderPath and 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)
+
+ // Generate layer descriptors
+ layers, err := layerPathsToDescriptors(parentLayerPaths)
+ if err != nil {
+ return err
+ }
+
+ 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
+ }
+
+ logrus.Debugf(title+"succeeded path=%s folder=%s", path, importFolderPath)
+ return nil
+}
+
+// LayerWriter is an interface that supports writing a new container image layer.
+type LayerWriter interface {
+ // Add adds a file to the layer with given metadata.
+ Add(name string, fileInfo *winio.FileBasicInfo) error
+ // AddLink adds a hard link to the layer. The target must already have been added.
+ AddLink(name string, target string) error
+ // Remove removes a file that was present in a parent layer from the layer.
+ Remove(name string) error
+ // Write writes data to the current file. The data must be in the format of a Win32
+ // backup stream.
+ Write(b []byte) (int, error)
+ // Close finishes the layer writing process and releases any resources.
+ Close() error
+}
+
+type legacyLayerWriterWrapper struct {
+ *legacyLayerWriter
+ path string
+ parentLayerPaths []string
+}
+
+func (r *legacyLayerWriterWrapper) Close() error {
+ defer os.RemoveAll(r.root.Name())
+ defer r.legacyLayerWriter.CloseRoots()
+ err := r.legacyLayerWriter.Close()
+ if err != nil {
+ return err
+ }
+
+ if err = ImportLayer(r.destRoot.Name(), r.path, r.parentLayerPaths); err != nil {
+ return err
+ }
+ for _, name := range r.Tombstones {
+ if err = safefile.RemoveRelative(name, r.destRoot); err != nil && !os.IsNotExist(err) {
+ return err
+ }
+ }
+ // Add any hard links that were collected.
+ for _, lnk := range r.PendingLinks {
+ if err = safefile.RemoveRelative(lnk.Path, r.destRoot); err != nil && !os.IsNotExist(err) {
+ return err
+ }
+ if err = safefile.LinkRelative(lnk.Target, lnk.TargetRoot, lnk.Path, r.destRoot); err != nil {
+ return err
+ }
+ }
+ // Prepare the utility VM for use if one is present in the layer.
+ if r.HasUtilityVM {
+ err := safefile.EnsureNotReparsePointRelative("UtilityVM", r.destRoot)
+ if err != nil {
+ return err
+ }
+ err = ProcessUtilityVMImage(filepath.Join(r.destRoot.Name(), "UtilityVM"))
+ if err != nil {
+ return err
+ }
+ }
+ return nil
+}
+
+// NewLayerWriter returns a new layer writer for creating a layer on disk.
+// The caller must have taken the SeBackupPrivilege and SeRestorePrivilege privileges
+// to call this and any methods on the resulting LayerWriter.
+func NewLayerWriter(path string, parentLayerPaths []string) (LayerWriter, error) {
+ if len(parentLayerPaths) == 0 {
+ // This is a base layer. It gets imported differently.
+ f, err := safefile.OpenRoot(path)
+ if err != nil {
+ return nil, err
+ }
+ return &baseLayerWriter{
+ root: f,
+ }, nil
+ }
+
+ importPath, err := ioutil.TempDir("", "hcs")
+ if err != nil {
+ return nil, err
+ }
+ w, err := newLegacyLayerWriter(importPath, parentLayerPaths, path)
+ if err != nil {
+ return nil, err
+ }
+ return &legacyLayerWriterWrapper{
+ legacyLayerWriter: w,
+ path: importPath,
+ parentLayerPaths: parentLayerPaths,
+ }, nil
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/layerexists.go b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/layerexists.go
new file mode 100644
index 000000000..71287ff8a
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/layerexists.go
@@ -0,0 +1,25 @@
+package wclayer
+
+import (
+ "github.com/Microsoft/hcsshim/internal/hcserror"
+ "github.com/sirupsen/logrus"
+)
+
+// 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)
+
+ // Call the procedure itself.
+ var exists uint32
+ err := layerExists(&stdDriverInfo, path, &exists)
+ if err != nil {
+ err = hcserror.Errorf(err, title, "path=%s", path)
+ logrus.Error(err)
+ return false, err
+ }
+
+ logrus.Debugf(title+"succeeded path=%s exists=%d", path, exists)
+ return exists != 0, nil
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/layerid.go b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/layerid.go
new file mode 100644
index 000000000..90df3bedc
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/layerid.go
@@ -0,0 +1,13 @@
+package wclayer
+
+import (
+ "path/filepath"
+
+ "github.com/Microsoft/hcsshim/internal/guid"
+)
+
+// LayerID returns the layer ID of a layer on disk.
+func LayerID(path string) (guid.GUID, error) {
+ _, file := filepath.Split(path)
+ return NameToGuid(file)
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/layerutils.go b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/layerutils.go
new file mode 100644
index 000000000..a1b8b9882
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/layerutils.go
@@ -0,0 +1,96 @@
+package wclayer
+
+// This file contains utility functions to support storage (graph) related
+// functionality.
+
+import (
+ "syscall"
+
+ "github.com/Microsoft/hcsshim/internal/guid"
+ "github.com/sirupsen/logrus"
+)
+
+/* To pass into syscall, we need a struct matching the following:
+enum GraphDriverType
+{
+ DiffDriver,
+ FilterDriver
+};
+
+struct DriverInfo {
+ GraphDriverType Flavour;
+ LPCWSTR HomeDir;
+};
+*/
+
+type driverInfo struct {
+ Flavour int
+ HomeDirp *uint16
+}
+
+var (
+ utf16EmptyString uint16
+ stdDriverInfo = driverInfo{1, &utf16EmptyString}
+)
+
+/* To pass into syscall, we need a struct matching the following:
+typedef struct _WC_LAYER_DESCRIPTOR {
+
+ //
+ // The ID of the layer
+ //
+
+ GUID LayerId;
+
+ //
+ // Additional flags
+ //
+
+ union {
+ struct {
+ ULONG Reserved : 31;
+ ULONG Dirty : 1; // Created from sandbox as a result of snapshot
+ };
+ ULONG Value;
+ } Flags;
+
+ //
+ // Path to the layer root directory, null-terminated
+ //
+
+ PCWSTR Path;
+
+} WC_LAYER_DESCRIPTOR, *PWC_LAYER_DESCRIPTOR;
+*/
+type WC_LAYER_DESCRIPTOR struct {
+ LayerId guid.GUID
+ Flags uint32
+ Pathp *uint16
+}
+
+func layerPathsToDescriptors(parentLayerPaths []string) ([]WC_LAYER_DESCRIPTOR, error) {
+ // Array of descriptors that gets constructed.
+ var layers []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)
+ return nil, err
+ }
+
+ p, err := syscall.UTF16PtrFromString(parentLayerPaths[i])
+ if err != nil {
+ logrus.Debugf("Failed conversion of parentLayerPath to pointer %s", err)
+ return nil, err
+ }
+
+ layers = append(layers, WC_LAYER_DESCRIPTOR{
+ LayerId: g,
+ Flags: 0,
+ Pathp: p,
+ })
+ }
+
+ return layers, nil
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/legacy.go b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/legacy.go
new file mode 100644
index 000000000..b8ea5d263
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/legacy.go
@@ -0,0 +1,815 @@
+package wclayer
+
+import (
+ "bufio"
+ "encoding/binary"
+ "errors"
+ "fmt"
+ "io"
+ "io/ioutil"
+ "os"
+ "path/filepath"
+ "strings"
+ "syscall"
+
+ "github.com/Microsoft/go-winio"
+ "github.com/Microsoft/hcsshim/internal/longpath"
+ "github.com/Microsoft/hcsshim/internal/safefile"
+)
+
+var errorIterationCanceled = errors.New("")
+
+var mutatedUtilityVMFiles = map[string]bool{
+ `EFI\Microsoft\Boot\BCD`: true,
+ `EFI\Microsoft\Boot\BCD.LOG`: true,
+ `EFI\Microsoft\Boot\BCD.LOG1`: true,
+ `EFI\Microsoft\Boot\BCD.LOG2`: true,
+}
+
+const (
+ filesPath = `Files`
+ hivesPath = `Hives`
+ utilityVMPath = `UtilityVM`
+ utilityVMFilesPath = `UtilityVM\Files`
+)
+
+func openFileOrDir(path string, mode uint32, createDisposition uint32) (file *os.File, err error) {
+ return winio.OpenForBackup(path, mode, syscall.FILE_SHARE_READ, createDisposition)
+}
+
+func hasPathPrefix(p, prefix string) bool {
+ return strings.HasPrefix(p, prefix) && len(p) > len(prefix) && p[len(prefix)] == '\\'
+}
+
+type fileEntry struct {
+ path string
+ fi os.FileInfo
+ err error
+}
+
+type legacyLayerReader struct {
+ root string
+ result chan *fileEntry
+ proceed chan bool
+ currentFile *os.File
+ backupReader *winio.BackupFileReader
+}
+
+// newLegacyLayerReader returns a new LayerReader that can read the Windows
+// container layer transport format from disk.
+func newLegacyLayerReader(root string) *legacyLayerReader {
+ r := &legacyLayerReader{
+ root: root,
+ result: make(chan *fileEntry),
+ proceed: make(chan bool),
+ }
+ go r.walk()
+ return r
+}
+
+func readTombstones(path string) (map[string]([]string), error) {
+ tf, err := os.Open(filepath.Join(path, "tombstones.txt"))
+ if err != nil {
+ return nil, err
+ }
+ defer tf.Close()
+ s := bufio.NewScanner(tf)
+ if !s.Scan() || s.Text() != "\xef\xbb\xbfVersion 1.0" {
+ return nil, errors.New("Invalid tombstones file")
+ }
+
+ ts := make(map[string]([]string))
+ for s.Scan() {
+ t := filepath.Join(filesPath, s.Text()[1:]) // skip leading `\`
+ dir := filepath.Dir(t)
+ ts[dir] = append(ts[dir], t)
+ }
+ if err = s.Err(); err != nil {
+ return nil, err
+ }
+
+ return ts, nil
+}
+
+func (r *legacyLayerReader) walkUntilCancelled() error {
+ root, err := longpath.LongAbs(r.root)
+ if err != nil {
+ return err
+ }
+
+ r.root = root
+ ts, err := readTombstones(r.root)
+ if err != nil {
+ return err
+ }
+
+ err = filepath.Walk(r.root, func(path string, info os.FileInfo, err error) error {
+ if err != nil {
+ return err
+ }
+
+ // Indirect fix for https://github.com/moby/moby/issues/32838#issuecomment-343610048.
+ // Handle failure from what may be a golang bug in the conversion of
+ // UTF16 to UTF8 in files which are left in the recycle bin. Os.Lstat
+ // which is called by filepath.Walk will fail when a filename contains
+ // unicode characters. Skip the recycle bin regardless which is goodness.
+ if strings.EqualFold(path, filepath.Join(r.root, `Files\$Recycle.Bin`)) && info.IsDir() {
+ return filepath.SkipDir
+ }
+
+ if path == r.root || path == filepath.Join(r.root, "tombstones.txt") || strings.HasSuffix(path, ".$wcidirs$") {
+ return nil
+ }
+
+ r.result <- &fileEntry{path, info, nil}
+ if !<-r.proceed {
+ return errorIterationCanceled
+ }
+
+ // List all the tombstones.
+ if info.IsDir() {
+ relPath, err := filepath.Rel(r.root, path)
+ if err != nil {
+ return err
+ }
+ if dts, ok := ts[relPath]; ok {
+ for _, t := range dts {
+ r.result <- &fileEntry{filepath.Join(r.root, t), nil, nil}
+ if !<-r.proceed {
+ return errorIterationCanceled
+ }
+ }
+ }
+ }
+ return nil
+ })
+ if err == errorIterationCanceled {
+ return nil
+ }
+ if err == nil {
+ return io.EOF
+ }
+ return err
+}
+
+func (r *legacyLayerReader) walk() {
+ defer close(r.result)
+ if !<-r.proceed {
+ return
+ }
+
+ err := r.walkUntilCancelled()
+ if err != nil {
+ for {
+ r.result <- &fileEntry{err: err}
+ if !<-r.proceed {
+ return
+ }
+ }
+ }
+}
+
+func (r *legacyLayerReader) reset() {
+ if r.backupReader != nil {
+ r.backupReader.Close()
+ r.backupReader = nil
+ }
+ if r.currentFile != nil {
+ r.currentFile.Close()
+ r.currentFile = nil
+ }
+}
+
+func findBackupStreamSize(r io.Reader) (int64, error) {
+ br := winio.NewBackupStreamReader(r)
+ for {
+ hdr, err := br.Next()
+ if err != nil {
+ if err == io.EOF {
+ err = nil
+ }
+ return 0, err
+ }
+ if hdr.Id == winio.BackupData {
+ return hdr.Size, nil
+ }
+ }
+}
+
+func (r *legacyLayerReader) Next() (path string, size int64, fileInfo *winio.FileBasicInfo, err error) {
+ r.reset()
+ r.proceed <- true
+ fe := <-r.result
+ if fe == nil {
+ err = errors.New("LegacyLayerReader closed")
+ return
+ }
+ if fe.err != nil {
+ err = fe.err
+ return
+ }
+
+ path, err = filepath.Rel(r.root, fe.path)
+ if err != nil {
+ return
+ }
+
+ if fe.fi == nil {
+ // This is a tombstone. Return a nil fileInfo.
+ return
+ }
+
+ if fe.fi.IsDir() && hasPathPrefix(path, filesPath) {
+ fe.path += ".$wcidirs$"
+ }
+
+ f, err := openFileOrDir(fe.path, syscall.GENERIC_READ, syscall.OPEN_EXISTING)
+ if err != nil {
+ return
+ }
+ defer func() {
+ if f != nil {
+ f.Close()
+ }
+ }()
+
+ fileInfo, err = winio.GetFileBasicInfo(f)
+ if err != nil {
+ return
+ }
+
+ if !hasPathPrefix(path, filesPath) {
+ size = fe.fi.Size()
+ r.backupReader = winio.NewBackupFileReader(f, false)
+ if path == hivesPath || path == filesPath {
+ // The Hives directory has a non-deterministic file time because of the
+ // nature of the import process. Use the times from System_Delta.
+ var g *os.File
+ g, err = os.Open(filepath.Join(r.root, hivesPath, `System_Delta`))
+ if err != nil {
+ return
+ }
+ attr := fileInfo.FileAttributes
+ fileInfo, err = winio.GetFileBasicInfo(g)
+ g.Close()
+ if err != nil {
+ return
+ }
+ fileInfo.FileAttributes = attr
+ }
+
+ // The creation time and access time get reset for files outside of the Files path.
+ fileInfo.CreationTime = fileInfo.LastWriteTime
+ fileInfo.LastAccessTime = fileInfo.LastWriteTime
+
+ } else {
+ // The file attributes are written before the backup stream.
+ var attr uint32
+ err = binary.Read(f, binary.LittleEndian, &attr)
+ if err != nil {
+ return
+ }
+ fileInfo.FileAttributes = attr
+ beginning := int64(4)
+
+ // Find the accurate file size.
+ if !fe.fi.IsDir() {
+ size, err = findBackupStreamSize(f)
+ if err != nil {
+ err = &os.PathError{Op: "findBackupStreamSize", Path: fe.path, Err: err}
+ return
+ }
+ }
+
+ // Return back to the beginning of the backup stream.
+ _, err = f.Seek(beginning, 0)
+ if err != nil {
+ return
+ }
+ }
+
+ r.currentFile = f
+ f = nil
+ return
+}
+
+func (r *legacyLayerReader) Read(b []byte) (int, error) {
+ if r.backupReader == nil {
+ if r.currentFile == nil {
+ return 0, io.EOF
+ }
+ return r.currentFile.Read(b)
+ }
+ return r.backupReader.Read(b)
+}
+
+func (r *legacyLayerReader) Seek(offset int64, whence int) (int64, error) {
+ if r.backupReader == nil {
+ if r.currentFile == nil {
+ return 0, errors.New("no current file")
+ }
+ return r.currentFile.Seek(offset, whence)
+ }
+ return 0, errors.New("seek not supported on this stream")
+}
+
+func (r *legacyLayerReader) Close() error {
+ r.proceed <- false
+ <-r.result
+ r.reset()
+ return nil
+}
+
+type pendingLink struct {
+ Path, Target string
+ TargetRoot *os.File
+}
+
+type pendingDir struct {
+ Path string
+ Root *os.File
+}
+
+type legacyLayerWriter struct {
+ root *os.File
+ destRoot *os.File
+ parentRoots []*os.File
+ currentFile *os.File
+ bufWriter *bufio.Writer
+ currentFileName string
+ currentFileRoot *os.File
+ backupWriter *winio.BackupFileWriter
+ Tombstones []string
+ HasUtilityVM bool
+ uvmDi []dirInfo
+ addedFiles map[string]bool
+ PendingLinks []pendingLink
+ pendingDirs []pendingDir
+ currentIsDir bool
+}
+
+// newLegacyLayerWriter returns a LayerWriter that can write the contaler layer
+// transport format to disk.
+func newLegacyLayerWriter(root string, parentRoots []string, destRoot string) (w *legacyLayerWriter, err error) {
+ w = &legacyLayerWriter{
+ addedFiles: make(map[string]bool),
+ }
+ defer func() {
+ if err != nil {
+ w.CloseRoots()
+ w = nil
+ }
+ }()
+ w.root, err = safefile.OpenRoot(root)
+ if err != nil {
+ return
+ }
+ w.destRoot, err = safefile.OpenRoot(destRoot)
+ if err != nil {
+ return
+ }
+ for _, r := range parentRoots {
+ f, err := safefile.OpenRoot(r)
+ if err != nil {
+ return w, err
+ }
+ w.parentRoots = append(w.parentRoots, f)
+ }
+ w.bufWriter = bufio.NewWriterSize(ioutil.Discard, 65536)
+ return
+}
+
+func (w *legacyLayerWriter) CloseRoots() {
+ if w.root != nil {
+ w.root.Close()
+ w.root = nil
+ }
+ if w.destRoot != nil {
+ w.destRoot.Close()
+ w.destRoot = nil
+ }
+ for i := range w.parentRoots {
+ w.parentRoots[i].Close()
+ }
+ w.parentRoots = nil
+}
+
+func (w *legacyLayerWriter) initUtilityVM() error {
+ if !w.HasUtilityVM {
+ err := safefile.MkdirRelative(utilityVMPath, w.destRoot)
+ if err != nil {
+ return err
+ }
+ // Server 2016 does not support multiple layers for the utility VM, so
+ // clone the utility VM from the parent layer into this layer. Use hard
+ // links to avoid unnecessary copying, since most of the files are
+ // immutable.
+ err = cloneTree(w.parentRoots[0], w.destRoot, utilityVMFilesPath, mutatedUtilityVMFiles)
+ if err != nil {
+ return fmt.Errorf("cloning the parent utility VM image failed: %s", err)
+ }
+ w.HasUtilityVM = true
+ }
+ return nil
+}
+
+func (w *legacyLayerWriter) reset() error {
+ err := w.bufWriter.Flush()
+ if err != nil {
+ return err
+ }
+ w.bufWriter.Reset(ioutil.Discard)
+ if w.currentIsDir {
+ r := w.currentFile
+ br := winio.NewBackupStreamReader(r)
+ // Seek to the beginning of the backup stream, skipping the fileattrs
+ if _, err := r.Seek(4, io.SeekStart); err != nil {
+ return err
+ }
+
+ for {
+ bhdr, err := br.Next()
+ if err == io.EOF {
+ // end of backupstream data
+ break
+ }
+ if err != nil {
+ return err
+ }
+ switch bhdr.Id {
+ case winio.BackupReparseData:
+ // The current file is a `.$wcidirs$` metadata file that
+ // describes a directory reparse point. Delete the placeholder
+ // directory to prevent future files being added into the
+ // destination of the reparse point during the ImportLayer call
+ if err := safefile.RemoveRelative(w.currentFileName, w.currentFileRoot); err != nil {
+ return err
+ }
+ w.pendingDirs = append(w.pendingDirs, pendingDir{Path: w.currentFileName, Root: w.currentFileRoot})
+ default:
+ // ignore all other stream types, as we only care about directory reparse points
+ }
+ }
+ w.currentIsDir = false
+ }
+ if w.backupWriter != nil {
+ w.backupWriter.Close()
+ w.backupWriter = nil
+ }
+ if w.currentFile != nil {
+ w.currentFile.Close()
+ w.currentFile = nil
+ w.currentFileName = ""
+ w.currentFileRoot = nil
+ }
+ return nil
+}
+
+// copyFileWithMetadata copies a file using the backup/restore APIs in order to preserve metadata
+func copyFileWithMetadata(srcRoot, destRoot *os.File, subPath string, isDir bool) (fileInfo *winio.FileBasicInfo, err error) {
+ src, err := safefile.OpenRelative(
+ subPath,
+ srcRoot,
+ syscall.GENERIC_READ|winio.ACCESS_SYSTEM_SECURITY,
+ syscall.FILE_SHARE_READ,
+ safefile.FILE_OPEN,
+ safefile.FILE_OPEN_REPARSE_POINT)
+ if err != nil {
+ return nil, err
+ }
+ defer src.Close()
+ srcr := winio.NewBackupFileReader(src, true)
+ defer srcr.Close()
+
+ fileInfo, err = winio.GetFileBasicInfo(src)
+ if err != nil {
+ return nil, err
+ }
+
+ extraFlags := uint32(0)
+ if isDir {
+ extraFlags |= safefile.FILE_DIRECTORY_FILE
+ }
+ dest, err := safefile.OpenRelative(
+ subPath,
+ destRoot,
+ syscall.GENERIC_READ|syscall.GENERIC_WRITE|winio.WRITE_DAC|winio.WRITE_OWNER|winio.ACCESS_SYSTEM_SECURITY,
+ syscall.FILE_SHARE_READ,
+ safefile.FILE_CREATE,
+ extraFlags)
+ if err != nil {
+ return nil, err
+ }
+ defer dest.Close()
+
+ err = winio.SetFileBasicInfo(dest, fileInfo)
+ if err != nil {
+ return nil, err
+ }
+
+ destw := winio.NewBackupFileWriter(dest, true)
+ defer func() {
+ cerr := destw.Close()
+ if err == nil {
+ err = cerr
+ }
+ }()
+
+ _, err = io.Copy(destw, srcr)
+ if err != nil {
+ return nil, err
+ }
+
+ return fileInfo, nil
+}
+
+// cloneTree clones a directory tree using hard links. It skips hard links for
+// the file names in the provided map and just copies those files.
+func cloneTree(srcRoot *os.File, destRoot *os.File, subPath string, mutatedFiles map[string]bool) error {
+ var di []dirInfo
+ err := safefile.EnsureNotReparsePointRelative(subPath, srcRoot)
+ if err != nil {
+ return err
+ }
+ err = filepath.Walk(filepath.Join(srcRoot.Name(), subPath), func(srcFilePath string, info os.FileInfo, err error) error {
+ if err != nil {
+ return err
+ }
+
+ relPath, err := filepath.Rel(srcRoot.Name(), srcFilePath)
+ if err != nil {
+ return err
+ }
+
+ fileAttributes := info.Sys().(*syscall.Win32FileAttributeData).FileAttributes
+ // Directories, reparse points, and files that will be mutated during
+ // utility VM import must be copied. All other files can be hard linked.
+ isReparsePoint := fileAttributes&syscall.FILE_ATTRIBUTE_REPARSE_POINT != 0
+ // In go1.9, FileInfo.IsDir() returns false if the directory is also a symlink.
+ // See: https://github.com/golang/go/commit/1989921aef60c83e6f9127a8448fb5ede10e9acc
+ // Fixes the problem by checking syscall.FILE_ATTRIBUTE_DIRECTORY directly
+ isDir := fileAttributes&syscall.FILE_ATTRIBUTE_DIRECTORY != 0
+
+ if isDir || isReparsePoint || mutatedFiles[relPath] {
+ fi, err := copyFileWithMetadata(srcRoot, destRoot, relPath, isDir)
+ if err != nil {
+ return err
+ }
+ if isDir && !isReparsePoint {
+ di = append(di, dirInfo{path: relPath, fileInfo: *fi})
+ }
+ } else {
+ err = safefile.LinkRelative(relPath, srcRoot, relPath, destRoot)
+ if err != nil {
+ return err
+ }
+ }
+
+ return nil
+ })
+ if err != nil {
+ return err
+ }
+
+ return reapplyDirectoryTimes(destRoot, di)
+}
+
+func (w *legacyLayerWriter) Add(name string, fileInfo *winio.FileBasicInfo) error {
+ if err := w.reset(); err != nil {
+ return err
+ }
+
+ if name == utilityVMPath {
+ return w.initUtilityVM()
+ }
+
+ name = filepath.Clean(name)
+ if hasPathPrefix(name, utilityVMPath) {
+ if !w.HasUtilityVM {
+ return errors.New("missing UtilityVM directory")
+ }
+ if !hasPathPrefix(name, utilityVMFilesPath) && name != utilityVMFilesPath {
+ return errors.New("invalid UtilityVM layer")
+ }
+ createDisposition := uint32(safefile.FILE_OPEN)
+ if (fileInfo.FileAttributes & syscall.FILE_ATTRIBUTE_DIRECTORY) != 0 {
+ st, err := safefile.LstatRelative(name, w.destRoot)
+ if err != nil && !os.IsNotExist(err) {
+ return err
+ }
+ if st != nil {
+ // Delete the existing file/directory if it is not the same type as this directory.
+ existingAttr := st.Sys().(*syscall.Win32FileAttributeData).FileAttributes
+ if (uint32(fileInfo.FileAttributes)^existingAttr)&(syscall.FILE_ATTRIBUTE_DIRECTORY|syscall.FILE_ATTRIBUTE_REPARSE_POINT) != 0 {
+ if err = safefile.RemoveAllRelative(name, w.destRoot); err != nil {
+ return err
+ }
+ st = nil
+ }
+ }
+ if st == nil {
+ if err = safefile.MkdirRelative(name, w.destRoot); err != nil {
+ return err
+ }
+ }
+ if fileInfo.FileAttributes&syscall.FILE_ATTRIBUTE_REPARSE_POINT == 0 {
+ w.uvmDi = append(w.uvmDi, dirInfo{path: name, fileInfo: *fileInfo})
+ }
+ } else {
+ // Overwrite any existing hard link.
+ err := safefile.RemoveRelative(name, w.destRoot)
+ if err != nil && !os.IsNotExist(err) {
+ return err
+ }
+ createDisposition = safefile.FILE_CREATE
+ }
+
+ f, err := safefile.OpenRelative(
+ name,
+ w.destRoot,
+ syscall.GENERIC_READ|syscall.GENERIC_WRITE|winio.WRITE_DAC|winio.WRITE_OWNER|winio.ACCESS_SYSTEM_SECURITY,
+ syscall.FILE_SHARE_READ,
+ createDisposition,
+ safefile.FILE_OPEN_REPARSE_POINT,
+ )
+ if err != nil {
+ return err
+ }
+ defer func() {
+ if f != nil {
+ f.Close()
+ safefile.RemoveRelative(name, w.destRoot)
+ }
+ }()
+
+ err = winio.SetFileBasicInfo(f, fileInfo)
+ if err != nil {
+ return err
+ }
+
+ w.backupWriter = winio.NewBackupFileWriter(f, true)
+ w.bufWriter.Reset(w.backupWriter)
+ w.currentFile = f
+ w.currentFileName = name
+ w.currentFileRoot = w.destRoot
+ w.addedFiles[name] = true
+ f = nil
+ return nil
+ }
+
+ fname := name
+ if (fileInfo.FileAttributes & syscall.FILE_ATTRIBUTE_DIRECTORY) != 0 {
+ err := safefile.MkdirRelative(name, w.root)
+ if err != nil {
+ return err
+ }
+ fname += ".$wcidirs$"
+ w.currentIsDir = true
+ }
+
+ f, err := safefile.OpenRelative(fname, w.root, syscall.GENERIC_READ|syscall.GENERIC_WRITE, syscall.FILE_SHARE_READ, safefile.FILE_CREATE, 0)
+ if err != nil {
+ return err
+ }
+ defer func() {
+ if f != nil {
+ f.Close()
+ safefile.RemoveRelative(fname, w.root)
+ }
+ }()
+
+ strippedFi := *fileInfo
+ strippedFi.FileAttributes = 0
+ err = winio.SetFileBasicInfo(f, &strippedFi)
+ if err != nil {
+ return err
+ }
+
+ if hasPathPrefix(name, hivesPath) {
+ w.backupWriter = winio.NewBackupFileWriter(f, false)
+ w.bufWriter.Reset(w.backupWriter)
+ } else {
+ w.bufWriter.Reset(f)
+ // The file attributes are written before the stream.
+ err = binary.Write(w.bufWriter, binary.LittleEndian, uint32(fileInfo.FileAttributes))
+ if err != nil {
+ w.bufWriter.Reset(ioutil.Discard)
+ return err
+ }
+ }
+
+ w.currentFile = f
+ w.currentFileName = name
+ w.currentFileRoot = w.root
+ w.addedFiles[name] = true
+ f = nil
+ return nil
+}
+
+func (w *legacyLayerWriter) AddLink(name string, target string) error {
+ if err := w.reset(); err != nil {
+ return err
+ }
+
+ target = filepath.Clean(target)
+ var roots []*os.File
+ if hasPathPrefix(target, filesPath) {
+ // Look for cross-layer hard link targets in the parent layers, since
+ // nothing is in the destination path yet.
+ roots = w.parentRoots
+ } else if hasPathPrefix(target, utilityVMFilesPath) {
+ // Since the utility VM is fully cloned into the destination path
+ // already, look for cross-layer hard link targets directly in the
+ // destination path.
+ roots = []*os.File{w.destRoot}
+ }
+
+ if roots == nil || (!hasPathPrefix(name, filesPath) && !hasPathPrefix(name, utilityVMFilesPath)) {
+ return errors.New("invalid hard link in layer")
+ }
+
+ // Find to try the target of the link in a previously added file. If that
+ // fails, search in parent layers.
+ var selectedRoot *os.File
+ if _, ok := w.addedFiles[target]; ok {
+ selectedRoot = w.destRoot
+ } else {
+ for _, r := range roots {
+ if _, err := safefile.LstatRelative(target, r); err != nil {
+ if !os.IsNotExist(err) {
+ return err
+ }
+ } else {
+ selectedRoot = r
+ break
+ }
+ }
+ if selectedRoot == nil {
+ return fmt.Errorf("failed to find link target for '%s' -> '%s'", name, target)
+ }
+ }
+
+ // The link can't be written until after the ImportLayer call.
+ w.PendingLinks = append(w.PendingLinks, pendingLink{
+ Path: name,
+ Target: target,
+ TargetRoot: selectedRoot,
+ })
+ w.addedFiles[name] = true
+ return nil
+}
+
+func (w *legacyLayerWriter) Remove(name string) error {
+ name = filepath.Clean(name)
+ if hasPathPrefix(name, filesPath) {
+ w.Tombstones = append(w.Tombstones, name)
+ } else if hasPathPrefix(name, utilityVMFilesPath) {
+ err := w.initUtilityVM()
+ if err != nil {
+ return err
+ }
+ // Make sure the path exists; os.RemoveAll will not fail if the file is
+ // already gone, and this needs to be a fatal error for diagnostics
+ // purposes.
+ if _, err := safefile.LstatRelative(name, w.destRoot); err != nil {
+ return err
+ }
+ err = safefile.RemoveAllRelative(name, w.destRoot)
+ if err != nil {
+ return err
+ }
+ } else {
+ return fmt.Errorf("invalid tombstone %s", name)
+ }
+
+ return nil
+}
+
+func (w *legacyLayerWriter) Write(b []byte) (int, error) {
+ if w.backupWriter == nil && w.currentFile == nil {
+ return 0, errors.New("closed")
+ }
+ return w.bufWriter.Write(b)
+}
+
+func (w *legacyLayerWriter) Close() error {
+ if err := w.reset(); err != nil {
+ return err
+ }
+ if err := safefile.RemoveRelative("tombstones.txt", w.root); err != nil && !os.IsNotExist(err) {
+ return err
+ }
+ for _, pd := range w.pendingDirs {
+ err := safefile.MkdirRelative(pd.Path, pd.Root)
+ if err != nil {
+ return err
+ }
+ }
+ if w.HasUtilityVM {
+ err := reapplyDirectoryTimes(w.destRoot, w.uvmDi)
+ if err != nil {
+ return err
+ }
+ }
+ return nil
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/nametoguid.go b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/nametoguid.go
new file mode 100644
index 000000000..741994ba4
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/nametoguid.go
@@ -0,0 +1,24 @@
+package wclayer
+
+import (
+ "github.com/Microsoft/hcsshim/internal/guid"
+ "github.com/Microsoft/hcsshim/internal/hcserror"
+ "github.com/sirupsen/logrus"
+)
+
+// NameToGuid converts the given string into a GUID using the algorithm in the
+// 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 "
+
+ err = nameToGuid(name, &id)
+ if err != nil {
+ err = hcserror.Errorf(err, title, "name=%s", name)
+ logrus.Error(err)
+ return
+ }
+
+ logrus.Debugf(title+"name:%s guid:%s", name, 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
new file mode 100644
index 000000000..bd4005dc4
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/preparelayer.go
@@ -0,0 +1,40 @@
+package wclayer
+
+import (
+ "sync"
+
+ "github.com/Microsoft/hcsshim/internal/hcserror"
+ "github.com/sirupsen/logrus"
+)
+
+var prepareLayerLock sync.Mutex
+
+// PrepareLayer finds a mounted read-write layer matching path and enables the
+// the filesystem filter for use on that layer. This requires the paths to all
+// 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)
+
+ // Generate layer descriptors
+ layers, err := layerPathsToDescriptors(parentLayerPaths)
+ if err != nil {
+ return err
+ }
+
+ // This lock is a temporary workaround for a Windows bug. Only allowing one
+ // call to prepareLayer at a time vastly reduces the chance of a timeout.
+ prepareLayerLock.Lock()
+ defer prepareLayerLock.Unlock()
+ err = prepareLayer(&stdDriverInfo, path, layers)
+ if err != nil {
+ err = hcserror.Errorf(err, title, "path=%s", path)
+ logrus.Error(err)
+ return err
+ }
+
+ logrus.Debugf(title+"succeeded path=%s", path)
+ return nil
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/processimage.go b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/processimage.go
new file mode 100644
index 000000000..884207c3e
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/processimage.go
@@ -0,0 +1,23 @@
+package wclayer
+
+import "os"
+
+// ProcessBaseLayer post-processes a base layer that has had its files extracted.
+// The files should have been extracted to <path>\Files.
+func ProcessBaseLayer(path string) error {
+ err := processBaseImage(path)
+ if err != nil {
+ return &os.PathError{Op: "ProcessBaseLayer", Path: path, Err: err}
+ }
+ return nil
+}
+
+// ProcessUtilityVMImage post-processes a utility VM image that has had its files extracted.
+// The files should have been extracted to <path>\Files.
+func ProcessUtilityVMImage(path string) error {
+ err := processUtilityImage(path)
+ if err != nil {
+ return &os.PathError{Op: "ProcessUtilityVMImage", Path: path, Err: err}
+ }
+ return nil
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/unpreparelayer.go b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/unpreparelayer.go
new file mode 100644
index 000000000..5f1b4f4f4
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/unpreparelayer.go
@@ -0,0 +1,23 @@
+package wclayer
+
+import (
+ "github.com/Microsoft/hcsshim/internal/hcserror"
+ "github.com/sirupsen/logrus"
+)
+
+// 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)
+
+ err := unprepareLayer(&stdDriverInfo, path)
+ if err != nil {
+ err = hcserror.Errorf(err, title, "path=%s", path)
+ logrus.Error(err)
+ return err
+ }
+
+ logrus.Debugf(title+"succeeded path=%s", path)
+ return nil
+}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/wclayer.go b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/wclayer.go
new file mode 100644
index 000000000..78f2aacd8
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/wclayer.go
@@ -0,0 +1,27 @@
+package wclayer
+
+import "github.com/Microsoft/hcsshim/internal/guid"
+
+//go:generate go run ../../mksyscall_windows.go -output zsyscall_windows.go wclayer.go
+
+//sys activateLayer(info *driverInfo, id string) (hr error) = vmcompute.ActivateLayer?
+//sys copyLayer(info *driverInfo, srcId string, dstId string, descriptors []WC_LAYER_DESCRIPTOR) (hr error) = vmcompute.CopyLayer?
+//sys createLayer(info *driverInfo, id string, parent string) (hr error) = vmcompute.CreateLayer?
+//sys createSandboxLayer(info *driverInfo, id string, parent uintptr, descriptors []WC_LAYER_DESCRIPTOR) (hr error) = vmcompute.CreateSandboxLayer?
+//sys expandSandboxSize(info *driverInfo, id string, size uint64) (hr error) = vmcompute.ExpandSandboxSize?
+//sys deactivateLayer(info *driverInfo, id string) (hr error) = vmcompute.DeactivateLayer?
+//sys destroyLayer(info *driverInfo, id string) (hr error) = vmcompute.DestroyLayer?
+//sys exportLayer(info *driverInfo, id string, path string, descriptors []WC_LAYER_DESCRIPTOR) (hr error) = vmcompute.ExportLayer?
+//sys getLayerMountPath(info *driverInfo, id string, length *uintptr, buffer *uint16) (hr error) = vmcompute.GetLayerMountPath?
+//sys getBaseImages(buffer **uint16) (hr error) = vmcompute.GetBaseImages?
+//sys importLayer(info *driverInfo, id string, path string, descriptors []WC_LAYER_DESCRIPTOR) (hr error) = vmcompute.ImportLayer?
+//sys layerExists(info *driverInfo, id string, exists *uint32) (hr error) = vmcompute.LayerExists?
+//sys nameToGuid(name string, guid *_guid) (hr error) = vmcompute.NameToGuid?
+//sys prepareLayer(info *driverInfo, id string, descriptors []WC_LAYER_DESCRIPTOR) (hr error) = vmcompute.PrepareLayer?
+//sys unprepareLayer(info *driverInfo, id string) (hr error) = vmcompute.UnprepareLayer?
+//sys processBaseImage(path string) (hr error) = vmcompute.ProcessBaseImage?
+//sys processUtilityImage(path string) (hr error) = vmcompute.ProcessUtilityImage?
+
+//sys grantVmAccess(vmid string, filepath string) (hr error) = vmcompute.GrantVmAccess?
+
+type _guid = guid.GUID
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/wclayer/zsyscall_windows.go b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/zsyscall_windows.go
new file mode 100644
index 000000000..2105703dc
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/internal/wclayer/zsyscall_windows.go
@@ -0,0 +1,457 @@
+// Code generated mksyscall_windows.exe DO NOT EDIT
+
+package wclayer
+
+import (
+ "syscall"
+ "unsafe"
+
+ "github.com/Microsoft/hcsshim/internal/interop"
+ "golang.org/x/sys/windows"
+)
+
+var _ unsafe.Pointer
+
+// Do the interface allocations only once for common
+// Errno values.
+const (
+ errnoERROR_IO_PENDING = 997
+)
+
+var (
+ errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING)
+)
+
+// errnoErr returns common boxed Errno values, to prevent
+// allocations at runtime.
+func errnoErr(e syscall.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 (
+ modvmcompute = windows.NewLazySystemDLL("vmcompute.dll")
+
+ procActivateLayer = modvmcompute.NewProc("ActivateLayer")
+ procCopyLayer = modvmcompute.NewProc("CopyLayer")
+ procCreateLayer = modvmcompute.NewProc("CreateLayer")
+ procCreateSandboxLayer = modvmcompute.NewProc("CreateSandboxLayer")
+ procExpandSandboxSize = modvmcompute.NewProc("ExpandSandboxSize")
+ procDeactivateLayer = modvmcompute.NewProc("DeactivateLayer")
+ procDestroyLayer = modvmcompute.NewProc("DestroyLayer")
+ procExportLayer = modvmcompute.NewProc("ExportLayer")
+ procGetLayerMountPath = modvmcompute.NewProc("GetLayerMountPath")
+ procGetBaseImages = modvmcompute.NewProc("GetBaseImages")
+ procImportLayer = modvmcompute.NewProc("ImportLayer")
+ procLayerExists = modvmcompute.NewProc("LayerExists")
+ procNameToGuid = modvmcompute.NewProc("NameToGuid")
+ procPrepareLayer = modvmcompute.NewProc("PrepareLayer")
+ procUnprepareLayer = modvmcompute.NewProc("UnprepareLayer")
+ procProcessBaseImage = modvmcompute.NewProc("ProcessBaseImage")
+ procProcessUtilityImage = modvmcompute.NewProc("ProcessUtilityImage")
+ procGrantVmAccess = modvmcompute.NewProc("GrantVmAccess")
+)
+
+func activateLayer(info *driverInfo, id string) (hr error) {
+ var _p0 *uint16
+ _p0, hr = syscall.UTF16PtrFromString(id)
+ if hr != nil {
+ return
+ }
+ return _activateLayer(info, _p0)
+}
+
+func _activateLayer(info *driverInfo, id *uint16) (hr error) {
+ if hr = procActivateLayer.Find(); hr != nil {
+ return
+ }
+ r0, _, _ := syscall.Syscall(procActivateLayer.Addr(), 2, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), 0)
+ if int32(r0) < 0 {
+ hr = interop.Win32FromHresult(r0)
+ }
+ return
+}
+
+func copyLayer(info *driverInfo, srcId string, dstId string, descriptors []WC_LAYER_DESCRIPTOR) (hr error) {
+ var _p0 *uint16
+ _p0, hr = syscall.UTF16PtrFromString(srcId)
+ if hr != nil {
+ return
+ }
+ var _p1 *uint16
+ _p1, hr = syscall.UTF16PtrFromString(dstId)
+ if hr != nil {
+ return
+ }
+ return _copyLayer(info, _p0, _p1, descriptors)
+}
+
+func _copyLayer(info *driverInfo, srcId *uint16, dstId *uint16, descriptors []WC_LAYER_DESCRIPTOR) (hr error) {
+ var _p2 *WC_LAYER_DESCRIPTOR
+ if len(descriptors) > 0 {
+ _p2 = &descriptors[0]
+ }
+ if hr = procCopyLayer.Find(); hr != nil {
+ return
+ }
+ 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)
+ }
+ return
+}
+
+func createLayer(info *driverInfo, id string, parent string) (hr error) {
+ var _p0 *uint16
+ _p0, hr = syscall.UTF16PtrFromString(id)
+ if hr != nil {
+ return
+ }
+ var _p1 *uint16
+ _p1, hr = syscall.UTF16PtrFromString(parent)
+ if hr != nil {
+ return
+ }
+ return _createLayer(info, _p0, _p1)
+}
+
+func _createLayer(info *driverInfo, id *uint16, parent *uint16) (hr error) {
+ if hr = procCreateLayer.Find(); hr != nil {
+ return
+ }
+ 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)
+ }
+ return
+}
+
+func createSandboxLayer(info *driverInfo, id string, parent uintptr, descriptors []WC_LAYER_DESCRIPTOR) (hr error) {
+ var _p0 *uint16
+ _p0, hr = syscall.UTF16PtrFromString(id)
+ if hr != nil {
+ return
+ }
+ return _createSandboxLayer(info, _p0, parent, descriptors)
+}
+
+func _createSandboxLayer(info *driverInfo, id *uint16, parent uintptr, descriptors []WC_LAYER_DESCRIPTOR) (hr error) {
+ var _p1 *WC_LAYER_DESCRIPTOR
+ if len(descriptors) > 0 {
+ _p1 = &descriptors[0]
+ }
+ if hr = procCreateSandboxLayer.Find(); hr != nil {
+ return
+ }
+ 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)
+ }
+ return
+}
+
+func expandSandboxSize(info *driverInfo, id string, size uint64) (hr error) {
+ var _p0 *uint16
+ _p0, hr = syscall.UTF16PtrFromString(id)
+ if hr != nil {
+ return
+ }
+ return _expandSandboxSize(info, _p0, size)
+}
+
+func _expandSandboxSize(info *driverInfo, id *uint16, size uint64) (hr error) {
+ if hr = procExpandSandboxSize.Find(); hr != nil {
+ return
+ }
+ r0, _, _ := syscall.Syscall(procExpandSandboxSize.Addr(), 3, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), uintptr(size))
+ if int32(r0) < 0 {
+ hr = interop.Win32FromHresult(r0)
+ }
+ return
+}
+
+func deactivateLayer(info *driverInfo, id string) (hr error) {
+ var _p0 *uint16
+ _p0, hr = syscall.UTF16PtrFromString(id)
+ if hr != nil {
+ return
+ }
+ return _deactivateLayer(info, _p0)
+}
+
+func _deactivateLayer(info *driverInfo, id *uint16) (hr error) {
+ if hr = procDeactivateLayer.Find(); hr != nil {
+ return
+ }
+ r0, _, _ := syscall.Syscall(procDeactivateLayer.Addr(), 2, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), 0)
+ if int32(r0) < 0 {
+ hr = interop.Win32FromHresult(r0)
+ }
+ return
+}
+
+func destroyLayer(info *driverInfo, id string) (hr error) {
+ var _p0 *uint16
+ _p0, hr = syscall.UTF16PtrFromString(id)
+ if hr != nil {
+ return
+ }
+ return _destroyLayer(info, _p0)
+}
+
+func _destroyLayer(info *driverInfo, id *uint16) (hr error) {
+ if hr = procDestroyLayer.Find(); hr != nil {
+ return
+ }
+ r0, _, _ := syscall.Syscall(procDestroyLayer.Addr(), 2, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), 0)
+ if int32(r0) < 0 {
+ hr = interop.Win32FromHresult(r0)
+ }
+ return
+}
+
+func exportLayer(info *driverInfo, id string, path string, descriptors []WC_LAYER_DESCRIPTOR) (hr error) {
+ var _p0 *uint16
+ _p0, hr = syscall.UTF16PtrFromString(id)
+ if hr != nil {
+ return
+ }
+ var _p1 *uint16
+ _p1, hr = syscall.UTF16PtrFromString(path)
+ if hr != nil {
+ return
+ }
+ return _exportLayer(info, _p0, _p1, descriptors)
+}
+
+func _exportLayer(info *driverInfo, id *uint16, path *uint16, descriptors []WC_LAYER_DESCRIPTOR) (hr error) {
+ var _p2 *WC_LAYER_DESCRIPTOR
+ if len(descriptors) > 0 {
+ _p2 = &descriptors[0]
+ }
+ if hr = procExportLayer.Find(); hr != nil {
+ return
+ }
+ 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)
+ }
+ return
+}
+
+func getLayerMountPath(info *driverInfo, id string, length *uintptr, buffer *uint16) (hr error) {
+ var _p0 *uint16
+ _p0, hr = syscall.UTF16PtrFromString(id)
+ if hr != nil {
+ return
+ }
+ return _getLayerMountPath(info, _p0, length, buffer)
+}
+
+func _getLayerMountPath(info *driverInfo, id *uint16, length *uintptr, buffer *uint16) (hr error) {
+ if hr = procGetLayerMountPath.Find(); hr != nil {
+ return
+ }
+ 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)
+ }
+ return
+}
+
+func getBaseImages(buffer **uint16) (hr error) {
+ if hr = procGetBaseImages.Find(); hr != nil {
+ return
+ }
+ r0, _, _ := syscall.Syscall(procGetBaseImages.Addr(), 1, uintptr(unsafe.Pointer(buffer)), 0, 0)
+ if int32(r0) < 0 {
+ hr = interop.Win32FromHresult(r0)
+ }
+ return
+}
+
+func importLayer(info *driverInfo, id string, path string, descriptors []WC_LAYER_DESCRIPTOR) (hr error) {
+ var _p0 *uint16
+ _p0, hr = syscall.UTF16PtrFromString(id)
+ if hr != nil {
+ return
+ }
+ var _p1 *uint16
+ _p1, hr = syscall.UTF16PtrFromString(path)
+ if hr != nil {
+ return
+ }
+ return _importLayer(info, _p0, _p1, descriptors)
+}
+
+func _importLayer(info *driverInfo, id *uint16, path *uint16, descriptors []WC_LAYER_DESCRIPTOR) (hr error) {
+ var _p2 *WC_LAYER_DESCRIPTOR
+ if len(descriptors) > 0 {
+ _p2 = &descriptors[0]
+ }
+ if hr = procImportLayer.Find(); hr != nil {
+ return
+ }
+ 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)
+ }
+ return
+}
+
+func layerExists(info *driverInfo, id string, exists *uint32) (hr error) {
+ var _p0 *uint16
+ _p0, hr = syscall.UTF16PtrFromString(id)
+ if hr != nil {
+ return
+ }
+ return _layerExists(info, _p0, exists)
+}
+
+func _layerExists(info *driverInfo, id *uint16, exists *uint32) (hr error) {
+ if hr = procLayerExists.Find(); hr != nil {
+ return
+ }
+ 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)
+ }
+ return
+}
+
+func nameToGuid(name string, guid *_guid) (hr error) {
+ var _p0 *uint16
+ _p0, hr = syscall.UTF16PtrFromString(name)
+ if hr != nil {
+ return
+ }
+ return _nameToGuid(_p0, guid)
+}
+
+func _nameToGuid(name *uint16, guid *_guid) (hr error) {
+ if hr = procNameToGuid.Find(); hr != nil {
+ return
+ }
+ r0, _, _ := syscall.Syscall(procNameToGuid.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(guid)), 0)
+ if int32(r0) < 0 {
+ hr = interop.Win32FromHresult(r0)
+ }
+ return
+}
+
+func prepareLayer(info *driverInfo, id string, descriptors []WC_LAYER_DESCRIPTOR) (hr error) {
+ var _p0 *uint16
+ _p0, hr = syscall.UTF16PtrFromString(id)
+ if hr != nil {
+ return
+ }
+ return _prepareLayer(info, _p0, descriptors)
+}
+
+func _prepareLayer(info *driverInfo, id *uint16, descriptors []WC_LAYER_DESCRIPTOR) (hr error) {
+ var _p1 *WC_LAYER_DESCRIPTOR
+ if len(descriptors) > 0 {
+ _p1 = &descriptors[0]
+ }
+ if hr = procPrepareLayer.Find(); hr != nil {
+ return
+ }
+ 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)
+ }
+ return
+}
+
+func unprepareLayer(info *driverInfo, id string) (hr error) {
+ var _p0 *uint16
+ _p0, hr = syscall.UTF16PtrFromString(id)
+ if hr != nil {
+ return
+ }
+ return _unprepareLayer(info, _p0)
+}
+
+func _unprepareLayer(info *driverInfo, id *uint16) (hr error) {
+ if hr = procUnprepareLayer.Find(); hr != nil {
+ return
+ }
+ r0, _, _ := syscall.Syscall(procUnprepareLayer.Addr(), 2, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), 0)
+ if int32(r0) < 0 {
+ hr = interop.Win32FromHresult(r0)
+ }
+ return
+}
+
+func processBaseImage(path string) (hr error) {
+ var _p0 *uint16
+ _p0, hr = syscall.UTF16PtrFromString(path)
+ if hr != nil {
+ return
+ }
+ return _processBaseImage(_p0)
+}
+
+func _processBaseImage(path *uint16) (hr error) {
+ if hr = procProcessBaseImage.Find(); hr != nil {
+ return
+ }
+ r0, _, _ := syscall.Syscall(procProcessBaseImage.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
+ if int32(r0) < 0 {
+ hr = interop.Win32FromHresult(r0)
+ }
+ return
+}
+
+func processUtilityImage(path string) (hr error) {
+ var _p0 *uint16
+ _p0, hr = syscall.UTF16PtrFromString(path)
+ if hr != nil {
+ return
+ }
+ return _processUtilityImage(_p0)
+}
+
+func _processUtilityImage(path *uint16) (hr error) {
+ if hr = procProcessUtilityImage.Find(); hr != nil {
+ return
+ }
+ r0, _, _ := syscall.Syscall(procProcessUtilityImage.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
+ if int32(r0) < 0 {
+ hr = interop.Win32FromHresult(r0)
+ }
+ return
+}
+
+func grantVmAccess(vmid string, filepath string) (hr error) {
+ var _p0 *uint16
+ _p0, hr = syscall.UTF16PtrFromString(vmid)
+ if hr != nil {
+ return
+ }
+ var _p1 *uint16
+ _p1, hr = syscall.UTF16PtrFromString(filepath)
+ if hr != nil {
+ return
+ }
+ return _grantVmAccess(_p0, _p1)
+}
+
+func _grantVmAccess(vmid *uint16, filepath *uint16) (hr error) {
+ if hr = procGrantVmAccess.Find(); hr != nil {
+ return
+ }
+ r0, _, _ := syscall.Syscall(procGrantVmAccess.Addr(), 2, uintptr(unsafe.Pointer(vmid)), uintptr(unsafe.Pointer(filepath)), 0)
+ if int32(r0) < 0 {
+ hr = interop.Win32FromHresult(r0)
+ }
+ return
+}